Viewing contents of file '../idllib/contrib/buie/hmstorad.pro'
;+
; NAME:
; hmstorad
; PURPOSE: (one line)
; Convert from hours, minutes, and seconds of Right Ascension to radians.
; DESCRIPTION:
;
; CATEGORY:
; Astronomy
; CALLING SEQUENCE:
; hmstorad, hour, min, sec, radians
; 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:
; radians : Converted angle in radians.
; COMMON BLOCKS:
;
; SIDE EFFECTS:
;
; RESTRICTIONS:
;
; PROCEDURE:
;
; MODIFICATION HISTORY:
; Copyright (C) 1987, by Marc W. Buie
; Version dated 87/6/3
; Ported by Doug Loucks, Lowell Observatory, August 12, 1993, from the
; C-Language version written by Marc Buie.
;-
; ------------------------------------------------------------------------------
; Procedure hmstorad
; ------------------------------------------------------------------------------
PRO hmstorad, hh, mm, ss, radians
rad_per_hour = 0.26179938779914943654D0
; Check for correct number of parameters.
IF N_PARAMS() NE 4 THEN BEGIN
; Display the calling sequence.
PRINT, 'hmstorad, hour, min, sec, radians'
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
radians = hh + ( mm + ss / 60.0 ) / 60.0
radians = radians * rad_per_hour
END