function match_saa_state, roadmap, saa_state=saa_state ; ; boolean - does input match requested saa state? ; ; nout=n_elements(roadmap) case 1 of data_chk(saa_state,/undef): retval=lonarr(nout) + 1 ; dont care (all yes) saa_state(0): retval=saa_in(roadmap,/fem_only) else: retval=1-(saa_in(roadmap,/fem_only)) endcase return,retval end pro mk_sff_pair,infil,ssl,ssm,sss,indat=indat,$ triplet=triplet, quiet=quiet, $ saa_state=saa_state, $ debug=debug,count=count, $ maxdt=maxdt,nuden_ok=nuden_ok,$ outindex=outindex,outdata=outdata ;+ ; Name: mk_sff_pair ; ; Purpose: make pairings for SXT full disk composites. ; The logic is adjusted to work for the period ; prior to firming up of the standard SXT FFI table ; which took place with Table 298, 19-Apr-92 14:44. ; ; Calling sequence: ; mk_sff_pair,infil,ssl,ssm,sss,indat=indat,$ ; triplet=triplet, $ ; saa_state=saa_state, $ ; debug=debug,count=count, $ ; maxdt=maxdt,nuden_ok=nuden_ok,$ ; outindex=outindex,outdata=outdata ; ; Input Parameters: ; infil - list of SFR files OR SXT INDEX records ; NOTE: If infil is an INDEX structure then keyword ; indat=indat must contain the corresponding data array. ; ; Output Paramters: ; ssl - subscripts of LONG exposures matching criteria ; ssm - subscripts of Medium (if /triplet set) ; sss - subscripts of associated SHORT exposures ; Note: ssm and/or sss eq -2 means no saturation in longer exposure. ; ; Keyword Ouput ; count, used by mk_ssc. ; ; Optional Keyword Output ; outindex, index structure used in making sff_pairs ; outdata, data cube used in making sff_pairs. ; ; Optional Keyword Input Parameters: ; /triplet - make 3-exposure composites ; /quiet - eliminate most print output. ; /debug - stop multiples places for debugging. ; /nuden_ok - don't reject data using filter (Default is to reject.) ; maxdt - maximum deltaT to allow LONG:SHORT - in seconds ; Default: maxdt=660 except for ; Change maxdt for 3-nov-94 eclipse to 1800 sec. ; Change maxdt for 24-oct-95 eclipse to 1200 sec. ; Change maxdt for 9-Mar-97 eclipse to 1380 sec. ; Change maxdt for PFI-dominant interval in May 2000 to 1200 sec. ; saa_state - choose where to make SSCs w/t SAA (default is off) ; SAA_STATE = undefined => don't care about SAA (ie, all) ; SAA_STATE = 1 => ONLY include SAA images ; SAA_STATE = 0 => Only include NON-SAA images ; ; Restrictions: ; This code uses the program get_llow_lhi.pro which reads the ; file 'tbl_chng.txt' which provides parameters to deal with ; pre-table-298 (STANDARD table) exposure experiments. ; ; History: ; 14-apr-1998 - S.L.Freeland - break/rework mk_sfd ; 31-Jan-2000 - S.L.Freeland - enable /TRIPLET ; 7-Nov-2003 - S.L.Freeland - made DELTA = maximum delta (pair or triplet) ; added MAXDT keyword/function ; 19-nov-2003 - S.L.Freeland - required INDEX, not ROADMAPs ; (CCD Temp check added) ; 13-Jan-2004 - LWA - Removed filta=1 requirement for short and med. ; Widened short to 4-15 dpe and med to 16-26 dpe. ; Permit warm CCD before 2-oct-91 09:05. ; 19-Jan-2004 - LWA - Lowered required percentd to gt 95. ; Increased default maxdt to 660 seconds. ; Major rewrite of flow of pairing process. ; 20-Jan-2004 - LWA - Installed test for images with CCD bleed. ; For short and medium exposures ignore lost ; data outside of active latitudes (rows 150:405 in HR) ; and permit one minor frame of missing data ; within the active latitude band. ; 24-Jan-2004 - LWA - Added test for image data completeness of LONG ; exposures because percentd not always reliable. ; Added test for unsaturated long/medium exposures. ; Will pass -1 in ssm or sss to mk_ssc for these cases. ; 26-Jan-2004 - LWA - Debugged spaghetti logic. ; 31-Jan-2004 - LWA - Corrected inconsistency in image counting. ; 25-Mar-2004 - LWA - Fixed bug in short image logic. ; 26-Mar-2004 - LWA - Fixed bug in "nearest short" logic. ; 17-Aug-2004 - LWA - Added keyword indat. ; 27-Sep-2004 - LWA - Hardwired variable "junk" to deal with a ; limited number of pathological long exposures. ; Now require percentd=100 for NuDen short exposures. ; 1-Oct-2004 - LWA - Restricted NuDen images from use as mid exposures ; in triplets. ; 18-Nov-2004 - LWA - Reversed edit of 1-Oct-2004. ; Incorporated SSC7 guideline to ; use no filtA=6 (NuDen) images post-14Nov92. ; 20-Nov-2004 - LWA - Tested and debugged. ; 17-Mar-2005 - LWA - In case of multiple short exposures with a variety ; of DPE values now use unsaturated short with largest ; DPE value that is closest in time to long exposure. ; Deleted development print and help commands. ; 18-Mar-2005 - LWA - Fixed a bug in line 338. ; Deleted non-functional keyword delta. ; Added keyword nuden_ok. ; 1-Feb-2006 - LWA - Added keywords outindex and outdata. ; 2-Feb-2006 - LWA - Corrected old errors introduced with NuDen business. ; 29-Feb-2006 - LWA - Oct/Nov 1991 DPE experimental version. ; 21-May-2007 - LWA - Fixed typo in ssli 'where' statement from 26-Jan-2004. ; 23-May-2007 - LWA - Use with get_llow_lhi.pro for early months. ; 29-May-2007 - LWA - Completed revisions for use in early months. ; 30-May-2007 - LWA - 'nuther debug. Updated header. ; 31-May-2007 - LWA - Created from mk_sff_pair_91.pro. ; 8-Jun-2007 - LWA - Corrected "-2" problem combining ssm's and sss's. ; 12-Jul-2007 - LWA - Ignore saturation prior to 24-Sep-91 11:18. ; 27-Jul-2007 - LWA - Sharpened early-singlets ignore-saturation criteria. ; Replaced "filtb" as an index with "filtx". ; 22-Aug-2007 - LWA - Quieted fmt_timer printout. ; 24-Aug-2007 - LWA - Added note '..rejects ALL images w/o FiltA open.' ; 25-Aug-2007 - LWA - Handle case where no longs pass the bleed test. ; 21-Dec-2007 - LWA - Fixed bug in case statement. ; 4-Feb-2008 - LWA - Reject images for which DPE and expdur disagree ; by more than 5%. ; 6-Feb-2008 - LWA- Arrange to keep 28 o.k. DPE=30 exposures that ; fail the 5% test. ; 10-Aug-2008 - LWA - Removed requirement for cold CCD. ; 5-Jun-2009 - LWA - Cleaned up indentation. ; 6-Jun-2009 - LWA - satlong=1 for Table 1830. ; 8-Jun-2009 - LWA - Change maxdt to 1200 sec for 24-Oct-95 eclipse. ; 9-Jun-2009 - LWA - Corrected typo. maxtds ==> maxdts ; 15-Jul-2009 - LWA - Change maxdt to 1800 sec for 3-Nov-94 eclipse. ; 27-Jul-2009 - LWA - Ignore saturation for 17-Apr-96 eclipse. ; Change maxdt to 1380 sec for 9-Mar-97 eclipse. ; 20-Aug-2009 - LWA - maxdts set incorrectly, fixed eclipse logic statement. ; Fixed indexing error on choosing short exposure. ; 21-Aug-2009 - LWA - End-to-end review of program. ; Removed obsolete keywords al_only and almg_only. ; Added short image adjacency test for case of ; no unsaturated short exposures. ; 12-Feb-2010 LWA Mod. to handle too-large data array. ; 10-Apr-2012 LWA Change maxdt for PFI-dominant interval in May 2000 ; to 1200 sec. ; Change all maxdt intervals to be full days. ; 18-May-2012 LWA Removed requirement for percentd=100 for NuDen. ; 23-May-2012 LWA Set loud=1 if keyword noiz is set. ;- common mk_ssc_blk1, lweek, files, roadmap, xdata triplet=keyword_set(triplet) noiz=1-keyword_set(quiet) if noiz then loud=1 else loud=0 if NOT triplet then ssmcnt=0 ;Needed for if statement later on. debug=keyword_set(debug) nuden_ok=keyword_set(nuden_ok) ; ---- Roadmap & xdata either generated internally or ---------------- ; ---- obtained from the common statement ---------------------------- ; ---- Although called "roadmap" actually index records required ----- ; ------- input sfr file list or INDEX ------------------------------- ; ; The following are a list of AlMg DPE=30 times for which gt_expdur ; is less than 30 seconds but greater than 10.7 seconds. They have ; all been inspected and are good composites even though underexposed. ; LWA 6-Feb-2008 ok30=[ '15-Jan-93 00:20:31.663',$ '20-Jan-93 21:22:52.808',$ '12-Jul-93 20:20:48.910',$ '02-Oct-93 04:30:22.766',$ '03-May-94 19:00:28.259',$ '13-May-94 15:29:26.178',$ '23-Aug-94 07:18:08.055',$ '23-Aug-94 12:16:26.012',$ '03-Dec-94 13:56:35.889',$ '06-Dec-94 13:13:15.317',$ '16-Feb-95 22:57:33.840',$ '18-Feb-95 01:10:35.644',$ '21-Feb-95 20:12:48.924',$ '22-Feb-95 22:13:18.703',$ '16-Jun-95 20:20:51.120',$ '12-Nov-95 19:27:54.439',$ '19-Dec-95 23:01:47.352',$ '18-Jan-96 07:49:42.638',$ '18-Apr-96 10:46:24.362',$ '13-May-96 00:54:27.233',$ '10-May-97 16:37:37.284',$ '11-Jul-97 10:31:41.029',$ '08-Aug-97 08:06:39.094',$ '30-Jan-98 20:42:47.603',$ '12-Jan-99 21:53:07.007',$ '01-May-99 12:19:26.661',$ '25-Dec-99 03:05:53.240',$ '04-Oct-00 21:31:07.903'] if data_chk(infil,/string) then rd_xda,infil,-1,roadmap,xdata if data_chk(infil,/struct) then begin roadmap=infil if not keyword_set(indat) then begin print,'If you use an index structure for infil then you ',$ ' must input the sfr data cube as indata. Returning.' return endif else begin xdata=indat endelse endif ; -------- Reject NuDen images after 14-Nov-1992 -------------------- ; -------- unless keyword nuden_ok is set. -------------------------- ; --Note that this section also rejects ALL images w/o FiltA open.-- if not nuden_ok then begin ent=get_yo_dates(/ent) ttsssi=int2secarr(roadmap,ent(1)) help,roadmap,ttsssi,xdata bef=where(ttsssi le 0,nbef) aft=where(ttsssi gt 0,naft) nw_n=0 ;19-Nov-2004 LWA if naft gt 0 then chk_nuden=where(gt_filta(roadmap(aft)) eq 1,nw_n) if nw_n gt 0 then begin wo_nuden=where(gt_filta(roadmap(aft)) eq 1) case 1 of nbef gt 0 : begin roadmap=[roadmap(bef),roadmap(aft(wo_nuden))] xdata=[[[xdata(*,*,bef)]],[[xdata(*,*,aft(wo_nuden))]]] end nbef eq 0 : begin roadmap=roadmap(aft(wo_nuden)) sizx=size(xdata) tmp=bytarr(sizx(1),sizx(2),n_elements(wo_nuden)) for zz=0,n_elements(wo_nuden)-1 do tmp(0,0,zz)=xdata(*,*,aft(wo_nuden(zz))) xdata=temporary(tmp) end endcase endif endif else begin nw_n=0 endelse if not keyword_set(maxdt) then maxdt=660 else maxdt=maxdt ;default->11 mins maxdts=maxdt kool='2-oct-91 09:05' ;Time of CCD cooling to -20 C. junk=['7-Oct-2001 21:46:00'] ;Pathological FFI. ; stdtbl='19-apr-92 14:44' ;Standard table used after this. ; -------- Define uniq pairing combinations ------ res= [1,2] ; half / quarter get_llow_lhi,roadmap,triplet=triplet,ntym=ntym,/chk_n,dun=dun,$ nset_out=nset_out,debug=debug,loud=loud if noiz then begin print,'MK_SFF_PAIR step STOP 2' help,roadmap,triplet,ntym,dun,nset_out endif if debug then print,'STOP 2' if debug then stop if dun then goto, nodice for tymi=0,ntym do begin if noiz then begin help,tymi print,'&&&& TYMI =',tymi endif for nseti=0,nset_out do begin ; --------- initialize output variables ------------ ssl=[-1] ; long subscripts ssm=[-1] sss=[-1] ; paired subscripts if (data_type(index) ne 8 or n_elements(ssl_out) le 0) $ then frstind=0 else frstind=1 get_llow_lhi, triplet=triplet, roadmap, xdata, index, data,$ dun=dun, llow, lhi, ssmin, ssmax, res, fb, tymi=tymi,$ nset_in=nseti,debug=debug,loud=loud ;quiet=quiet if noiz then begin print,'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' fmt_timer,roadmap fmt_timer,index help,tymi, llow print,llow help, lhi print,lhi help, ssmin, ssmax, res, fb print,'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$' endif tim2orbit, index, tim2night=tim2night ; get time2nights if noiz then print,'RES = ',res if noiz then print,'FB = ',fb if dun then goto, tymout for resx=0,n_elements(res)-1 do begin ; for each resolution for filtx=0,n_elements(fb)-1 do begin ; for each filter ; ----- Test for 1991 pre-CCD-cool images ----- tc = int2secarr(index,anytim(kool,/yohkoh)) - $ int2secarr(anytim(kool,/yohkoh)) ; ------ Flag promising LONG exposures --------- ; ----- Test for pathological images ----- ssli=where(gt_percentd(index) gt 95 and $ ;Fixed typo 5/21/07, LWA. gt_filtb(index) eq fb(filtx) and $ gt_filta(index) eq 1 and $ gt_res(index) eq res(resx) and $ gt_expmode(index) eq 0 and $ match_saa_state(index, saa_state=saa_state) and $ gt_dpe(index) ge llow(triplet) and $ gt_dpe(index) le lhi(triplet) and $ (gt_shape_cmd(index,/x) eq gt_shape_cmd(index,/y)) and $ (abs(anytim(index)-anytim(junk)) gt 1.0) and $ ;LWA 9/27/04 tim2night gt 2.0,sslcnt) ;2 minute limit. nnssl=sslcnt if noiz then print, ' sslcnt = ',strtrim(sslcnt,2) ; ----- Eliminate LONGS where DPE and expdur don't agree ------------ ; ----- Then must match within le 5%. ------------------------- if sslcnt gt 0 then begin bad_exp=where(abs((gt_dpe(index(ssli),/conv)-$ gt_expdur(index(ssli)))/gt_dpe(index(ssli),/conv)) gt 0.05,nbe) if nbe gt 0 then begin ; The following 9 lines of code are designed to retain the ; DPE=30 exposures listed in the array ok30. kp30=matchem(anytim(index(ssli(bad_exp))),anytim(ok30)) if kp30(0) ne -1 then begin nbp=tim2dset(index(ssli(bad_exp)),anytim(kp30,/yo)) bad_exp=delind(indgen(n_elements(bad_exp)),nbp) case 1 of bad_exp(0) eq -1 : goto,allok bad_exp(0) ne -1 : nbe=nbe-n_elements(kp30) endcase endif case 1 of sslcnt eq nbe : begin ssli=-1 sslcnt=0 nnssl=0 end nbe lt sslcnt : begin okexp=delind(indgen(n_elements(ssli)),bad_exp) ssli=ssli(okexp) sslcnt=n_elements(ssli) nnssl=n_elements(ssli) end endcase endif allok: endif ; ----- Eliminate LONGS with bleed ------------------- if n_elements(data) ne 0 and sslcnt gt 0 then begin bleed=sxt_bleedtest(index(ssli),data(*,*,ssli)) bb=where(bleed eq 0,nbb) if nbb lt n_elements(ssli) then begin case 1 of bb(0) eq -1 : begin ssli=-1 sslcnt=0 nnssl=0 end bb(0) gt -1 : begin ssli=ssli(bb) sslcnt=n_elements(ssli) nnssl=n_elements(ssli) end endcase endif endif if noiz then print, ' sslcnt = ',strtrim(sslcnt,2) ; ---- Eliminate LONGS with missing data > 1 minor frame ---- if sslcnt gt 0 then begin sskp=intarr(sslcnt) for sl=0,n_elements(ssli)-1 do begin nrow=511/gt_res(index(ssli(sl))) ngdok=8/gt_res(index(ssli(sl))) datatest=total(data(0:nrow,0:nrow,ssli(sl)),1) ngd=where(datatest eq 0,nngd) if nngd gt ngdok then begin ;Permit one minor frame missing. sskp(sl)=1 sslcnt=sslcnt-1 nnssl=nnssl-1 endif endfor sskpi=where(sskp eq 0,nsskpi) if nsskpi gt 0 then ssli=ssli(sskpi) endif if noiz then print, ' sslcnt = ',strtrim(sslcnt,2) ; ------ Cycle through the set of LONG exposures -------- if sslcnt gt 0 then for ll=0,sslcnt-1 do begin rdm=index(ssli(ll)) ; ---- Check for saturation in LONG exposure ---- ; ---- sxt_satscreen returns a 1 for unsaturated images ---- satlong=sxt_satscreen(index(ssli(ll)),data(*,*,ssli(ll))) if noiz then print,gt_filtb(fb(filtx),/string),' ',$ gt_res(res(resx),/string),' satlong = ',satlong ; Ignore saturation for certain early dates and filters. if anytim(index(ssli(ll))) lt anytim('19-Sep-91 12:32') then satlong=1 if (anytim(index(ssli(ll))) lt anytim('24-Sep-91 11:18')) $ and (gt_filtb(index(ssli(ll))) eq 3) then satlong=1 ; Ignore saturation for 17-Apr-96 eclipse. LWA 7/27/09 if (anytim(index(ssli(ll))) gt anytim('17-Apr-96 22:03')) and $ (anytim(index(ssli(ll))) lt anytim('18-Apr-96 00:08')) $ then satlong=1 ; Ignore saturation for longs_only Table 1830. LWA 6/6/09 if (anytim(index(ssli(ll))) gt anytim('17-jan-97 08:42')) and $ (anytim(index(ssli(ll))) lt anytim('22-Jan-97 00:04')) $ then satlong=1 ; ------------- MEDIUM exposure (triplet only) -------- if triplet then begin if satlong then begin ssmi=-2 sssi=-2 ssmcnt=1 ssscnt=1 goto,SKIP endif ; ----- Necessary to specify whole days for this test. ; Change maxdt for 3-nov-94 eclipse. if anytim(index(0)) gt anytim('3-Nov-94 00:00') and $ anytim(index(n_elements(index)-1)) lt anytim('4-Nov-94 01:00') $ then maxdts=1800 ;else maxdts=maxdt ; Change maxdt for 24-oct-95 eclipse. if anytim(index(0)) gt anytim('24-Oct-95 00:00') and $ anytim(index(n_elements(index)-1)) lt anytim('25-Oct-95 01:00') $ then maxdts=1200 ;else maxdts=maxdt ; Change maxdts for 9-Mar-97 eclipse. if anytim(index(0)) gt anytim('8-Mar-97 00:00') and $ anytim(index(n_elements(index)-1)) lt anytim('11-Mar-97 01:00') $ then maxdts=1380 ;else maxdts=maxdt ; Change maxdts for PFI-dominant interval in May 2000. if anytim(index(0)) gt anytim('6-May-00 00:00') and $ anytim(index(n_elements(index)-1)) lt anytim('9-May-00 01:00') $ then maxdts=1200 ;else maxdts=maxdt ssmi=where(gt_filtb(index) eq fb(filtx) and $ gt_res(index) eq res(resx) and $ gt_expmode(index) eq 0 and $ match_saa_state(index, saa_state=saa_state) and $ gt_dpe(index) ge llow(1-triplet) and $ gt_dpe(index) le lhi(1-triplet) and $ (gt_shape_cmd(index,/x) eq gt_shape_cmd(index,/y)) and $ tim2night gt 2.0 and $ abs(int2secarr(index)-int2secarr(rdm,index(0))) le maxdts,ssmcnt) ; ----- Eliminate MEDIUMS where DPE and expdur don't agree ------------ ; ----- They must match within le 5%. ------------------------- if ssmcnt gt 0 then begin bad_exp=where(abs((gt_dpe(index(ssmi),/conv)-$ gt_expdur(index(ssmi)))/gt_dpe(index(ssmi),/conv)) gt 0.05,nbe) if nbe gt 0 then begin case 1 of ssmcnt eq nbe : begin ssmi=-1 ssmcnt=0 nnssl=nnssl-1 end nbe lt ssmcnt : begin okexp=delind(indgen(n_elements(ssmi)),bad_exp) ssmi=ssmi(okexp) ssmcnt=n_elements(ssmi) nnssl=nnssl-nbe end endcase endif endif ; ---- Allow partial images if active latitudes present ---- if ssmcnt gt 0 then begin nrow=511/gt_res(index(ssli(ll))) actband=fix(indgen(256)+150)/gt_res(index(ssli(ll))) ngdok=8/gt_res(index(ssli(ll))) sskp=intarr(ssmcnt) for pd=0,ssmcnt-1 do begin datatest=total(data(0:nrow,0:nrow,ssmi(pd)),1) ngd=where(datatest(actband) eq 0,nngd) if nngd gt ngdok then begin ;Permit one minor frame missing. sskp(pd)=1 ssmcnt=ssmcnt-1 endif endfor sskpi=where(sskp eq 0,nsskpi) if nsskpi gt 0 then ssmi=ssmi(sskpi) endif ; ---- Select which exposure to use -------------- if ssmcnt gt 0 then begin case 1 of ssmcnt gt 1 : begin ;Choose medium exposure nearest in time. ssmdt=tim2dset(index(ssmi),rdm) ssmi=ssmi(ssmdt) end ssmcnt eq 1 : ssmi=ssmi endcase ssmcnt=1 endif ; ----- Eliminate MEDIUMS with bleed ------------------- if n_elements(data) ne 0 and ssmcnt gt 0 then begin bleed=sxt_bleedtest(index(ssmi),data(*,*,ssmi)) bb=where(bleed eq 0,nbb) if nbb ne 1 then begin ssmcnt=0 ssscnt=0 nnssl=nnssl-1 endif endif ; ---- Check for saturation in MEDIUM exposure ---- if ssmcnt gt 0 then begin satmed=sxt_satscreen(index(ssmi),data(*,*,ssmi)) endif if ssmcnt le 0 then begin ssmcnt=0 ssscnt=0 nnssl=nnssl-1 endif endif ; ---- SHORT exposures w/matching resolution and filter ---------- if triplet and ssmcnt ne 0 then begin if satlong or satmed then begin sssi=-2 ssmcnt=1 ssscnt=1 goto,SKIP endif endif if NOT triplet and satlong then begin ;LONG not saturated sssi=-2 ssscnt=1 goto,SKIP endif xx=0 if NOT triplet then xx=1 if (triplet and ssmcnt gt 0) then xx=1 if xx then begin ; ----- Necessary to specify whole days for this test. ; Change maxdt for 3-nov-94 eclipse. if anytim(index(0)) gt anytim('3-Nov-94 00:00') and $ anytim(index(n_elements(index)-1)) lt anytim('4-Nov-94 01:00') $ then maxdts=1800 ;else maxdts=maxdt ; Change maxdt for 24-oct-95 eclipse. if anytim(index(0)) gt anytim('24-Oct-95 00:00') and $ anytim(index(n_elements(index)-1)) lt anytim('25-Oct-95 01:00') $ then maxdts=1200 ;else maxdts=maxdt ; Change maxdts for 9-Mar-97 eclipse. if anytim(index(0)) gt anytim('8-Mar-97 00:00') and $ anytim(index(n_elements(index)-1)) lt anytim('11-Mar-97 01:00') $ then maxdts=1380 ;else maxdts=maxdt ; Change maxdts for PFI-dominant interval in May 2000. if anytim(index(0)) gt anytim('6-May-00 00:00') and $ anytim(index(n_elements(index)-1)) lt anytim('9-May-00 01:00') $ then maxdts=1200 ;else maxdts=maxdt sssi=where(gt_filtb(index) eq fb(filtx) and $ gt_res(index) eq res(resx) and $ gt_expmode(index) eq 0 and $ gt_dpe(index) ge ssmin and gt_dpe(index) le ssmax and $ (gt_shape_cmd(index,/x) eq gt_shape_cmd(index,/y)) and $ tim2night gt 2.0 and $ abs(int2secarr(index)-int2secarr(rdm,index(0))) le maxdts, $ ssscnt) if ssscnt le 0 then nnssl=nnssl-1 ; ----- Eliminate SHORTS where DPE and expdur don't agree ------------ ; ----- Then must match within le 5%. ------------------------- if ssscnt gt 0 then begin bad_exp=where(abs((gt_dpe(index(sssi),/conv)-$ gt_expdur(index(sssi)))/gt_dpe(index(sssi),/conv)) gt 0.05,nbe) if nbe gt 0 then begin case 1 of ssscnt eq nbe : begin sssi=-1 ssscnt=0 nnssl=nnssl-1 end nbe lt ssscnt : begin okexp=delind(indgen(n_elements(sssi)),bad_exp) sssi=sssi(okexp) ssscnt=n_elements(sssi) nnssl=nnssl-nbe end endcase endif endif ; ---- Check for incomplete NuDen images ---- goto,whydothis if ssscnt gt 0 then begin ;NuDen filters special case nuden=where(gt_filta(index(sssi)) eq 6,nnud) if nnud ge 1 then begin nudok=where(gt_percentd(index(sssi(nuden))) eq 100,nnudok) if nnudok gt 0 then begin sssi=sssi(nuden(nudok)) ssscnt=nnudok endif else begin sssi=-1 ssscnt=0 endelse endif endif whydothis: ; ---- Allow partial images if active latitudes present ---- if ssscnt gt 0 then begin nrow=511/gt_res(index(ssli(ll))) actband=fix(indgen(256)+150)/gt_res(index(ssli(ll))) ngdok=8/gt_res(index(ssli(ll))) sskp=intarr(ssscnt) for pd=0,ssscnt-1 do begin datatest=total(data(0:nrow,0:nrow,sssi(pd)),1) ngd=where(datatest(actband) eq 0,nngd) if nngd gt ngdok then begin ;Permit only one minor frame missing. sskp(pd)=1 ssscnt=ssscnt-1 endif endfor sskpi=where(sskp eq 0,nsskpi) if nsskpi gt 0 then sssi=sssi(sskpi) if ssscnt eq 0 then nnssl=nnssl-1 ;LWA 31-Jan-2004 endif ; ---- Select which exposure to use -------------- ; ---- Select the optimum DPE ---- if ssscnt gt 0 then begin if ssscnt gt 1 then begin ;Choose largest unsaturated DPE value. sdpe=gt_dpe(index(sssi)) nsat=sxt_satscreen(index(sssi),data(*,*,sssi)) nsatii=where(nsat eq 1,nnsatii) ;Unsaturateds eq 1. if nnsatii ge 1 then begin ;Search only unsaturateds. sdii=where(sdpe(nsatii) eq max(sdpe(nsatii)),nsdii) if nsdii gt 1 then begin ;Choose nearest exposure. ttsd=abs(int2secarr(index(sssi(sdii)),index(0)) - $ int2secarr(rdm,index(0))) ttsdi=where(ttsd eq min(ttsd)) if n_elements(ttsdi) gt 1 then ttsdi=ttsdi(0) sd=sdii(ttsdi) endif else begin sd=nsatii(sdii) ;Fixed index error. LWA 8/20/09 endelse endif else begin if ssscnt gt 1 then begin ;Choose nearest exposure. ttsd=abs(int2secarr(index(sssi),index(0)) - $ int2secarr(rdm,index(0))) ttsdi=where(ttsd eq min(ttsd)) if n_elements(ttsdi) gt 1 then ttsdi=ttsdi(0) sd=ttsdi endif else begin sd=0 endelse endelse endif else begin sd=0 endelse sssi=sssi(sd) ssscnt=1 endif if NOT triplet then begin ;Only worry about bleeds for doublets. ; ----- Eliminate SHORTS with bleed ------------------- if n_elements(data) ne 0 and ssscnt gt 0 then begin bleed=sxt_bleedtest(index(sssi),data(*,*,sssi)) bb=where(bleed eq 0,nbb) if nbb ne 1 then begin sssi=-1 ssscnt=0 nnssl=nnssl-1 endif endif endif endif SKIP: if (triplet and ssmcnt eq 1 and ssscnt eq 1) then begin ssl=[ssl,ssli(ll)] ssm=[ssm,ssmi] sss=[sss,sssi] endif if (NOT triplet and ssscnt eq 1) then begin ssl=[ssl,ssli(ll)] sss=[sss,sssi] endif endfor ;End of long-exposure loop. mess=['#images w/filter '+gt_filtb(fb(filtx),/string) + $ '& resolution of '+ gt_res(res(resx),/string)+' = ' + strtrim(nnssl,2)] if noiz then box_message,mess endfor ;End of filter loop. endfor ;End of resolution loop. if noiz then print,ssl if noiz then print,ssm if noiz then print,sss if max(ssl) eq -1 then goto, tymout if frstind eq 0 then begin rdmout=index datout=data if (triplet and max(ssl) ge 0) then begin ssl_out=ssl(where(ssl ne -1)) ssm_out=ssm(where(ssm ne -1)) sss_out=sss(where(sss ne -1)) endif if (NOT triplet and max(ssl) ge 0) then begin ssl_out=ssl(where(ssl ne -1)) sss_out=sss(where(sss ne -1)) endif endif else begin if triplet then begin ssltmp=ssl(where(ssl ne -1))+n_elements(rdmout) ssl_out=[ssl_out,ssltmp] ssmtmp=ssm(where(ssm ne -1))+n_elements(rdmout) m2=where(ssm eq -2,nm2) if nm2 gt 0 then begin m2=m2-1 ssmtmp(m2)=-2 endif ssm_out=[ssm_out,ssmtmp] ssstmp=sss(where(sss ne -1))+n_elements(rdmout) m2=where(sss eq -2,nm2) if nm2 gt 0 then begin m2=m2-1 ssstmp(m2)=-2 endif sss_out=[sss_out,ssstmp] endif if NOT triplet then begin ssltmp=ssl(where(ssl ne -1))+n_elements(rdmout) ssl_out=[ssl_out,ssltmp] ssstmp=sss(where(sss ne -1))+n_elements(rdmout) m2=where(sss eq -2,nm2) if nm2 gt 0 then begin m2=m2-1 ssstmp(m2)=-2 endif sss_out=[sss_out,ssstmp] endif rdmout=concat_struct(rdmout,index) datout=[[[datout]],[[data]]] endelse tymout: endfor ;End of nset loop. endfor ;End of tym loop. nodice : dun=0 if n_elements(rdmout) eq 0 then begin count=0 if debug then stop return endif roadmap=rdmout xdata=datout ssl=ssl_out if triplet then ssm=ssm_out sss=sss_out if noiz then print count=n_elements(ssl) ; ------------- time sort all output ------------ order=0 if n_elements(ssl) gt 1 then order=sort_index(roadmap(ssl),/ss) ssl=ssl(order) if triplet then ssm=ssm(order) sss=sss(order) if not keyword_set(triplet) then ssm=sss ; ------------ eliminate duplicates -------------- ttdup=int2secarr(roadmap(ssl),'1-sep-91') uudup=uniq(ttdup) ssl=ssl(uudup) ssm=ssm(uudup) sss=sss(uudup) outindex=roadmap outdata=xdata if debug then begin print,'STOP END of mk_sff_pair.' stop endif end