8000 JP-2819: Bugfix - ensure wavelength array is of equivalent shape to data array by tapastro · Pull Request #7005 · spacetelescope/jwst · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

JP-2819: Bugfix - ensure wavelength array is of equivalent shape to data array #7005

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

Merged
merged 6 commits into from
Aug 31, 2022

Conversation

tapastro
Copy link
Contributor
@tapastro tapastro commented Aug 26, 2022

Resolves JP-2819

Closes #

This PR fixes a bug in the previous PR #6964, which truncated the wavelength array extent for nan regions, causing array shape mismatch issues between the wavelength and data. This PR uses the data array shape to create the wavelength array.

Checklist for maintainers

  • added entry in CHANGES.rst within the relevant release section
  • updated or added relevant tests
  • updated relevant documentation
  • added relevant milestone
  • added relevant label(s)
  • ran regression tests, post a link to the Jenkins job below.
    How to run regression tests on a PR
  • Make sure the JIRA ticket is resolved properly

@tapastro tapastro added this to the Build 9.0 milestone Aug 26, 2022
@tapastro tapastro requested review from nden and hbushouse August 26, 2022 19:02
@tapastro
Copy link
Contributor Author

@hbushouse
Copy link
Collaborator

Yes, that kind of change log entry is fine.

@codecov
Copy link
codecov bot commented Aug 26, 2022

Codecov Report

Base: 79.68% // Head: 79.70% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (05dca55) compared to base (d1eda60).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 05dca55 differs from pull request most recent head 51ff9e3. Consider uploading reports for the commit 51ff9e3 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7005      +/-   ##
==========================================
+ Coverage   79.68%   79.70%   +0.02%     
==========================================
  Files         411      411              
  Lines       37231    37225       -6     
==========================================
+ Hits        29667    29670       +3     
+ Misses       7564     7555       -9     
Flag Coverage Δ
nightly 79.66% <100.00%> (+0.02%) ⬆️
unit 53.23% <100.00%> (-0.01%) ⬇️
Impacted Files Coverage Δ
jwst/assign_wcs/util.py 83.56% <ø> (-0.23%) ⬇️
jwst/assign_wcs/assign_wcs.py 80.70% <100.00%> (+0.34%) ⬆️
jwst/extract_1d/extract.py 80.26% <0.00%> (+0.21%) ⬆️
jwst/white_light/white_light.py 93.47% <0.00%> (+6.52%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@hbushouse
Copy link
Collaborator

In addition to some unrelated differences in NIRCam results (due to updated ref files), the regtest run shows the expected additional wavelength extension in some of the slitless products, but the calints also shows slight differences in the SCI and ERR arrays. Could this be due to slightly different wavelength values being computed than before, which is then leading to slightly different flux cal values during application of photom? If so, how do we know which wavelength values are correct?

@hbushouse
Copy link
Collaborator

Tracing through photom to see how wavelengths were computed previously for LRS slitless, I'm assuming it ends up calling create_2d_conversion, which in turn calls the lib.wcs_utils.get_wavelengths function, which does its computations starting here https://github.com/spacetelescope/jwst/blob/master/jwst/lib/wcs_utils.py#L65

I'm wondering how that matches (or doesn't) what's being done in this PR (conceptually similar, but details differ). Also wondering if the get_wavelengths function could just be called from this location in assign_wcs, instead of using another set of similar code.

@nden
Copy link
Collaborator
nden commented Aug 29, 2022

IIRC, originally the wavelength array was intended only for Nirspec data to allow to do the wavelength correction step, which prevented getting a complete WCS result by simply evaluating the WCS. The intention was to all other modes to simply evaluate the WCS. Computing wavelength arrays seems like a shift in policy.
I wonder if it can be misleading to users, since it is strictly one use case - evaluating the WCS at the center of each pixel. If the WCS result at the edges is needed that would need evaluation on different inputs.

@hbushouse
Copy link
Collaborator

For the case of LRS slitless I don't see a problem with populating the wavelength array. The wavelengths don't get corrected or modified by anything else in the pipeline and should give the same results as before when going through the extract_1d step. This is because the extract_1d step first checks to see if the wavelength array is populated and, if so, use it rather than computing the wavelengths on the fly. And the way it computed the wavelengths on the fly is identical to what's being done in this PR. It also seems foolish to have the wavelength array in the data products if it's not populated. Of course that could be solved by just making sure that the wavelength attribute in the datamodel is set to None, so that it doesn't get created in the LRS slitless products.

@hbushouse
Copy link
Collaborator

@tapastro were you going to modify the PR code yet to just call the get_wavelengths function, rather than duplicating the code that's in it here?

@tapastro
Copy link
Contributor Author

Yes, sorry - I was running regtests against this commit to see if any functional difference existed. I'll clean it up and ping a review request.

@tapastro tapastro force-pushed the lrs-slitless-wavelengths branch from 2fbd7cd to 05dca55 Compare August 30, 2022 15:39
@tapastro
Copy link
Contributor Author

Realized I hadn't run regtests against the code update - started one here: https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/408/

@hbushouse hbushouse added the 8.1 patch PR candidate for an 8.1 patch release label Aug 31, 2022
@hbushouse
Copy link
Collaborator

The regtest results show the expected differences due to the presence of the wavelength extension in products that didn't have it before, but it's also showing 100% differences in the wavelength extension values for the calints product: https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/408/testReport/junit/jwst.regtest/test_miri_lrs_slitless/_stable_deps__test_miri_lrs_slitless_tso_spec2_calints_/

Have you looked at the wavelength values in the new results to make sure they're OK?

@tapastro
Copy link
Contributor Author

The regtest results show the expected differences due to the presence of the wavelength extension in products that didn't have it before, but it's also showing 100% differences in the wavelength extension values for the calints product: https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/408/testReport/junit/jwst.regtest/test_miri_lrs_slitless/_stable_deps__test_miri_lrs_slitless_tso_spec2_calints_/

Have you looked at the wavelength values in the new results to make sure they're OK?

The new wavelengths look correct - they are nan where they aren't defined, and real-valued where they are. The current truth value is an array of zeroes.

@hbushouse
Copy link
Collaborator

Interesting that the current calints truth file has all the wavelengths zero. They should've been calculated and populated during the photom step and hence included in the calints results. Weird.

@tapastro
Copy link
Contributor Author

Yeah, this was the main issue raised in the initial issue #6963 - it's quite possible I solved this in a more roundabout way than needed, as I didn't realize this info should be calculated in photom. I assumed such information would populated once available, in assign_wcs.

@hbushouse
Copy link
Collaborator

You're right. In the existing flow the 2D array of wavelengths is computed during the photom step, but only used locally to then compute the flux conversion factors for each pixel (because they're wavelength-dependent). That wavelength array was never stored in the model.wavelength attribute (just garbage collected at the end of the step).

@zacharyburnett zacharyburnett enabled auto-merge (squash) August 31, 2022 18:22
@hbushouse hbushouse disabled auto-merge August 31, 2022 18:32
@hbushouse hbushouse merged commit ed9a26a into spacetelescope:master Aug 31, 2022
zacharyburnett pushed a commit that referenced this pull request Aug 31, 2022
…ata array (#7005)

* populate wavelength extension for MIRI LRS slitless

* is this kind of changelog edit allowed?

* does the dtype change results?

* remove duplicate function

Co-authored-by: Howard Bushouse <bushouse@stsci.edu>

(cherry picked from commit ed9a26a)
@hbushouse hbushouse modified the milestones: Build 9.0, Build 8.1.2 Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.1 patch PR candidate for an 8.1 patch release assign_wcs MIRI LRS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0