Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/coordin_range.pro'
function coordin_range, Raw_Mosaic, IN_WINDOW=in_win
;+
; NAME:
;	coordin_range
; PURPOSE:
;	Get the range of arc-sec coordinate system for raw mosaic structure.
; CALLING EXAMPLE:
;	range = coordin_range( Raw_Mosaic, /IN_WINDOW )
; INPUTS:
;	Raw_Mosaic = structured array of images (image_List type structure)
;			or image pointers (mosaic_List type structure),
;			containing fields for ARCSX and ARCSY.
; KEYWORDS:
;	/IN_WINDOW : then computes coordinate range for whole of current window.
; RESULT:
;	Function returns a 2 by 2 matrix: [ [xmin,ymin], [xmax,ymax] ] (arcsec).
; EXTERNAL CALLS:
;	function N_struct
; PROCEDURE:
; MODIFICATION HISTORY:
;	Written, Frank Varosi NASA/GSFC 1993.
;-
	if N_struct( Raw_Mosaic ) LE 0 then return,[[0,0],[1,1]]

	BELL = string( 7b )
	Tags = tag_names( Raw_Mosaic )

	if (NOT max( tags EQ "ARCSX" )) then begin
		message,"arc-sec coordinate system not defined" + $
			" for this image structure" + BELL, /INFO
		wait,1
		return,[[0,0],[1,1]]
	   endif

	Rarcs = [ [ min( Raw_Mosaic.arcsx, MAX=maxax ), $
		    min( Raw_Mosaic.arcsy, MAX=maxay ) ], [ maxax, maxay ] ]

	if keyword_set( in_win ) then begin

		Rdev = [ [ min( Raw_Mosaic.xmin, MAX=maxx ), $
			   min( Raw_Mosaic.ymin, MAX=maxy ) ], [ maxx, maxy ] ]

		arcs_pix = ( Rarcs(*,1) - Rarcs(*,0) ) / $
				( Rdev(*,1) - Rdev(*,0) )

		Rarcs(0,0) = Rarcs(*,0) - arcs_pix * Rdev(*,0)
		Rarcs(0,1) = Rarcs(*,1) + $
				arcs_pix * ( [!D.x_size,!D.y_size] - Rdev(*,1) )
	   endif

return, Rarcs
end