def ra_to_sex (ra, delimiter = ':', decimalPlaces = 2):
   """Decimal RA to Sexagesimal converter.

   Args:
        ra: Right Ascension
        delimiter: Optional delimiter - assumed to be colon by default
        decimalPlaces: Number of decimal places to calculate onto returned result.

   Returns:
        RA string in sexagesimal
   """

   if decimalPlaces < 2:
      decimalPlaces = 2

   if decimalPlaces > 4:
      decimalPlaces = 4

   accuracy = 10**decimalPlaces

   # Calculation from Decimal Degrees:
   # 2013-09-17 KWS We're getting occasional RAs with negative values.
   #                I've assumed that we can just add 360.0 to these.

   if ra < 0.0:
      ra = ra + 360.0

   ra_hh   = int(ra/15)
   ra_mm   = int((ra/15 - ra_hh)*60)
   ra_ss   = int(((ra/15 - ra_hh)*60 - ra_mm)*60)
   ra_ff  = int((((ra/15 - ra_hh)*60 - ra_mm)*60 - ra_ss)*accuracy)

   return ('%02d' %ra_hh + delimiter + '%02d' %ra_mm + delimiter + '%02d' %ra_ss + '.' + '%0*d' % (decimalPlaces, ra_ff))