Viewing contents of file '../idllib/uit/pro/cirrange.pro'
PRO cirrange, ang, RADIANS=rad
;+
; NAME:
;	CIRRANGE
; PURPOSE:
;	To force an angle into the range 0 <= ang < 360.
; CALLING SEQUENCE:
;	cirrange, ang
; INPUTS/OUTPUTS:
;	ang     - The angle to modify, in degrees.  This parameter is
;	          changed by this procedure.  Can be a scalar or vector.
; KEYWORDS:
;	RADIANS - If present and non-zero, the angle is specified in
;  	          radians rather than degrees.  It is forced into the range
;	          0 <= ang < 2 PI.
; PROCEDURE:
;	The upper limit is added to negative values until there are no
;	more.  Then the MOD operator is applied to all the angles to deal
;	with values that are too large.
; MODIFICATION HISTORY:
;	Written by Michael R. Greason, Hughes STX, 10 February 1994.
;-
;			Check arguments.
;
IF (n_params() LT 1) THEN message, 'Syntax:  cirrange, ang'
;
;			Determine the additive constant.
;
IF (keyword_set(rad)) THEN cnst = !pi * 2.d $
                      ELSE cnst = 360.d
;
;			Deal with the lower limit.
;
ind = where(ang LT 0.)
WHILE (ind(0) GE 0) DO BEGIN
	ang(ind) = ang(ind) + cnst
	ind = where(ang LT 0.)
ENDWHILE
;
;			Deal with the upper limit.
;
ang = ang MOD cnst
;
RETURN
END