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

adding support for temporal subsets #2168

Merged
merged 1 commit into from
May 1, 2023
Merged
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
27 changes: 24 additions & 3 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from astropy.io import fits
from astropy import units as u
from astropy.coordinates import Angle
from astropy.time import Time
from regions import PixCoord, CirclePixelRegion, RectanglePixelRegion, EllipsePixelRegion

from echo import CallbackProperty, DictCallbackProperty, ListCallbackProperty
Expand Down Expand Up @@ -686,8 +687,13 @@ def get_data_from_viewer(self, viewer_reference, data_label=None,
if cls is not None:
handler, _ = data_translator.get_handler_for(cls)
try:
layer_data = handler.to_object(layer_data,
statistic=statistic)
if cls == Spectrum1D:
kecnry marked this conversation as resolved.
Show resolved Hide resolved
# if this is a spectrum, apply the `statistic`:
layer_data = handler.to_object(layer_data,
statistic=statistic)
else:
# otherwise simply translate to an object:
layer_data = handler.to_object(layer_data)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to leave open the possibility of having a light curve collapsed down from 2D temporal slices (which would require statistic)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a 2D temporal slice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing like spectral cube but in time domain?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I meant. Is that actually a thing that we expect to be loaded at some point? No idea!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will eventually want to support target pixel files and modifying the aperture, but if its not obvious how to handle that now, we can just add a note and modify this logic later when needed (I don't think we'll be adding support for that in the terribly near future).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I know that is a thing in heliophysics, so definitely possible.

except IncompatibleAttribute:
continue

Expand Down Expand Up @@ -878,8 +884,9 @@ def get_subsets(self, subset_name=None, spectral_only=False,
all_subsets[label] = None
continue

# Is the subset spectral or spatial?
# Is the subset spectral, spatial, temporal?
is_spectral = self._is_subset_spectral(subset_region)
is_temporal = self._is_subset_temporal(subset_region)

# Remove duplicate spectral regions
if is_spectral and isinstance(subset_region, SpectralRegion):
Expand All @@ -903,6 +910,12 @@ def get_subsets(self, subset_name=None, spectral_only=False,
else:
all_subsets[label] = subset_region

if not (spectral_only or spatial_only) and is_temporal:
if object_only:
all_subsets[label] = [reg['region'] for reg in subset_region]
else:
all_subsets[label] = subset_region

all_subset_names = [subset.label for subset in dc.subset_groups]
if subset_name and subset_name in all_subset_names:
return all_subsets[subset_name]
Expand Down Expand Up @@ -935,6 +948,14 @@ def _is_subset_spectral(self, subset_region):
return True
return False

def _is_subset_temporal(self, subset_region):
if isinstance(subset_region, Time):
return True
elif isinstance(subset_region, list) and len(subset_region) > 0:
if isinstance(subset_region[0]['region'], Time):
return True
return False

def _remove_duplicate_bounds(self, spec_regions):
regions_no_dups = None

Expand Down
Loading