Skip to content

Commit

Permalink
Merge pull request #2127 from desihub/average-flux-calibration
Browse files Browse the repository at this point in the history
Minor PR: add option bin/desi_average_flux_calibration
  • Loading branch information
julienguy authored Oct 9, 2023
2 parents 0a968c9 + 5ae6b9d commit 8de794d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bin/desi_average_flux_calibration
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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__':
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8de794d

Please sign in to comment.