diff --git a/docs/plugins.rst b/docs/plugins.rst index ea766aa..383179b 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -218,6 +218,39 @@ The time selector plugin allows defining the time indicated in all light curve v Jdaviz documentation on the Slice plugin. +.. _photometric-extraction: + +Photometric Extraction +====================== + +Note that this plugin is only available if TPF data is loaded into the app. + +.. admonition:: User API Example + :class: dropdown + + See the :class:`~lcviz.plugins.stitch.stitch.Stitch` user API documentation for more details. + + .. code-block:: python + + from lcviz import LCviz + from lightkurve import search_targetpixelfile + tpf = search_targetpixelfile("KIC 001429092", + mission="Kepler", + cadence="long", + quarter=10).download() + lcviz = LCviz() + lcviz.load_data(tpf) + lcviz.show() + + ext = lcviz.plugins['Photometric Extraction'] + ext.open_in_tray() + + +.. seealso:: + + This plugin uses the following ``lightkurve`` implementations: + + * :meth:`lightkurve.KeplerTargetPixelFile.extract_aperture_photometry` .. _stitch: diff --git a/lcviz/helper.py b/lcviz/helper.py index a9ac0db..f44afed 100644 --- a/lcviz/helper.py +++ b/lcviz/helper.py @@ -103,7 +103,7 @@ class LCviz(ConfigHelper): 'toolbar': ['g-data-tools', 'g-subset-tools', 'g-viewer-creator', 'lcviz-coords-info'], 'tray': ['lcviz-metadata-viewer', 'flux-column', 'lcviz-plot-options', 'lcviz-subset-plugin', - 'lcviz-markers', 'time-selector', + 'lcviz-markers', 'time-selector', 'photometric-extraction', 'stitch', 'flatten', 'frequency-analysis', 'ephemeris', 'binning', 'lcviz-export'], 'viewer_area': [{'container': 'col', diff --git a/lcviz/plugins/__init__.py b/lcviz/plugins/__init__.py index bdde8f1..331b9f2 100644 --- a/lcviz/plugins/__init__.py +++ b/lcviz/plugins/__init__.py @@ -10,6 +10,7 @@ from .markers.markers import * # noqa from .time_selector.time_selector import * # noqa from .metadata_viewer.metadata_viewer import * # noqa +from .photometric_extraction.photometric_extraction import * # noqa from .plot_options.plot_options import * # noqa from .stitch.stitch import * # noqa from .subset_plugin.subset_plugin import * # noqa diff --git a/lcviz/plugins/photometric_extraction/__init__.py b/lcviz/plugins/photometric_extraction/__init__.py new file mode 100644 index 0000000..5c40516 --- /dev/null +++ b/lcviz/plugins/photometric_extraction/__init__.py @@ -0,0 +1 @@ +from .photometric_extraction import * # noqa diff --git a/lcviz/plugins/photometric_extraction/photometric_extraction.py b/lcviz/plugins/photometric_extraction/photometric_extraction.py new file mode 100644 index 0000000..56fea4a --- /dev/null +++ b/lcviz/plugins/photometric_extraction/photometric_extraction.py @@ -0,0 +1,62 @@ +from traitlets import Bool, observe + +from jdaviz.core.registries import tray_registry +from jdaviz.core.template_mixin import (PluginTemplateMixin, + DatasetSelectMixin, AddResultsMixin, + skip_if_no_updates_since_last_active, + with_spinner, with_temp_disable) +from jdaviz.core.user_api import PluginUserApi + + +__all__ = ['PhotometricExtraction'] + + +@tray_registry('photometric-extraction', label="Photometric Extraction") +class PhotometricExtraction(PluginTemplateMixin, DatasetSelectMixin, + AddResultsMixin): + """ + See the :ref:`Photometric Extraction Plugin Documentation ` + for more details. + + Only the following attributes and methods are available through the + :ref:`public plugin API `: + + * :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show` + * :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray` + * :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.close_in_tray` + * ``dataset`` (:class:`~jdaviz.core.template_mixin.DatasetSelect`): + Dataset to bin. + * ``add_results`` (:class:`~jdaviz.core.template_mixin.AddResults`) + * :meth:`extract` + """ + template_file = __file__, "photometric_extraction.vue" + uses_active_status = Bool(True).tag(sync=True) + + show_live_preview = Bool(True).tag(sync=True) + + apply_enabled = Bool(True).tag(sync=True) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + def is_tpf(data): + return len(data.shape) == 3 + self.dataset.add_filter(is_tpf) + + @property + def user_api(self): + expose = ['show_live_preview', 'dataset', + 'add_results', 'extract'] + return PluginUserApi(self, expose=expose) + + @property + def marks(self): + marks = {} + return marks + + @with_spinner() + def extract(self, add_data=True): + raise NotImplementedError + + def vue_apply(self, event={}): + self.extract(add_data=True) diff --git a/lcviz/plugins/photometric_extraction/photometric_extraction.vue b/lcviz/plugins/photometric_extraction/photometric_extraction.vue new file mode 100644 index 0000000..8a7ee50 --- /dev/null +++ b/lcviz/plugins/photometric_extraction/photometric_extraction.vue @@ -0,0 +1,55 @@ +