-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-40128: Fix brighter-fatter loading errors #279
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1027,6 +1027,9 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs): | |
|
||
detector = inputs['ccdExposure'].getDetector() | ||
|
||
# This is use for header provenance. | ||
additionalInputDates = {} | ||
|
||
if self.config.doCrosstalk is True: | ||
# Crosstalk sources need to be defined by the pipeline | ||
# yaml if they exist. | ||
|
@@ -1071,13 +1074,20 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs): | |
|
||
# Load the correct style of brighter-fatter kernel, and repack | ||
# the information as a numpy array. | ||
brighterFatterSource = None | ||
if self.config.doBrighterFatter: | ||
brighterFatterKernel = inputs.pop('newBFKernel', None) | ||
if brighterFatterKernel is None: | ||
# This type of kernel must be in (y, x) index | ||
# ordering, as it used directly as the .array | ||
# component of the afwImage kernel. | ||
brighterFatterKernel = inputs.get('bfKernel', None) | ||
brighterFatterSource = 'bfKernel' | ||
additionalInputDates[brighterFatterSource] = self.extractCalibDate(brighterFatterKernel) | ||
|
||
if brighterFatterKernel is None: | ||
# This was requested by the config, but none were found. | ||
raise RuntimeError("No brighter-fatter kernel was supplied.") | ||
|
||
if brighterFatterKernel is not None and not isinstance(brighterFatterKernel, numpy.ndarray): | ||
# This is a ISR calib kernel. These kernels are | ||
|
@@ -1086,6 +1096,9 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs): | |
# component of the afwImage kernel. This is done | ||
# explicitly below when setting the ``bfKernel`` | ||
# input. | ||
brighterFatterSource = 'newBFKernel' | ||
additionalInputDates[brighterFatterSource] = self.extractCalibDate(brighterFatterKernel) | ||
|
||
detName = detector.getName() | ||
level = brighterFatterKernel.level | ||
|
||
|
@@ -1128,16 +1141,30 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs): | |
if self.config.doHeaderProvenance: | ||
# Add calibration provenanace info to header. | ||
exposureMetadata = inputs['ccdExposure'].getMetadata() | ||
for inputName in sorted(inputs.keys()): | ||
|
||
# These inputs change name during this step. These should | ||
# have matching entries in the additionalInputDates dict. | ||
additionalInputs = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not that it matters much but couldn't you just set this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would certainly work the same, but I think it would require some variable name and comment rewrites. I think in the long term, this can eventually go away if all cameras switch to |
||
if self.config.doBrighterFatter: | ||
additionalInputs.append(brighterFatterSource) | ||
|
||
for inputName in sorted(list(inputs.keys()) + additionalInputs): | ||
reference = getattr(inputRefs, inputName, None) | ||
if reference is not None and hasattr(reference, "run"): | ||
runKey = f"LSST CALIB RUN {inputName.upper()}" | ||
runValue = reference.run | ||
idKey = f"LSST CALIB UUID {inputName.upper()}" | ||
idValue = str(reference.id) | ||
dateKey = f"LSST CALIB DATE {inputName.upper()}" | ||
|
||
if inputName in additionalInputDates: | ||
dateValue = additionalInputDates[inputName] | ||
else: | ||
dateValue = self.extractCalibDate(inputs[inputName]) | ||
|
||
exposureMetadata[runKey] = runValue | ||
exposureMetadata[idKey] = idValue | ||
exposureMetadata[dateKey] = dateValue | ||
|
||
outputs = self.run(**inputs) | ||
butlerQC.put(outputs, outputRefs) | ||
|
@@ -1320,51 +1347,32 @@ def run(self, ccdExposure, *, camera=None, bias=None, linearizer=None, | |
if (self.config.doDeferredCharge and deferredChargeCalib is None): | ||
raise RuntimeError("Must supply a deferred charge calibration if config.doDeferredCharge=True.") | ||
|
||
if self.config.doHeaderProvenance: | ||
# Inputs have been validated, so we can add their date | ||
# information to the output header. | ||
exposureMetadata = ccdExposure.getMetadata() | ||
if self.config.doBias: | ||
exposureMetadata["LSST CALIB DATE BIAS"] = self.extractCalibDate(bias) | ||
self.compareCameraKeywords(exposureMetadata, bias, "bias") | ||
if self.config.doBrighterFatter: | ||
exposureMetadata["LSST CALIB DATE BFK"] = self.extractCalibDate(bfKernel) | ||
self.compareCameraKeywords(exposureMetadata, bfKernel, "brighter-fatter") | ||
if self.config.doCrosstalk: | ||
exposureMetadata["LSST CALIB DATE CROSSTALK"] = self.extractCalibDate(crosstalk) | ||
self.compareCameraKeywords(exposureMetadata, crosstalk, "crosstalk") | ||
if self.config.doDark: | ||
exposureMetadata["LSST CALIB DATE DARK"] = self.extractCalibDate(dark) | ||
self.compareCameraKeywords(exposureMetadata, dark, "dark") | ||
if self.config.doDefect: | ||
exposureMetadata["LSST CALIB DATE DEFECTS"] = self.extractCalibDate(defects) | ||
self.compareCameraKeywords(exposureMetadata, defects, "defects") | ||
if self.config.doDeferredCharge: | ||
exposureMetadata["LSST CALIB DATE CTI"] = self.extractCalibDate(deferredChargeCalib) | ||
self.compareCameraKeywords(exposureMetadata, deferredChargeCalib, "CTI") | ||
if self.config.doFlat: | ||
exposureMetadata["LSST CALIB DATE FLAT"] = self.extractCalibDate(flat) | ||
self.compareCameraKeywords(exposureMetadata, flat, "flat") | ||
if (self.config.doFringe and physicalFilter in self.fringe.config.filters): | ||
exposureMetadata["LSST CALIB DATE FRINGE"] = self.extractCalibDate(fringes.fringes) | ||
self.compareCameraKeywords(exposureMetadata, fringes.fringes, "fringe") | ||
if (self.config.doIlluminationCorrection and physicalFilter in self.config.illumFilters): | ||
exposureMetadata["LSST CALIB DATE ILLUMINATION"] = self.extractCalibDate(illumMaskedImage) | ||
self.compareCameraKeywords(exposureMetadata, illumMaskedImage, "illumination") | ||
if self.doLinearize(ccd): | ||
exposureMetadata["LSST CALIB DATE LINEARIZER"] = self.extractCalibDate(linearizer) | ||
self.compareCameraKeywords(exposureMetadata, linearizer, "linearizer") | ||
if self.config.usePtcGains or self.config.usePtcReadNoise: | ||
exposureMetadata["LSST CALIB DATE PTC"] = self.extractCalibDate(ptc) | ||
self.compareCameraKeywords(exposureMetadata, ptc, "PTC") | ||
if self.config.doStrayLight: | ||
exposureMetadata["LSST CALIB DATE STRAYLIGHT"] = self.extractCalibDate(strayLightData) | ||
self.compareCameraKeywords(exposureMetadata, strayLightData, "straylight") | ||
if self.config.doAttachTransmissionCurve: | ||
exposureMetadata["LSST CALIB DATE OPTICS_TR"] = self.extractCalibDate(opticsTransmission) | ||
exposureMetadata["LSST CALIB DATE FILTER_TR"] = self.extractCalibDate(filterTransmission) | ||
exposureMetadata["LSST CALIB DATE SENSOR_TR"] = self.extractCalibDate(sensorTransmission) | ||
exposureMetadata["LSST CALIB DATE ATMOSP_TR"] = self.extractCalibDate(atmosphereTransmission) | ||
# Validate that the inputs match the exposure configuration. | ||
exposureMetadata = ccdExposure.getMetadata() | ||
if self.config.doBias: | ||
self.compareCameraKeywords(exposureMetadata, bias, "bias") | ||
if self.config.doBrighterFatter: | ||
self.compareCameraKeywords(exposureMetadata, bfKernel, "brighter-fatter") | ||
if self.config.doCrosstalk: | ||
self.compareCameraKeywords(exposureMetadata, crosstalk, "crosstalk") | ||
if self.config.doDark: | ||
self.compareCameraKeywords(exposureMetadata, dark, "dark") | ||
if self.config.doDefect: | ||
self.compareCameraKeywords(exposureMetadata, defects, "defects") | ||
if self.config.doDeferredCharge: | ||
self.compareCameraKeywords(exposureMetadata, deferredChargeCalib, "CTI") | ||
if self.config.doFlat: | ||
self.compareCameraKeywords(exposureMetadata, flat, "flat") | ||
if (self.config.doFringe and physicalFilter in self.fringe.config.filters): | ||
self.compareCameraKeywords(exposureMetadata, fringes.fringes, "fringe") | ||
if (self.config.doIlluminationCorrection and physicalFilter in self.config.illumFilters): | ||
self.compareCameraKeywords(exposureMetadata, illumMaskedImage, "illumination") | ||
if self.doLinearize(ccd): | ||
self.compareCameraKeywords(exposureMetadata, linearizer, "linearizer") | ||
if self.config.usePtcGains or self.config.usePtcReadNoise: | ||
self.compareCameraKeywords(exposureMetadata, ptc, "PTC") | ||
if self.config.doStrayLight: | ||
self.compareCameraKeywords(exposureMetadata, strayLightData, "straylight") | ||
|
||
# Begin ISR processing. | ||
if self.config.doConvertIntToFloat: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this just be
elif not isinstance(brighterFatterKernel, numpy.ndarray)
now?