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

Tickets/DM-47188: Fix bug where CalcZernikesTask fails if number of intra/extra stamps isn't equal #279

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

jfcrenshaw
Copy link
Collaborator

No description provided.

@jfcrenshaw jfcrenshaw requested a review from suberlak October 28, 2024 02:45
stampsExtra.extend([stampsExtra[0]])

# Now estimate Zernikes
self.task.run(stampsExtra, stampsIntra)
Copy link
Contributor

Choose a reason for hiding this comment

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

So if it's supposed to stop can you test that indeed it's not going further? Or what would have happened if break wasn't there to test the new functionality.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test was added to reproduce the error, then the fix was written so this test passed.

Before, if e.g. there were more donuts in extraStamps than in intraStamps, it would hit a zk = None. This is because it had passed the number zernikes available. This happens because we are using zip_longest instead of zip, because this enables functionality in CalcZernikesUnpaired (where there are only intra or extra stamps, but not both). Hitting a zk = None caused an error because below it calls zk[j - 4], and None is not subscriptable.

Now, when it gets to zk = None it stops, because it knows it has iterated through every paired stamp.

if "ENTROPY" in list(donutStamps.metadata):
entropyValue = np.asarray(donutStamps.metadata.getArray("ENTROPY"))
fillVals = np.asarray(donutStamps.metadata.getArray("ENTROPY"))
Copy link
Contributor

Choose a reason for hiding this comment

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

is this helping with the case where most of the donutStamps do not have entropy, but only some do? I'm wondering about the ordering (entropyValue has the same length as donutCatalog that corresponds to cutout donutStamps, so why would fillVals be shorter than that?

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 happens when you append a new DonutStamp to DonutStamps (like I do in the unit test I added). The DonutStamps append/extend methods don't extend the metadata at all, so e.g. donutStamps.metadata.getArray("ENTROPY") will return an array shorter than donutStamps.

We should probably create a ticket that fixes these methods so that metadata is properly carried along, however the append/extend methods are never used in the tasks, so it's low priority.

Copy link
Contributor

@suberlak suberlak left a comment

Choose a reason for hiding this comment

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

Thanks for the update! Small comments to help document improvement, no changes needed.

# If zk is None, we need to stop. This can happen when running
# paired Zernike estimation and the number of intra/extra stamps
# is not the same
if zk 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.

So for one of the stamps not being there, we get None rather than [] ? I'm checking against

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, simply because we are using zip_longest instead of zip. However, this only happens when running inside the paired task.

Interestingly, I think the method you link to there is a little outdated. It still functions totally fine, however its structure is leftover from before the paired and unpaired estimation methods became separate tasks. I think it could be simplified now. (although definitely not high priority since it works fine).

@jfcrenshaw jfcrenshaw merged commit fea710f into develop Oct 28, 2024
6 checks passed
@jfcrenshaw jfcrenshaw deleted the tickets/DM-47188 branch October 28, 2024 04:30
jfcrenshaw added a commit that referenced this pull request Oct 28, 2024
* Change zernikes output to QTable.

* Add roundtrip for VisitInfo <-> dict

* Remove VisitInfo from CutOutDonutsScienceSensorTask connections. Update addVisitInfoToCatTable test.

* Add round trip dict to visit info test.

* Add exposure time to visit_info dict. Add all keys to round trip test.

* Add necessary metadata to tasks downstream of donutTables.

* Update production pipeline for ComCam.

* Enable RubinTV upload on production pipelines

* Remove MJD assertion between intra and extra donut stamps.

* tickets/DM-46117: single-side-of-focus pipeline (#273)

* tickets/DM-47163: Cut on fraction of bad pixels; run stamp selection during CalcZernikeTask by default (#277)

* Switch to new ISR task

* Fixed bug where original mask bits aren't persisted in stamps.

* Tickets/DM-47188: Fix bug where CalcZernikesTask fails if number of intra/extra stamps isn't equal (#279)

* Increase stamp size in rapid analysis pipeline so donut edges aren't clipped (#280)

---------

Co-authored-by: J. Bryce Kalmbach <[email protected]>
Co-authored-by: Josh Meyers <[email protected]>
Co-authored-by: Merlin Fisher-Levine <[email protected]>
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.

2 participants