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

Fix bad thumbnails #997

Merged
merged 4 commits into from
Jul 24, 2022

Conversation

bhilbert4
Copy link
Collaborator

This PR makes some tweaks to the preview image generator in an effort to finally fix the bad thumbnail images that have been plaguing us forever.

Previously, the thumbnail images were created using matplotlib's imshow() function. This function creates an AxesImage object. However, preview images are generated by first creating a matplotlib Figure object, and then populating the axes of that object with an AxesImage object via imshow(). It turns out that plt.close only closes Figure objects. This means that thumbnail images were not being closed at the end of the preview image generation process, and this must have been leading to multiple images open at the same time, resulting in bad thumbnail images.

This PR changes the thumbnail creation to be like that of the preview images. We first create a Figure object and then populate that using imshow. Local testing on several programs showed no bad thumbnails while using this. We should try a larger scale test on the server, but it looks promising that this PR will put an end to our bad thumbnail images.

I also fixed a small bug that was preventing some thumbnails from being created, where NaN values in the data were causing bad min/max values for the display.

Resolves #958

@bhilbert4 bhilbert4 self-assigned this Jul 21, 2022
@bhilbert4 bhilbert4 added this to In progress in v1.2.0 via automation Jul 21, 2022
@pep8speaks
Copy link

pep8speaks commented Jul 21, 2022

Hello @bhilbert4, Thank you for updating !

Line 50:1: E402 module level import not at top of file
Line 51:1: E402 module level import not at top of file
Line 52:1: E402 module level import not at top of file
Line 453:5: E303 too many blank lines (2)

Comment last updated at 2022-07-22 17:29:15 UTC

@bhilbert4
Copy link
Collaborator Author

We also need to explicitly set the figure size for thumbnail images now, with these changes. At the moment that is hardwired to be 3x3. Is this appropriate? We don't want the figures to be much larger than necessary, since that would slow down image loading and therefore the JWQL webpages.

@bhilbert4 bhilbert4 changed the title [WIP]: Fix bad thumbnails Fix bad thumbnails Jul 21, 2022
@bhilbert4
Copy link
Collaborator Author

Tests on the test server were successful. I didn't see any bad thumbnails when using this code. Also, running generate_preview_images is a lot faster when it ignores all of the guide star tracking files.

I feel like this has been a long battle that @BradleySappington, @mfixstsci, and I have been fighting. I'm excited for it to be over. 🤞

@mfixstsci I think this is ready for review.

@BradleySappington
Copy link
Collaborator

I'm absurdly excited

@mfixstsci
Copy link
Collaborator

@bhilbert4 @bhilbert4 lets go! I am going to start my review

Copy link
Collaborator

@mfixstsci mfixstsci left a comment

Choose a reason for hiding this comment

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

Looks good @bhilbert4 I know you and @BradleySappington have been working hard on this and hope this solves it once and for all.

jwql/jwql_monitors/generate_preview_images.py Show resolved Hide resolved
jwql/utils/preview_image.py Show resolved Hide resolved
@bhilbert4
Copy link
Collaborator Author

Fixed a small conflict that came about after the merge of #968

@mfixstsci mfixstsci merged commit d35a321 into spacetelescope:develop Jul 24, 2022
v1.2.0 automation moved this from In progress to Done Jul 24, 2022
@bhilbert4 bhilbert4 deleted the finally-fix-thumbnails branch July 24, 2022 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

Bad thumbnail images
4 participants