Function index2unc, index0, photons=photons, logte=logte ;+ ;NAME: ; index2unc ;PURPOSE: ; For given level_1 index structure(s), this function goes back to ; the level_0 images and runs SXT_PREP (and SXT_DN_UNC, if set) ; to return the uncertainty array. ; ;CALLING SEQUENCE: ; unc_arr = index2unc(index) ; unc_arr = index2unc(index,/photon,logte=7.0) ;INPUT: ; item - The index structure (Level_1 indexes, in most cases). ; The structure can be the roadmap, or observing log. ; ;OPTIONAL INPUT (keyword): ; photons - if set, add photon statistical errors. ; logte - the log10 of electron temperature of the emitting plasma. ; to pass to SXT_DN_UNC. If omitted, then Te = alog10(3.e6) ; is assumed. ;OUTPUT: ; returns - uncertainly array (calclated by SXT_PREP, i.e. ; non-statistical errors such as from decompression ; and dark correction). See the routine SXT_DN_UNC ; to add in the photon statistics. ; ;Calling : index2lev0file.pro, gt_serialnum.pro, sxt_prep, sxt_dn_unc. ; ;HISTORY: ; Written 27-Jul-2010 (Aki Takeda) ; 27-Jun-2011 (Aki T.) added set-up procedure for YLstone. ;- ;************** setup environment ***************** m_name=get_host(/short) print,'*********************************' print,'machine name : ',m_name print,'*********************************' ; case m_name of 'ylstone': yl_setup_yls 'helios': yl_setup_helio else : yl_setup_helic endcase ; nn=n_elements(index0) xs=max(gt_shape(index0,/x)) ys=max(gt_shape(index0,/y)) unc_arr=fltarr(xs,ys,nn) ; ;----- search level_0 files ----- l0files=index2lev0file(index0) ; for i=0,nn-1 do begin ;----- read level_0 files ----- rd_xda,l0files(i),-1,ichk,/nodata ss=where(gt_serialnum(ichk) eq gt_serialnum(index0(i))) if ss(0) ne -1 then begin rd_xda,l0files(i),ss,ii,dd ;***** non-statistical errors ***** choose_sfc,ii sxt_prep,ii,dd,iout,dout,unc0,/float,/dc_interp,/dc_orbit_correct, $ /sxt_cleanx,rest_low8=yn_lw8,/ssc_norm unc1=unc0 ;***** statistical errors ***** if keyword_set(photons) then $ unc1=sxt_dn_unc(iout,dout,unc0,te=logte) xx=gt_shape(iout,/x) yy=gt_shape(iout,/y) unc_arr(0:xx-1,0:yy-1,i)=unc1 endif endfor ; unc=unc_arr if (nn eq 1) then unc = unc_arr(0) ;turn it into a scalar ; return, unc ; end