8000 JP-1478: extract_1d enhancements for NRC_TSGRISM by hbushouse · Pull Request #5414 · spacetelescope/jwst · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

JP-1478: extract_1d enhancements for NRC_TSGRISM #5414

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
Oct 21, 2020

Conversation

hbushouse
Copy link
Collaborator

Updates to the extract_1d step to allow for an EXTRACT1D reference file to be used for NRC_TSGRISM mode, so that necessary column-by-column background extraction and subtraction can be performed. Previously the code was hardwired to not use EXTRACT1D ref file params for NRC_TSGRISM mode, which defaulted to very simplistic extraction with no background subtraction.

In addition to enabling the use of the reference file for this mode, a new parameter bkg_fit has been added, which now allows the user to specify whether to perform the default polynomial fit to background values or do simple mean and median computations. Functions to perform the mean and median background computations have been added to the code. Note that even when mean/median are used, the background model is still created in the form of a polynomial, but in this case it's a zero-order polynomial with the 0th-order coefficient set to the mean/median. That allows the background model to be used as-is in the downstream extraction functions.

Documentation for the extract_1d step and EXTRACT1D reference file have also been updated to account for the changes and to give more details on how the various extraction parameters are actually used in the code.

Fixes #5000 / JP-1478

@hbushouse hbushouse added this to the Build 7.7 milestone Oct 19, 2020
@codecov
Copy link
codecov bot commented Oct 20, 2020

Codecov Report

Merging #5414 into master will decrease coverage by 0.01%.
The diff coverage is 18.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5414      +/-   ##
==========================================
- Coverage   52.39%   52.38%   -0.02%     
==========================================
  Files         414      414              
  Lines       37679    37707      +28     
  Branches     5828     5838      +10     
==========================================
+ Hits        19742    19752      +10     
- Misses      16676    16695      +19     
+ Partials     1261     1260       -1     
Flag Coverage Δ
#unit 52.38% <18.75%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
jwst/extract_1d/extract_1d_step.py 9.09% <ø> (ø)
jwst/extract_1d/extract.py 9.07% <2.63%> (-0.11%) ⬇️
jwst/extract_1d/extract1d.py 38.93% <80.00%> (+0.92%) ⬆️
jwst/datamodels/model_base.py 84.56% <0.00%> (-0.89%) ⬇️
jwst/jump/twopoint_difference.py 100.00% <0.00%> (+1.96%) ⬆️
jwst/cube_build/data_types.py 53.48% <0.00%> (+3.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e2116d...992de4f. Read the comment docs.

@hbushouse
Copy link
Collaborator Author

By the way, these changes include a fix for another previously undiscovered bug at https://github.com/spacetelescope/jwst/pull/5414/files#diff-8e03eb4c28c8d698c106149c2306a1becf8f1a7c4e4027bf5dfeae9bc76395abR1782. The wrong object was being returned from the function that was setting up background region coeffs, such that even when the extract1d ref file specified background regions, they were not getting used and hence no background extraction or subtraction was ever actually happening. This leads to differences (good ones!) in at least the NIRISS SOSS regression tests, because it has background regions defined in its extract1d ref file.

@hbushouse
Copy link
Collaborator Author

OK, the last commit contained a few minor updates to make the new code work for all existing modes and also updated the TSGRISM regression test to use the prototype tsgrism extract1d ref file. That can be reverted once there's a ref file available in CRDS.

This is now ready for review.

@hbushouse
Copy link
Collaborator Author

Of course the changes to step docs and code related to anything for IFU data will get superseded in the near future when 8000 @jemorrison finishes all the updates for IFU extraction.

Copy link
Collaborator
@jdavies-st jdavies-st 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.

Some specific comments below about test coverage. The extract.py module is only unit tested at the 9% level, which is pretty crazy given it is 3791 lines long. Would be nice to toss in a unit test on the areas you touched so we can start getting some coverage.

Comment on lines +278 to +282
extract_params['bkg_coeff'] = None # no background sub.
extract_params['smoothing_length'] = 0 # because no background sub.
extract_params['bkg_fit'] = None # because no background sub.
extract_params['bkg_order'] = 0 # because no background sub.
extract_params['subtract_background'] = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this block is not unit tested. Perhaps a small unit test that just checks that this function works as expected when called with ref_dict=None

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. Fortunately it is at least tested by 1 or 2 regression tests, specifically the WFSS mode, which does not use an extract1d ref file and hence the ref_dict is None.

Comment on lines +341 to +346
if extract_params['bkg_coeff'] is not None:
extract_params['subtract_background'] = True
extract_params['bkg_fit'] = aper.get('bkg_fit', 'poly')
else:
extract_params['bkg_fit'] = None
extract_params['subtract_background'] = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here. Not unit tested, but perhaps a small test could target some of this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Again, this is at least tested in the regression tests, where the NIRISS SOSS extract1d ref file specifies bkg_coeff values, but none of the other spectral modes do, so both branches do get tested in regtest. But unit test coverage certainly couldn't hurt.

@hbushouse hbushouse merged commit 5c69bad into spacetelescope:master Oct 21, 2020
@hbushouse hbushouse deleted the jp-1478 branch October 21, 2020 11:40
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.

Enable use of extract_1d reference file for NRC_TSGRISM data
3 participants
0