Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/conv_loc_slpe.pro'
;+
; NAME:
;	Conv_Loc_SLPE
; PURPOSE:
;	Convert cursor Location to SLP and Energy.
; CALLING:
;	Conv_Loc_SLPE, Lx, Ly, cinfo, zratio, ISLP, Energy, ASLP
; INPUTS:
;	Lx, Ly = cursor Location
;	cinfo = structure, coordinate system info.
;	zratio = ratio of max zoom to current [x,y] zoom factors.
; OUTPUTS:
;	ISLP = integer, quantum numbers.
;	Energy = floating point.
;	ASLP = string, SLP in standard characters (e.g. 2Pe).
; COMMON BLOCKS:
;	common Conv_Loc_SLPE, Lchar, Pchar
; EXTERNAL CALLS:
;	function N_struct
; HISTORY:
;	Written: Frank Varosi NASA/GSFC 1995.
;-

pro Conv_Loc_SLPE, Lx, Ly, cinfo, zratio, ISLP, Energy, ASLP, XSLP=slpx

   common Conv_Loc_SLPE, Lchar, Pchar

	if N_elements( Pchar ) NE 2 then begin
		Lchar = ["S","P","D","F","G","H","I","J","K"]
		Pchar = ["e","o"]
	   endif

	if N_struct( cinfo ) NE 1 then begin
		ISLP = Lx
		ASLP = string( Lx )
		Energy = Ly
		return
	   endif

	Energy = cinfo.Emax * ( Ly*zratio(1) - cinfo.offset(1) ) / cinfo.size(1)

	if keyword_set( slpx ) then begin
		ISLP = Lx*zratio(0)
		return
	   endif

	Xslp = round( Lx*zratio(0) - cinfo.offset(0) ) / cinfo.Xinc
	Xslp = (Xslp > 0) < (cinfo.Xmax-1)
	Energy = (Energy > 0) < cinfo.Emax

	Xp = Xslp MOD 2
	Xslp = round( Xslp )/2
	XL = Xslp MOD cinfo.maxL
	Xs = 2 * (Xslp/cinfo.maxL) + cinfo.minS
	ISLP = 100*Xs + 10*XL + Xp
	ASLP = SLP_char( Xs, XL, Xp )
end