Skip to content

Commit

Permalink
Better default TPF stretch
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Apr 26, 2024
1 parent 9ed3e5d commit dada60f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lcviz/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def light_curve_parser(app, file_obj, data_label=None, show_in_viewer=True, **kw
vid='image', name='image')
app.add_data_to_viewer('image', new_data_label)

# set TPF viewer's stretch to custom defaults:
plot_options_plugin = app._jdaviz_helper.plugins.get('Plot Options', None)
if plot_options_plugin is not None:
plot_options_plugin._obj._default_tpf_stretch()

else:
if show_in_viewer:
for viewer_id, viewer in app._viewer_store.items():
Expand Down
16 changes: 16 additions & 0 deletions lcviz/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import numpy as np

from jdaviz.configs.default.plugins import PlotOptions
from jdaviz.core.registries import tray_registry

Expand Down Expand Up @@ -31,6 +33,20 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.docs_link = f"https://lcviz.readthedocs.io/en/{self.vdocs}/plugins.html#plot-options"

def _default_tpf_stretch(
self, vmin_percentile=5, vmax_percentile=99, tpf_viewer_reference='image'
):
viewer = self.app.get_viewer(tpf_viewer_reference)
image = viewer.layers[0].get_image_data()
vmin, vmax = np.nanpercentile(
image, [vmin_percentile, vmax_percentile]
)

self.viewer_selected = tpf_viewer_reference
self.stretch_function_value = 'log'
self.stretch_vmin_value = vmin
self.stretch_vmax_value = vmax

@property
def user_api(self):
api = super().user_api
Expand Down

0 comments on commit dada60f

Please sign in to comment.