diff --git a/bin/desi_average_flux_calibration b/bin/desi_average_flux_calibration index 37e4fb14f..2465fc43b 100755 --- a/bin/desi_average_flux_calibration +++ b/bin/desi_average_flux_calibration @@ -11,6 +11,7 @@ This script averages the flux calibration for a DESI spectrograph camera. from desispec.io.fluxcalibration import read_flux_calibration,write_average_flux_calibration,read_average_flux_calibration from desispec.averagefluxcalibration import AverageFluxCalib from desiutil.log import get_logger +from desispec.io.util import replace_prefix import argparse import os @@ -42,10 +43,10 @@ def get_ffracflux_wave(seeing, ffracflux, wave, fac_wave_power): Returns: Fiber acceptance for seeing, normalized to ffracflux at 6500A - + Comment: GFA now provide ffrac for fiber_diameter=1.52", so no need to correct for different diameters - we do the normalization using fac_wave, and then to be interpolated to wave + we do the normalization using fac_wave, and then to be interpolated to wave """ # desi = desimodel.io.load_desiparams() @@ -61,7 +62,7 @@ def get_ffracflux_wave(seeing, ffracflux, wave, fac_wave_power): ffracflux_wave /= ffracflux_wave[np.abs(fac_wave-6500).argmin()] # AR normalizing to 1 at 6500A ffracflux_wave *= ffracflux # AR normalising to ffracflux[i] at 6500A return np.interp(wave, fac_wave, ffracflux_wave) # AR interpolating on wave - + if __name__ == '__main__': @@ -78,6 +79,7 @@ if __name__ == '__main__': parser.add_argument('--seeing_key', type = str, default = 'RADPROF_FWHM_ASEC', choices = ['FWHM_ASEC', 'RADPROF_FWHM_ASEC'], help = 'key in GFA catalog for seeing (default=RADPROF_FWHM_ASEC)') parser.add_argument('--fac_wave_power', type = float, default = -0.25, help = 'wavelength dependence of fiber acceptance (default=-0.25)') parser.add_argument('--first_night', type = int, default = None, help = 'first night for which this calibration is usable (default=None)') + parser.add_argument('--unflat', action='store_true', help="undo flatfield correction to get the variation of thru from spectro to spectro") args = parser.parse_args() log=get_logger() @@ -152,6 +154,12 @@ if __name__ == '__main__': log.error("calib has nan") continue + if args.unflat : + ffilename=replace_prefix(filename, "fluxcalib", "fiberflatexp") + log.info(f"reading {ffilename}") + flat=fitsio.read(ffilename) + cal.calib *= flat + mcalib = np.median(cal.calib,axis=0) # undo the heliocentric/barycentric correction