Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/error_info.pro'
;+
; NAME:
; error_info
; PURPOSE:
; Define structure for storing error (noise) information and
; if image array is passed then estimate the error properties of image.
; Called by function headinfo to define the structures, and
; then used by function sig_ref.
; CALLING:
; einfo = error_info( image )
; INPUTS:
; image = 2D array
; KEYWORDS:
; /NO_TITLE : suppress printing of title line when results are printed
; via call to pro print_struct.
; OUTPUTS:
; Function returns information about errors (expected values and variance)
; in image as a structure variable.
; COMMON BLOCKS:
; common TUT_setup, center_xy, cradius
; common error_info, boxsize, reject
; EXTERNAL CALLS:
; function Local_Variance
; function Disk_Region
; function Trapez
; function stdev
; pro MinMax_Histo
; pro Bin_Scat
; PROCEDURE:
; Compute local variances and histograms in central disk region,
; then integrate sqrt(variance) with respect to histogram distribution.
; HISTORY:
; written, Frank Varosi 1997.
;-
function error_info, image, NO_TITLE=no_title
common error_options, fast_err_comp
common error_info, boxsize, reject
common error_info1, wd, cxy, crad
common TUT_setup, center_xy, cradius
si = { mean:0.0 ,$
stdev:0.0 ,$
E_value:0.0 ,$
E_stdev:0.0 ,$
P_value:0.0 ,$
P_stdev:0.0 ,$
L_value:0.0 ,$
L_stdev:0.0 ,$
bins:fltarr(30) ,$
hist:Lonarr(30) ,$
vari:fltarr(30) ,$
vard:fltarr(30) ,$
cxy:intarr(2) ,$
cradius:0 ,$
bias_mean:0.0 ,$
bias_sigma:0.0 }
sim = size( image )
if sim(0) eq 2 then begin
if N_elements( wd ) LT 1 then begin
cxy = [0,0]
crad = 0
endif
cmin = ( center_xy - cradius ) > 0
cmax = ( center_xy + cradius ) < (sim(1:2)-1)
imcbox = image(cmin(0):cmax(0),cmin(1):cmax(1))
if (crad NE cradius) or $
(max( abs( cxy - center_xy ) ) gt 0) then begin
crad = cradius
cxy = center_xy
wd = Disk_Region( [cradius,cradius], RADIUS=cradius-1, $
SIZE=size( imcbox ) )
endif
imwd = imcbox(wd)
si.stdev = stdev( imwd, mean )
si.mean = mean
si.cxy = center_xy
si.cradius = cradius
if keyword_set( fast_err_comp ) then begin
si.E_value = si.mean
si.E_stdev = si.stdev
print_struct, si, TR=[0,3], NO_TITLE=no_title
endif else begin
imv = Local_Variance( imcbox, BOX=boxsize )
MinMax_Histo, imwd, minv, maxv, REJ=reject
if !DEBUG then help, boxsize, reject, minv, maxv
Bin_Scat, imwd, imv(wd), MIN=minv, MAX=maxv, $
XBIN=xbin, XH=xhi, MEAN=vav, STDEV=vsd,$
NBIN=N_elements( si.bins )
si.bins = xbin
si.hist = xhi
si.vari = vav
si.vard = vsd
hnorm = 1/Trapez( xhi, xbin )
si.E_value = Trapez( xhi * xbin, xbin ) * hnorm
si.E_stdev = Trapez( xhi * sqrt(vav), xbin ) * hnorm
Lh = N_elements( xbin )-1
si.P_value = xbin(Lh)
si.P_stdev = sqrt( vav(Lh) )
si.L_value = xbin(0)
si.L_stdev = sqrt( vav(0) )
print_struct, si, TR=[0,7], NO_TITLE=no_title
endelse
endif
return, si
end