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

Bugfix: lcviz TPFs are sliced by cube index rather than time slice #3235

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Bug Fixes

- Improved performance and removed jittering for the matched box zoom tool. [#3215]

- Fix Slice plugin for indexing through temporal slices. [#3235]

Cubeviz
^^^^^^^

Expand Down
48 changes: 30 additions & 18 deletions jdaviz/configs/cubeviz/plugins/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,39 @@
)

for layer in self.layers:
world_comp_ids = layer.layer.data.world_component_ids

if not len(world_comp_ids):
# rampviz uses coordinate components:
world_comp_ids = layer.layer.data.coordinate_components

if self.slice_index >= len(world_comp_ids):
# Case where 2D image is loaded in image viewer
continue

try:
# Retrieve layer data and units using the slice index of the world components ids
data_comp = layer.layer.data.get_component(world_comp_ids[self.slice_index])
except (AttributeError, KeyError):
continue
coords = layer.layer.data.coords
if hasattr(coords, 'temporal_wcs'):
data_units = coords.temporal_wcs.unit
data = coords.temporal_wcs.pixel_to_world_values(

Check warning on line 102 in jdaviz/configs/cubeviz/plugins/mixins.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/mixins.py#L101-L102

Added lines #L101 - L102 were not covered by tests
np.arange(layer.layer.data.shape[0])
)

data = np.asarray(data_comp.data.take(0, take_inds[0]).take(0, take_inds[1]), # noqa
dtype=float)
else:
world_comp_ids = layer.layer.data.world_component_ids

if not len(world_comp_ids):
# rampviz uses coordinate components:
world_comp_ids = layer.layer.data.coordinate_components

if self.slice_index >= len(world_comp_ids):
# Case where 2D image is loaded in image viewer
continue

try:
# Retrieve layer data and units using the slice index
# of the world components ids
data_comp = layer.layer.data.get_component(
world_comp_ids[self.slice_index]
)
except (AttributeError, KeyError):
continue

Check warning on line 124 in jdaviz/configs/cubeviz/plugins/mixins.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/mixins.py#L123-L124

Added lines #L123 - L124 were not covered by tests

data = np.asarray(
data_comp.data.take(0, take_inds[0]).take(0, take_inds[1]),
dtype=float)
data_units = getattr(data_comp, 'units', None)

# Convert to display units if applicable
data_units = getattr(data_comp, 'units', None)
if slice_display_units and data_units and slice_display_units != data_units:
converted_axis = (data * u.Unit(data_units)).to_value(
slice_display_units,
Expand Down
Loading