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-33297: Add correction of systematic photodiode error #118

Merged
merged 12 commits into from Feb 21, 2022

Conversation

craiglagegit
Copy link
Collaborator

This ticket was to add the photodiode and photodiode systematic correction code to the linearizer.

@mfisherlevine mfisherlevine changed the title Tickets/dm 33297 DM-33297: Add correction of systematic photodiode error Jan 28, 2022
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.

The test error is the biggest issue. Everything else is mostly style and documentation stuff.

config:
connections.inputPtc: ptc
connections.inputLinearizer: linearizer
connections.outputPhotodiodeCorrection: pdCorrection
Copy link
Contributor

Choose a reason for hiding this comment

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

Github complaint. Even though this doesn't cause a build error, it should still be fixed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I don't understand what needs to be fixed here.

Copy link
Contributor

Choose a reason for hiding this comment

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

It needs a newline at the end of the last line.

continue

if (len(inputPtc.expIdMask[ampName]) == 0) or self.config.ignorePtcMask:
self.log.warning("Mask not found for %s in non-linearity fit. Using all points.", ampName)
self.log.warning("Mask not found for %s in detector %s in fit.Using all points.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Space after period.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed this.

inputOrdinate = np.array(inputPtc.rawMeans[ampName])[mask]
if self.config.usePhotodiode:
# Here's where we bring in the photodiode data
# TODO: replace when pd data is ingested.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should have a ticket reference after the TODO. I added DM-33586 for this work.

ETA: Thinking it through, this block may need to be moved to the PtcExtract code due to the way connections are handled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added the reference to DM-33586.

except (RuntimeError, OSError):
continue
if nExps > 0:
# The 5E8 factor bring the modExpTimes back to about
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be scaled? It is just for visualization?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's just for visualization, so the plots look similar to the plots vs exposure time. We can remove this factor if you think that's best.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you can note that in the comment, it's fine. I just wanted to make sure I wasn't missing something.

python/lsst/cp/pipe/linearity.py Show resolved Hide resolved
python/lsst/cp/pipe/pdCorrection.py Show resolved Hide resolved
(`lsst.ip.isr.IsrProvenance`).

Notes
-----
Copy link
Contributor

Choose a reason for hiding this comment

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

Or here. Notes shouldn't be empty if the header is there, though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added an explanation of the algorithm in the notes.

@@ -354,7 +424,20 @@ def run(self, inputPtc, dummy, camera, inputDims):
linearizer.fitParams[ampName] = np.array(polyFit)
linearizer.fitParamsErr[ampName] = np.array(polyFitErr)
linearizer.fitChiSq[ampName] = chiSq

linearizer.linearFit[ampName] = linearFit
residuals = inputOrdinate[fluxMask] - modelOrdinate
Copy link
Contributor

Choose a reason for hiding this comment

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

This line causes a build error from tests/test_ptc.py: "ValueError: operands could not be broadcast together with shapes (20,) (10,)".

Ok, it looks like the fluxMask gets reset by the threshold test, and that marks everything as good (the (20,)), and modelOrdinate is defined using the previous definition (it's the (10,)).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK. I need to study the testing some more. I'll work on it, but it won't be until the week of Feb 14.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see what's happening here, but we need to discuss the best fix. I had only tested it with linearity.Type='Spline', where this line works. The modelOrdinate is different lengths for 'Spline' than for the others. In the other fit types ('Polynomial', 'Squared', 'LookupTable'), the modelOrdinate is only as long as linearAbscissa, which is just the low flux part of the curve. In 'Spline', linearOrdinate is increased to the full length of the data with this line:

linearOrdinate = linearFit[0] + linearFit[1] * inputAbscissa
.
I think the spline fit is correct, but the other fits are not. The modelOrdinate should include the full length of the data like it does in 'Spline'. But maybe I am confused.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thinking about this some more, I think I see a simple fix, which I have pushed.

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.

Other than the two style issues, I think this is good.

config:
connections.inputPtc: ptc
connections.inputLinearizer: linearizer
connections.outputPhotodiodeCorrection: pdCorrection
Copy link
Contributor

Choose a reason for hiding this comment

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

It needs a newline at the end of the last line.

except (RuntimeError, OSError):
continue
if nExps > 0:
# The 5E8 factor bring the modExpTimes back to about
Copy link
Contributor

Choose a reason for hiding this comment

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

If you can note that in the comment, it's fine. I just wanted to make sure I wasn't missing something.

Provenance data for the new calibration
(`lsst.ip.isr.IsrProvenance`).

Notes:
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to have the underline of five -, and no :.

@mfisherlevine mfisherlevine merged commit 7b180ad into main Feb 21, 2022
@mfisherlevine mfisherlevine deleted the tickets/DM-33297 branch February 21, 2022 21:18
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

3 participants