Skip to content
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-37554: Check that ISR usage of gains is consistent #282

Merged
merged 18 commits into from Nov 8, 2023
Merged

Conversation

plazas
Copy link
Contributor

@plazas plazas commented Oct 30, 2023

No description provided.

@plazas plazas requested a review from czwa October 30, 2023 18:22
Copy link
Contributor

@czwa czwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor rearrangement suggestions. I'm happy to take a second look afterwards if you think it's needed.

Parameters
------
ptcDataset : `lsst.ip.isr.PhotonTransferCurveDataset`
Inout Photon Transfer Curve dataset.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo.

# Try first with the PTC gains.
gainProvenanceString = "amp"
if self.config.usePtcGains:
if ptcDataset is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this check to ~L1348, with the other checks for if doX and X is None? If the config doesn't match what was supplied, it's better to raise early.

else:
# Try then with the amplifier gain.
# We already have a detector at this point. If there was no
# detector to beging with, one would have been created with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo.

noise = overscanResults.residualSigma[0]
elif self.config.usePtcReadNoise:
# Try then with the PTC noise.
if ptcDataset is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my suggestion above, I think this just goes away.

else:
# Finally, try with the amplifier noise.
# We already have a detector at this point. If there
# was no detector to beging with, one would have
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same typo.

# self.config.noise.
noise = amp.getReadNoise()

self.log.info("%s - Noise provenance: %s, Gain provenance: %s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this (and the metadata entries) can be pulled out of the loop. All amps should follow the same logic, so all amps should have the same provenance, right?


# At this point, the effective PTC should have
# gain and noise values.
gain = ptcDataset.gain[ampName]
if math.isnan(gain):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be moved to the effectivePtc method? It's here because this was historically the first use, but keeping all of the logic in one place is simpler.


metadata = ampExposure.getMetadata()
metadata[f'LSST GAIN {amp.getName()}'] = gain
metadata[f'LSST READNOISE {amp.getName()}'] = readNoise
metadata[f"LSST GAIN {amp.getName()}"] = gain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with these metadata updates. It's only here for historical reasons.


isrFunctions.updateVariance(
maskedImage=ampExposure.getMaskedImage(),
gain=gain,
readNoise=readNoise,
)

# isrFunctions.updateVariance applied the gain.
# Update the units.
metadata["LSST ISR UNITS"] = 'electrons'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is true. The image units didn't change.

Copy link
Contributor

@czwa czwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this does the right thing now. I'm happy if Jenkins is happy.

@@ -774,3 +775,33 @@ def getGoodPoints(self, ampName):
Boolean array of good points used in PTC.
"""
return self.expIdMask[ampName]

def validateGainNoiseTurnoffValues(self, ampName):
"""Ensure the gain, read noise, and PTC turnoff have
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring, even though it's trivial.

@plazas plazas merged commit 57db375 into main Nov 8, 2023
2 checks passed
@plazas plazas deleted the tickets/DM-37554 branch November 8, 2023 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants