Skip to content

Commit

Permalink
updates to handle jdaviz PR 2758
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Apr 15, 2024
1 parent 6982333 commit 50c8918
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lcviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ def _link_new_data(app, reference_data=None, data_to_be_linked=None):
return


def _get_display_unit(app, axis):
if app._jdaviz_helper is None or app._jdaviz_helper.plugins.get('Unit Conversion') is None: # noqa
# fallback on native units (unit conversion is not enabled)
if axis == 'time':
return u.dimensionless_unscaled
elif axis == 'flux':
return app._jdaviz_helper.default_time_viewer._obj.data()[0].flux.unit
else:
raise ValueError(f"could not find units for axis='{axis}'")
try:
# TODO: need to implement and add unit conversion plugin for this to be able to work
return getattr(app._jdaviz_helper.plugins.get('Unit Conversion')._obj,
f'{axis}_unit_selected')
except AttributeError:
raise ValueError(f"could not find display unit for axis='{axis}'")


class LCviz(ConfigHelper):
_default_configuration = {
'settings': {'configuration': 'lcviz',
Expand Down Expand Up @@ -92,6 +109,10 @@ def __init__(self, *args, **kwargs):
lambda *args, **kwargs: _link_new_data(self.app, *args, **kwargs)
)

self.app._get_display_unit = (
lambda *args, **kwargs: _get_display_unit(self.app, *args, **kwargs)
)

# inject custom css from lcviz_style.vue (on top of jdaviz styles)
self.app._add_style((__file__, 'lcviz_style.vue'))

Expand Down
8 changes: 8 additions & 0 deletions lcviz/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def slice_component_label(self):
# calling data_collection_item.get_component(slice_component_label) must work
return 'dt'

@property
def slice_axis(self):
return 'time'

def data(self, cls=None):
data = []

Expand Down Expand Up @@ -334,6 +338,10 @@ def slice_index(self):
# index in viewer.slices corresponding to the slice axis
return 0

@property
def slice_axis(self):
return 'time'

def _initial_x_axis(self, *args):
# Make sure that the x_att/y_att is correct on data load
# called via a callback set upstream in CubevizImageView when reference_data is changed
Expand Down

0 comments on commit 50c8918

Please sign in to comment.