;+ ; NAME: ; hmstoh ; PURPOSE: (one line) ; Convert from hours, minutes, and seconds of time to decimal hours ; DESCRIPTION: ; ; CATEGORY: ; Astronomy ; CALLING SEQUENCE: ; hmstorad, hour, min, sec,decimalhours ; INPUTS: ; hour : Hour. 0 <= hour < 24. ; min : Minute. 0 <= min < 60. ; sec : Second. 0.0 <= sec < 60.0. ; If more than one of these are vectors, they must be the same length. ; A mixture of scalar and vector input parameters is equivalent to all three ; inputs being vectors: The scalar inputs are treated as replicated vectors. ; OPTIONAL INPUT PARAMETERS: ; ; KEYWORD PARAMETERS: ; ; OUTPUTS: ; decimalhours : Converted time in hours ; COMMON BLOCKS: ; ; SIDE EFFECTS: ; ; RESTRICTIONS: ; ; PROCEDURE: ; ; MODIFICATION HISTORY: ; 2005 July 14 Leslie Young, ; modified from hmstorad, M. Buie, Lowell Observatory ;- ; ------------------------------------------------------------------------------ ; Procedure hmstorad ; ------------------------------------------------------------------------------ PRO hmstoh, hh, mm, ss, h ;rad_per_hour = 0.26179938779914943654D0 ; Check for correct number of parameters. IF N_PARAMS() NE 4 THEN BEGIN ; Display the calling sequence. PRINT, 'hmstohours, hour, min, sec, decimalhours' RETURN ENDIF ; Verify the type and rank of the input parameters. Allowed types are ; integer, long, float, or double. Allowed ranks are scalar (0) or ; vector (1). IF badpar( hh, [2,3,4,5], [0,1], CALLER='DMSTORAD ', NPTS=hh_size, $ RANK=hh_rank ) THEN RETURN ; IF badpar( mm, [2,3,4,5], [0,1], CALLER='DMSTORAD ', NPTS=mm_size, $ RANK=mm_rank ) THEN RETURN ; IF badpar( ss, [2,3,4,5], [0,1], CALLER='DMSTORAD ', NPTS=ss_size, $ RANK=ss_rank ) THEN RETURN check = [ hh_size, mm_size, ss_size ] z = WHERE( check NE 1, count ) IF count NE 0 THEN BEGIN IF MIN( check[z] ) NE MAX( check[z] ) THEN BEGIN MESSAGE, 'Vector input parameters must be the same length.', /INFO RETURN ENDIF ENDIF i = WHERE( hh LT 0 OR hh GE 24, count ) IF count NE 0 THEN BEGIN MESSAGE, 'Parameter out of range: 0 <= hour < 24.', /INFO RETURN ENDIF i = WHERE( mm LT 0 OR mm GE 60, count ) IF count NE 0 THEN BEGIN MESSAGE, 'Parameter out of range: 0 <= min < 60.', /INFO RETURN ENDIF i = WHERE( ss LT 0.0 OR ss GE 60.0, count ) IF count NE 0 THEN BEGIN MESSAGE, 'Parameter out of range. 0.0 <= sec < 60.0.', /INFO RETURN ENDIF h = hh + ( mm + ss / 60.0d ) / 60.0d END