-
Notifications
You must be signed in to change notification settings - Fork 76
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
kecnry
merged 3 commits into
spacetelescope:main
from
kecnry:cube-spec-extract-wireframe
Jan 26, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -18,6 +18,7 @@ | |
DatasetSelectMixin, | ||
SelectPluginComponent, | ||
ApertureSubsetSelectMixin, | ||
ApertureSubsetSelect, | ||
AddResultsMixin, | ||
with_spinner) | ||
from jdaviz.core.user_api import PluginUserApi | ||
|
@@ -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) | ||
|
||
function_items = List().tag(sync=True) | ||
function_selected = Unicode('Sum').tag(sync=True) | ||
filename = Unicode().tag(sync=True) | ||
|
@@ -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', | ||
|
@@ -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'] | ||
if self.dev_subpixel_support: | ||
expose += ['subpixel'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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') | ||
|
||
@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 | ||
# 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() | ||
|
@@ -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 | ||
|
||
@with_spinner() | ||
def collapse_to_spectrum(self, add_data=True, **kwargs): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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."There was a problem hiding this comment.
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).