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

RCAL-629: static preview generation script #953

Merged
merged 20 commits into from
Nov 6, 2023

Conversation

zacharyburnett
Copy link
Collaborator

@zacharyburnett zacharyburnett commented Oct 25, 2023

Resolves RCAL-629

add script for enabling static preview image generation from the command line, following what was discussed in the meetings:

  • preview file
  • thumbnail file
    • 300p x 300p PNG
    • filename <original>_thumb.png
  • gathering mean values from binned pixels
  • 90th percentile linear histogram stretch
  • using afmhot colormap

Installation

pip install ".[sdp]"

(adds stpreview and typer to the environment)

Usage

roman_static_preview preview /grp/roman/TEST_DATA/23Q4_B11/aligntest/r0000501001001001001_01101_0001_WFI01_cal.asdf

r0000501001001001001_01101_0001_WFI01_cal

roman_static_preview thumbnail /grp/roman/TEST_DATA/23Q4_B11/aligntest/r0000501001001001001_01101_0001_WFI01_cal.asdf

thumbnail

Checklist

  • added entry in CHANGES.rst under the corresponding subsection
  • updated relevant tests
  • updated relevant documentation
  • updated relevant milestone(s)
  • added relevant label(s)
  • ran regression tests, post a link to the Jenkins job below. How to run regression tests on a PR

@zacharyburnett zacharyburnett self-assigned this Oct 25, 2023
@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Oct 25, 2023
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Attention: 32 lines in your changes are missing coverage. Please review.

Files Coverage Δ
romancal/scripts/static_preview.py 11.11% <11.11%> (ø)

... and 1 file with indirect coverage changes

📢 Thoughts on this report? Let us know!.

@zacharyburnett
Copy link
Collaborator Author

@nden when you get a chance, could you point me to JWST sample data as well? Thanks!

@zacharyburnett
Copy link
Collaborator Author

❯ roman_static_preview preview --help  
Usage: roman_static_preview preview [OPTIONS] INPUT [OUTPUT] [SHAPE]...

  create a preview image with a north arrow overlay indicating orientation

Arguments:
  INPUT       path to ASDF file with 2D image data  [required]
  [OUTPUT]    path to output image file
  [SHAPE]...  desired pixel resolution of output image  [default: 1080, 1080]

Options:
  --compass / --no-compass  whether to draw a north arrow on the image
                            [default: compass]
  --help                    Show this message and exit.
❯ roman_static_preview thumbnail --help
Usage: roman_static_preview thumbnail [OPTIONS] INPUT [OUTPUT] [SHAPE]...

Arguments:
  INPUT       path to ASDF file with 2D image data  [required]
  [OUTPUT]    path to output image file
  [SHAPE]...  desired pixel resolution of output image  [default: 300, 300]

Options:
  --compass / --no-compass  whether to draw a north arrow on the image
                            [default: no-compass]
  --help                    Show this message and exit.

@zacharyburnett zacharyburnett requested a review from nden October 31, 2023 16:44
@zacharyburnett zacharyburnett changed the title static preview generation script RCAL-629: static preview generation script Oct 31, 2023
@zacharyburnett zacharyburnett marked this pull request as ready for review October 31, 2023 17:24
@zacharyburnett zacharyburnett requested a review from a team as a code owner October 31, 2023 17:24
@ddavis-stsci
Copy link
Collaborator

I assume that this is to be run on ImageModels only? Is there a check for that?

@zacharyburnett
Copy link
Collaborator Author

I assume that this is to be run on ImageModels only? Is there a check for that?

Good point, is there a flag in roman.meta that indicates whether it's an image or not? If not I can write a check

@ddavis-stsci
Copy link
Collaborator

ddavis-stsci commented Nov 1, 2023 via email

CHANGES.rst Outdated Show resolved Hide resolved
Copy link
Collaborator

@schlafly schlafly left a comment

Choose a reason for hiding this comment

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

This looks good to me. I worry a little about the simple mean used by default in the downsampling, but I guess since we're "only" downsampling 10x10 or so for the thumbnails isolated cosmics blowing up a pixel or something aren't that big of a problem (and jump detection should have caught them).

Do we have preview requirements on L1 images?

@zacharyburnett zacharyburnett requested review from perrygreenfield and a team November 2, 2023 14:21
@schlafly
Copy link
Collaborator

schlafly commented Nov 2, 2023

Do we have preview requirements on L1 images?

Answering my own question here, no, only on L2. I'm a little surprised and it's not crazy to want to make these previews for L1 images (e.g., by using the last frame of the L1 image, or the difference between the last and first frames). But out of scope for this PR, which looks good to me.

@nden
Copy link
Collaborator

nden commented Nov 3, 2023

We need to generate also previews for L3 images but this is due in later builds.

@nden
Copy link
Collaborator

nden commented Nov 3, 2023

@schlafly @stscieisenhamer Is there a case when ramp_fitting will set a pixel value in the image to NaN? e.g. if the slope cannot be computed or some other condition? If that's a possibility the downsample function needs to use np.nanmean

@schlafly
Copy link
Collaborator

schlafly commented Nov 3, 2023

That's a good point. Jonathan's code didn't ever return NaNs, but William's update does, so we should use nanmean. The L3s also use NaNs.

pyproject.toml Outdated Show resolved Hide resolved
Copy link
Collaborator

@nden nden left a comment

Choose a reason for hiding this comment

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

LGTM

@zacharyburnett zacharyburnett merged commit 6f31ae6 into spacetelescope:main Nov 6, 2023
23 checks passed
@zacharyburnett zacharyburnett deleted the script/preview branch November 6, 2023 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants