Viewing contents of file '../idllib/ghrs/pro/calc_carpos.pro'
pro calc_carpos,grating,order,wave,carpos,angle
;+
;*NAME:
;		calc_carpos
;
;*PURPOSE:
; Procedure to compute carrousel position from wavelength and
; order number
;
;*CALLING SEQUENCE:
;	calc_carpos,grating,order,wave,carpos,angle
;
; INPUTS:
;	grating - grating mode (1-7)  (EA=6, EB=7)
;	order - spectral order number (1 for first order gratings)
;	wave - wavelength
;
;   Either order or wave may be vectors, if both are vectors they should
;   be the same length.  If order or wave are vectors then carpos will
;   be returned as a vector.
;
; OUTPUTS:
;	carpos - carrousel position to center wavelength on the
;		photocathode.
;	angle - grating scan angle in radians
;
; HISTORY:
;	version 1  D. Lindler June 88
;	9-AUG-1991	JKF/ACC		- moved to GHRS DAF (IDL Version 2)
;-
;------------------------------------------------------------------------
;
; parameters for carrousel equation (Pre-Launch Calibration Report,
;		BASD HRS-2176-051  31 March 86)
;
A = [0, 3301.815, 4020.502, 4615.660, 5539.488, 33013.449, 62886.313, 63194.086]
C = [0, 11106.51, 54807.90, 30600.90, 14887.26,  49183.15, 39021.18,  50575.02]
B = 10430.378		; steps per radian

A = A(grating)
C = C(grating)
;
; compute carrousel position
;
status= check_math(0,1)
carpos = C - B*asin(order*float(wave)/A)
status= check_math(0,0) 
if status ne 0 then begin
	print,' '
	print,'WARNING: MATH error detected in routine CALC_CARPOS'
	print,'   Please check  ORDER and WAVELENGTH: '
	print,check_math_msg( status)
	print,' '
	end
angle = (C - carpos)/B		;angle in radians
return
end