! ! prepare.prg :: prepare flat field and wavelength solution ! ! convert into midas ! rotate ! create median bias ! subtract median bias ! DEFINE/PARAM p1 ? N "Enter grism number:" !! above you can append a range for the grism number, so midas will !! check that the number is not crap load/lut heat set/context long !! copy line catalog into current dir, midas sometimes does not like !! the remote location... !! $ cp /scisoft/midas/calib/data/spec/line/hear.tbl stdlines.tbl !! set default parameters !! @@ defaultpars{p1} !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! fits -> bdf !! $ls *.fits > in.cat $ls *.fits | sed s/fits/bdf/ > out.cat ! $paste in.cat out.cat indisk/fits in.cat out.cat !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! rotate, to have lambda from sx to dx !! !! overwrites original images !! restores descriptors start and step !! $ls *.bdf | awk '{print "rotate/clock "$1" r"$1}' > rclock.prg write/out rotating images ... @@ rclock $cat rclock.prg | awk '{print "mv "$3,$2}' > mv.sh $sh mv.sh crea/icat all exec/cat write/descr all.cat start 1,1 exec/cat write/descr all.cat step 1,1 exec/cat copy/dd all.cat ESO.TEL.AIRM.END all.cat o_airm !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! create median bias frame !! !! get cursor to stop processing !! crea/icat bias *Dark*.bdf $vi bias.cat !! edit catalog to remove unwanted (e.g. dark) COMBINE/LONG bias bias MEDIAN load bias scale=-3 STAT/IMAGE bias plot=p excess=0,300 write/out this BIAS will be subtracted from frames write/out exit from display to continue get/cur !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! subtract bias from all images !! exec/cat compute/ima all.cat = all.cat - bias !! goto end flatfield: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! create master flat field !! !! trim !! create median !! normalize !! show !! !! CREATE/ICAT flat *FlatSpec*.bdf $vi flat.cat !! trim flat field !! PREPARE/LONG flat.cat tflat CREATE/ICAT flat tflat*.bdf COMBINE/LONG flat medflat median !! normalization: the degree of the polynomial is decided by !! set/long fdeg=xxx !! NORMALIZE/FLAT medflat masterflat 0 !! ^ ^ !! bias level !! load masterflat cuts=f,ihap scale=-2 write/out frames will be divided by this master flat write/out exit from display to continue ... get/cur !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! trim objects and HeAr !! write/out trimming HeAr !! !!crea/icat spectra *Spectrum*bdf !!prepare/long spectra.cat obj !! crea/icat spectra obj*bdf !!!!!!!! trimhear: crea/icat hear *HeAr*bdf !! edit HeAr catalog, leave just the best arc $vi hear.cat prepare/long hear.cat hear crea/icat hear hear*bdf !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! divide objects and HeAr by master flatfield !! and check final result !! !!exec/cat compute/ima spectra.cat = spectra.cat / masterflat !!exec/cat load spectra.cat cuts=f,ihap scale=-2 !! Actually dividing the hear by the masterflat can create spurious !! lines (e.g. grism 2 of EFOSC), so better not do it! !! !!exec/cat compute/ima hear.cat = hear.cat / masterflat !!exec/cat load hear.cat cuts=f,ihap scale=-2 !! !! create master HeAr frame, and show !! avera/ima masterhear = hear.cat ? ? median load masterhear cuts=f,ihap scale=-2 !! calibrate in lambda, based on a guess session !! !! override some parameters with reference session !! $cp ~/midwork/initial_{p1}.tbl refsess.tbl $cp ~/midwork/initial_{p1}COE.tbl refsessCOE.tbl init/long refsess @@ waveguess end: