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

WIP: JP-3248 MIRI Subarrays 390 Hz EMI #7857

Merged
merged 44 commits into from
Dec 13, 2023

Conversation

penaguerrero
Copy link
Contributor

@penaguerrero penaguerrero commented Aug 29, 2023

Resolves JP-3248

Closes #7729

This PR addresses the creation of a new step to correct MIRI images for EMI contamination.

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

@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

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

Comparison is base (bd3558e) 75.18% compared to head (2edc01d) 75.24%.

Files Patch % Lines
jwst/emicorr/emicorr.py 90.29% 26 Missing ⚠️
jwst/emicorr/emicorr_step.py 36.58% 26 Missing ⚠️
jwst/extract_2d/nirspec.py 0.00% 5 Missing ⚠️
jwst/pipeline/calwebb_dark.py 50.00% 1 Missing ⚠️
jwst/pipeline/calwebb_detector1.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7857      +/-   ##
==========================================
+ Coverage   75.18%   75.24%   +0.05%     
==========================================
  Files         467      470       +3     
  Lines       38102    38420     +318     
==========================================
+ Hits        28647    28908     +261     
- Misses       9455     9512      +57     
Flag Coverage Δ *Carryforward flag
nightly 77.37% <ø> (ø) Carriedforward from bd3558e

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@penaguerrero
Copy link
Contributor Author

Need to request a new pmap for CRDS so that the code knows about any potential entry for the new step.

@penaguerrero penaguerrero force-pushed the fix_miri_emi branch 3 times, most recently from 326bfb7 to 53b4d00 Compare October 31, 2023 21:02
@penaguerrero penaguerrero force-pushed the fix_miri_emi branch 2 times, most recently from 81ef3ba to 46c8332 Compare November 16, 2023 16:38
@penaguerrero penaguerrero changed the title WIP: JP-3248 MIRI Subarrays 390 Hz EMI JP-3248 MIRI Subarrays 390 Hz EMI Nov 29, 2023
@penaguerrero penaguerrero force-pushed the fix_miri_emi branch 3 times, most recently from 4959437 to 26548a3 Compare December 6, 2023 22:20
@penaguerrero penaguerrero changed the title JP-3248 MIRI Subarrays 390 Hz EMI WIP: JP-3248 MIRI Subarrays 390 Hz EMI Dec 7, 2023
@hbushouse hbushouse added this to the Build 10.1 milestone Dec 8, 2023
Copy link
Collaborator

@hbushouse hbushouse left a comment

Choose a reason for hiding this comment

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

Only gotten through the first half of the files so far. More to come ...

CHANGES.rst Outdated Show resolved Hide resolved
docs/jwst/emicorr/arguments.rst Outdated Show resolved Hide resolved
docs/jwst/emicorr/arguments.rst Outdated Show resolved Hide resolved
docs/jwst/emicorr/description.rst Outdated Show resolved Hide resolved
docs/jwst/emicorr/description.rst Outdated Show resolved Hide resolved
docs/jwst/emicorr/description.rst Outdated Show resolved Hide resolved
docs/jwst/emicorr/description.rst Outdated Show resolved Hide resolved
docs/jwst/references_general/emi_reffile.inc Outdated Show resolved Hide resolved
docs/jwst/references_general/emi_reffile.inc Outdated Show resolved Hide resolved
docs/jwst/references_general/emi_selection.inc Outdated Show resolved Hide resolved
Copy link
Collaborator

@hbushouse hbushouse left a comment

Choose a reason for hiding this comment

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

OK, finished going through everything now. That's a lot of new code! Mostly minor comments everywhere.

docs/jwst/emicorr/description.rst Show resolved Hide resolved
jwst/emicorr/emicorr.py Show resolved Hide resolved
jwst/emicorr/emicorr.py Outdated Show resolved Hide resolved
jwst/emicorr/emicorr.py Outdated Show resolved Hide resolved
jwst/emicorr/emicorr.py Outdated Show resolved Hide resolved
jwst/emicorr/emicorr.py Show resolved Hide resolved
jwst/emicorr/emicorr_step.py Outdated Show resolved Hide resolved
jwst/emicorr/emicorr_step.py Outdated Show resolved Hide resolved
jwst/emicorr/emicorr_step.py Outdated Show resolved Hide resolved
jwst/pipeline/calwebb_detector1.py Show resolved Hide resolved
These changes should fix the formatting of the numbered list and footnotes.
@penaguerrero
Copy link
Contributor Author

The docs now build but I had to remove the % and type the word instead... I don't like that solution tho.

@hbushouse
Copy link
Collaborator

I committed more reformatting of that rst file and the percent sign now works OK. I think it was really the bad formatting of the numbered list that was screwing it up. See https://jwst-pipeline--7857.org.readthedocs.build/en/7857/jwst/emicorr/description.html

@hbushouse
Copy link
Collaborator

@hbushouse
Copy link
Collaborator

Everything here looks good, but seeing a number of errors in the regtest run. Will need to wait till they finish to investigate. Hopefully they're unrelated.

@hbushouse
Copy link
Collaborator

Rats. All the errors in the regtest run are due to the use of CRDS-OPS, which doesn't yet have definitions for the new "emicorr" reference file type, hence all the calls to retrieve the ref file throw an error. Need to switch to using CRDS_TEST. Will start a new regtest using that.

@penaguerrero
Copy link
Contributor Author

the docs look good except for the formatting of the reference file description, I think i need to add a white line so that the ASDF tree looks like we want

Attempting to maintain the ASDF dictionary tree format
@penaguerrero
Copy link
Contributor Author

ok, the docs built and the tree looks ok but not pretty: https://jwst-pipeline--7857.org.readthedocs.build/en/7857/jwst/emicorr/reference_files.html

@hbushouse
Copy link
Collaborator

ok, the docs built and the tree looks ok but not pretty: https://jwst-pipeline--7857.org.readthedocs.build/en/7857/jwst/emicorr/reference_files.html

You could try enclosing the tree text in a literal block. To do that, end the preceding paragraph with "::" and then have your ascii text tree indented, with a blank line before and after, e.g.

This is my intro text::

  This block of text, which is indented,
  should get rendered as a literal, with no formatting.

  Keep indenting each line that you want included in the
  literal block.

Then revert to normal text.

second attempt to fix ASDF dictionary tree format
@penaguerrero
Copy link
Contributor Author

yay! that worked! https://jwst-pipeline--7857.org.readthedocs.build/en/7857/jwst/emicorr/reference_files.html
thanks!

@hbushouse
Copy link
Collaborator

Still getting errors in regtests, even when using emicorr ref file from CRDS_TEST. Here's what I've found:

test_miri_image_detector1, in emicorr.py:

                        if colstop == 258:
>                           times_this_int[k, j, nx4-1] = times_this_int[k, j, nx4-1] + ref_pix_sample.astype('ulonglong')
E                           AttributeError: 'int' object has no attribute 'astype'

test_miri_dark is complaining that it can't find an emicorr ref file in CRDS. This might be due to the test data file having a DATE-OBS that's older than 2022-04-01, which is the USEAFTER on the emicorr ref file. Which, in my opinion is stupid. Why not have the USEAFTER go all the way back to cover all possible existing MIRI data. Surely the EMI problem did not just start in April 2022.

@hbushouse
Copy link
Collaborator

hbushouse commented Dec 12, 2023

@penaguerrero Please try running jwst/regtest/test_miri_image.py locally to debug why it's crashing.

See https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1098/testReport/jwst.regtest/test_miri_image/_stable_deps__test_miri_image_detector1_dq_init_/ for the traceback we're getting in the regtest.

@penaguerrero
Copy link
Contributor Author

ok! Reg tests ran with some failures but not associated to this PR: https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1099/#showFailuresLink

@hbushouse
Copy link
Collaborator

ok! Reg tests ran with some failures but not associated to this PR: https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1099/#showFailuresLink

This run is again showing all of the "E crds.core.exceptions.CrdsLookupError: Error determining best reference for 'emicorr' = Unknown reference type 'emicorr'" errors, even for MIRI datasets, presumably because it was run using CRDS Ops, but the new emicorr ref file only exists in CRDS_TEST. Need to run again with "CRDS_PATH=/grp/crds/jwst/test" set in the "ENV_VARS" box that comes up after you click on "Build with Parameters" to start the run.

@hbushouse
Copy link
Collaborator

hbushouse commented Dec 13, 2023

Woot! Regtest run https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1101/ shows differences (but no crashes) in the MIRI tests that use subarrays due to new keywords:

     Extra keyword 'R_MIREMI' in a: 'crds://jwst_miri_emicorr_0001.asdf'
     Extra keyword 'S_MIREMI' in a: 'COMPLETE'

and slight changes to pixel values, so that looks like the step is running!

Copy link
Collaborator

@hbushouse hbushouse left a comment

Choose a reason for hiding this comment

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

I hereby approve this PR.

@hbushouse hbushouse merged commit 52d0546 into spacetelescope:master Dec 13, 2023
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MIRI Subarrays 390 Hz EMI
5 participants