pro movie_review,yyyy,month,day,week=week,$ holdit=holdit,mkfile=mkfile,$ outdat=outdat,info=info,img=img,$ indx=indx,movy=movy,noroll=noroll,$ header=header,check=check,scale=scale,$ stdate=stdate,endate=endate,nolimit=nolimit,$ kurdir=kurdir,indir=indir,outfile=outfile,fastqr=fastqr,$ calndr_wk=calndr_wk,wl=wl,outdir=outdir,pauz=pauz,$ xsize=xsize,sho_pfi=sho_pfi,one_res=one_res,quiet=quiet ;+ ; NAME ; movie_review ; PURPOSE ; To efficiently view SXT movie (from fits files) 500 images ; at a time and flag problem images. A limited index structure ; and flag vector is saved using savegen. If desired, the ; FITS header and associated image may be returned in response ; to a question. Draw a limb circle if /circle is set ; CALLING SEQUENCE ; movie_review,yyyy,month,day,week=week,$ ; holdit=holdit,mkfile=mkfile,$ ; outdat=outdat,info=info,img=img,$ ; indx=indx,movy=movy,noroll=noroll,$ ; header=header,check=check,scale=scale,$ ; stdate=stdate,endate=endate,nolimit=nolimit,$ ; kurdir=kurdir,indir=indir,outfile=outfile,fastqr=fastqr,$ ; calndr_wk=calndr_wk,wl=wl,outdir=outdir,pauz=pauz,$ ; xsize=xsize,sho_pfi=sho_pfi,one_res=one_res,quiet=quiet ; INPUT ; yyyy, year (if this is the only input entire year is done). ; OPTIONAL INPUT ; month, [1 -> 12] only the chosen month is done. ; day, [1 -> 31] only the chosen day is done. Must input month ; to use day. If day not entered entire month is done. ; OPTIONAL KEYWORD INPUT ; /calndr_wk, read calender week rather than default FEM week. ; (Only effective if keyword week is used.) ; /fastqr, rebin to 256x256 for faster running. This sets nolimit=1. ; /holdit, stop at end before returning. ; /mkfile, write output genx file. ; /outdat, set keyword outdat to return specified info & img. ; week, read an entire week at once (ex: '2001_14') ; /noroll, read data from /fix_att ; stdate, Starting time for review, e.g., '9-aug-01 10:30' ; endate, Ending time for review, e.g., '10-aug-01 01:22' ; (If stdate given and not endate then endate=stdate+24 hours.) ; /nolimit, Normally this program loads and shows the movie ; 250 frames at a time. This keyword removes this limit ; and all frames are loaded at once. BEWARE, it is easy ; to overwhelm the computer memory. ; /kurdir, write output to curdir(). Else 'mov_rev/'. ; outdir, where to write the output review files. ; indir, where to go for movies, $ ; default: /disk/yla/www/archive/yohkoh/sxtmov33. ; /wl, review the YLA white light images. ; pauz, number of sec to wait between frames. ; xsize, display image size if rebin desired. ; /sho_pfi, overlay PFI FOV on every image. ; one_res, set keyword to 'HR' or 'QR' to display only one resolution. ; /scale, use tvscl in stepper rather than tv. ; /quiet, do not print intro stuff for stepper. ; OUTPUT ; A limited index structure and flag vector is saved using savegen. ; The flag vector is an array of 0's, 1's and 2's, corresponding ; to use of the 0, 1, 2, 3 or 4 keys during the stepper3 viewing of ; the movie. Normally: ; 0 indicates a good image. ; 1 indicates an attitude problem with the short exposure. ; 2 indicates an attitude problem with the long exposure. ; 3 indicates a roll problem. ; 4 indicates a totally junk image. ; OPTIONAL OUTPUT ; OPTIONAL KEYWORD OUTPUT ; outfile, path and name of .genx file saved. ; info, FITS header for selected image. ; img, SXT movie image ; indx, the index array from sxt_fits_info ; movy, the movie array ; header, the entire FITS header array ; check, the flag vector ; PROGRAMS USED ; findfile, fix, execute, ssc_mreadfits, readfits, sxt_fits_info, ; fmt_tim, strtrim, stepper3, stepper3_s1, merge_struct, ; savegen ; HISTORY ; 4-May-2005 LWA, Written. ; 5-May-2005 LWA, Converted to .genx output. ; 9-May-2005 LWA, Corrected savegen name. ; 14-May-2005 LWA, Added info to the savegen call. ; Simplified code considerably. ; 6-Jul-2005 LWA, Added keyword nofile. ; 21-Jul-2005 LWA, Added capability to return head,img. ; 2-Aug-2005 LWA, Installed AkT fix for 100 image case. ; Changed info output to FITS header. ; 3-Aug-2005 LWA, Added triplet keyword. ; 5-Aug-2005 LWA, Made graceful return if no files found. ; Made ind and mov optional returned output. ; 29-Sep-2005 LWA, Changed sxtf* to sx* in filename calls. ; Added keywords ind,mov,week. ; 4-Oct-2005 LWA, Added mov7 keyword. ; 7-Oct-2005 LWA, Added noroll keyword. ; 14-Oct-2005 LWA, Changed ind to indx and mov to movy. ; 17-Oct-2005 LWA, Changed logic to return all indx, movy. ; 25-Oct-2005 LWA, Added keyword header. ; 31-Oct-2005 LWA, Updated calling sequence. ; Fixed case for use of week. ; Updated hardwired directories. ; 1-Nov-2005 LWA, Debugged. ; 3-Nov-2005 LWA, Added ind=rem_tag2(ind,'TEMP_HK') ; 10-Nov-2005 LWA, Added keyword stdate, endate and nolimit. ; 11-Nov-2005 LWA, Debugged, nolimit=keyword_set(nolimit). ; 7-Dec-2005 LWA, Added keyword kurdir. ; 9-Dec-2005 LWA, Minor yyyy debug. ; 8-Feb-2006 LWA Added keyword indir. ; 6-Jul-2006 LWA Removed mov7 and noroll functions. ; Changed default /disk/yl1/sx[2or3]mov9. ; 17-Jul-2006 LWA Revived /noroll using /disk/yl5/sx2mov8_nr. ; 23-Jan-2007 LWA Now default is NOT to write file. ; Updated movie directory hardcode. ; 17-Feb-2007 LWA Updated mov_rev directory for .genx output. ; Added keyword outfile. ; Updated header for keyword indir. ; 20-Feb-2007 LWA Set indir to version 10 movies. ; 20-Jun-2007 LWA Disabled keyword sst. ; Set indir to sxtmov9. ; Time order files because of SSC, SST mix. ; 27-Jun-2007 LWA Replaced my time ordering with ssc_mreadfits. ; Replaced concat_struct with merge_struct. ; 3-Jul-2007 LWA Changed default indir to sxtmov10. ; Changed dir='mov_rev' to dir='mov_rev/' ; Changed procedure for sorting files. ; 5-Jul-2007 LWA Deleted all reference to sst. ; 15-Oct-2007 LWA Added keyword output check. ; 19-Oct-2007 LWA Deleted a couple useless statements. ; 4-Jan-2008 LWA Changed default indir to /disk/hl3/ylegacy/sxtmov16 ; Added keyword fastqr. ; 9-Jan-2008 LWA Added runtime message. ; 18-Jan-2008 LWA Corrected header re/ kurdir. ; 22-Jan-2008 LWA Updated txt for "final" YLA movie reviews. ; 23-Jan-2008 LWA Added keyword bite_scl. ; 27-Jan-2008 LWA Deleted keyword bite_scl. ; 28-Jan-2008 LWA Added keyword calndr_wk, default is to read FEM week. ; 20-Mar=2008 LWA Added keyword /fast to all mreadfits calls. ; 9-May-2008 LWA Added keyword /wl to read aspect images. ; 14-May-2008 LWA Added keyword outdir. ; 20-May-2008 LWA Corrected bug in WL outdir statement. ; 18-Jul-2008 LWA Added new 0,1,2,3,4 usage and updated txt. ; 8-Aug-2008 LwA Header improvements. ; 25-Jan-2009 LWA Added keyword pauz. ; 20-Apr-2009 LWA Handle special /mkfile case. ; 11-May-2009 LWA Eliminate get_movy_info. Header now compatible ; with all gt_xxx functions. ; Default indir now '/disk/sb1/sxtmov22' ; 12-May-2009 LWA Added keyword xsize and sho_pfi. ; 2-Jun-2009 LWA Added keyword one_res. ; 6-Feb-2010 LWA Default indir now '/disk/sb1/sxtmov26' ; 26-Apr-2010 LWA Default indir now '/disk/hl3/ylegacy/sxtmov30' ; Added keyword scale. ; 4-May-2010 LWA Added keyword quiet. ; 7-Jul-2010 LWA indir='/disk/sb1/sxtmov30a' ; Clarified header re/ use of "day". ; 16-Feb-2011 LWA Default indir temporarily '/disk/sb1/sxtmov32' ; 3-Aug-2011 LWA Default indir '/disk/yla/www/archive/yohkoh/sxtmov33' ; 5-Apr-2012 LWA View images in blocks of 250. ;- txt=['These data were produced with the program movie_review.pro.', $ 'HEAD is the array of FITS headers for all movie images in the period', $ 'identified in the file name. Entries in the corresponding vector,', $ 'CHECK, have the values 0, 1, 2, 3 or 4. A 0 signifies an OK image.', $ 'A 1 denotes an image requiring attitude correction of the short exposure.', $ 'A 2 indicates attitude problems with the long exposure. A 3 signifies', $ 'a roll problem and a 4 indicates that the image is totally junk.'] start_time = systime(1) wl=keyword_set(wl) scale=1-keyword_set(scale) if keyword_set(one_res) then begin case 1 of one_res eq 'hr' : ores=1 one_res eq 'qr' : ores=2 else : begin print,'*** Keyword one_res, if set, must be HR or QR.' print,'*** Returning.' return end endcase endif help,one_res,ores mkfile=keyword_set(mkfile) noroll=keyword_set(noroll) nolimit=keyword_set(nolimit) fastqr=keyword_set(fastqr) if fastqr then nolimit=1 femwk=1-keyword_set(calndr_wk) if not keyword_set(indir) and not wl then begin mdir='sxtmov33' disk='/disk/yla/www/archive/yohkoh/' endif else begin mdir=indir disk='' endelse if noroll then begin mdir='fix_att' disk='/disk/hl2/pd1/acton/' endif kurdir=keyword_set(kurdir) if keyword_set(outdir) then kurdir=0 help,mdir,disk,kurdir,outdir if not keyword_set(week) and not keyword_set(stdate) then begin yyyy=strtrim(yyyy,2) mml=['00','01','02','03','04','05','06','07','08','09','10','11','12'] ddl=[mml,strtrim(indgen(19)+13,2)] if keyword_set(month) then begin mn=mml(month) mm0=mn endif else begin mn='*' mm0='mm' endelse if keyword_set(day) then begin dy=ddl(day) dd0=dy endif else begin dy='*' dd0='dd' endelse if n_elements(month) eq 0 then begin t1='1-jan-'+yyyy+' 00:00' t2='31-dec-'+yyyy+' 23:59' dirr=disk+mdir if wl then files=ssw_time2paths(t1,t2,dirr,file='sa*') else $ files=ssw_time2paths(t1,t2,dirr,file='sx*') nfil=n_elements(files) endif else begin if wl then begin files=findfile(disk+mdir+'/'+yyyy+'/'+mn+'/'+dy+'/sa*',count=nfil) endif else begin files=findfile(disk+mdir+'/'+yyyy+'/'+mn+'/'+dy+'/sx*',count=nfil) endelse endelse if nfil le 0 then begin print,'*** No files found for '+mdir+'/'+yyyy+'/'+mn+'/'+dy+', returning' return endif mreadfits,files,index,/fast aa=anytim(index) ss=sort(aa) uu=uniq(ss) files=files(ss(uu)) endif if keyword_set(week) and not keyword_set(stdate) then begin xxx=anytim(weekid2ex(week,t1,t2)) yyyy=strmid(anytim(xxx,/ccsds),0,4) print,' Week = ',week,' t1 = ',t1,' t2 = ',t2 dirr=disk+mdir help,dirr if not femwk then begin if wl then files=ssw_time2paths(t1,t2,dirr,file='sa*') else $ files=ssw_time2paths(t1,t2,dirr,file='sx*') endif else begin iwk=fix(strmid(week,5,2)) rd_week_file,iwk,yyyy,'FEM',fem first_ut=anytim2ints(fem(0)) last_ut=anytim2ints(fem(n_elements(fem)-1),$ off=fem(n_elements(fem)-1).night) print,' FEM week: ' & fmt_timer,[first_ut,last_ut] files=rd_movy_files(first_ut,last_ut,mdir=indir,wl=wl) endelse if files(0) eq '' then begin print,'*** No files found for week ',week,'. ***' return endif mreadfits,files,index aa=anytim(index) ss=sort(aa) uu=uniq(ss) files=files(ss(uu)) endif if keyword_set(stdate) then begin yyyy=strmid(anytim(stdate,/ccsds),0,4) tt1=anytim(stdate,/ints) if not keyword_set(endate) then begin tt2=tt1 tt2.day=tt1.day+1 endif else begin tt2=anytim(endate,/ints) endelse print,'Time interval: '+fmt_tim(tt1)+' '+fmt_tim(tt2)+'.' dirr=disk+mdir if wl then files=ssw_time2paths(tt1,tt2,dirr,file='sa*') else $ files=ssw_time2paths(tt1,tt2,dirr,file='sx*') if files(0) eq '' then begin print,'*** No files found for interval'+fmt_tim(tt1)+' '+fmt_tim(tt2)+'. ***' return endif mreadfits,files,index aa=anytim(index) ss=sort(aa) uu=uniq(ss) files=files(ss(uu)) index=index(ss(uu)) xx=sel_timrange(index,tt1,tt2,/between) files=files(xx) endif help,files if not nolimit then begin ;nn=fix((n_elements(files)/100.01)+1) ; Credit: AkT, 8/2/05. nn=fix((n_elements(files)/250.01)+1) ; LWA 4/5/2012.. endif else begin nn=1 endelse help,nn begn=0 for i=0,nn-1 do begin if not nolimit then begin if ((i+1)*250-1 lt n_elements(files)-1) then $ oo=(i+1)*250-1 else oo=n_elements(files)-1 mreadfits,files(i*250:oo),ind,mov,/silent endif else begin mreadfits,files,ind,mov,/silent if fastqr then begin for j=0,n_elements(ind)-1 do begin mov(0:255,0:255,j)=rebin(mov(*,*,j),256,256) endfor mov=mov(0:255,0:255,*) endif endelse print print,i,' ',fmt_tim(ind(0)),' to ',$ fmt_tim(ind(n_elements(ind)-1)) if wl then noscale=0 else noscale=scale ;LWA 26-Apr-2010 help,ind,mov if keyword_set(one_res) then begin rez=where(gt_res(ind,/original) eq ores) if rez(0) ne -1 then begin ind=ind(rez) mov=mov(*,*,rez) endif else begin print,'*** No '+one_res+' images. Skipping ahead.' goto,no_one_res endelse endif help,rez,ind if fastqr then begin work=stepper3q(ind,mov,noscale=noscale,pauz=pauz) endif else begin work=stepper3(ind,mov,noscale=noscale,pauz=pauz,$ xsize=xsize,sho_pfi=sho_pfi,quiet=quiet) endelse if begn eq 0 then begin head=ind check=work movy=mov begn=1 endif else begin head=merge_struct(head,ind) check=[check,work] movy=[[[movy]],[[mov]]] endelse no_one_res: endfor if mkfile then begin case 1 of keyword_set(outdir) : dir=outdir+'/' kurdir and not wl : dir=curdir()+'/' wl : dir='wl_rev/' else : dir='mov_rev/' endcase ; if keyword_set(stdate) then dir=curdir()+'/' ;LWA 5/11/09. case 1 of wl : begin if NOT keyword_set(week) then outfile=dir+'wl_rev_'+yyyy+mm0+dd0 $ else outfile=dir+'wl_rev_'+week end else : begin if NOT keyword_set(week) then begin if not_exist(mm0) then begin outfile=dir+'mov_rev_'+stdate endif else begin outfile=dir+'mov_rev_'+yyyy+mm0+dd0 endelse endif else begin outfile=dir+'mov_rev_'+week endelse end endcase help,outfile savegen,file=outfile,head,check,names=['head','check'],text=txt endif if keyword_set(outdat)then begin print print,'Do you want to save an image? Enter -1 if NO.' print,'Enter an image number if YES.' read,prompt=' Which image number: ',image if image ne -1 then begin nn=strtrim(fix(image),2) info=head(nn) img=movy(*,*,nn) endif endif if keyword_set(holdit) then stop header=head end_time = systime(1) run_time = (end_time-start_time)/60. print, 'MOVIE_REVIEW took', run_time, ' minutes to process your request.' end