Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude TPF from plugins that expect lcs as input #118

Merged
merged 2 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, #117]
* Support loading, viewing, and slicing through TPF data cubes. [#82, #117, #118]

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

Expand Down
3 changes: 2 additions & 1 deletion lcviz/plugins/binning/binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from lcviz.parsers import _data_with_reftime
from lcviz.viewers import TimeScatterView, PhaseScatterView
from lcviz.components import EphemerisSelectMixin
from lcviz.utils import is_not_tpf


__all__ = ['Binning']
Expand Down Expand Up @@ -61,7 +62,7 @@ def __init__(self, *args, **kwargs):
# https://github.com/spacetelescope/jdaviz/pull/2239
def not_from_binning_plugin(data):
return data.meta.get('Plugin', None) != self.__class__.__name__
self.dataset.add_filter(not_from_binning_plugin)
self.dataset.add_filter(not_from_binning_plugin, is_not_tpf)

# TODO: viewer added also needs to repopulate marks
self.hub.subscribe(self, ViewerAddedMessage, handler=self._on_add_viewer)
Expand Down
3 changes: 3 additions & 0 deletions lcviz/plugins/ephemeris/ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from lcviz.events import EphemerisComponentChangedMessage, EphemerisChangedMessage
from lcviz.viewers import PhaseScatterView
from lcviz.utils import is_not_tpf

__all__ = ['Ephemeris']

Expand Down Expand Up @@ -94,6 +95,8 @@ def __init__(self, *args, **kwargs):
self._ephemerides = {}
self._prev_wrap_at = _default_wrap_at

self.dataset.add_filter(is_not_tpf)

self.component = EditableSelectPluginComponent(self,
name='ephemeris',
mode='component_mode',
Expand Down
5 changes: 3 additions & 2 deletions lcviz/plugins/flatten/flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from lcviz.components import FluxColumnSelectMixin
from lcviz.marks import LivePreviewTrend, LivePreviewFlattened
from lcviz.utils import data_not_folded
from lcviz.utils import data_not_folded, is_not_tpf
from lcviz.viewers import TimeScatterView, PhaseScatterView
from lcviz.parsers import _data_with_reftime

Expand Down Expand Up @@ -77,7 +77,8 @@ def __init__(self, *args, **kwargs):
'flux_label_invalid_msg')

# do not support flattening data in phase-space
self.dataset.add_filter(data_not_folded)
# do not allow TPF as input
self.dataset.add_filter(data_not_folded, is_not_tpf)

# marks do not exist for the new viewer, so force another update to compute and draw
# those marks
Expand Down
4 changes: 4 additions & 0 deletions lcviz/plugins/flux_column/flux_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from jdaviz.core.user_api import PluginUserApi

from lcviz.components import FluxColumnSelectMixin
from lcviz.utils import is_not_tpf

__all__ = ['FluxColumn']

Expand All @@ -28,6 +29,9 @@ class FluxColumn(PluginTemplateMixin, FluxColumnSelectMixin, DatasetSelectMixin)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# NOTE: may eventually want to add support for choosing the column for TPFs
self.dataset.add_filter(is_not_tpf)

@property
def user_api(self):
expose = ['dataset', 'flux_column']
Expand Down
4 changes: 2 additions & 2 deletions lcviz/plugins/frequency_analysis/frequency_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DatasetSelectMixin, SelectPluginComponent, PlotMixin)
from jdaviz.core.user_api import PluginUserApi

from lcviz.utils import data_not_folded
from lcviz.utils import data_not_folded, is_not_tpf


__all__ = ['FrequencyAnalysis']
Expand Down Expand Up @@ -61,7 +61,7 @@ def __init__(self, *args, **kwargs):
self._ignore_auto_update = False

# do not support data only in phase-space
self.dataset.add_filter(data_not_folded)
self.dataset.add_filter(data_not_folded, is_not_tpf)

self.method = SelectPluginComponent(self,
items='method_items',
Expand Down
5 changes: 3 additions & 2 deletions lcviz/plugins/stitch/stitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
with_spinner)
from jdaviz.core.user_api import PluginUserApi

from lcviz.utils import data_not_folded
from lcviz.utils import data_not_folded, is_not_tpf

__all__ = ['Stitch']

Expand Down Expand Up @@ -41,7 +41,8 @@ def __init__(self, *args, **kwargs):

self.dataset.multiselect = True
# do not support stitching data in phase-space
self.dataset.add_filter(data_not_folded)
# do not allow TPF as input
self.dataset.add_filter(data_not_folded, is_not_tpf)

self.results_label_default = 'stitched'

Expand Down
12 changes: 11 additions & 1 deletion lcviz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
from astropy.wcs.wcsapi.wrappers.base import BaseWCSWrapper
from astropy.wcs.wcsapi import HighLevelWCSMixin

__all__ = ['TimeCoordinates', 'LightCurveHandler', 'data_not_folded', 'enable_hot_reloading']
__all__ = ['TimeCoordinates', 'LightCurveHandler',
'data_not_folded', 'is_tpf', 'is_not_tpf',
'enable_hot_reloading']


component_ids = {'dt': ComponentID('dt')}
Expand Down Expand Up @@ -501,3 +503,11 @@ class TessTPFHandler(TPFHandler):
# plugin component filters
def data_not_folded(data):
return data.meta.get('_LCVIZ_EPHEMERIS', None) is None


def is_tpf(data):
return len(data.shape) == 3


def is_not_tpf(data):
return not is_tpf(data)
Loading