Skip to content

Commit

Permalink
plugin wireframe for photometric extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed May 29, 2024
1 parent e5aadd8 commit a351dc8
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 1 deletion.
33 changes: 33 additions & 0 deletions docs/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion lcviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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',
Expand Down
1 change: 1 addition & 0 deletions lcviz/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions lcviz/plugins/photometric_extraction/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .photometric_extraction import * # noqa
62 changes: 62 additions & 0 deletions lcviz/plugins/photometric_extraction/photometric_extraction.py
Original file line number Diff line number Diff line change
@@ -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 <photometric-extraction>`
for more details.
Only the following attributes and methods are available through the
:ref:`public plugin API <plugin-apis>`:
* :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)
55 changes: 55 additions & 0 deletions lcviz/plugins/photometric_extraction/photometric_extraction.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template>
<j-tray-plugin
description='Extract light curve from TPF data.'
:link="'https://lcviz.readthedocs.io/en/'+vdocs+'/plugins.html#photometric-extraction'"
:uses_active_status="uses_active_status"
@plugin-ping="plugin_ping($event)"
:keep_active.sync="keep_active"
:popout_button="popout_button">

<v-row>
<v-expansion-panels popout>
<v-expansion-panel>
<v-expansion-panel-header v-slot="{ open }">
<span style="padding: 6px">Settings</span>
</v-expansion-panel-header>
<v-expansion-panel-content>
<v-row>
<v-switch
v-model="show_live_preview"
label="Show live preview"
hint="Whether to show live preview of binning options."
persistent-hint
></v-switch>
</v-row>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</v-row>

<plugin-dataset-select
:items="dataset_items"
:selected.sync="dataset_selected"
:show_if_single_entry="false"
label="Data"
hint="Select the TPF as input."
/>

<plugin-add-results
:label.sync="results_label"
:label_default="results_label_default"
:label_auto.sync="results_label_auto"
:label_invalid_msg="results_label_invalid_msg"
:label_overwrite="results_label_overwrite"
label_hint="Label for the extracted light curve."
:add_to_viewer_items="add_to_viewer_items"
:add_to_viewer_selected.sync="add_to_viewer_selected"
action_label="Extract"
action_tooltip="Extract photometry"
:action_disabled="!apply_enabled"
:action_spinner="spinner"
@click:action="apply"
></plugin-add-results>

</j-tray-plugin>
</template>

0 comments on commit a351dc8

Please sign in to comment.