parameter ichip iflat if ichip>0 string outfield '{field}%i1' ichip else string outfield {field} end_if open shift {outfield}/{outfield}a.shift ii=1 work1=102 do ifilt=1,nfilt string filt 'filt%i1' ifilt string var 'nframe%i1' ifilt do iframe=1,{var} ! get the appropriate file name string var2 'name%i1%i2.2' ifilt iframe if ichip>0 string name '{{var2}}%i1' ichip else string name '{{var2}}' end_if ! Read in data frame rd $ii '{name}' {pictype} ! Read the noiseless fake star frame rd 101 tmp/{name}fake full ! Flat field and distortion if wfpc==1 if iflat==0 $echo {{filt}} | awk '\{print toupper($0)\}' > /tmp/tmp.lis open tmp /tmp/tmp.lis string ufilt {tmp} close tmp string flat 'iflat_{ufilt}_%i1' ichip rd $work1 wfpc2cal/flats/{flat} div 101 $work1 end_if string file 'pixarea_%i1' ichip rd $work1 wfpc2cal/distort/{file} div 101 $work1 call wfpcgain ii ichip end_if ! get proper nomalization for each frame, which is exposure time and ! possibly extinction correction (if extinction coef has been defined). ! load normalization factor into scaleII variables string scvar 'scale%i2.2' ii string extvar 'ext%i2.2' ii string k 'k%i1' ifilt err continue hjd $ii err goto noair {extvar}=10^(0.4*{k}*{ii:am}) {scvar}={?ii:exptime}*{extvar} air0=0 goto haveair noair: {extvar}=1 {scvar}={?ii:exptime} air0=-1 haveair: exp1={scvar} ! Scale appropriately string cnts 'fake%i1' ifilt mul 101 c={cnts}*exp1*gain0/gain photons 101 mean=0 gain=gain rn=0 poisson add $ii 101 wd $ii tmp/{name} {pictype} full ii=ii+1 end_do end_do end