-
Notifications
You must be signed in to change notification settings - Fork 76
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
lcviz cube support #2678
lcviz cube support #2678
Conversation
* would be nice to generalize to read from the helper the expected order of axes
if self.app.config == 'lcviz': | ||
value = arr[viewer.state.slices[0], int(round(y)), int(round(x))] | ||
else: | ||
# cubeviz case: | ||
value = arr[int(round(x)), int(round(y)), viewer.state.slices[-1]] |
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 we store the indices in the helper, is there any way to generalize this line? 🤔
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.
Helpers could have hidden __getitem__
-like methods for indexing the source data, right?
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.
ummm, we could maybe monkeypatch it on to the data-layer, but I'm not sure helper-level makes sense since helpers can have multiple types of data each with their own dimensionality, etc.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2678 +/- ##
==========================================
- Coverage 90.86% 90.85% -0.01%
==========================================
Files 162 162
Lines 21127 21157 +30
==========================================
+ Hits 19196 19222 +26
- Misses 1931 1935 +4 ☔ View full report in Codecov by Sentry. |
# needed for cubeviz | ||
ix_shape = 0 | ||
iy_shape = 1 | ||
if self.app.config == 'lcviz': |
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.
Is there no other way? I don't know how I feel about having special logic for a config that does not exist in this repo. This might be a slippery slope.
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.
see my comment - if you can think of a way to generalize that line if these indices are stored in the helper, then I am happy to do that. The other option would be to refactor so that this part can be overridden without having to copy and paste the rest of the entire method (perhaps a _get_image_layer_data
method).
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.
Even if we manage to generalize this part, what about things like this?
} else if (this.$props.viewer.config === 'lcviz') {
if (this.$props.viewer.reference.startsWith('tpf')) {
multi_select = false
}
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 have a ticket to refactor that (the data-menu visibility logic) to be more downstream-friendly. Until we can prioritize that, at least these will live in dedicated if-statements 🤷♂️
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 think if you do if config == "cubeviz"
instead, then we don't have to worry about lcviz logic sneaking in here as lcviz then would go the route of "else".
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 rather refactor - I don't like the idea of having the fallback behavior in jdaviz be the behavior needed by lcviz. That will make it too hard to remove the logic when we do do a refactor and also risks accidentally breaking downstream.
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.
Really, it is only cubeviz that has the weird transposing due to specutils swapaxes. Everything else (like lcviz) should be in else
.
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.
So, if we ever have TRampViz, it would theoretically follow the same indexing as lcviz.
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.
Does 1989b85 work for you? Downstream this would then look something like spacetelescope/lcviz#83
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.
Yes, except the variable assignments (another comment I just made).
@@ -127,6 +127,10 @@ module.exports = { | |||
if (this.$props.viewer.reference === 'spectrum-2d-viewer') { | |||
multi_select = false | |||
} | |||
} else if (this.$props.viewer.config === 'lcviz') { | |||
if (this.$props.viewer.reference.startsWith('tpf')) { |
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 was going to leave this comment in a review on the lcviz TPF viewer work, but I'll put it here: are we committed to a viewer name starting with tpf
? I think we could do better, since the light curve viewer is also showing TPF data. The distinguishing feature is that this corresponds to an image/slice 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.
nope, suggestions welcomed!
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.
Some words for thought: in Kepler and TESS we call the usual spatial image data product a "postage stamp," for stars in the KIC/TIC. In TESS you can also use tesscut
to cutout an analogous small spatial region for the same purpose. I wouldn't want to call the viewer stamp
since not all TPF cubes are postage stamps. I like aperture
, but I'd be cautious about that, only because we might make an aperture-related plugin, and we wouldn't want to confuse the viewer and plugin names. image
is the least ambiguous – this is one of the very few types of images we expect to see in lcviz.
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.
ok, I'll remove this from this PR at least until a decision is made in lcviz. I think image is probably fine as well and we can always change it to be more specific if needed.
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 isn't removed yet but I got a ping to review. What is going on? Hope you can clarify. Thanks.
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.
ah I removed it from the other place (title case), I still need it for the if-statements but will update with the new label suggested by @bmorris3 that has been merged for lcviz. Sorry about that!
I think we still need this here until we prioritize a significant refactor to allow downstream overriding.
if self.app.config == 'lcviz': | ||
value = arr[viewer.state.slices[0], int(round(y)), int(round(x))] | ||
else: | ||
# cubeviz case: | ||
value = arr[int(round(x)), int(round(y)), viewer.state.slices[-1]] |
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.
Helpers could have hidden __getitem__
-like methods for indexing the source data, right?
|
||
if isinstance(data, GroupedSubset): | ||
# don't update histogram for subsets: | ||
return | ||
|
||
comp = data.get_component(data.main_components[0]) | ||
comp = data.get_component(layer.state.attribute) |
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.
Is this really equivalent to main_component[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.
No, but I think its what we actually want. Shouldn't this always be the plotted data?
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 dunno. Further down, there is a block that calls data.get_component
under some condition. Will that still be consistent?
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.
That logic probably also could use rewriting to be more specific as well (currently only applies to 2d spectral viewers, afaik), but should not affect this at all (that is for the x-y limit determination, this is for the actual "color" axis of the image which is what should be plotted on the histogram). Feel free to find a case that breaks if you have any concerns!
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 not expert in Plot Options, so this is fine. I won't do this to, say, aperture photometry though, but that is irrelevant 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.
layer.state.attribute
is the requested column to be plotted, data.main_components[0]
is just the first "main" component (which probably is the default column to be plotted, but is not general enough). For the histogram, we definitely want to plot the same data in the histogram as is shown in the image viewer itself, so I think the previous assumption is not general enough.
@@ -426,7 +430,11 @@ def _image_viewer_update(self, viewer, x, y): | |||
arr = image.get_component(attribute).data | |||
unit = image.get_component(attribute).units | |||
if image.ndim == 3: | |||
value = arr[int(round(x)), int(round(y)), viewer.state.slices[-1]] | |||
if self.app.config == 'lcviz': |
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.
* which effectively removes all mentions of lcviz from coords-info in jdaviz * downstream implementation in spacetelescope/lcviz#83
def _image_shape_inds(self, image): | ||
if image.ndim == 3: | ||
# cubeviz case | ||
return (0, 1) |
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 prefer you keep the ix_shape
and iy_shape
assignments here instead of tuples without any explanation.
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.
clarified with inline comments
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.
Thanks, this should work!
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.
Good enough. Nice compromise. Thanks!
* lcviz-case for cube mouseover * stretch histogram - use layer attribute instead of assuming first * refactor coords info so downstream can override * downstream implementation in spacetelescope/lcviz#83
Description
This pull request:
adds an lcviz exception to which indices from the cube array to pull mouseover information. This would be nice to generalize in a way that the helper or viewer can store the order, but is difficult to do.. Refactor coords_info (mouseover information) so that lcviz can override the dimensions to grab from the cube in make use of upstream refactor to override indices in lcviz lcviz#83.This is not expected to change any behavior in jdaviz itself.
To test in lcviz, use with spacetelescope/lcviz#81
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.