;+
; NAME:
;	cvsmei_init
; PURPOSE:
;	Set scaling parameters for cvsmei
; CATEGORY:
;	camera/idl/toolbox
; CALLING SEQUENCE:
	PRO cvsmei_init 	 			, $
		mode 	= mode	 			, $
		str 	= str	 			, $
		cxy 	= cxy	 			, $
		mpb 	= mpb	 			, $
		dim 	= dim	 			, $
		degrees	= degrees			, $
		from_maptype = from_maptype , $
		to_maptype	 = to_maptype	, $
		reset	= reset	 			, $
		silent	= silent 			, $
		get 	= get
; INPUTS:
; OPTIONAL INPUT PARAMETERS:
;	mode = mode 	scalar; type: string
;						map type: one of 'lores','eqmap','npmap','spmap','eqfull','eclsun'
;	str  = str		scalar; type: string
;	cxy  = cxy		array[2]; type: any
;	mpb  = mpb		scalar; type: double
;	dim  = dim		array[2]; type: integer
;	/degrees		if set, angular units are degrees (default: radians)
;	/get			if set, retrieve settings
;	/reset			if set, reset everything for standard full-sky maps
;	/silent 		suppress informational messages
; INCLUDE:
	@compile_opt.pro		; On error, return to caller
; COMMON BLOCKS:
	common cvsmei_save, map_modes, str_modes, cxy_modes, dpb_modes, dim_modes, $
		from_maptype_save, to_maptype_save
; PROCEDURE:
;	Common block updates
; MODIFICATION HISTORY:
;	FEB-2006, Paul Hick (UCSD/CASS)
;	APR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
;		Added mode 'eclsun'
;-
InitVar, reset  , /key
InitVar, degrees, /key
InitVar, silent , 0
InitVar, get	, /key

IF reset THEN destroyvar, map_modes

IF IsType(map_modes, /undefined) THEN BEGIN

	IF silent LE 2 THEN message, /info, 'reset to full-map values'

	map_modes = ['lores','eqmap','npmap','spmap','eqfull','eclsun']
	str_modes = ['low-res','equatorial','north-polar','south-polar','equatorial','helioecliptic']
	cxy_modes = [[-0.5d0,179.5d0],[-0.5d0,599.5d0],[399.5d0,399.5d0],[399.5d0,399.5d0],[-0.5d0,899.5d0],[359.5d0,179.5d0]]
	dpb_modes = [0.5d0,0.1d0,0.1d0,0.1d0,0.1d0,0.5d0]
	dim_modes = [[720,360],[3600,1200],[800,800],[800,800],[3600,1800],[720,360]]

	from_maptype_save = 'eqmap'
	to_maptype_save   = 'eqmap'

ENDIF

CASE get OF

0: BEGIN

	CASE 1 OF

	IsType(from_maptype,/defined): from_maptype_save = from_maptype
	IsType(to_maptype  ,/defined): to_maptype_save   = to_maptype

	ELSE: BEGIN

		InitVar, mode, from_maptype_save
		m = (where(mode EQ map_modes))[0]

		IF m NE -1 THEN BEGIN
			IF IsType(str,/defined) THEN str_modes[  m] = str
			IF IsType(cxy,/defined) THEN cxy_modes[*,m] = cxy
			IF IsType(mpb,/defined) THEN dpb_modes[  m] = mpb*ToDegrees(degrees=degrees)
			IF IsType(dim,/defined) THEN dim_modes[*,m] = dim
		ENDIF

	END

	ENDCASE

END

1: BEGIN

	CASE 1 OF

	arg_present(from_maptype): from_maptype = from_maptype_save
	arg_present(to_maptype	): to_maptype	= to_maptype_save

	ELSE: BEGIN

		InitVar, mode, from_maptype_save
		m = (where(mode EQ map_modes))[0]

		IF m NE -1 THEN BEGIN
			IF arg_present(str) THEN str = str_modes[  m]
			IF arg_present(cxy) THEN cxy = cxy_modes[*,m]
			IF arg_present(mpb) THEN mpb = dpb_modes[  m]/ToDegrees(degrees=degrees)
			IF arg_present(dim) THEN dim = dim_modes[*,m]
		ENDIF

	END

	ENDCASE

END

ENDCASE

RETURN  &  END
