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

Display units: line lists #2148

Merged

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Apr 12, 2023

Description

This pull request updates the line lists plugin so that existing lines are unit-aware. This does not yet update the display of lines in the plugin itself to show in the display units - that work will likely be deferred for the refactor of the line list plugin as both of those efforts will require changing the way the information is stored internally.

Screen.Recording.2023-04-12.at.3.57.14.PM.mov

Changelog will point to #2127 so is ignored from CI here.

Closes #2028

Change log entry

  • Is a change log needed? If yes, is it added to 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, maintainer
    should 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.

  • 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 milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry changed the title Display units line lists Display units: line lists Apr 12, 2023
@kecnry kecnry added the no-changelog-entry-needed changelog bot directive label Apr 13, 2023
@kecnry kecnry added this to the 3.5 milestone Apr 13, 2023
@kecnry kecnry marked this pull request as ready for review April 13, 2023 16:24
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.

I tried adding custom lines after changing the units and also adding custom lines in different units and then switching to those units. Everything worked as expected. I did notice that the table at the bottom of the plugin showing rest and observed units could potentially be updated if it made scientific sense. Should the observed value be in the original units of the line or should it update with the spectral unit? Since I don't know if that is a valid question and everything else looks good I'll go ahead and approve!

@kecnry
Copy link
Member Author

kecnry commented Apr 13, 2023

I did notice that the table at the bottom of the plugin showing rest and observed units could potentially be updated if it made scientific sense. Should the observed value be in the original units of the line or should it update with the spectral unit?

I think we'll eventually want this (at least as the default), but I think it makes sense to defer until the refactor (which will make use of a database of all lines, etc).

@kecnry

This comment was marked as resolved.

@kecnry kecnry marked this pull request as draft April 13, 2023 19:44
@codecov
Copy link

codecov bot commented Apr 13, 2023

Codecov Report

❗ No coverage uploaded for pull request base (dev-display-units@819ed17). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@                 Coverage Diff                  @@
##             dev-display-units    #2148   +/-   ##
====================================================
  Coverage                     ?   91.96%           
====================================================
  Files                        ?      146           
  Lines                        ?    15960           
  Branches                     ?        0           
====================================================
  Hits                         ?    14678           
  Misses                       ?     1282           
  Partials                     ?        0           

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.

@kecnry kecnry marked this pull request as ready for review April 13, 2023 20:16
@rosteen
Copy link
Collaborator

rosteen commented Apr 17, 2023

Thought I had approved this, sorry. I tested and saw that everything worked on Friday, let me do one more pass of the actual code before I give it a check mark.

class BaseSpectrumVerticalLine(Lines, HubListener):
class PluginMark():
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, this doesn't inherit anything...does the base python Class init handle setting self.[whatever] for kwargs if you call super().__init__ like this?

Copy link
Member Author

Choose a reason for hiding this comment

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

turns out its required in order for the comm to be set correctly when other classes inherit from this and Lines

jdaviz/core/marks.py Outdated Show resolved Hide resolved
@rosteen rosteen removed the request for review from pllim April 17, 2023 18:50
@rosteen
Copy link
Collaborator

rosteen commented Apr 17, 2023

I removed the other reviewer tags since I'm 2, I think that's at least in the direction of what we agreed on for avoiding overloading reviews 😃

@kecnry kecnry requested a review from rosteen April 17, 2023 19:35
jdaviz/core/marks.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@rosteen rosteen left a comment

Choose a reason for hiding this comment

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

I did one more quick test post-changes and it still works, thanks!

@kecnry kecnry merged commit ede01ff into spacetelescope:dev-display-units Apr 17, 2023
@kecnry kecnry deleted the display-units-line-lists branch April 17, 2023 20:04
kecnry added a commit that referenced this pull request Apr 17, 2023
* BaseSpectrumVerticalLine to inherit unit-support from PluginMark
* convert units on internal rest value
* code cleanup
kecnry added a commit that referenced this pull request Apr 18, 2023
* BaseSpectrumVerticalLine to inherit unit-support from PluginMark
* convert units on internal rest value
* code cleanup
kecnry added a commit that referenced this pull request Apr 19, 2023
* BaseSpectrumVerticalLine to inherit unit-support from PluginMark
* convert units on internal rest value
* code cleanup
kecnry added a commit that referenced this pull request May 4, 2023
* BaseSpectrumVerticalLine to inherit unit-support from PluginMark
* convert units on internal rest value
* code cleanup
rosteen pushed a commit to rosteen/jdaviz that referenced this pull request May 11, 2023
* BaseSpectrumVerticalLine to inherit unit-support from PluginMark
* convert units on internal rest value
* code cleanup
rosteen pushed a commit to rosteen/jdaviz that referenced this pull request May 15, 2023
* BaseSpectrumVerticalLine to inherit unit-support from PluginMark
* convert units on internal rest value
* code cleanup
rosteen added a commit that referenced this pull request Jun 13, 2023
* Added .ico and .svg files

* app-wide display unit in specviz (#2048)

* basic app-wide display unit in specviz (not all plugins are updated yet)
* unit-aware select component which maps to glue-supported unit strings
* implement use_display_units option for get_data, get_subsets

Co-authored-by: Jesse Averbukh <javerbukh@gmail.com>
Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>

* bump glue-core to necessary version for display units

* change PR number in changelog to main PR

* Display units line analysis (#2128)

* emit event when display unit changed
* update line analysis for unit changes

* cubeviz/slice plugin unit conversion support

(we might want to generalize some of this logic more into the mark's _update_data when adding support for spectral lines as well)

* Display units support for markers plugin (#2130)

* update markers plugin for display units
* move unit-updating logic to mark itself
* LineUncertainties to be unit-aware
* fix support for markers in cubeviz

* display units: fix failing tests (#2132)

* fix error raised when spectrum uncertainty is None
* fix RTD build failure because of missing mixin available in import
* fix test setting display unit now that um is preferred to micron
* add disabled unit conversion plugin to mosviz
* avoid unit-conversion error in cubeviz tests
* bump versions of glue/glue-jupyter
* fix deg intialization in cubeviz slice plugin
* add LinesAutoUnit to __all__ so RTD can find it
* add use_display_units kwarg to get_spectral_regions
* fix setting display units for unitless data
* Apply suggestions from code review

Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>

* Display units: line lists (#2148)

* BaseSpectrumVerticalLine to inherit unit-support from PluginMark
* convert units on internal rest value
* code cleanup

* remove unit conversion plugin from all bug specviz

* for initial implementation - eventually we'll want to implement across all plugins/viewers

* get_display_unit fallback for configs without unit conversion plugin

* Update glue-core dependency

* Update Subset Tools plugin to use display units (#2195)

* bump glue-core to necessary version for display units

* cubeviz/slice plugin unit conversion support

(we might want to generalize some of this logic more into the mark's _update_data when adding support for spectral lines as well)

* display units: fix failing tests (#2132)

* fix error raised when spectrum uncertainty is None
* fix RTD build failure because of missing mixin available in import
* fix test setting display unit now that um is preferred to micron
* add disabled unit conversion plugin to mosviz
* avoid unit-conversion error in cubeviz tests
* bump versions of glue/glue-jupyter
* fix deg intialization in cubeviz slice plugin
* add LinesAutoUnit to __all__ so RTD can find it
* add use_display_units kwarg to get_spectral_regions
* fix setting display units for unitless data
* Apply suggestions from code review

Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>

* remove unit conversion plugin from all bug specviz

* for initial implementation - eventually we'll want to implement across all plugins/viewers

* Working on unit conversion handling in subset plugin

* Get subset updating working in non-default units

* Add changelog

* Update jdaviz/configs/default/plugins/subset_plugin/subset_plugin.vue

Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>

---------

Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>
Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>

* allow downstream apps to set what classes are considered native marks

* Fix unit conversion for PluginMarks and y-limits (#2215)

* Fix unit conversion for PluginMarks and y-limits

* Only use equivalency if it's a spec viewer

* Store wavelength unit on data update

* Remove redundant line

* Better check in marks

* Replace subset_to_apply in docs where possible (#2223)

* Replace subset_to_apply in docs where possible (#2223)

* Avoid trying to convert units of empty marks arrays

* Add open method to automatically detect config and load data

* Update demo notebooks

* Codestyle

* Add autoconfig test coverage

* Revert "Update demo notebooks"

This reverts commit cc513b3.

* Add mention of open to relevant example notebooks

* Prepare to support open via cli

* Remove the need to open file twice for autoconfig detection

* Fix Helper vs App Docstring

* TST: Change PIP_EXTRA_INDEX_URL
because packages moved where they upload nightly builds.

* Display units: model fitting (#2216)

* model component compatibility based on display units
* equation validity based on display units
* allow re-estimating model parameters to update compat checks
* test coverage
* get_data(use_display_units) to pass spectral_density equivalency
* handle whitespace in model equation

* Add clarity for kwargs

* plugin results: support overwriting when data loaded in multiple viewers (#2222)

* reverts removal of call to set_plot_axes when loading data into viewer (#2235)

* fixes a bug in the axes labels on cube viewers in cubeviz as well as setting the correct attributes in lcviz

* Subsume failing identifier test into autoconfig test

* Update subset plugin UI (#2234)

* Update subset plugin UI

* Apply suggestions from code review

Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>

---------

Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>

* Changelog

* Add docs page to explain how to create jdaviz-readable products (#2228)

* Add page for data products

* Update index

* Fix title

* Capital letters

* Address first review comments

* Edit format

* Apply suggestions from code review

Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>

* Including reference in import_data

* Update docs/create_products.rst

* Update docs/create_products.rst

---------

Co-authored-by: Camilla Pacifici <cpacifici@stsci.edu>
Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>
Co-authored-by: Ricky O'Steen <39831871+rosteen@users.noreply.github.com>

* FEAT: Load annulus from file
and allow IMPORT DATA to load reg files.

Annulus support provided by glue-viz/glue#2403 and glue-viz/glue-astronomy#92

Add test for exception.

Bump minimum requirements for glue-core and glue-astronomy.

* disallow gaussian smooth output as input

* BUG: Fix ellipse translation
in app.get_subsets()

* DOC: Use pydata-sphinx-theme (#2243)

* DOC: Use pydata-sphinx-theme
that has dark mode, modern design, and mobile friendly

DOC: No longer need tomli

DOC: Now requires sphinx-astropy 1.9.1

* Add cards to index page
with icons

* Remove iframe hardcoding so it scales
in mobile mode

* DOC: Insert small logo next to title
instead of a giant logo above the title

* Add app method to simplify spectral subset (#2237)

* Add app method to simplify spectral subset

Add simplify button to subset plugin

* Fix xor bug exposed by simplify button

* Fix style checks

* Remove print statements

* Add tooltip to simplify button

* Make button appear only if the subset can be simplified

* Make simplify button appear only when applicable

* Apply suggestions from code review

Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>

* Update changes file

---------

Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>

* Fix missed conflict

---------

Co-authored-by: Jennifer Kotler <jkotler@esme.stsci.edu>
Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>
Co-authored-by: Jesse Averbukh <javerbukh@gmail.com>
Co-authored-by: Ricky O'Steen <rosteen@stsci.edu>
Co-authored-by: Ricky O'Steen <39831871+rosteen@users.noreply.github.com>
Co-authored-by: Duy Nguyen <duytnguyendtn.open@gmail.com>
Co-authored-by: Camilla Pacifici <camilla.pacifici@gmail.com>
Co-authored-by: Camilla Pacifici <cpacifici@stsci.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants