Skip to content

Commit

Permalink
(disabled) ability to "freeze" subsets by converting to masks
Browse files Browse the repository at this point in the history
fix event handling for choosing config from launcher

filepath fallback when object from config-detection fails to load

fix: support for notebook 7 (spacetelescope#2420)

Notebook 7 requires a different way to detect if the app runs in
a notebook context.

Fix explanation in markdown cell.

DOC: Footprints plugin API docs (spacetelescope#2426)

* build footprints API docs

* add code snippet in plugin docs

* fix syntax in API docs

---------

Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>

prevent overwriting user-API methods (spacetelescope#2425)

fix default color for overlay when traitlet set by user

* for the FIRST overlay, the user could have set the color traitlet before the internal overlay object is created (which occurs as soon as the plugin is first shown).  In that case, we want to respect the user choice of color.

similar fixes for any other traitlet when plugin inactive

regression test

change log entry

fix API import of single region and overwriting existing entry

* along with regression testing

TST: Also pull in scikit-image dev
to get rid of incompatibility with numpy

Use new "true circle" tool from glue-jupyter (spacetelescope#2332)

* Use truecircle tool
from glue-viz/glue-jupyter#376

* MNT: Bump glue-jupyter minversion
that can use this new tool

* Add change log

* Fix line too long

* Fix change log verbiage

Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>

---------

Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>

Enable multiselect in subset plugin for recentering (spacetelescope#2430)

* Enable multiselect in subset plugin for recentering

* Fix bug with default text

* Remove unused import

* Fix bug in aperature photometry

* Address review comments

* Remove commented out code

* Add initial tests

* Fix bug when exiting multiselect and switching subsets

* Add documentation and update CHANGES file

* Remove print statement

* Add comment about recentering taking multiple iterations to docs

* fix chip styling in subset dropdown

* only set selected_has_subregions if exists

* only show multiselect toggle in imviz

* Apply suggestions from code review

Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>

---------

Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>
Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>

Debug standalone build (spacetelescope#2441)

* Log jdaviz output for debugging

* Run workflow on debugging branch

* See if collecting data from jupyter-client will fix this, otherwise might need to downgrade

* Remove debugging stuff

MNT: Bump actions/checkout to v4

Enable workflow_dispatch for standalone

because it cannot be enabled outside of main apparently

[ci skip] [rtd skip]

EXP: Update workflow versions

Fix Mosviz slit overlay (spacetelescope#2434)

* Fix Mosviz slit overlay
by using polygon instead of forcing a rectangle without angle info.

Co-authored-by: Camilla Pacifici <camilla.pacifici@gmail.com>

* Off by one error in predicted PR num

---------

Co-authored-by: Camilla Pacifici <camilla.pacifici@gmail.com>

API access (hidden) to disable cubeviz movie UI (spacetelescope#2440)

* (hidden) API access to disable cubeviz movie UI
* default movie_enabled based on new app-setting server_is_remote
* test coverage

TST: Ignore ASDF warning about gwcs-1.0.0 schema
because gwcs dev and/or asdf-wcs-schemas 0.2.0 triggers the warning because the schema is no longer supported.
  • Loading branch information
kecnry authored and javerbukh committed Sep 18, 2023
1 parent 09141f8 commit fdb3ae9
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
52 changes: 51 additions & 1 deletion jdaviz/configs/default/plugins/subset_plugin/subset_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from glue.core.message import EditSubsetMessage, SubsetUpdateMessage
from glue.core.edit_subset_mode import (AndMode, AndNotMode, OrMode,
ReplaceMode, XorMode)
from glue.core.exceptions import IncompatibleAttribute
from glue.core.roi import CircularROI, CircularAnnulusROI, EllipticalROI, RectangularROI
from glue.core.subset import RoiSubsetState, RangeSubsetState, CompositeSubsetState
from glue.core.subset import SubsetState, RoiSubsetState, RangeSubsetState, CompositeSubsetState
from glue.icons import icon_path
from glue_jupyter.widgets.subset_mode_vuetify import SelectionModeMenu
from glue_jupyter.common.toolbar_vuetify import read_icon
Expand All @@ -32,6 +33,44 @@
}


class MultiMaskSubsetState(SubsetState):
"""
A subset state that can include a different mask for different datasets.
Adopted from https://github.com/glue-viz/glue/pull/2415
Parameters
----------
masks : dict
A dictionary mapping data UUIDs to boolean arrays with the same
dimensions as the data arrays.
"""

def __init__(self, masks=None):
super(MultiMaskSubsetState, self).__init__()
self._masks = masks

def to_mask(self, data, view=None):
if data.uuid in self._masks:
mask = self._masks[data.uuid]
if view is not None:
mask = mask[view]
return mask
else:
raise IncompatibleAttribute()

def copy(self):
return MultiMaskSubsetState(masks=self._masks)

def __gluestate__(self, context):
serialized = {key: context.do(value) for key, value in self._masks.items()}
return {'masks': serialized}

@classmethod
def __setgluestate__(cls, rec, context):
masks = {key: context.object(value) for key, value in rec['masks'].items()}
return cls(masks=masks)


@tray_registry('g-subset-plugin', label="Subset Tools")
class SubsetPlugin(PluginTemplateMixin, DatasetSelectMixin):
template_file = __file__, "subset_plugin.vue"
Expand All @@ -51,6 +90,7 @@ class SubsetPlugin(PluginTemplateMixin, DatasetSelectMixin):
multiselect = Bool(False).tag(sync=True)
is_centerable = Bool(False).tag(sync=True)
can_simplify = Bool(False).tag(sync=True)
can_freeze = Bool(False).tag(sync=True)

icon_replace = Unicode(read_icon(os.path.join(icon_path("glue_replace", icon_format="svg")), 'svg+xml')).tag(sync=True) # noqa
icon_or = Unicode(read_icon(os.path.join(icon_path("glue_or", icon_format="svg")), 'svg+xml')).tag(sync=True) # noqa
Expand Down Expand Up @@ -258,6 +298,16 @@ def _get_subset_definition(self, *args):

self._unpack_get_subsets_for_ui()

def vue_freeze_subset(self, *args):
sgs = {sg.label: sg for sg in self.app.data_collection.subset_groups}
sg = sgs.get(self.subset_selected)

masks = {}
for data in self.app.data_collection:
masks[data.uuid] = sg.subset_state.to_mask(data)

sg.subset_state = MultiMaskSubsetState(masks)

def vue_simplify_subset(self, *args):
if self.multiselect:
self.hub.broadcast(SnackbarMessage("Cannot simplify spectral subset "
Expand Down
13 changes: 8 additions & 5 deletions jdaviz/configs/default/plugins/subset_plugin/subset_plugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,13 @@
</div>

<v-row v-if="!multiselect" justify="end">
<j-tooltip v-if="can_simplify" tooltipcontent="Convert composite subset to use only add mode to connect subregions">
<v-btn color="primary" text @click="simplify_subset">Simplify</v-btn>
</j-tooltip>
<v-btn color="primary" text @click="update_subset">Update</v-btn>
</v-row>
<j-tooltip v-if="can_freeze" tooltipcontent="Freeze subset to a mask on the underlying data entries">
<v-btn color="primary" text @click="freeze_subset">Freeze</v-btn>
</j-tooltip>
<j-tooltip v-if="can_simplify" tooltipcontent="Convert composite subset to use only add mode to connect subregions">
<v-btn color="primary" text @click="simplify_subset">Simplify</v-btn>
</j-tooltip>
<v-btn color="primary" text @click="update_subset">Update</v-btn>
</v-row>
</j-tray-plugin>
</template>

0 comments on commit fdb3ae9

Please sign in to comment.