FUNCTION dec2seg, array, RA=ra, DEG=deg ;CONVERTS RA OR DEC IN DECIMAL HOURS/DEGREES TO SEXIGESIMAL FORMAT ; ;INPUT: ARRAY OF FLOATS. IF KEYWORD RA SET, THEN OUTPUT WILL BE ##:##:##.# ; (10 CHARS WIDE), ELSE IT WILL BE s##:##:## (9 CHARS WIDE, WHERE ; s IS '-' IF DEC IS NEGATIVE). NO ERROR CHECKING IS DONE OTHER ; THAN SKIPPING VALUES OF -99.99, SO ANY ADDITION CHECKING SHOULD ; BE DONE BEFORE CALLING. ; ;RETURNS: ARRAY OF STRINGS ; ;WRITTEN: 000620, DJK ; ;UPDATED: 030110, DJK - Added decimal degrees for RA: IF KEYWORD DEG IS SET, ; ALONG WITH RA, IT IS ASSUMED THAT THE RA INPUT ARRAY IS IN DECIMAL ; DEGREE FORMAT, NOT HOURS. newarray = strarr(N_ELEMENTS(array)) FOR i=0, N_ELEMENTS(array)-1 DO BEGIN decval = array[i] IF decval EQ -99.99 THEN BEGIN ;DEAL WITH -99.99 VALUES IF KEYWORD_SET(RA) THEN BEGIN newarray[i] = '-99.99 ' ENDIF ELSE newarray[i] = '-99.99 ' ENDIF ELSE BEGIN IF KEYWORD_SET(DEG) THEN decval=decval*24.0/360.0 hd = FIX(ABS(decval)) num = STRING(decval) ;had to do this to avoid precision problems mins = FLOAT(STRMID(num, STRPOS(num, '.'))*60.) min = FIX(mins) sec = (mins-min)*60. IF KEYWORD_SET(RA) THEN BEGIN newarray[i]= STRING(hd, min, sec, \$ FORMAT='(i2, ":", i2, ":", f4.1)') ENDIF ELSE BEGIN IF decval LT 0 THEN sign='-' ELSE sign = ' ' sec = ROUND(sec) newarray[i]= STRING(sign, hd, min, sec, \$ FORMAT='(a1, i2, ":", i2, ":", i2)') ENDELSE ENDELSE ENDFOR RETURN, newarray END