Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/contour_coordin.pro'
;+
; NAME:
; contour_coordin
; PURPOSE:
; Setup up coordinate axes for contour/display of mosaic image.
; Called by pro contour_mosaic.
; CALLING EXAMPLE:
; contour_coordin, mosaic_spec, xcoor, xtit, xtickv, xticm, xtickLab, $
; ycoor, ytit, ytickv, yticm, ytickLab
; INPUT:
; mosaic_spec = structure containing all needed info.
; KEYWORDS:
; /PLATE_SCALE_SET : to change the arcsec/pixel stored in mosaic_spec.
; /CHANGE_ABSOLUTE : to change the absolute RA-DEC of origin.
; OUTPUTS:
; [x,y]coor = coordinates used in call to plot/contour.
; [x,y]tit = axis titles.
; [x,y]tickv = values for tick marks.
; [x,y]ticm = # of minor tick marks between major ticks.
; [x,y]tickLab = labels for ticks (for RA and DEC option only).
; COMMON BLOCKS:
; common contour_coordin, nticrel, nticabs
; nticrel = approx. # of tick marks to use for relative coordinates.
; nticabs = approx. # of tick marks to use for absol. RA & DEC coord.
; PROCEDURE:
; HISTORY:
; written, Frank Varosi STX @ NASA/GSFC 1990.
; mod, F.V. 1991, use mosaic_spec structure.
; mod, F.V. 1991, define origin and zoom info self consistently.
; mod, F.V. 1991, added common block contour_coordin with defaults.
; mod, F.V. 1996, added options for relative arcmins & degrees.
;-
pro contour_coordin, mosaic_spec, xcoor, xtit, xtickv, xticm, xtickLab, $
ycoor, ytit, ytickv, yticm, ytickLab, $
PLATE_SCALE_SET = plate_scale_set, $
CHANGE_ABSOLUTE = change_abs
common contour_coordin, nticrel, nticabs
if N_struct( mosaic_spec ) NE 1 then return
if keyword_set( plate_scale_set ) then begin
text = ""
print,mosaic_spec.winame
print," currently: RA. arcsec/pixel =",mosaic_spec.RA_pix
read," enter new value or take default : ",text
if strlen( text ) GT 0 then begin
mosaic_spec.RA_pix = float( text )
print," new value for RA. arcsec/pixel =",$
mosaic_spec.RA_pix
endif
print," currently: DEC. arcsec/pixel =",mosaic_spec.DEC_pix
read," enter new value or take default : ",text
if strlen( text ) GT 0 then begin
mosaic_spec.DEC_pix = float( text )
print," new value for DEC. arcsec/pixel =",$
mosaic_spec.DEC_pix
endif
endif
if (mosaic_spec.zoom_enable) then begin
zoomxy = mosaic_spec.zoom
nxpix = zoomxy(2) - zoomxy(0) + 1
nypix = zoomxy(3) - zoomxy(1) + 1
xpix = [ -0.5, findgen( nxpix ), nxpix-0.5 ] + zoomxy(0)
ypix = [ -0.5, findgen( nypix ), nypix-0.5 ] + zoomxy(1)
endif else begin
nxpix = mosaic_spec.size_image(1)
nypix = mosaic_spec.size_image(2)
xpix = [ -0.5, findgen( nxpix ), nxpix-0.5 ]
ypix = [ -0.5, findgen( nypix ), nypix-0.5 ]
endelse
;NOTE: the -0.5 is to use pixel centers in contour.
;get relative pixel coordinates, accounting for rotation, and proceed...
rotation = (mosaic_spec.rotation * mosaic_spec.rot_applied)
xpix = xpix - mosaic_spec.origin(0)
ypix = ypix - mosaic_spec.origin(1)
CASE rotation OF
0: BEGIN
xcoor = xpix
ycoor = ypix
END
1: BEGIN
xcoor = rotate( -ypix, 2 )
ycoor = xpix
END
2: BEGIN
xcoor = rotate( -xpix, 2 )
ycoor = rotate( -ypix, 2 )
END
3: BEGIN
xcoor = ypix
ycoor = rotate( -xpix, 2 )
END
4: BEGIN
xcoor = ypix
ycoor = xpix
END
5: BEGIN
xcoor = rotate( -xpix, 2 )
ycoor = ypix
END
6: BEGIN
xcoor = rotate( -ypix, 2 )
ycoor = rotate( -xpix, 2 )
END
7: BEGIN
xcoor = xpix
ycoor = rotate( -ypix, 2 )
END
else: BEGIN
xcoor = xpix
ycoor = ypix
END
ENDCASE
if (!DEBUG GT 3) then stop
CASE mosaic_spec.coord_spec(0) OF
"Relative": BEGIN
mosaic_spec.origin_rel = mosaic_spec.origin
if N_elements( nticrel ) NE 1 then nticrel=10
CASE mosaic_spec.coord_spec(1) OF
"Arcseconds": BEGIN
xtit = "RELATIVE R.A. (arcsec)"
ytit = "RELATIVE DEC (arcsec)"
xcoor = mosaic_spec.RA_pix * xcoor
ycoor = mosaic_spec.DEC_pix * ycoor
END
"Arcminutes": BEGIN
xtit = "RELATIVE R.A. (arcmin)"
ytit = "RELATIVE DEC (arcmin)"
xcoor = mosaic_spec.RA_pix * xcoor/60
ycoor = mosaic_spec.DEC_pix * ycoor/60
END
"Degrees": BEGIN
xtit = "Longitude (degrees)"
ytit = "Latitude (degrees)"
xcoor = mosaic_spec.RA_pix * xcoor/60/60
ycoor = mosaic_spec.DEC_pix * ycoor/60/60
END
"Pixels": BEGIN
xtit = "Relative Pixel Number"
ytit = "Relative Pixel Number"
simple_ticks, xcoor, xticm, nticrel, xtickv
simple_ticks, ycoor, yticm, nticrel, ytickv
return
END
ENDCASE
simple_ticks, xcoor, xticm, nticrel, xtickv
simple_ticks, ycoor, yticm, nticrel, ytickv
xtr = max( xtickv ) - min( xtickv )
xts = abs( xtickv(1) - xtickv(0) )
ytr = max( ytickv ) - min( ytickv )
yts = abs( ytickv(1) - ytickv(0) )
if (!DEBUG GT 2) then stop
if ((xtr LT 10) AND (xts NE 5)) OR $
(xts GE 10) then begin
double_ticks,xcoor,xtickv,xtickLab,/NEG
xticm = 5
endif else xtickLab = strtrim(-fix(xtickv),2)
if ((ytr LT 10) AND (yts NE 5)) OR $
(yts GE 10) then begin
double_ticks, ycoor, ytickv, ytickLab
yticm = 5
endif else ytickLab = strtrim(fix(ytickv),2)
END
"Absolute": BEGIN
nx = N_elements( xcoor )
ny = N_elements( ycoor )
if N_elements( nticabs ) NE 1 then nticabs=7
nticax = nticabs * ( ( float( nx )/ny ) < 1 )
nticay = nticabs * ( ( float( ny )/nx ) < 1 )
if keyword_set( change_abs ) then begin
ra = mosaic_spec.RA
dec = mosaic_spec.DEC
print,string(7b)
read_radec, ra,dec
mosaic_spec.RA = ra
mosaic_spec.DEC = dec
mosaic_spec.origin_abs = mosaic_spec.origin
endif else begin
ra = mosaic_spec.RA
dec = mosaic_spec.DEC
endelse
ycoor = dec + (mosaic_spec.DEC_pix * ycoor)/3600
astro_ticks, ycoor, nticay, ytickv, ytickLab, yticm
xcoor = (mosaic_spec.RA_pix * xcoor)/3600
yav = total( ycoor )/N_elements( ycoor )
xcoor = xcoor/cos( yav*!DTOR )
astro_ticks, (ra - xcoor), nticax, $
xtickv, xtickLab, xticm,/RA
xtickv = ra - xtickv
xtit = "RIGHT ASCENSION"
ytit = "DECLINATION"
END
else: BEGIN
xtit = "pixel number"
ytit = "pixel number"
simple_ticks, xcoor, xticm, 10, xtickv
simple_ticks, ycoor, yticm, 10, ytickv
END
ENDCASE
end