Skip to content

Commit

Permalink
fluxCalibtate(): check for SENSFUNCs on all specphot extensions and n…
Browse files Browse the repository at this point in the history
…o-op if any are missing
  • Loading branch information
chris-simpson committed Aug 17, 2020
1 parent 70ecfbc commit 4431fdc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions geminidr/core/primitives_spect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,10 +1686,15 @@ def fluxCalibrate(self, adinputs=None, **params):
len_std, len_ad = len(std), len(ad)
if len_std not in (1, len_ad):
log.warning("{} has {} extensions so cannot be used to "
"calibrate {} with {} extensions.".
"calibrate {} with {} extensions".
format(std.filename, len_std, ad.filename, len_ad))
continue

if not all(hasattr(ext, "SENSFUNC") for ext in std):
log.warning("SENSFUNC table missing from one or more extensions"
f" of {std.filename} so cannot flux calibrate")
continue

# Since 2D flux calibration just uses the wavelength info for the
# middle row/column, non-distortion-corrected data will have the
# wrong wavelength solution in other columns/rows
Expand All @@ -1707,12 +1712,7 @@ def fluxCalibrate(self, adinputs=None, **params):

for index, ext in enumerate(ad):
ext_std = std[max(index, len_std-1)]
try:
sensfunc = ext_std.SENSFUNC
except AttributeError:
log.warning("{}:{} has no SENSFUNC table. Cannot flux calibrate".
format(std.filename, ext_std.hdr['EXTVER']))
continue
sensfunc = ext_std.SENSFUNC

extver = '{}:{}'.format(ad.filename, ext.hdr['EXTVER'])

Expand Down

0 comments on commit 4431fdc

Please sign in to comment.