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

Add Direct Image to expected file list for NIRCam #1948

Merged
merged 4 commits into from
Jan 3, 2023

Conversation

rosteen
Copy link
Collaborator

@rosteen rosteen commented Dec 23, 2022

I think this is all that needs to be done to allow for direct image loading, but I need @camipacifici to test on her data.

@codecov
Copy link

codecov bot commented Dec 23, 2022

Codecov Report

Base: 91.79% // Head: 91.78% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (3955bcd) compared to base (ecc2658).
Patch coverage: 88.88% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1948      +/-   ##
==========================================
- Coverage   91.79%   91.78%   -0.01%     
==========================================
  Files         140      140              
  Lines       14950    14954       +4     
==========================================
+ Hits        13723    13726       +3     
- Misses       1227     1228       +1     
Impacted Files Coverage Δ
jdaviz/configs/mosviz/plugins/parsers.py 90.67% <84.61%> (-0.26%) ⬇️
jdaviz/configs/mosviz/helper.py 87.30% <100.00%> (+0.05%) ⬆️
jdaviz/configs/mosviz/tests/test_parsers.py 99.07% <100.00%> (ø)
...igs/default/plugins/model_fitting/model_fitting.py 83.71% <0.00%> (-0.16%) ⬇️
...figs/default/plugins/model_fitting/initializers.py 97.64% <0.00%> (ø)
...default/plugins/model_fitting/tests/test_plugin.py 100.00% <0.00%> (ø)
jdaviz/configs/imviz/plugins/viewers.py 88.83% <0.00%> (+0.05%) ⬆️

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.

@pllim pllim requested a review from camipacifici December 23, 2022 20:22
@pllim pllim added the bug Something isn't working label Dec 23, 2022
@pllim
Copy link
Contributor

pllim commented Dec 23, 2022

Technically a bug? I think this needs a change log. Thanks!

pllim
pllim previously approved these changes Dec 23, 2022
Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Codewise LGTM...

@rosteen
Copy link
Collaborator Author

rosteen commented Dec 23, 2022

I'll add a changelog if/when it turns out to actually solve the problem, not 100% sure yet. Might need a little more work.

@camipacifici
Copy link
Contributor

Screen Shot 2022-12-23 at 9 20 07 PM

It does not complain...but it does not load the image either...

@rosteen
Copy link
Collaborator Author

rosteen commented Dec 30, 2022

@camipacifici it turns out that the wrong FITS header keywords were being used for the filter to match between the 2D spectrum and direct image ("PUPIL" for NIRISS vs "FILTER" for NIRCam). The direct image loads now:

Screen Shot 2022-12-30 at 10 10 07 AM

@pllim
Copy link
Contributor

pllim commented Dec 30, 2022

Why is there "deg" in the image axis labels? Should be "pix" right?

@rosteen
Copy link
Collaborator Author

rosteen commented Dec 30, 2022

Why is there "deg" in the image axis labels? Should be "pix" right?

Hm, good question. I wonder if it's the same on main...

@rosteen
Copy link
Collaborator Author

rosteen commented Dec 30, 2022

This is the NIRISS example notebook on main, doesn't seem to have been introduced by this PR:

Screen Shot 2022-12-30 at 11 15 58 AM

if instrument == "niriss":
pupil = fits.getheader(image_file, ext=0).get('PUPIL')
elif instrument == "nircam":
pupil = fits.getheader(image_file, ext=0).get('FILTER')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add an else here or by the time you get here, it is either niriss or nircam and nothing else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right now those are the only two possible values, nirspec uses a different parser and anything else throws an error in load_data.

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, maybe less confusing to change

elif instrument == "nircam":

to this?

else:  # nircam

Copy link
Collaborator Author

@rosteen rosteen Dec 30, 2022

Choose a reason for hiding this comment

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

I'm inclined to leave it as-is, since if we unify another instrument into this parser and forget to add a case for it, it will throw an error, as opposed to maybe quietly being handled incorrectly by the else statement.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then isn't it slightly prettier like this:

else:  # pragma: no cover
    raise NotImplementedError(f'{instrument} is not supported')

@@ -190,8 +190,8 @@ def test_nircam_parser(mosviz_helper, tmp_path):
# Check that the correct amount of spectra got loaded in the correct order
assert len(mosviz_helper.app.data_collection) == 31
assert mosviz_helper.app.data_collection['MOS Table']['Identifier'][0] == 1112
assert mosviz_helper.app.data_collection[0].label == 'GRISMR Source 1112 spec2d R'
assert mosviz_helper.app.data_collection[15].label == 'GRISMR Source 1112 spec1d R'
assert mosviz_helper.app.data_collection[0].label == 'F322W2 Source 1112 spec2d R'
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this mean? That the parser has been loading the wrong thing for NIRCam test case all this time? 😱

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's loading the same thing, just labeling it differently. Due to differences in what goes in which header keyword between the instruments, NIRCam was trying to match up "GRISMR" from the 2D spectrum to "CLEAR" from the direct image, rather than this filter string like NIRISS does.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@camipacifici probably needs to confirm that displaying this filter rather than "GRISMR" in the table is ok. Maybe we want both.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it would be best to have both, but it can be part of a separate PR.

Copy link
Contributor

@camipacifici camipacifici left a comment

Choose a reason for hiding this comment

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

Image now loads. Thank you!

Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

Code changes look reasonable to me, thanks!

@rosteen
Copy link
Collaborator Author

rosteen commented Jan 3, 2023

Great, thank you both. I'll open a followup issue about displaying both grism and filter information.

@rosteen rosteen merged commit 3082c66 into spacetelescope:main Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mosviz
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants