PRO SXT_TEEM, index1, image1, index2, image2, te, em, d_te, d_em, Valid, $ t1=t1, t2=t2, interp=interp, gain=gain, $ ; Input thresh1=thresh1, thresh2=thresh2, date=date, $ ; Input average=average, sum=sum, satval=satval, $ ; Input sat1=sat1, sat2=sat2, unc1=unc1, unc2=unc2, $ ; Input mewe=mewe, corona=corona, hybrid=hybrid, $ ; Input photospheric=photospheric, sre_file=sre_file, $ ; Input subs=subs,version=version ; Returned ;+ ; NAME: ; SXT_TEEM ; PURPOSE: ; Compute Te, EM, d_Te, d_EM from the ratio of the two input data arrays. ; NOTE: To do this _without_ use of index structures use sxt_teem2.pro. ; CALLING SEQUENCE: ; sxt_teem, index1, Image1, index2, Image2, Te ; sxt_teem, index1, Image1, index2, Image2, Te, EM, gain=gain, subs=subs ; sxt_teem, index1, Image1, index2, Image2, Te, EM, d_Te, d_EM, Valid ; sxt_teem, index1, Image1, index2, Image2, Te, EM, d_Te, d_EM, sum=sum ; INPUTS: ; index1 = index (structure) of Image1 ; Image1 = SXT image (DN), if byte type then sxt_prep is called. ; index2 = index (structure) of Image2 ; Image2 = SXT image (DN) through a different filter, if byte ; type then sxt_prep is called. ; NOTE: The Image variables can be either the raw compressed ; SXT images, simple scalars, or images that have already ; been processed through SXT_PREP. In the latter case ; the index structure created by SXT_PREP must be supplied. ; It is O.K. to input exposure-normalized PREP'd images ; although the d_te and d_em results will not be identical ; as when using raw compressed data because of round-off ; error. ; When comparing results using raw compressed vs. PREP'd ; input care must be taken to assure that the registration ; reference image is the same in both cases. ; OPTIONAL INPUT KEYWORDS: ; t1,t2 = Exposure times in msec. These values will override ; those in index1 and index2 if index1 and index2 are supplied. ; If index1 and t1 are not supplied, default to 1000 msec. ; subs = If image1 and image2 are 3-d, index of images to process. ; gain = camera gain in e-/Dn. ; If not supplied, default= (~100). Used in EM calculation. ; interp = If set, use Spline interpolation of SXT response functions ; Default is linear interpolation. ; (NOTE: SPLINE [IDL user library] fails on lindexe images.) ; sat1,sat2=Array of saturated pixels (if Image is not byte-type). ; unc1,unc2=Array of decompression uncertainties (if Image not byte-type). ; sum = Sum over sum X sum pixels before computing Te. ; satval = value of sat1 or sat2 to treat as a saturated pixel (def=1). ; average = If set, return average Te and total EM for entire image. ; thresh1,thresh2 = Minimum threshold (in DN) of background subtracted ; and rebinned (sum=X) image1, image2 ; date = Time in any format (including structure). Used to ; determine entrance filter transmission (not needed if ; index1 or index3 is an SXT index structure). ; OUTPUTS: ; Te = log10(Temp) (invalid temps = 0) ; OPTIONAL OUTPUTS: ; EM = log10(Emission measure). ; d_Te = Statistical uncertainties of Te (log10 units) ; d_EM = Statistical uncertainties of EM (includes uncertainty of d_Te) ; (log10 units) ; Valid = Array of valid pixels (=0). -1 = bad ratio values. ; OPTIONAL OUTPUT KEYWORDS: ; version = version number of input data base file ; COMMON BLOCKs: ; None. (In sxt_teem2, sxt_teem_db contains SXT response curves: sre*genx) ; RESTRICTIONS: ; o Image1 and Image2 must be the same size (1-d or 2-d or 3-d). ; Possible calling options: ; ; Index Image ; -------- ------------ ; Structure Scalar ; Structure 2D image ; Vector of structures(k) 3D data cube (n,m,k) ; ; The output (Te, EM, dTe, dEM) will generally be the same dimensions as the ; input image array unless the sum or average keyword options are specified. ; PROCEDURE: ; o Will compute ratio of thicker/thinner to determine Te. ; o Calls sxt_prep with /reg, /float, and /dc_orbit correct ; if imageX is byte type. ; o Use thinner image for EM determination. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Double Valued Functions: ; The following filter ratios are doubled valued (launch entr. filters) ; Al12/Noback, Al12/Al.1, AL12/AlMg, Al12/Mg3 ; Mg3 /Noback, Mg3 /Al.1, Mg3 /AlMg ; The temperatures returned may be a LOWER limit to the actual value. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; MODIFICATION HISTORY: ; 29-mar-93, J. Lemen, Can now handle data cubes. ; (sxt_teem calls sxt_teem1 which calls sxt_teem2) ; 2-apr-93, J. Lemen, Fixed bug for t1, t2 in single image case. ; 22-dec-93, JRL, Fixed an IDL V3.1 related bug ; 8-sep-94, JRL, d_EM now includes uncertainty caused by d_Te ; Minor change to the informational timing messages ; 18-nov-94, JRL, Fixed an bug with cubes that are (1,1,N) ; 28-Jan-95, JRL, Updated the documentation for filter number ; 8-mar-95, JRL, Renamed one of the input variables. ; 15-Apr-02, LWA, Remaned "arg" parametes to "index". ; Updated header. ; 9-nov-2011, Aki Takeda, added /corona, /hybrid, /photospheric, ; /mewe, and sre_file keywords (in response to the ; creation of the new response functions). ;- ;---------------------------------------------------------------------------- ; **** Step 1: Information Section ;---------------------------------------------------------------------------- n_params0 = n_params() ; Tell sxt_teem1 what calculations to do ; if no parameters are present, assume information mode if n_params0 lt 5 then begin doc_library,'sxt_teem' print,format="(75('-'))" fastdoc,'sxt_teem',/summ ; Give the full parameter list print,format="(75('-'))" return endif ;---------------------------------------------------------------------------- ; **** Step 2: Perform Checks on Input Data ;---------------------------------------------------------------------------- Te=0. & EM=0. & d_Te=0. & d_EM=0. & Valid=0 ; In case we return early sz1 = size(image1) sz2 = size(image2) if sz1(0) gt 2 then nimg1 = sz1(3) else nimg1 = 1 if sz2(0) gt 2 then nimg2 = sz2(3) else nimg2 = 1 if nimg1 ne nimg2 then begin print,' *** Error in SXT_TEEM (1)***' print,' image1 and image2 must contain same number of images' help,image1,image2 & tbeep return endif ;---------------------------------------------------------------------------- ; **** Step 3: Call SXT_TEEM1 to calculate Te, Em, d_Te, d_EM ;---------------------------------------------------------------------------- if n_elements(sum) eq 0 then sum = 1 if sum gt 1 then print,'*** Sum mode: ',strtrim(sum,2),' by ',strtrim(sum,2) if nimg1 gt 1 then begin ; Do we need to loop? if n_elements(subs) eq 0 then subs1 = indgen(nimg1) else begin subs1 = subs nimg1 = n_elements(subs) endelse t0 = systime(1) & t00 = t0 print,'SXT_TEEM status (subs) (s) Remain (min)' for i=0,nimg1-1 do begin j = subs1(i) if n_elements(sat1) gt 0 then ssat1 = sat1(*,*,j) if n_elements(sat2) gt 0 then ssat2 = sat2(*,*,j) if n_elements(unc1) gt 0 then uunc1 = unc1(*,*,j) if n_elements(unc2) gt 0 then uunc2 = unc2(*,*,j) if n_elements(t1) gt 0 then tt1 = t1(j) if n_elements(t2) gt 0 then tt2 = t2(j) sxt_teem1, index1(j),image1(*,*,j),index2(j),image2(*,*,j), $ te1,em1,d_te1,d_em1,valid1, $ t1=tt1, t2=tt2, interp=interp, gain=gain, $ thresh1=thresh1, thresh2=thresh2, date=date, $ average=average, sum=sum, satval=satval, $ sat1=ssat1,sat2=ssat2,unc1=uunc1,unc2=uunc2, $ n_params0=n_params0, version=version, $ mewe=mewe, corona=corona, hybrid=hybrid, $ photospheric=photospheric, sre_file=sre_file ; Print a message about the time run_time0 = systime(1) - t0 ; Time for this call run_time1 = systime(1) - t00 ; Total time remain_time = (run_time1 / (i+1) * (nimg1-i-1)) / 60. ; Remaining time in min print,'SXT_TEEM finished',i+1,' out of',nimg1,' ('+strtrim(j,2)+')', $ run_time0,remain_time,format='(a,i4,a,i4,a,t43,f7.0,f7.1)' t0 = systime(1) ; Reset the clock ; Set up the output variables: if i eq 0 then begin if keyword_set(average) then te = fltarr(nimg1) else $ te = fltarr(sz1(1),sz1(2),nimg1) if n_params0 ge 6 then em = te if n_params0 ge 7 then d_te = te if n_params0 ge 8 then d_em = te if n_params0 ge 9 then valid = intarr(sz1(1),sz1(2),nimg1) endif ; Assign the results: if keyword_set(average) then begin te(i) = te1 if n_params0 ge 6 then em(i) = em1 if n_params0 ge 7 then d_te(i) = d_te1 if n_params0 ge 8 then d_em(i) = d_em1 endif else begin te(0,0,i) = te1 if n_params0 ge 6 then em(0,0,i) = em1 if n_params0 ge 7 then d_te(0,0,i)= d_te1 if n_params0 ge 8 then d_em(0,0,i)= d_em1 endelse if n_params0 ge 9 then valid(0,0,i) = valid1 endfor print,'SXT_TEEM took',run_time1/60.,' min',format='(a,f6.1,a)' endif else $ SXT_TEEM1, index1, image1, index2, image2, te, em, d_te, d_em, Valid, $ t1=t1, t2=t2, interp=interp, gain=gain, $ ; Input thresh1=thresh1, thresh2=thresh2, date=date, $ ; Input average=average, sum=sum, satval=satval, $ ; Input sat1=sat1, sat2=sat2, unc1=unc1, unc2=unc2, $ ; Input mewe=mewe, corona=corona, hybrid=hybrid, $ ; input photospheric=photospheric, sre_file=sre_file, $ ; input n_params0=n_params0, version=version ; Returned end