diff --git a/CHANGES.rst b/CHANGES.rst index 80d516b8..fbfdec9d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,10 +3,10 @@ * Clone viewer tool. [#74] -* Flux origin plugin to choose which column is treated as the flux column for each dataset. [#77] +* Flux column plugin to choose which column is treated as the flux column for each dataset. [#77] * Flatten plugin no longer creates new data entries, but instead appends a new column to the input - light curve and selects as the flux origin. [#77] + light curve and selects as the flux column (origin). [#77] 0.1.0 (12-14-2023) ------------------ diff --git a/docs/plugins.rst b/docs/plugins.rst index bf76e5eb..22f6c39e 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -35,13 +35,13 @@ This plugin allows viewing of any metadata associated with the selected data. :ref:`Jdaviz Metadata Viewer ` Jdaviz documentation on the Metadata Viewer plugin. -.. _flux-origin: +.. _flux-column: -Flux Origin +Flux Column =========== -This plugin allows choosing which column in the underlying data should be used as the flux origin -throughout the app (when plotting and in any data analysis plugins). +This plugin allows choosing which column in the underlying data should be used as the flux column +(origin) throughout the app (when plotting and in any data analysis plugins). .. admonition:: User API Example @@ -58,9 +58,9 @@ throughout the app (when plotting and in any data analysis plugins). lcviz.load_data(lc) lcviz.show() - flux_origin = lcviz.plugins['Flux Origin'] - print(flux_origin.flux_origin.choices) - flux_origin.flux_origin = 'sap_flux' + flux_col = lcviz.plugins['Flux Column'] + print(flux_col.flux_column.choices) + flux_col.flux_column = 'sap_flux' .. seealso:: diff --git a/lcviz/components/components.py b/lcviz/components/components.py index 33450407..e3ffdbad 100644 --- a/lcviz/components/components.py +++ b/lcviz/components/components.py @@ -5,12 +5,12 @@ from jdaviz.core.template_mixin import SelectPluginComponent -from lcviz.events import FluxOriginChangedMessage +from lcviz.events import FluxColumnChangedMessage -__all__ = ['FluxOriginSelect', 'FluxOriginSelectMixin'] +__all__ = ['FluxColumnSelect', 'FluxColumnSelectMixin'] -class FluxOriginSelect(SelectPluginComponent): +class FluxColumnSelect(SelectPluginComponent): def __init__(self, plugin, items, selected, dataset): super().__init__(plugin, items=items, @@ -22,8 +22,8 @@ def __init__(self, plugin, items, selected, dataset): self._on_change_dataset) # sync between instances in different plugins - self.hub.subscribe(self, FluxOriginChangedMessage, - handler=self._on_flux_origin_changed_msg) + self.hub.subscribe(self, FluxColumnChangedMessage, + handler=self._on_flux_column_changed_msg) def _on_change_dataset(self, *args): def _include_col(lk_obj, col): @@ -53,28 +53,28 @@ def _include_col(lk_obj, col): if lk_obj is None: return self.choices = [col for col in lk_obj.columns if _include_col(lk_obj, col)] - flux_origin = lk_obj.meta.get('FLUX_ORIGIN') - if flux_origin in self.choices: - self.selected = flux_origin + flux_column = lk_obj.meta.get('FLUX_ORIGIN') + if flux_column in self.choices: + self.selected = flux_column else: self.selected = '' - def _on_flux_origin_changed_msg(self, msg): + def _on_flux_column_changed_msg(self, msg): if msg.dataset != self.dataset.selected: return # need to clear the cache due to the change in metadata made to the data-collection entry self.dataset._clear_cache('selected_obj', 'selected_dc_item') self._on_change_dataset() - self.selected = msg.flux_origin + self.selected = msg.flux_column def _on_change_selected(self, *args): if self.selected == '': return dc_item = self.dataset.selected_dc_item - old_flux_origin = dc_item.meta.get('FLUX_ORIGIN') - if self.selected == old_flux_origin: + old_flux_column = dc_item.meta.get('FLUX_ORIGIN') + if self.selected == old_flux_column: # nothing to do here! return @@ -85,8 +85,8 @@ def _on_change_selected(self, *args): self.app._jdaviz_helper._set_data_component(dc_item, 'flux_err', dc_item[self.selected+"_err"]) # noqa dc_item.meta['FLUX_ORIGIN'] = self.selected - self.hub.broadcast(FluxOriginChangedMessage(dataset=self.dataset.selected, - flux_origin=self.selected, + self.hub.broadcast(FluxColumnChangedMessage(dataset=self.dataset.selected, + flux_column=self.selected, sender=self)) def add_new_flux_column(self, flux, flux_err, label, selected=False): @@ -99,19 +99,19 @@ def add_new_flux_column(self, flux, flux_err, label, selected=False): flux_err) # broadcast so all instances update to get the new column and selection (if applicable) - self.hub.broadcast(FluxOriginChangedMessage(dataset=self.dataset.selected, - flux_origin=label if selected else self.selected, # noqa + self.hub.broadcast(FluxColumnChangedMessage(dataset=self.dataset.selected, + flux_column=label if selected else self.selected, # noqa sender=self)) -class FluxOriginSelectMixin(VuetifyTemplate, HubListener): - flux_origin_items = List().tag(sync=True) - flux_origin_selected = Unicode().tag(sync=True) +class FluxColumnSelectMixin(VuetifyTemplate, HubListener): + flux_column_items = List().tag(sync=True) + flux_column_selected = Unicode().tag(sync=True) # assumes DatasetSelectMixin is also used (DatasetSelectMixin must appear after in inheritance) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.flux_origin = FluxOriginSelect(self, - 'flux_origin_items', - 'flux_origin_selected', + self.flux_column = FluxColumnSelect(self, + 'flux_column_items', + 'flux_column_selected', dataset='dataset') diff --git a/lcviz/events.py b/lcviz/events.py index 724471f4..97c0f783 100644 --- a/lcviz/events.py +++ b/lcviz/events.py @@ -2,7 +2,7 @@ __all__ = ['EphemerisComponentChangedMessage', 'EphemerisChangedMessage', - 'FluxOriginChangedMessage'] + 'FluxColumnChangedMessage'] class EphemerisComponentChangedMessage(Message): @@ -30,10 +30,10 @@ def __init__(self, ephemeris_label, *args, **kwargs): self.ephemeris_label = ephemeris_label -class FluxOriginChangedMessage(Message): - """Message emitted by the FluxOriginSelect component when the selection has been changed. - To subscribe to a change for a particular dataset, consider using FluxOriginSelect directly +class FluxColumnChangedMessage(Message): + """Message emitted by the FluxColumnSelect component when the selection has been changed. + To subscribe to a change for a particular dataset, consider using FluxColumnSelect directly and observing the traitlet, rather than subscribing to this message""" - def __init__(self, dataset, flux_origin, *args, **kwargs): + def __init__(self, dataset, flux_column, *args, **kwargs): self.dataset = dataset - self.flux_origin = flux_origin + self.flux_column = flux_column diff --git a/lcviz/helper.py b/lcviz/helper.py index b7b17904..9f234d37 100644 --- a/lcviz/helper.py +++ b/lcviz/helper.py @@ -72,7 +72,7 @@ class LCviz(ConfigHelper): 'dense_toolbar': False, 'context': {'notebook': {'max_height': '600px'}}}, 'toolbar': ['g-data-tools', 'g-subset-tools', 'lcviz-coords-info'], - 'tray': ['lcviz-metadata-viewer', 'flux-origin', + 'tray': ['lcviz-metadata-viewer', 'flux-column', 'lcviz-plot-options', 'lcviz-subset-plugin', 'lcviz-markers', 'flatten', 'frequency-analysis', 'ephemeris', 'binning', 'lcviz-export-plot'], diff --git a/lcviz/plugins/__init__.py b/lcviz/plugins/__init__.py index 90806175..2bf109b5 100644 --- a/lcviz/plugins/__init__.py +++ b/lcviz/plugins/__init__.py @@ -3,7 +3,7 @@ from .ephemeris.ephemeris import * # noqa from .export_plot.export_plot import * # noqa from .flatten.flatten import * # noqa -from .flux_origin.flux_origin import * # noqa +from .flux_column.flux_column import * # noqa from .frequency_analysis.frequency_analysis import * # noqa from .markers.markers import * # noqa from .metadata_viewer.metadata_viewer import * # noqa diff --git a/lcviz/plugins/binning/binning.py b/lcviz/plugins/binning/binning.py index 7be2a514..3c3dcd4d 100644 --- a/lcviz/plugins/binning/binning.py +++ b/lcviz/plugins/binning/binning.py @@ -13,7 +13,7 @@ with_spinner) from jdaviz.core.user_api import PluginUserApi -from lcviz.components import FluxOriginSelectMixin +from lcviz.components import FluxColumnSelectMixin from lcviz.events import EphemerisChangedMessage from lcviz.helper import _default_time_viewer_reference_name from lcviz.marks import LivePreviewBinning @@ -25,7 +25,7 @@ @tray_registry('binning', label="Binning") -class Binning(PluginTemplateMixin, FluxOriginSelectMixin, DatasetSelectMixin, +class Binning(PluginTemplateMixin, FluxColumnSelectMixin, DatasetSelectMixin, EphemerisSelectMixin, AddResultsMixin): """ See the :ref:`Binning Plugin Documentation ` for more details. @@ -152,7 +152,7 @@ def _toggle_marks(self, event={}): # then the marks themselves need to be updated self._live_update(event) - @observe('flux_origin_selected', 'dataset_selected', + @observe('flux_column_selected', 'dataset_selected', 'ephemeris_selected', 'n_bins', 'previews_temp_disable') @skip_if_no_updates_since_last_active() diff --git a/lcviz/plugins/flatten/flatten.py b/lcviz/plugins/flatten/flatten.py index 55ae8773..a10bc7c1 100644 --- a/lcviz/plugins/flatten/flatten.py +++ b/lcviz/plugins/flatten/flatten.py @@ -13,7 +13,7 @@ with_spinner) from jdaviz.core.user_api import PluginUserApi -from lcviz.components import FluxOriginSelectMixin +from lcviz.components import FluxColumnSelectMixin from lcviz.marks import LivePreviewTrend, LivePreviewFlattened from lcviz.utils import data_not_folded from lcviz.viewers import TimeScatterView, PhaseScatterView @@ -23,7 +23,7 @@ @tray_registry('flatten', label="Flatten") -class Flatten(PluginTemplateMixin, FluxOriginSelectMixin, DatasetSelectMixin): +class Flatten(PluginTemplateMixin, FluxColumnSelectMixin, DatasetSelectMixin): """ See the :ref:`Flatten Plugin Documentation ` for more details. @@ -44,7 +44,7 @@ class Flatten(PluginTemplateMixin, FluxOriginSelectMixin, DatasetSelectMixin): * ``unnormalize`` * ``flux_label`` (:class:`~jdaviz.core.template_mixin.AutoTextField`): Label for the resulting flux column added to ``dataset`` and automatically selected as the new - flux origin. + flux column (origin). * :meth:`flatten` """ template_file = __file__, "flatten.vue" @@ -122,7 +122,7 @@ def marks(self): return trend_marks, flattened_marks - @observe('dataset_selected', 'flux_origin_selected') + @observe('dataset_selected', 'flux_column_selected') def _set_default_label(self, event={}): '''Generate a label and set the results field to that value''' if not hasattr(self, 'dataset'): # pragma: no cover @@ -130,11 +130,11 @@ def _set_default_label(self, event={}): # TODO: have an option to create new data entry and drop other columns? # (or should that just go through future data cloning) - self.flux_label.default = f"{self.flux_origin_selected}_flattened" + self.flux_label.default = f"{self.flux_column_selected}_flattened" @observe('flux_label_label', 'dataset') def _update_label_valid(self, event={}): - if self.flux_label.value in self.flux_origin.choices: + if self.flux_label.value in self.flux_column.choices: self.flux_label.invalid_msg = '' self.flux_label_overwrite = True elif self.flux_label.value in getattr(self.dataset.selected_obj, 'columns', []): @@ -152,7 +152,7 @@ def flatten(self, add_data=True): ---------- add_data : bool Whether to add the resulting light curve as a flux column and select that as the new - flux origin for that data entry. + flux column (origin) for that data entry. Returns ------- @@ -180,9 +180,9 @@ def flatten(self, add_data=True): if add_data: # add data as a new flux and corresponding err columns in the existing data entry - # and select as flux origin + # and select as flux column (origin) data = _data_with_reftime(self.app, output_lc) - self.flux_origin.add_new_flux_column(flux=data['flux'], + self.flux_column.add_new_flux_column(flux=data['flux'], flux_err=data['flux_err'], label=self.flux_label.value, selected=True) @@ -212,14 +212,14 @@ def _toggle_marks(self, event={}): # then the marks themselves need to be updated self._live_update(event) - @observe('dataset_selected', 'flux_origin_selected', + @observe('dataset_selected', 'flux_column_selected', 'window_length', 'polyorder', 'break_tolerance', 'niters', 'sigma', 'previews_temp_disable') @skip_if_no_updates_since_last_active() def _live_update(self, event={}): if self.previews_temp_disable: return - if self.dataset_selected == '' or self.flux_origin_selected == '': + if self.dataset_selected == '' or self.flux_column_selected == '': self._clear_marks() return diff --git a/lcviz/plugins/flatten/flatten.vue b/lcviz/plugins/flatten/flatten.vue index a71bed3f..191df121 100644 --- a/lcviz/plugins/flatten/flatten.vue +++ b/lcviz/plugins/flatten/flatten.vue @@ -157,7 +157,7 @@ - + ` for more details. + See the :ref:`Flux Column Plugin Documentation ` for more details. Only the following attributes and methods are available through the public plugin API. * ``dataset`` (:class:`~jdaviz.core.template_mixin.DatasetSelect`): Dataset to bin. + * ``flux_column`` (:class:`~lcviz.components.FluxColumnSelect`) """ - template_file = __file__, "flux_origin.vue" + template_file = __file__, "flux_column.vue" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @property def user_api(self): - expose = ['dataset', 'flux_origin'] + expose = ['dataset', 'flux_column'] return PluginUserApi(self, expose=expose) diff --git a/lcviz/plugins/flux_origin/flux_origin.vue b/lcviz/plugins/flux_column/flux_column.vue similarity index 87% rename from lcviz/plugins/flux_origin/flux_origin.vue rename to lcviz/plugins/flux_column/flux_column.vue index f8dd95a7..810dad29 100644 --- a/lcviz/plugins/flux_origin/flux_origin.vue +++ b/lcviz/plugins/flux_column/flux_column.vue @@ -1,7 +1,7 @@