Viewing contents of file '../idllib/astron/contrib/varosi/vlibm/allpro/show_psf.pro'
;+
; NAME:
; show_psf
; PURPOSE:
; Display the PSF (image) in pseudo-color with Linear and Log-10 scale,
; and as surface (Log-10) with contours (SHOW3).
; Centroid is determined and marked, and optionally
; the FWHM and other parameters are determined and printed.
; CALLING:
; show_psf, psf, NAME=name, /PRINT_INFO, INFO_PARMS=pinfo
; INPUTS:
; psf = 2D array (image) giving point-spread-function (peaked source).
; KEYWORDS (in):
; NAME = string, name of PSF to use in titles.
; XSIZ_3D, YSIZ_3D = window size for 3D surface plot (def = 512 by 378 ).
; NPOWER_10 = # of powers of 10 to show on 3D surface.
; /NO_3D : skip the 3D surface plot.
; /PRINT_INFO
; /GET_PARMS
; KEYWORDS (out):
; INFO_PARMS = all parameters of PSF (if /PRINT_INFO)
; LORENTZIAN_PARAMS = parameters of PSF (if /PRINT_INFO or /GET_PARMS)
; GAUSSIAN_PARAMS = parameters of PSF (if /PRINT_INFO or /GET_PARMS)
; EXTERNAL CALLS:
; pro tvs
; pro show3
; pro centroid
; pro get_window
; function nint
; function fullwid_halfmax
; COMMON BLOCKS:
; common show_psf, winpsf2, winpsf3
; HISTORY:
; Written, Frank Varosi NASA/GSFC 1992.
;-
pro show_psf, psf, NAME=name, PRINT_INFO=print_info, INFO_PARMS=pinfo, $
NO_3D=no_3D, XSIZ_3D=xsiz, YSIZ_3D=ysiz, $
NPOWER_10=Nordmag, GET_PARMS=get, $
LORENTZIAN_PARAMS=parmL, GAUSSIAN_PARAMS=parmG
common show_psf, winpsf2, winpsf3
winold = !D.window
xcs = !D.x_ch_size
ycs = !D.y_ch_size
sim = size( psf )
magf = 256./total( sim(1:2)/2 )
if (magf LT 1) then magf = 1./nint( 1/magf ) $
else magf = nint( magf )
simm = magf*sim
ixsiz = simm(1) > 256
iysiz = simm(2)
wxsiz = 2*ixsiz
wysiz = iysiz + 2*ycs
get_window, winpsf2, TIT="PSF:2D", XS=wxsiz, XP=!DEVX-wxsiz, $
YS=wysiz, YP=!DEVY-wysiz
erase
wshow, winpsf2, ICON=0
maxpsf = max( psf )
Logmax = nint( aLog10( maxpsf ) )
if N_elements( Nordmag ) NE 1 then Nordmag = 4
Logmin = Logmax - Nordmag
minLog = 10.^Logmin
tvs, MAG=magf, psf
centroid, psf, cx,cy
stat = draw_mark( cx*magf, cy*magf, /NOSAVE )
if keyword_set( print_info ) OR keyword_set( get ) then begin
fwhmi = fullwid_halfmax( psf )
fwhmg = fullwid_halfmax( psf, /GAUSSIAN, FIT=parmG, CENT=cxyg )
fwhmL = fullwid_halfmax( psf, /LORENTZI, FIT=parmL, CENT=cxyL )
if N_elements( parmL ) LT 10 then parmL = fltarr( 2, 5 )
endif
if keyword_set( print_info ) then begin
pinfo = [ [cx,cy],[cxyg],[cxyL],[fwhmi],[fwhmg],[fwhmL],$
[parmL(*,3:*)] ]
pnam = [" centroid " ,$
" cntrd (G) " ,$
" cntrd (L) " ,$
" FWHM " ,$
" FWHM (G) " ,$
" FWHM (L) " ,$
" pscal (L) " ,$
" power (L) " ]
print," x y"
for i=0,N_elements( pnam )-1 do print,pnam(i),pinfo(*,i),$
FORM="((A),2F11.2)"
endif
tvs, LOG=minLog, MAG=magf, psf, ixsiz
stat = draw_mark( cx*magf + ixsiz, cy*magf, /NOSAVE )
xyouts, xcs, iysiz+0.5*ycs, /DEV,"Linear:",FONT=0
xyouts, ixsiz*1.7, iysiz+0.5*ycs, /DEV,"Log10:",FONT=0
if N_elements( name ) EQ 1 then $
xyouts, !D.x_vsize/2, !D.y_vsize-1.5*ycs, name, ALIGN=0.5,/DEV,FONT=0
empty
if NOT keyword_set( no_3D ) then begin
!P.font = -1
if N_elements( xsiz ) NE 1 then xsiz=512
if N_elements( ysiz ) NE 1 then ysiz=378
get_window, winpsf3, TIT="PSF:3D", XSIZ=xsiz, XPOS=!DEVX-xsiz,$
YSIZ=ysiz, YPOS=0
erase
wshow,winpsf3,ICON=0
tvcrs,0.5,0.5,/NORM
save_zran = !Z.range
save_ztit = !Z.title
!Z.range = [Logmin,Logmax]
!Z.title = "Log_10 ( PSF )"
if max( sim(1:2) ) GT 80 then begin
xr = ( [cx-40, cx+40] > 0) < (sim(1)-1)
yr = ( [cy-40, cy+40] > 0) < (sim(2)-1)
show3, aLog10( psf(xr(0):xr(1),yr(0):yr(1)) > minLog )
endif else show3, aLog10( psf > minLog )
!Z.range = save_zran
!Z.title = save_ztit
empty
endif
if (winold GE 0) then wset,winold
end