function sxt_get_grill, index, status, no_normal=no_normal, $ debug=debug, loud=loud, geny=geny ;+ ; Name: sxt_get_grill ; ; Purpose: return entrance-era dependent Al.1 Grill file ; ; Input Parameters: ; index - sxt index record (usually an SFC index) ; ; Output Paramters: ; status - return status 1=ok ; 0=found one but not in correct era ; -1=problem (index not Al.1 for example) ; Keyword Parameters: ; no_normal - if set, do not normalize ; geny - if set, use final set (*geny extension) ; APODIZED, lwa email circa 28-May-2003 ; (normalized to 1 second) ; Restrictions: ; Designed to do one record per call. ; ; History: ; 8-Jan-2000 - S.L.Freeland - break code from sfc_prep ; (since now may be applied to synthetic SFC) ; 2-jun-2003 - S.L.Freeland - add /GENY keyword and function ; 24-jul-2003 - S.L.Freeland - default return to fltarr(512,512)=0. ; don't print warning if non Al.1 input ; Use loc_file instead of file_list ; (intermittent problems with curdir?) ; 10-May-2007 LWA Modified to handle different all resolutions ; and image sizes. Now works for PFIs, too. ; 20-Oct-2008 Aki Takeda - Modified Loren's mod., return zero array when ; the FOV goes out of the full-CCD area (wierd, but ; such data do exist --- most are junks.) ; 3-Nov-2008 Aki Takeda - check y-cordinate of FOV ; (above mod only checks x-cordinate). ;- debug=keyword_set(debug) loud=keyword_set(loud) or debug no_normal=keyword_set(no_normal) geny=keyword_set(geny) common sxt_get_grill, lastgfile, lastgrill if n_elements(lastgfile) eq 0 then lastgfile='' status=-1 sxsy=gt_shape(index) corn=gt_corner_cmd(index) res=gt_res(index) retval=fltarr(sxsy(0),sxsy(1)) ; default return all zeros if not required_tags(index,'gen,sxt') then begin box_message,'Need SXT index record...' return, retval endif grill_files=loc_file(path='$DIR_SXT_CALIBRATE',$ 'al_grill_*.'+(['genx','geny'])(geny) ) al1ok=gt_filta(index) eq 1 and gt_filtb(index) eq 2 if not al1ok then begin if loud then box_message,'No Grill since not Al.1' return,retval endif ok=ssw_time_compare(index,(get_yo_dates(/ent))(1),/later) AND $ grill_files(0) ne '' if ok then begin earlier=ssw_time_compare(file2time(grill_files),index,/earlier) ss=(reverse(where(earlier,ecnt)))(0)>0 gfile=grill_files(ss) status=([1,2])(ecnt eq 0) if loud then begin mess=[ 'Using grill file: ' + ssw_strsplit(gfile,'/',/last,/tail), $ (['Normalizing','NOT Normalizing'])(no_normal)] if ecnt eq 0 then mess=mess+'Warning: grill is from previous era...' box_message,mess more,get_info(index,/non) endif if gfile eq lastgfile then grill=lastgrill else begin call_procedure,(['restgen','restgenx'])(geny),file=gfile,grill lastgrill=grill lastgfile=gfile endelse retval=temporary(grill)*([gt_expdur(index)/2.668e3,1.])(no_normal) endif else box_message,'No grill files' if debug then stop ; Match grill image to resolution and size of x-ray image. case 1 of res eq 0 : begin retval=rebin(retval,1024,1024)/4. xx=1024-corn(0)-sxsy(0) yy=corn(1) ; retval=retval(xx:xx+sxsy(0)-1,yy:yy+sxsy(1)-1) ; (20-oct-2008) end res eq 1 : begin xx=512-(corn(0)/2)-sxsy(0) yy=corn(1)/2 ; retval=retval(xx:xx+sxsy(0)-1,yy:yy+sxsy(1)-1) ; (20-oct-2008) end res eq 2 : begin retval=rebin(retval,256,256)*4. xx=256-(corn(0)/4)-sxsy(0) yy=corn(1)/4 ; retval=retval(xx:xx+sxsy(0)-1,yy:yy+sxsy(1)-1) ; (20-oct-2008) end endcase ; gr_size=1024/2^res if (xx ge 0) and (xx+sxsy(0)-1 le gr_size-1) and $ ; (3-nov-2008) (yy ge 0) and (yy+sxsy(1)-1 le gr_size-1) then $ ; (20-oct-2008) retval=retval(xx:xx+sxsy(0)-1,yy:yy+sxsy(1)-1) $ ; (20-oct-2008) else begin retval=fltarr(sxsy(0),sxsy(1)) ; return 0 array (20-oct-2008) print,'!!! FOV runs out of the CCD. returns zero array !!!', $ xx,xx+sxsy(0),yy,yy+sxsy(1) ; (3-nov-2008) endelse ; return,retval end