Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/contour_levels.pro'
;+
; NAME:
;	contour_Levels
; PURPOSE:
;	Define contour Levels by
;	calling function cursor_scale to get user input.
; CALLING:
;	contour_Levels, mosaic_spec
; INPUT and OUTPUT:
;	mosaic_spec =
; EXTERNAL CALLS:
;	function cursor_scale
; HISTORY:
;	Written: Frank Varosi NASA/GSFC 1992.
;	F.V.1994, generalized contour specs for Lin/Log.
;-

pro contour_Levels, mosaic_spec

	if N_struct( mosaic_spec ) NE 1 then return

	if (mosaic_spec.scaling EQ "Log10") then cs = mosaic_spec.contour_Log $
					    else cs = mosaic_spec.contour
	NLev = cs.NLev > 1
	MLev = N_elements( cs.Levels )
	wincur = !D.window

	range = cursor_scale( mosaic_spec.minT, mosaic_spec.maxT, $
				mosaic_spec.scaling, /INCREMENT,  $
				LOGMIN=mosaic_spec.minLog, $
				INIT=[ cs.Levels(0), cs.Levels(NLev-1) ] )

	if N_elements( range ) GT 3 then begin

		Levels = range( sort( range ) )
		NLev = N_elements( Levels )

		if( NLev GT MLev ) then begin
			message,"exceeded max # of Levels: using only " $
				+ strtrim( MLev, 2 ) + " out of " $
				+ strtrim( NLev, 2 ) + string(7b),/INFO
			Levels = Levels(0:MLev-1)
			NLev = MLev
		   endif

	 endif else begin

		if N_elements( range ) EQ 3 then begin
			Rmin = range(0)
			Ncint = (range(2) > 0) < (N_elements( cs.Levels )-1)
			Rmax = Rmin + Ncint * (range(1) > 0)
		  endif else begin
			window_set_show, wincur, DELAY=0.1
			Ncint = select_number( "# of contour intervals?", $
						0, MLev-1, INIT = NLev-1 )
			Rmin = range(0)
			Rmax = range(1)
		   endelse

		NLev = (Ncint + 1) > 1
		if (Rmax LE Rmin) then Rmax = Rmin+1
		Levels = (Rmax-Rmin) * findgen( NLev )/(Ncint>1) + Rmin
	  endelse

;	if (Levels(0) EQ mosaic_spec.minT) then begin
;		if (mosaic_spec.minT EQ 0) then Levels(0) = 1.e-6 $
;			else Levels(0) = mosaic_spec.minT + $
;			     10.^( fix( aLog10( abs( mosaic_spec.minT ) ) )-6 )
;	   endif

	cs.NLev = NLev
	cs.Levels = 0
	cs.Levels = Levels
	mosaic_spec.options.show_contours = 1	;turn all contours on.

	if (mosaic_spec.scaling EQ "Log10") then mosaic_spec.contour_Log = cs $
					    else mosaic_spec.contour = cs
end