A master flatfield is required to perform optimal flux extraction and to determine the blaze function. Due to the stability of the spectrograph, one master flatfield is typically 'valid' for at least a two-week period. Cross-comparison between different master flatfields taken months apart have not been conducted so far.
The procedure to create the master flatfield is a multi-step process.
3-5 flatfield images taken for the science fiber only (DFFFD). No light in the sky and simultaneous calibration fiber. Peak count levels should be 40k-45k DN in each arm.
3-5 flatfield images taken through the sky fiber and the simultaneous calibration fiber (FDDDF). Peak count levels should be 40k-45k DN in each arm.
Static instrument config files for blue and red arm.
2D frames with intermediate products and final master flat. See Reduction Procedure below.
STEP 1: Combination of individual images to increase SNR and remove particle hits (outliers).
From the base directory (maroonx_reduce) call: PYTHONPATH=${PWD} python reduce/recipes/make_master_flats.py
with the following parameters:
-dd DATA_DIRECTORY, --data_directory DATA_DIRECTORY Directory for fits input files.
--filename_FDDDF_b FILENAME_FDDDF_B Name of files to downselect blue FDDDF frames, e.g. 20211027T02*_FDDDF_b_0005.fits
--filename_FDDDF_r FILENAME_FDDDF_R Name of files to downselect red FDDDF frames, e.g. 20211027T02*_FDDDF_r_0001.fits
--filename_DFFFD_b FILENAME_DFFFD_B Name of files to downselect blue DFFFD frames, e.g. 20211027T02*_DFFFD_b_0005.fits
--filename_DFFFD_r FILENAME_DFFFD_R Name of files to downselect red DFFFD frames, e.g. 20211027T02*_DFFFD_r_0001.fits
--output_directory OUTPUT_DIRECTORY Existing directory for output fits files to overwrite default of
/datax/MaroonX_spectra_reduced/Maroonx_masterframes/YYYYMMxx/flats/
Example 1: PYTHONPATH=${PWD} python reduce/recipes/make_master_flats.py -dd /data6/MaroonX_spectra/20211027/ --filename_FDDDF_b *FDDDF_b_0005.fits
Example call collects all blue and red DFFFD and all red FDDDF frames in input directory /data6/MaroonX_spectra/20211027 but only blue FDDDF frames matching the given pattern and combines those to a number of master frames saved in /data6/MaroonX_spectra_reduced/Maroonx_masterframes/20111027/flats/. Files containing 'median', 'sigma', and 'diff' can be ignored. These are for QC only. The important output files are:
YYYYMMDDTHH_masterflat_DFFFD_C_TTTT.fits or
YYYYMMDDTHH_masterflat_FDDDF_C_TTTT.fits,
where date/time (YYYYMMDDHH), camera arm (C), and exposure time (TTTT) are from the first frame in each in input list.
STEP 2: Order tracing. The intermediate masterflats created in step 1 will be background subtracted in step 3. For that we need to know the location of the illuminated fibers in each frame. This is accomplished by running the file through reduce/extraction.py . In the GUI, use the masterflat fits file for both the 'science file' and the 'flat file' input, specify '1,5' and '2,3,4' for illuminated fibers of the FDDDF and DFFFD files, respectively, and select debug level 1. No dark file is required. Run the extraction separately for each of the four masterflats. The result are four HDF output files with the same name as the input file. These should be copied into the same directory as the master fits files.
STEP 3: Background subtraction is based on the photutils package Background2D.
From the base directory (maroonx_reduce) call: PYTHONPATH=${PWD} python reduce/recipes/backgroundfit.py
with the following parameters:
-dd DATA_DIRECTORY, --data_directory DATA_DIRECTORY Directory for fits input files.
--filename_FDDDF_b FILENAME_FDDDF_B Root of blue master FDDDF frame if non-standard or more than one in data_directory, e.g.
*T02_masterflat_FDDDF_b_0005
--filename_FDDDF_r FILENAME_FDDDF_R Root of red master FDDDF frame if non-standard or more than one in data_directory, e.g.
*T02_masterflat_FDDDF_r_0001
--filename_DFFFD_b FILENAME_DFFFD_B Root of blue master DFFFD frame if non-standard or more than one in data_directory, e.g.
*T02_masterflat_DFFFD_b_0005
--filename_DFFFD_r FILENAME_DFFFD_R Root of red master DFFFD frame if non-standard or more than one in data_directory, e.g.
*T02_masterflat_DFFFD_r_0001
--output_directory OUTPUT_DIRECTORY Existing directory for output fits files if different from input data directory
Example 1: PYTHONPATH=${PWD} python reduce/recipes/backgroundfit.py -dd /data6/MaroonX_spectra_reduced/Maroonx_masterframes/202110xx/flats/ --filename_FDDDF_b 20*_masterflat_FDDDF_b_0005
Example call fits background in the master flat files, using the downselected file for the blue FDDDF master flat. The output includes a pdf with the results of the fitting process for QC. After completion, four new output files are created at the location of the raw input files:
YYYYMMDDTHH_masterflat_backgroundsubtracted_DFFFD_b_TTTT.fits ,
YYYYMMDDTHH_masterflat_backgroundsubtracted_DFFFD_r_TTTT.fits ,
YYYYMMDDTHH_masterflat_backgroundsubtracted_FDDDF_b_TTTT.fits , and
YYYYMMDDTHH_masterflat_backgroundsubtracted_FDDDF_r_TTTT.fits ,
where date/time (YYYYMMDDHH), and exposure time (TTTT) are from the input fits file.
Additionally, the script combines the DFFFD and FDDDF frames into two background subtracted master flatfields, one per camera:
YYYYMMDDTHH_masterflat_backgroundsubtracted_FFFFF_b_TTTT.fits and
YYYYMMDDTHH_masterflat_backgroundsubtracted_FFFFF_r_TTTT.fits ,
where date/time, and exposure time are from the input fits file.
STEP 4: Producing a reduced master flat. This step will produce a HDF file for each of the two background subtracted masterflats produced in step 3. Like in step 2, run each of the two fits files through reduce/extraction.py . In the GUI, use these fits files for both the 'science file' and the 'flat file' input, specify '1,2,3,4,5' for illuminated fibers (or leave blank) of the and select debug level 1. No dark file is required. Run the extraction separately for each of the two masterflats. The result are two HDF output files with the same name as the input file. These HDF files will be used as the 'flat file' input in the extraction step of all other science and calibration files.
All steps could be combined in a single script since we can call the extraction procedure from the command line. A number of manual QC steps would need to be implemented as automatic routines:
Selection of the correct input frames (.e.g. exclusion of exposures with peak flux outside the desirable range of 40-45k DN.
Removal of frames in which the flux level deviates too much (1%?) from the median of all other frames.
Check for remaining outliers/artifacts in the master frames produced in step 1 (so far checked by eye in DS9).
Correct identification of orders in step 2.
Correct background fitting in step 3.
Correct identification of orders in step 4.