8000 JP-1557: Update master_background for NRS IFU pathloss by hbushouse · Pull Request #5125 · spacetelescope/jwst · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

JP-1557: Update master_background for NRS IFU pathloss #5125

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 4 commits into from
Jul 7, 2020

Conversation

hbushouse
Copy link
Collaborator

Updated the expand_to_2d module to call the new function correct_nrs_ifu_bgk when the science data is a point source, in order to apply the point source vs. uniform source pathloss mods to the computed 2D background, before subtracting from the science data.

Fixes #5104 / JP-1557

@hbushouse hbushouse added NIRSpec IFU master background Spectroscopic master bkg subtraction labels Jul 2, 2020
@hbushouse hbushouse added this to the Build 7.6 milestone Jul 2, 2020
@codecov
Copy link
codecov bot commented Jul 2, 2020

Codecov Report

Merging #5125 into master will increase coverage by 0.00%.
The diff coverage is 59.25%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5125   +/-   ##
=======================================
  Coverage   53.00%   53.01%           
=======================================
  Files         401      402    +1     
  Lines       35628    35654   +26     
  Branches     5521     5524    +3     
=======================================
+ Hits        18885    18901   +16     
- Misses      15603    15611    +8     
- Partials     1140     1142    +2     
Flag Coverage Δ
#unit 53.01% <59.25%> (+<0.01%) ⬆️
Impacted Files Coverage Δ
jwst/datamodels/ifuimage.py 61.53% <0.00%> (-11.19%) ⬇️
jwst/master_background/expand_to_2d.py 53.84% <25.00%> (-0.61%) ⬇️
jwst/master_background/nirspec_corrections.py 78.94% <78.94%> (ø)

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 93d7919...355d049. Read the comment docs.

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.

Can you add or modify one of the unit tests for this module? You might have to put in some empty pathloss_uniform and pathloss_point arrays.

"""

log.info('Applying point source pathloss updates to IFU background')
input.data *= (input.pathloss_point / input.pathloss_uniform)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens here if someone turns off the pathloss correction step? Might want a try block.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. But that raises an issue I was having while trying to run my first test on this new code. I was using an old cal file that still had the old "pathloss" array, but not the new "pathloss_point" or "pathloss_uniform" arrays. I could NOT find a useful way to test for the true existence of the new arrays. Any use of hasattr(model, 'pathloss_point') always returns True, because it's defined in the schema, model.pathloss_point.shape returns a valid looking (2048,2048), etc. About the only way I could tell whether the data were real or not was to see if the data array was filled with zeros (which for some kinds of corrections could be valid). How can you reliably test for the true existence of an attribute like this in our datamodels?!

Copy link
Collaborator

Choose a reason for hiding this comment

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

That is quite irritating. @stscieisenhamer is there a trick for doing this?

@hbushouse hbushouse requested a review from jdavies-st July 6, 2020 19:16
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.

Looks good. Just a small comment below.

pl_point = input.getarray_noinit('pathloss_point')
except AttributeError:
log.warning('Pathloss_point array not found in input')
log.warning('Skipping pathloss background updates')
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be good to set the step status keyword to "SKIPPED" in this block and the one below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But the master background step itself is not being skipped in this case. Only the application of the corrections to the master bkg signal. Perhaps we should in fact skip the entire step if the corrections can't be applied.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, right. I guess if the pathloss arrays are not there, the pathloss step was not run? Does that mean this is just fine as is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point. I was thinking of the case where someone was using old input files that don't have the proper pathloss arrays attached, but this would actually properly handle the case of the pathloss step having been skipped (I think). In that case the master bkg should already match the actual bkg, so there's no need to remove the previously applied correction.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But overall it would perhaps be best to skip the whole step, so that we don't deliver improperly calibrated results from the master bkg step. If someone has turned off pathloss upstream, they're going to get bad calibration on several fronts (i.e. flux cal won't be right, ...)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, at that point perhaps we are getting to the point where things need to be managed by the pipeline. If people decide to skip steps that are essential, then they do so at their own risk? Perhaps your original approach is correct. Just return the input, throw a big warning in the log, and be done with it.

@hbushouse hbushouse merged commit 503ef94 into spacetelescope:master Jul 7, 2020
@hbushouse hbushouse deleted the jp1557 branch July 7, 2020 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master background Spectroscopic master bkg subtraction NIRSpec IFU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update the master background step to correct NIRSpec IFU point sources
2 participants
0