Flat-field Correction Analysis (GPC1 2009.10)

* Generate a flat-field correction analysis run selecting an appropriate set of observations:

set options = "-simple -dbname gpc1 -definebyquery"
set options = "$options -set_label flatcorr.20091003"
set options = "$options -dateobs_begin 2009-06-10T00:00:00 -dateobs_end 2009-06-14T00:00:00"
set options = "$options -comment %sdss_radec_photcorr%"
set options = "$options -set_workdir neb://@HOST@.0/gpc1/flatcorr.20091003"
set options = "$options -set_dvodb /data/ipp009.0/gpc1/flatcorr.20091003"

flatcorr $options -filter g.00000
flatcorr $options -filter r.00000
flatcorr $options -filter i.00000
flatcorr $options -filter z.00000
flatcorr $options -filter y.00000

* Apply the corrections:

dettool -makecorrection -det_type FLATTEST -det_id 105 -iteration 0 -workdir neb://@HOST@.0/gpc1/flatcorr.20091003 -dbname gpc1
dettool -makecorrection -det_type FLATTEST -det_id 106 -iteration 0 -workdir neb://@HOST@.0/gpc1/flatcorr.20091003 -dbname gpc1
dettool -makecorrection -det_type FLATTEST -det_id 107 -iteration 0 -workdir neb://@HOST@.0/gpc1/flatcorr.20091003 -dbname gpc1
dettool -makecorrection -det_type FLATTEST -det_id 109 -iteration 0 -workdir neb://@HOST@.0/gpc1/flatcorr.20091003 -dbname gpc1
dettool -makecorrection -det_type FLATTEST -det_id 110 -iteration 0 -workdir neb://@HOST@.0/gpc1/flatcorr.20091003 -dbname gpc1

* Test the corrections:

set options = "-simple -dbname gpc1 -definebyquery -make_correction"
set options = "$options -set_reduction FLATTEST -det_type FLATTEST"
set options = "$options -set_label flattest.20091010"
set options = "$options -dateobs_begin 2009-06-10T00:00:00 -dateobs_end 2009-06-14T00:00:00"
set options = "$options -comment %sdss_radec_photcorr%"
set options = "$options -set_workdir neb://@HOST@.0/gpc1/flattest.20091010"
set options = "$options -set_dvodb /data/ipp009.0/gpc1/flattest.20091010"
set options = "$options -set_region 240,255:-5,5"

flatcorr $options -filter g.00000
flatcorr $options -filter r.00000
flatcorr $options -filter i.00000
flatcorr $options -filter z.00000
flatcorr $options -filter y.00000

After the flattest ran successfully, I changed the det_type of the test flat (the corrected flat) to FLAT, and the original input flat to (FLAT_RAW).

In fact, this is a little confusing in the database: the r-band correction analysis failed initially, but I still created the detRun for the correction, setting the state to 'wait' so it would not be processed. But, I created the corrected flat-field detRun for r-band, which means the corrected flat (FLATTEST originally, now FLAT) comes before the correction for r-band (since the correction is created only after the processing finishes).