parameter i1 i2 nointer ! Gets shifts between images ! Sorts files into stacks for CR rejections by pointing only ! Sorts files into stacks for combination by pointing and exptime open input ./fields.lis stat n=count[input] string field {input} call {field}setup if acs==1 n=2 end_if if wfpc==1 n=4 end_if if mosaic==1 n=8 end_if if i1==0 i1=1 i2=n else_if i2==0 i2=i1 end_if $mkdir oldcomb $mv comb_*.out oldcomb/ ! Do two passes. First pass will just use header shifts and will then ! call PICCRS for CR rejection. Second pass will use the CR-rejected ! frames and get shifts by cross-correlation do ipass=1,2 $'rm' cross.dat getshift.err do ifield=1,n if ifield>=i1&ifield<=i2 if wfpc==1|mosaic==1|acs==1 call {field}setup ifield else call {field}setup end_if call look ipass-1 nn=ntot tmax=0 do i=1,nn t={i:exptime} if (t>tmax) iref=i tmax=t end_if end_do i=0 do ifilt=1,nfilt do isort=1,2 if isort==1 ! For CR reject, sort by pointing only tmin=0 tmax=1e10 dmax=0.3 else_if isort==2 ! For combining , sort by pointing and exposure time if wfpc==1 tmin=0.5 tmax=2. end_if dmax=0.5 end_if npoint=0 string nf 'nframe%i1' ifilt do j=1,{nf} i=i+1 if (i==iref) dx=0 dy=0 dxhead=0 dyhead=0 else if ipass==1 call getshift iref i 0 else call getshift iref i 1 end_if end_if if (i==1) dx0=dx dy0=dy end_if texp={i:exptime} call getfilt i ! string filt {i:filtnam1} string var 'name%i1%i2.2' ifilt j if isort==1 printf '%4f8.2 {filt} {i:exptime} {{var}}' dx-dx0 dy-dy0 | dxhead-dx0 dyhead-dy0 >>./cross.dat string rout 'crmask_{filt}' else string rout 'comb_{filt}' end_if jpoint=0 new=0 if npoint>0 do ipoint=1,npoint string xvar 'pdx%i' ipoint string yvar 'pdy%i' ipoint string tvar 'pexp%i' ipoint if (abs[dx-{xvar}]tmin&texp/{tvar}./{out}.out else printf '{{var}}_c0f %2f8.2' dx dy >>./{out}.out end_if else if new==1 printf '{{var}}_c0f %2f8.2' dx-{pdx} dy-{pdy} >./{out}.out else printf '{{var}}_c0f %2f8.2' dx-{pdx} dy-{pdy} >>./{out}.out end_if if j==1 printf '{{var}}_c0f %2f8.2' dx dy >./{rout}.all else printf '{{var}}_c0f %2f8.2' dx dy >>./{rout}.all end_if end_if end_do if isort==1 i=i-{nf} ! Find out if any of the pointings only have one image, in which case we will ! want to CR-reject them along with another pointing do jpoint=1,npoint string var 'n%i' jpoint string out '{rout}%i' jpoint open inpoint ./{out}.out stat {var}=count[inpoint] close inpoint end_do end_if end_do end_do end_if end_do if ipass==1 oldshift=ishift ishift=1 call piccrs ishift=oldshift else $'rm' red/*[1-4].fits red/z*.img red/z*.hdr end_if end_do $'rm' crmask.all do ifilt=1,nfilt string nf 'nframe%i1' ifilt if {nf}==1 $cat crmask_*.all > crmask.all end_if end_do $mkdir newcomb $cp comb_*.out newcomb/ $diff oldcomb newcomb >./{field}.diffcomb end