diff --git a/lcviz/parsers.py b/lcviz/parsers.py index 6b1799ed..13831092 100644 --- a/lcviz/parsers.py +++ b/lcviz/parsers.py @@ -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(): diff --git a/lcviz/plugins/plot_options/plot_options.py b/lcviz/plugins/plot_options/plot_options.py index b0dcb028..2fbfe387 100644 --- a/lcviz/plugins/plot_options/plot_options.py +++ b/lcviz/plugins/plot_options/plot_options.py @@ -1,3 +1,5 @@ +import numpy as np + from jdaviz.configs.default.plugins import PlotOptions from jdaviz.core.registries import tray_registry @@ -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