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

Use get_data internally instead of get_data_from_viewer #2072

Merged
merged 16 commits into from
Mar 13, 2023

Conversation

rosteen
Copy link
Collaborator

@rosteen rosteen commented Mar 8, 2023

Note that I left the call in app.get_subsets_from_viewer, since I think that will be part of @javerbukh's subset work, although I did implement something rather related in specviz.get_spectra.

I believe there is one last failing test, and I probably need to get rid of some references to the old method in the docs. Other than that I think this is ready for other eyes.

@rosteen rosteen added the plugin Label for plugins common to multiple configurations label Mar 8, 2023
@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@dea7a90). Click here to learn what that means.
Patch coverage: 94.11% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2072   +/-   ##
=======================================
  Coverage        ?   92.13%           
=======================================
  Files           ?      140           
  Lines           ?    15431           
  Branches        ?        0           
=======================================
  Hits            ?    14218           
  Misses          ?     1213           
  Partials        ?        0           
Impacted Files Coverage Δ
jdaviz/configs/specviz/helper.py 75.23% <82.60%> (ø)
...aviz/configs/cubeviz/plugins/tests/test_regions.py 100.00% <100.00%> (ø)
...z/configs/default/plugins/line_lists/line_lists.py 74.45% <100.00%> (ø)
...igs/default/plugins/model_fitting/model_fitting.py 83.84% <100.00%> (ø)
...z/configs/imviz/plugins/coords_info/coords_info.py 94.46% <100.00%> (ø)
...igs/specviz/plugins/line_analysis/line_analysis.py 97.81% <100.00%> (ø)
jdaviz/configs/specviz/plugins/parsers.py 90.52% <100.00%> (ø)
jdaviz/configs/specviz/tests/test_helper.py 100.00% <100.00%> (ø)
jdaviz/core/template_mixin.py 92.61% <100.00%> (ø)

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 in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines +72 to +74
assert list(spectral_subsets.keys()) == ['has_microns[FLUX]',
'has_microns[FLUX] (Subset 1)',
'has_microns[FLUX] (Subset 2)'], spectral_subsets # noqa
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't remember if this paradigm for how data from get_spectra() is returned has been discussed yet but if <filename> (<subset name>) is the way we want to go, we need to update the SpecvizExample notebook cell specviz.get_spectra('Subset 1'). I am not opposed to it but I think we should run it by the team before I use the same paradigm in the get_subset work.

Copy link
Contributor

@javerbukh javerbukh left a comment

Choose a reason for hiding this comment

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

Code looks good and works well, thanks! I think I would just like to run the get_spectra() update by the team but otherwise this is good to merge.

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.

Seems reasonable.

docs/cubeviz/export_data.rst Outdated Show resolved Hide resolved
docs/specviz2d/export_data.rst Outdated Show resolved Hide resolved
viewer_data = self.app.get_data_from_viewer(
self._default_spectrum_viewer_reference_name
).get(label)
viewer_data = self.app._jdaviz_helper.get_data(data_label=label)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahh, I understand your desire to make get_data available via the app. Personally I think how it is here, while clunky, is probably a more robust way to implement it, but I could be convinced otherwise

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So is that an approval or a change request? 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

Haha nothing to hold out on. Just a note

@rosteen
Copy link
Collaborator Author

rosteen commented Mar 10, 2023

@pllim I applied your suggestions, thanks.

Copy link
Collaborator

@duytnguyendtn duytnguyendtn left a comment

Choose a reason for hiding this comment

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

Code review looks good on my end. Basically ready to approve, but wondering if the 3.11 failure is a known one that I'm out of the loop on?

@rosteen
Copy link
Collaborator Author

rosteen commented Mar 10, 2023

Code review looks good on my end. Basically ready to approve, but wondering if the 3.11 failure is a known one that I'm out of the loop on?

I hadn't noticed that error, but it appears to be unrelated. Looks like a unit order mismatch in Blackbody fitting.

@rosteen
Copy link
Collaborator Author

rosteen commented Mar 10, 2023

FYI I just updated the Cubeviz and Specviz example notebooks to accurately reflect the changes to get_spectra.

@pllim
Copy link
Contributor

pllim commented Mar 10, 2023

Looks like a unit order mismatch in Blackbody fitting

Oh.... astropy/astropy#14439 😬

(see #2076)

@camipacifici
Copy link
Contributor

The output from get_spectra() is much more intuitive than before!
I was a bit confused by the way masks are applied, but I understand now that the True stands for masked.
I would suggest to add a specific example to the docs on how to get out the specific portion of the spectrum that is highlighted as subset and say explicitly that that is where the mask is False.

@rosteen
Copy link
Collaborator Author

rosteen commented Mar 13, 2023

@camipacifici I added your suggestions to the Specviz exporting data section. If the additions sound good to you I'll go ahead and merge this.

Copy link
Contributor

@bmorris3 bmorris3 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! Added one suggestion for now, and one comment that we can address after merge.

docs/cubeviz/export_data.rst Outdated Show resolved Hide resolved
Comment on lines +43 to +48
.. code-block:: python

spec = specviz.get_data(subset_to_apply='Subset 1')
subset_spec = Spectrum1D(flux=spec.flux[~spec.mask],
spectral_axis=spec.spectral_axis[~spec.mask])
specviz.load_spectrum(subset_spec)
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 this makes sense for now. But since Spectrum1D already has a mask attribute, we could(/should?) make specviz.load_spectrum load the mask so that you don't have to also index by the not-mask. Does the parser do this already/is this step necessary?

Copy link
Collaborator Author

@rosteen rosteen Mar 13, 2023

Choose a reason for hiding this comment

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

The parser does load the mask (I believe you can show the mask and uncertainties, should be a toggle somewhere), but what Cami wanted to do was load in the data such that the data outside the subset is gone completely, which is what this does.

@camipacifici
Copy link
Contributor

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api API change plugin Label for plugins common to multiple configurations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants