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-22776: Update Gen3 isrTask for BF corrections #124

Merged
merged 2 commits into from Feb 3, 2020
Merged

Conversation

czwa
Copy link
Contributor

@czwa czwa commented Jan 28, 2020

Update isrTask runQuantum for new-style BF correction. This requires examining the object returned from the butler and reworking it to match the expectation of IsrTask().run().

@czwa czwa requested a review from natelust January 28, 2020 20:40
Copy link
Contributor

@natelust natelust left a comment

Choose a reason for hiding this comment

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

Some things to look at

# the information as a numpy array.
if self.config.doBrighterFatter:
brighterFatterKernel = inputs.pop('newBFKernel', None)
if brighterFatterKernel 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.

why do this line, the if statement below will never be triggered by the bfKernel as it is an array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a newBFKernel exists in the inputs, then we should use that (and do the block beginning on line 848 to pull the kernel for the detector we have). Otherwise, we should use the old style, which does not need to do the L848 block (and inputs['bfKernel'] remains what we received from the butler).


if brighterFatterKernel is not None and not isinstance(brighterFatterKernel, numpy.ndarray):
detId = detector.getId()
inputs['bfGains'] = brighterFatterKernel.gain
Copy link
Contributor

Choose a reason for hiding this comment

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

bfGains does not seem to be populated if not newBFKernel, is that what you want?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is correct. bfGains will not be in inputs, will then be None inside run(), and will be passed as such to the correction code (which handles the None case by using camera gain values).

@@ -943,7 +969,7 @@ def readIsrData(self, dataRef, rawExposure):
# If using a new-style kernel, always use the self-consistent
# gains, i.e. the ones inside the kernel object itself
brighterFatterKernel = dataRef.get("brighterFatterKernel")
brighterFatterGains = brighterFatterKernel.gain
brighterFatterGains = getattr(brighterFatterKernel, 'gain', None)
Copy link
Contributor

Choose a reason for hiding this comment

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

not that its bad, but why getattr here? if it is a new style then gain will be an attribute, if its an old style an exception will be thrown (likely by the dataRef.get) and this block wont be executed. I would be more worried about getting this far if it is an old style. If you wanted to be safe, then maybe a different except block? This seems like it will just hide a problem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a possibility that there will be no .gains attribute, depending on how the kernel was generated. I will ask @mfisherlevine if this is still possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

In short, yes, Chris is right, that is technically possible. However, I think that's a bug. The generating code always has them, and downstream code should be able to rely upon them being stored in the kernel so the gains can be applied in a consistent manner, so I think the best course of action here is to allow yourselves to rely up this, and ticket fixing up the BF code so it always stores the gain. The patch should be trivial. Does that sound OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DM-23273 requests that gain existence be enforced. Marking this done, and will merge after testing.

@czwa czwa merged commit eb244cf into master Feb 3, 2020
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

4 participants