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-39622: Add plotting for images #61

Merged
merged 1 commit into from Nov 1, 2023
Merged

DM-39622: Add plotting for images #61

merged 1 commit into from Nov 1, 2023

Conversation

madamow
Copy link
Collaborator

@madamow madamow commented Sep 26, 2023

No description provided.

python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
tests/test_plotting.py Outdated Show resolved Hide resolved
savePlotAs=outputFilename)
self.assertTrue(os.path.isfile(outputFilename))
self.assertTrue(os.path.getsize(outputFilename) > 10000)

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 it might be worth adding a loop to check that the various stretching options work. You don't need to save and check every plot, I don't think, but something that tests all the stretch options at least would be a good addition I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe manipulate one of the pixels in the image to set it to nan, too, just to check that everything is nan-safe too.

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 set a small area of the image to nans and added code to test stretches.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's nearly it, but None is not the same as NaN. Please set them to np.nan so that the nan-safety can be properly checked.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, actually, this doesn't check that it works with all-nan images, and I think that is something that needs to at least not crash, and at present that is indeed a crash because the colorbar can't handle the limits. Once that's fixed I think this is basically good to merge (after running Jenkins and rebasing and fixing these final comments, that is)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How do you want to proceed here? Exit with an error that nans are in the image or give a warning that nans are in the image and they will be replaced with something that the code can handle?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the image is all Nan there is no point in plotting. The code will check if image is pure nan and will raise ValueError.

Copy link
Contributor

Choose a reason for hiding this comment

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

Some nans in the image is perfectly acceptable, and the code should (and I think already does?) handle it fine, I'm just saying that there should be a test for it.

For all-nan images there is no point in plotting, but it happens, and this code should give an all-white image rather than raising. You could do a quick check for if the entire array is nan if you like and then just return a blank image, perhaps. At this point I'm happy for you to just file another ticket for that, assign it to me, and add a TODO in the code though. Do please add the test for the some-nans case 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.

Part of this is already in the code (check if image is all nan). There is also a test for cases with few nans in the image. It is included in test for plotting.py. I will change the ValueError part to blank image.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, I just checked and that all seems to be working perfectly now, thanks.

python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
@mfisherlevine
Copy link
Contributor

Final comment is that you need to remove the merge commits on here before merging. DM uses a rebase main workflow not a merge-main-to-branch-and-back-again workflow, so that needs redoing.

@mfisherlevine
Copy link
Contributor

Rebase workflow is here:
https://developer.lsst.io/work/flow.html#pushing-code

@madamow
Copy link
Collaborator Author

madamow commented Nov 1, 2023

I made all the changes; it is ready for merge.

@mfisherlevine
Copy link
Contributor

Sorry, but it is still full or merge commits. These must be removed before it can merge.

@mfisherlevine
Copy link
Contributor

Apologies - I am wrong, I'd missed that because you squashed everything into a single commit. That is certainly one approach, so yeah, I think once Jenkins passes it's good to merge. Build is running here:
https://rubin-ci.slac.stanford.edu/blue/organizations/jenkins/stack-os-matrix/detail/stack-os-matrix/579/pipeline/

Once that's green you can hit merge.

@madamow madamow merged commit 251969f into main Nov 1, 2023
1 check passed
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