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

mosviz niriss parser: transpose R 2d spectra #1619

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Aug 31, 2022

Description

This pull request transposes the input data before creating the Spectrum1D object for 2d spectra for all R grism inputs.

Fixes #1353

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a change log needed? If yes, is it added to CHANGES.rst?
  • Is a milestone set?
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added this to the 2.11 milestone Aug 31, 2022
@@ -708,7 +708,15 @@ def mos_niriss_parser(app, data_dir):
# The wavelength is stored in a WAVELENGTH HDU. This is
# a 2D array, but in order to be able to use Spectrum1D
# we use the average wavelength for all image rows
wav = temp[wav_hdus[sci]].data.mean(axis=0) * u.micron

if orientation == 'R':
Copy link
Member Author

Choose a reason for hiding this comment

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

alternatively, should we not rely on this "orientation" and instead assume that the wavelength axis should be longer and change this check to if data.shape[0] > data.shape[1]?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is fair to assume that the dispersion axis is longer than the cross-dispersion axis and it will be simpler to adapt to other instruments that do not use the R/C nomenclature.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I switched to that logic. But note that this is currently only implemented for the niriss parser (although we could copy similar logic elsewhere or consider a refactor to have this somewhere more general if needed down the road). Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but it will soon be time to extend to NIRCam ;)

@kecnry kecnry force-pushed the niriss-r-transpose branch from c510e8e to 75c2949 Compare August 31, 2022 17:06
@kecnry kecnry added the bug Something isn't working label Aug 31, 2022
@codecov
Copy link

codecov bot commented Aug 31, 2022

Codecov Report

Base: 86.35% // Head: 86.35% // Increases project coverage by +0.00% 🎉

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1619   +/-   ##
=======================================
  Coverage   86.35%   86.35%           
=======================================
  Files          94       94           
  Lines        9407     9410    +3     
=======================================
+ Hits         8123     8126    +3     
  Misses       1284     1284           
Impacted Files Coverage Δ
jdaviz/configs/mosviz/plugins/parsers.py 89.54% <100.00%> (+0.08%) ⬆️

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.

@kecnry kecnry marked this pull request as ready for review August 31, 2022 17:20
@kecnry kecnry requested a review from camipacifici August 31, 2022 17:20
@kecnry kecnry force-pushed the niriss-r-transpose branch from 75c2949 to bb143e6 Compare September 1, 2022 20:02
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.

Does what it says, thanks!
I found the as_step option to switch on by itself, but I doubt it was introduced here. I will create a new ticket for that.

Copy link
Contributor

@ojustino ojustino left a comment

Choose a reason for hiding this comment

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

I can see the flip in MosvizNIRISSExample.ipynb's 2D, R-oriented spectra on main and also see that it's fixed here. I didn't encounter any new issues while loading data. If @camipacifici says the length assumption for wavelength axes is fair, that works for me, too.

I have a small comment about the changelog but don't think it should prevent an approval.

CHANGES.rst Outdated
@@ -49,6 +49,8 @@ Imviz
Mosviz
^^^^^^

- R-grism data are now loaded with the correct orientation. [#1619]
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend including a "2D" descriptor to be more specific about the resolved issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea, added to the changelog and will merge once CI passes. Thanks!

* currently only in niriss parser since occurs for R-grism data
* check is based on the assumption that the dispersion direction should be longer than the cross-dispersion
@kecnry kecnry force-pushed the niriss-r-transpose branch from bb143e6 to afbbc6f Compare September 2, 2022 15:48
@kecnry kecnry merged commit 1c9fef2 into spacetelescope:main Sep 2, 2022
@kecnry kecnry deleted the niriss-r-transpose branch September 2, 2022 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mosviz NIRISS dataset: axis of R grism 2D spectra should be swapped before displaying
3 participants