Skip to content

Commit

Permalink
Flatten: separate previews for flattened and trend (#41)
Browse files Browse the repository at this point in the history
* separate toggle for flattened and trend live-preview visibility
  • Loading branch information
kecnry authored Oct 19, 2023
1 parent 93d5a14 commit a5065e5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
22 changes: 14 additions & 8 deletions lcviz/plugins/flatten/flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ class Flatten(PluginTemplateMixin, DatasetSelectMixin, AddResultsMixin):
Only the following attributes and methods are available through the
public plugin API.
* ``show_live_preview``
* ``show_live_preview`` : bool
Whether to show the live-preview of the (unnormalized) flattened light curve
* ``show_trend_preview`` : bool
Whether to show the live-preview of the trend curve used to flatten the light curve
* ``default_to_overwrite``
* ``dataset`` (:class:`~jdaviz.core.template_mixin.DatasetSelect`):
Dataset to flatten.
Expand All @@ -43,6 +46,7 @@ class Flatten(PluginTemplateMixin, DatasetSelectMixin, AddResultsMixin):
uses_active_status = Bool(True).tag(sync=True)

show_live_preview = Bool(True).tag(sync=True)
show_trend_preview = Bool(True).tag(sync=True)
default_to_overwrite = Bool(True).tag(sync=True)
flatten_err = Unicode().tag(sync=True)

Expand All @@ -65,7 +69,7 @@ def __init__(self, *args, **kwargs):

@property
def user_api(self):
expose = ['show_live_preview', 'default_to_overwrite',
expose = ['show_live_preview', 'show_trend_preview', 'default_to_overwrite',
'dataset', 'add_results',
'window_length', 'polyorder', 'break_tolerance',
'niters', 'sigma', 'unnormalize', 'flatten']
Expand Down Expand Up @@ -160,17 +164,19 @@ def _clear_marks(self):
mark.clear()
mark.visible = False

@observe('is_active', 'show_live_preview')
@observe('is_active', 'show_live_preview', 'show_trend_preview')
def _toggle_marks(self, event={}):
visible = self.show_live_preview and self.is_active
live_visible = self.show_live_preview and self.is_active
trend_visible = self.show_trend_preview and self.is_active

trend_marks, flattened_marks = self.marks
for mark in trend_marks.values():
mark.visible = visible
mark.visible = trend_visible
for mark in flattened_marks.values():
mark.visible = visible
mark.visible = live_visible

if visible and event.get('name') in ('is_active', 'show_live_preview'):
if ((live_visible or trend_visible) and
event.get('name') in ('is_active', 'show_live_preview', 'show_trend_preview')):
# then the marks themselves need to be updated
self._live_update(event)

Expand All @@ -187,7 +193,7 @@ def _live_update(self, event={}):
return
self.flatten_err = ''

if event.get('name') not in ('is_active', 'show_live_preview'):
if event.get('name') not in ('is_active', 'show_live_preview', 'show_trend_preview'):
# mark visibility hasn't been handled yet
self._toggle_marks(event)

Expand Down
12 changes: 10 additions & 2 deletions lcviz/plugins/flatten/flatten.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@
<v-row>
<v-switch
v-model="show_live_preview"
label="Show live preview"
hint="Whether to show live preview of flattening options. Note that the live-preview of the flattened light curve is not yet normalized."
label="Show flattened preview"
hint="Whether to show live-preview of the unnormalized flattened light curve."
persistent-hint
></v-switch>
</v-row>
<v-row v-if="show_live_preview && !unnormalize">
<v-alert type="warning">Live preview is unnormalized, but flattening will normalize.</v-alert>
</v-row>
<v-row>
<v-switch
v-model="show_trend_preview"
label="Show trend preview"
hint="Whether to show live-preview of the trend used for flattening."
persistent-hint
></v-switch>
</v-row>
<v-row>
<v-switch
v-model="default_to_overwrite"
Expand Down

0 comments on commit a5065e5

Please sign in to comment.