-
Notifications
You must be signed in to change notification settings - Fork 75
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
loading line lists at redshifted wavelength #2726
Conversation
# Load remaining lines | ||
specviz_helper.plot_spectral_lines(global_redshift) | ||
|
||
viewer_lines = [mark for mark in specviz_helper.app.get_viewer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anyone has a suggestion to get around using a loop here and in the second test. It is here to get the SpectralLines in the viewer, and make sure the redshift is applied. The Qtable doesn't update automatically if redshift is applied so I went with this methodology for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kecnry might know.
@@ -664,7 +665,8 @@ def vue_show_all_in_list(self, listname): | |||
self.list_contents = lc | |||
self.send_state('list_contents') | |||
|
|||
self._viewer.plot_spectral_lines() | |||
self._viewer.plot_spectral_lines(global_redshift=self._global_redshift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conditional also may be removed and it could just be global_redshift. It will either be 0 or whatever the value was updated to in the GUI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and in the subsequent locations where plot_spectral_line
and plot_spectral_lines
is called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a global_redshift
to be actually global app-wide would make more sense then passing it in like this, no? But I didn't design this plugin, so maybe other devs can chime in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are redesigning line shifts in the near future to have this more clearly defined, so I think as a bugfix this is probably fine for now, but we probably should check to make sure this doesn't break any known notebooks that may try advanced (non-advertized) functionality for per-line or per-list redshifts.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2726 +/- ##
==========================================
+ Coverage 88.07% 88.08% +0.01%
==========================================
Files 108 108
Lines 15883 15889 +6
==========================================
+ Hits 13989 13996 +7
+ Misses 1894 1893 -1 ☔ View full report in Codecov by Sentry. |
@@ -524,7 +524,8 @@ def _list_from_notebook(self, msg): | |||
self.send_state('loaded_lists') | |||
self.send_state('list_contents') | |||
|
|||
self._viewer.plot_spectral_lines(tmp_names_rest) | |||
self._viewer.plot_spectral_lines(tmp_names_rest, global_redshift=self._global_redshift | |||
if self._global_redshift != 0 else None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is floating point comparison, would allclose
be safer?
Same comment applies to all similar occurrences.
spec = Spectrum1D(flux=np.random.rand(100)*u.Jy, | ||
spectral_axis=np.arange(6000, 7000, 10)*u.AA) | ||
specviz_helper.load_data(spec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to generate your own test data, especially since you already passing in the fixture.
spec = Spectrum1D(flux=np.random.rand(100)*u.Jy, | |
spectral_axis=np.arange(6000, 7000, 10)*u.AA) | |
specviz_helper.load_data(spec) | |
specviz_helper.load_data(spectrum1d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both tests have been updated to use the fixture data
lt = QTable() | ||
lt['linename'] = ['O III', 'Halpha'] | ||
lt['rest'] = [5000., 6000.]*u.AA | ||
lt['redshift'] = u.Quantity([0.0, 0.0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can shorten thus to one line. Also it bothers me the wavelengths are incorrect.
lt = QTable() | |
lt['linename'] = ['O III', 'Halpha'] | |
lt['rest'] = [5000., 6000.]*u.AA | |
lt['redshift'] = u.Quantity([0.0, 0.0]) | |
lt = QTable({'linename': ['O III', 'Halpha'], 'rest': [5007, 6563] * u.AA, 'redshift': u.Quantity([0, 0])}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two new tests are now shortened to one line for Qtables, I held off on updating the other tests in line_list, which use multiple lines to create the table
@@ -664,7 +665,8 @@ def vue_show_all_in_list(self, listname): | |||
self.list_contents = lc | |||
self.send_state('list_contents') | |||
|
|||
self._viewer.plot_spectral_lines() | |||
self._viewer.plot_spectral_lines(global_redshift=self._global_redshift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a global_redshift
to be actually global app-wide would make more sense then passing it in like this, no? But I didn't design this plugin, so maybe other devs can chime in here.
assert viewer_lines[0].redshift == 0.01 | ||
assert viewer_lines[1].redshift == 0.01 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is floating point comparison, would allclose
be safer?
spec = Spectrum1D(flux=np.random.rand(100)*u.Jy, | ||
spectral_axis=np.arange(6000, 7000, 10)*u.AA) | ||
specviz_helper.load_data(spec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec = Spectrum1D(flux=np.random.rand(100)*u.Jy, | |
spectral_axis=np.arange(6000, 7000, 10)*u.AA) | |
specviz_helper.load_data(spec) | |
specviz_helper.load_data(spectrum1d) |
lt = QTable() | ||
lt['linename'] = ['O III', 'Halpha', 'O III'] | ||
lt['rest'] = [5000., 6000., 7000.]*u.AA | ||
lt['redshift'] = u.Quantity([0.0, 0.0, 0.0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lt = QTable() | |
lt['linename'] = ['O III', 'Halpha', 'O III'] | |
lt['rest'] = [5000., 6000., 7000.]*u.AA | |
lt['redshift'] = u.Quantity([0.0, 0.0, 0.0]) | |
lt = QTable({'linename': ['O III', 'Halpha', 'O III'], 'rest': [5007, 6563, 4959] * u.AA, 'redshift': u.Quantity([0, 0, 0])}) |
# Load remaining lines | ||
specviz_helper.plot_spectral_lines(global_redshift) | ||
|
||
viewer_lines = [mark for mark in specviz_helper.app.get_viewer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kecnry might know.
assert viewer_lines[0].redshift == 0.01 | ||
assert viewer_lines[1].redshift == 0.01 | ||
assert viewer_lines[2].redshift == 0.01 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is floating point comparison, would allclose
be safer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the asserts are now updated to use allclose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since plugin is going to be refactored anyway, this is good enough. Thanks!
@kecnry , do you have certain notebooks in mind, as per your comment above?
Still need a change log under v3.8.3 section for bug fix. FYI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me for now! We'll obviously need to re-think some of this when we redesign to break global redshift assumption, but we have the go ahead to ignore that for now. Thanks!
This is a simple question that I should've asked a while ago, is there a way to know which version a PR belongs to? |
The milestone should be set, and if it is to a bugfix, then the backport bugfix label must be added manually. |
…new line being added to viewer
…r: more readable if; line_list: cut conditional logic of redshift
d859265
to
7512c20
Compare
CHANGES.rst
Outdated
- Fix redshifted line lists that were displaying at rest wavelengths. Global redshift | ||
used, this will be refactored in the future when setting redshift per-line or per-list. [#2726] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be confusing from the user-perspective, maybe this is sufficient?
- Fix redshifted line lists that were displaying at rest wavelengths. Global redshift | |
used, this will be refactored in the future when setting redshift per-line or per-list. [#2726] | |
- Fix redshifted line lists that were displaying at rest wavelengths, by assuming a global redshift. [#2726] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks!
This comment was marked as resolved.
This comment was marked as resolved.
* updating lines so they receive redshift if redshift applied prior to new line being added to viewer * test: cut/simplied logic and excess data, allclose for asserts; viewer: more readable if; line_list: cut conditional logic of redshift * added change log * change log text altered (cherry picked from commit 128d642)
* updating lines so they receive redshift if redshift applied prior to new line being added to viewer * test: cut/simplied logic and excess data, allclose for asserts; viewer: more readable if; line_list: cut conditional logic of redshift * added change log * change log text altered (cherry picked from commit 128d642)
Description
This pull request is to address the following ticket:
https://jira.stsci.edu/browse/JDAT-2780
Where observed wavelengths are showing the correct shifted value but are being plotted at rest wavelengths until there is some interaction with the redshift in which case they immediately update to the correct position.
Pre-PR Behavior:
https://github.com/spacetelescope/jdaviz/assets/42986583/c690234c-85b6-442d-92b4-5c3010132c29
Post-PR Behavior:
https://github.com/spacetelescope/jdaviz/assets/42986583/636e517e-87f6-4576-adcf-b1c0bda1cc59
Fixes #
Change log entry
CHANGES.rst
? If you want to avoid merge conflicts,list the proposed change log here for review and add to
CHANGES.rst
before merge. If no, maintainershould add a
no-changelog-entry-needed
label.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.
trivial
label.