-
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
Add Rampviz helper, generalize cube config helper and profile viewer #3120
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3120 +/- ##
==========================================
- Coverage 88.82% 87.20% -1.63%
==========================================
Files 112 121 +9
Lines 17626 18239 +613
==========================================
+ Hits 15657 15905 +248
- Misses 1969 2334 +365 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
7e4f6b6
to
125aa09
Compare
125aa09
to
7aaf4d0
Compare
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.
I've updated this file's docstring, which had a bunch of pre-existing issues that are unrelated to this PR.
@@ -55,6 +55,16 @@ Jdaviz | |||
|
|||
Jump to Mosviz | |||
|
|||
.. grid-item-card:: | |||
:img-top: logos/cube.svg |
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.
Of course, we don't have a Rampviz logo yet, and won't until we have Jenn back. I'm leaving the cubeviz logo here in the mean time.
Ramp Extraction | ||
=============== | ||
|
||
|
||
|
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.
To be added once we converge on the way it works...
.. automodapi:: jdaviz.configs.cubeviz.plugins.spectral_extraction.spectral_extraction | ||
:no-inheritance-diagram: | ||
|
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.
Can you believe this was missing!?
jdaviz/app.py
Outdated
elif linked_data.ndim == 2: | ||
# load a several 1D ramp profiles from a 2D NDDataArray: | ||
ref_group_component = dc[0].components[-2] | ||
ref_flux_component = dc[0].components[-1] | ||
linked_group_component = dc[-1].components[1] | ||
linked_flux_component = dc[-1].components[2] | ||
|
||
links = [ | ||
LinkSame(ref_group_component, linked_group_component), | ||
LinkSame(ref_flux_component, linked_flux_component) | ||
] | ||
|
||
dc.add_link(links) | ||
return |
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 case may or may not actually be useful if we want to enable loading more than one 1D ramp profile in the integration viewer from a 2D NDDataArray. I'm asking Tom+Derek for advice on whether or not that's plausible to implement.
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.
just a few thoughts from a first skim. It would be helpful to have a bullet list of high-level changes, and then how those are planned to be changed in the future (i.e., what will inherit from what, where will there be shared logic, how do we move from here to deconfigging?).
@@ -14,7 +15,7 @@ def slice_component_label(self): | |||
|
|||
@property | |||
def slice_display_unit_name(self): | |||
return 'spectral' | |||
return 'spectral' if self.default_class != NDDataArray else 'temporal' |
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 logic feels a little fragile, would it be better to override in a subclass (both here and in the slice plugin)?
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.
I agree that it's fragile. I hesitate to make a subclass to override only this.
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.
Maybe we can check against the config instead of the default_class
?
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.
Sounds good!
_cube_viewer_cls = CubevizImageView | ||
_cube_viewer_default_label = 'flux-viewer' | ||
_cube_viewer_cls = (CubevizImageView, RampvizImageView) | ||
_cube_viewer_default_label = None # must be filled in by helper on initialization |
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.
I really don't like the helper being responsible for setting something in the plugin, can this be retrieved from the helper during init instead? Or would a subclass here as well help?
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.
Agreed, this is a good idea. I've reworked this as suggested:
can this be retrieved from the helper during init instead?
jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py
Show resolved
Hide resolved
class RampExtraction(PluginTemplateMixin, ApertureSubsetSelectMixin, | ||
DatasetSelectMixin, AddResultsMixin): |
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.
can this not inherit from spectral extraction? Is there any shared logic that can be moved up?
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.
I'd say it shouldn't inherit from anything spectral, but we could make a CubeExtraction
parent to both.
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.
lcviz does currently inherit and tried to make the spectral extraction as generic as possible, but I'd definitely be in favor of a completely generic base class that spectral, ramp, and photometric can all inherit from
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.
I am too, let's do it. Do you want to see that in this ticket/PR, or do you mind if I put that together with this one?
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.
separate is probably fine to keep the diff somewhat manageable
ccf233a
to
282f193
Compare
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.
My eyes started glazing over 2/3 of the way through, I'll come back later to finish looking through the code - so far I didn't see anything that I object to.
I appreciate you moving ProfileFromCube
into the default config - we keep generalizing things (e.g coords_info.py
) and leaving them in the original config directories, and I've been wanting to go through and move some things for a while. In that vein, would it make sense to move the slice plugin to the default config at this point now that it supports Cubeviz and Rampviz?
Agreed @rosteen, I wrote the same thing in my notes above:
|
Well, that you did! Consider me a yes to that question then 🙂 |
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.
I mostly made sure this didn't break anything in Cubeviz and read through the code, made a couple minor comments but overall it looks pretty good to me.
FYI I did try out the RampvizExample notebook and it was definitely slow on my machine with one or two things possibly broken - the main one being that deleting a spatial subset doesn't seem to clear the extracted ramps from that subset as I would expect in the profile viewer.
jdaviz/core/marks.py
Outdated
try: | ||
self._update_unit(reference_data.get_object(cls=Spectrum1D).spectral_axis.unit) | ||
except (TypeError, ValueError): | ||
# don't update x units for rampviz, which doesn't convert to 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.
Would it be possible to have an explicit config check here rather than a try/except that could potentially hide real failures?
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.
I've changed this in the latest commit to check if self.viewer.jdaviz_app.config == 'rampviz'
, as suggested.
) | ||
|
||
has_spectral_coords = ( | ||
any(str(coord).startswith('WAVE') for coord in wcs_coords) or |
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.
Maybe also add an or clause for frequency? I'm not sure if the WCS has something like FREQ
in that case.
Good eye, I just caught that in 23d6bd1. |
99206ff
to
9d857db
Compare
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.
can't guarantee I've thought about every line, but I think this is good enough to go in and build on top of... we can always iterate on the generalization and rampviz-specifics in subsequent PRs. Thanks!
9d857db
to
18f8263
Compare
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.
I agree with Kyle, this is looking good enough to get in and iterate on later if needed. Thanks for all the work!
@bmorris3 please make sure all the other changes from https://github.com/spacetelescope/jdaviz/pull/2094/files are re-applied as well if haven't already. Thanks! |
Demo video
Watch on Box. The demo uses an example notebook that's included in this PR, which downloads a Roman L1 file stored on Box.
Description
This PR introduces
Rampviz
, which had a proof of concept in PR #2376. Rampviz is a helper for visualizing Level 1 data products (IR ramps) from Roman and JWST. Rampviz and Cubeviz share a lot of common infrastructure, since both use 3D data cubes that are viewed as slices in an image viewer, and "profiles" – spectral profiles in Cubeviz and what I'm calling "ramp profiles" in Rampviz.Here's what I've reorganized or generalized to keep these tools consistent (where possible):
CubeConfigHelper
class, and both Cubeviz and Rampviz inherit from the new class. All spectral cube-specific helper methods are introduced in the Cubeviz helper, and the ramp-specific helper methods are in Rampviz.spectrum-viewer
in Cubeviz is an instance ofCubevizProfileView
, which inherits fromSpecvizProfileView
. I created a newJdavizProfileView
class containing any methods previously inSpecvizProfileView
that are not spectrum-specific. The spectrum-specific methods remain inSpecvizProfileView
. I then created a newRampvizProfileView
that inherits fromJdavizProfileView
.cubeviz/plugins
directory, but we could/should? move it todefault/plugins
.Here's what's totally new:
NDDataArrays
into theintegration-viewer
. Getting the JWST parser up to speed will come later.RampvizProfileView
andRampvizImageView
, which are just like their Cubeviz equivalents sans assumptions about spectral data types._extract_from_aperture
method, which uses numpy functions to collapse the subset of a cached ramp cube to a 1D ramp profile. The demo ramp in Rampviz has ten 4k images in the cube. It turns out that our spectral extraction in Cubeviz always makes copies of the spectral and uncertainty cubes before doing an extraction, which is not performant on these larger ramp cubes. By introducing a cache, we get speedups of a factor of 2-5. Switching from the NDData approach in cubeviz for error+mask propagation to this simpler numpy-based approach may not be necessary, and we can use NDData instead if we want to include uncertainties, but I don't believe that's useful for ramp cube subset statistics, so I've dropped it for this plugin.Deferred to a later PR:
integration-viewer
, analogous to spectral subsets in specviz or cubeviz) 🎫Closes #2376
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.