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 df51b0d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
0.4.0 (unreleased)
------------------

* Support loading, viewing, and slicing through TPF data cubes. [#82]
* Support loading, viewing, and slicing through TPF data cubes. [#82, #117]

* Default data labels no longer include flux-origin, but do include quarter/campaign/sector. [#111]

Expand Down
6 changes: 6 additions & 0 deletions lcviz/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lightkurve

from lcviz.viewers import PhaseScatterView, TimeScatterView
from lcviz.plugins.plot_options import PlotOptions

__all__ = ["light_curve_parser"]

Expand Down Expand Up @@ -75,6 +76,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 = PlotOptions(app=app)
if plot_options_plugin is not None:
plot_options_plugin._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 df51b0d

Please sign in to comment.