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

feature-flagged wireframe for cubeviz spec extraction plan #2676

Merged
merged 3 commits into from
Jan 26, 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
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Cubeviz

- Single-pixel subset tool now shows spectrum-at-spaxel on hover. [#2647]

- Spectral extraction plugin re-organized into subsections to be more consistent with specviz2d. [#2676]

Imviz
^^^^^

Expand All @@ -39,6 +41,8 @@ Specviz
Specviz2d
^^^^^^^^^

- Spectral extraction plugin: highlighting of active header section. [#2676]

API Changes
-----------

Expand Down
13 changes: 12 additions & 1 deletion jdaviz/components/plugin_section_header.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<template>
<div class="strike text--secondary">
<div :class="active ? 'strike strike-active text--secondary': 'strike text--secondary'">
<span>
<slot></slot>
</span>
</div>
</template>

<script>
module.exports = {
props: ['active'],
};
</script>


<style scoped>
.strike {
Expand Down Expand Up @@ -34,6 +40,11 @@
background: rgba(0, 0, 0, 0.15);
}

.strike-active > span:before,
.strike-active > span:after {
background: #c75d2c; /* active orange */
}

.strike > span:before {
right: 100%;
margin-right: 15px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from astropy.nddata import (
NDDataArray, StdDevUncertainty, NDUncertainty
)
from traitlets import Bool, Float, List, Unicode, observe
from traitlets import Any, Bool, Float, List, Unicode, observe

from jdaviz.core.custom_traitlets import FloatHandleEmpty
from jdaviz.core.events import SnackbarMessage, SliceWavelengthUpdatedMessage
Expand All @@ -18,6 +18,7 @@
DatasetSelectMixin,
SelectPluginComponent,
ApertureSubsetSelectMixin,
ApertureSubsetSelect,
AddResultsMixin,
with_spinner)
from jdaviz.core.user_api import PluginUserApi
Expand Down Expand Up @@ -52,11 +53,23 @@
uses_active_status = Bool(True).tag(sync=True)

# feature flag for cone support
dev_cone_support = Bool(False).tag(sync=True)
dev_cone_support = Bool(False).tag(sync=True) # when enabling: add entries to docstring
dev_bg_support = Bool(False).tag(sync=True) # when enabling: add entries to docstring
dev_subpixel_support = Bool(False).tag(sync=True) # when enabling: add entries to docstring

active_step = Unicode().tag(sync=True)

wavelength_dependent = Bool(False).tag(sync=True)
reference_wavelength = FloatHandleEmpty().tag(sync=True)
slice_wavelength = Float().tag(sync=True)

bg_items = List([]).tag(sync=True)
bg_selected = Any('').tag(sync=True)
bg_scale_factor = Float(1).tag(sync=True)
bg_wavelength_dependent = Bool(False).tag(sync=True)

subpixel = Bool(False).tag(sync=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder: let's change references to subpixel to something which is not the name of one of the three aperture masking methods ({exact, subpixel, center}). It's clunky but accurate to call these "aperture masking methods."

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave this up to #2679 to modify (with no objections if we do in fact go with three methods instead of just two).


function_items = List().tag(sync=True)
function_selected = Unicode('Sum').tag(sync=True)
filename = Unicode().tag(sync=True)
Expand Down Expand Up @@ -84,6 +97,14 @@
self.aperture.items = [{"label": "Entire Cube"}]
self.aperture.select_default()

self.background = ApertureSubsetSelect(self,
'bg_items',
'bg_selected',
'bg_scale_factor',
dataset='dataset',
multiselect=None,
default_text='None')

self.function = SelectPluginComponent(
self,
items='function_items',
Expand Down Expand Up @@ -111,27 +132,37 @@

@property
def user_api(self):
return PluginUserApi(
self,
expose=(
'function', 'spatial_subset', 'aperture',
'add_results', 'collapse_to_spectrum'
)
)
expose = ['function', 'spatial_subset', 'aperture',
'add_results', 'collapse_to_spectrum']
if self.dev_cone_support:
expose += ['wavelength_dependent', 'reference_wavelength']
if self.dev_bg_support:
expose += ['background', 'bg_wavelength_dependent']

Check warning on line 140 in jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py#L140

Added line #L140 was not covered by tests
if self.dev_subpixel_support:
expose += ['subpixel']

Check warning on line 142 in jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py#L142

Added line #L142 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

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

(Replace me please 🙏)


return PluginUserApi(self, expose=expose)

@property
@deprecated(since="3.9", alternative="aperture")
def spatial_subset(self):
return self.user_api.aperture

@observe('active_step')
def _active_step_changed(self, *args):
self.aperture._set_mark_visiblities(self.active_step in ('', 'ap', 'ext'))
self.background._set_mark_visiblities(self.active_step == 'bg')

Check warning on line 154 in jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py#L153-L154

Added lines #L153 - L154 were not covered by tests

@property
def slice_plugin(self):
return self.app._jdaviz_helper.plugins['Slice']

@observe('wavelength_dependent')
@observe('wavelength_dependent', 'bg_wavelength_dependent')
def _wavelength_dependent_changed(self, *args):
if self.wavelength_dependent:
self.reference_wavelength = self.slice_plugin.wavelength
else:
self.bg_wavelength_dependent = False

Check warning on line 165 in jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py#L165

Added line #L165 was not covered by tests
# NOTE: this can be redundant in the case where reference_wavelength changed and triggers
# the observe, but we need to ensure it is updated if reference_wavelength is unchanged
self._update_mark_scale()
Expand All @@ -149,8 +180,12 @@
def _update_mark_scale(self, *args):
if not self.wavelength_dependent:
self.aperture.scale_factor = 1.0
return
self.aperture.scale_factor = self.slice_wavelength/self.reference_wavelength
else:
self.aperture.scale_factor = self.slice_wavelength/self.reference_wavelength
if not self.bg_wavelength_dependent:
self.background.scale_factor = 1.0
else:
self.background.scale_factor = self.slice_wavelength/self.reference_wavelength

Check warning on line 188 in jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py#L188

Added line #L188 was not covered by tests

@with_spinner()
def collapse_to_spectrum(self, add_data=True, **kwargs):
Expand Down
Loading