Skip to content

Commit

Permalink
markers plugin (#1953)
Browse files Browse the repository at this point in the history
* basic markers plugin implementation
* log info from coords_info mouseover display
* allow user to select layer used in mouseover/markers
* revert disabling spectrum locking during zoom/subset tool
* fallback on exposing cursor information when no valid layer match
* table subcomponent: always show columns in same order
* limit precision shown in UI version of the table (also applies to table in aperture photometry plugin)

Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>
  • Loading branch information
kecnry and pllim authored Mar 16, 2023
1 parent 358d516 commit e158ca5
Show file tree
Hide file tree
Showing 35 changed files with 868 additions and 73 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ New Features
- Configurations that support multiple, simultaneous data files now allow
multiple data products to be specified in the command line. [#1890]

- Ability to cycle through datasets to expose information during mouseover. [#1953]

- New markers plugin to log mouseover information to a table. [#1953]

Cubeviz
^^^^^^^

Expand Down
7 changes: 7 additions & 0 deletions docs/cubeviz/export_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,10 @@ the ``x`` and ``y`` parameters identify specifically which spaxel fits are to be
for models applied to every spaxel using the :guilabel:`Apply to Cube` button.
Leaving ``x`` or ``y`` as ``None`` will mean that the models fit to every spaxel
across that axis will be returned.

Markers Table
=============

All mouseover information in the :ref:`markers plugin <markers-plugin>` can be exported to an
:ref:`astropy table <astropy:astropy-table>`
by calling :meth:`~jdaviz.core.template_mixin.TableMixin.export_table` (see :ref:`plugin-apis`).
9 changes: 9 additions & 0 deletions docs/cubeviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ Subset Tools
:ref:`Subset Tools <imviz-subset-plugin>`
Imviz documentation describing the concept of subsets in Jdaviz.


Markers
=======

.. seealso::

:ref:`Markers <markers-plugin>`
Imviz documentation describing the markers plugin.

.. _slice:

Slice
Expand Down
4 changes: 4 additions & 0 deletions docs/imviz/displayimages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ cursor's location in pixel space (X and Y), the RA and Dec at that point, and th
of the data there. This information is displayed in the top bar of the UI, on the
middle-right side.

By default, the cursor information will correspond to the top image layer in the viewer.
To change to a specific data-layer, click the layer-icon in the top bar to cycle between
"auto", "cursor", or specific data layers.

Notes on GWCS
-------------

Expand Down
12 changes: 12 additions & 0 deletions docs/imviz/export_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,15 @@ The columns are as follow:

Once you have the results in a table, you can further manipulated them as
documented in :ref:`astropy:astropy-table`.

Markers Table
=============

All mouseover information in the :ref:`markers plugin <markers-plugin>` can be exported to an
:ref:`astropy table <astropy:astropy-table>`
by calling :meth:`~jdaviz.core.template_mixin.TableMixin.export_table` (see :ref:`plugin-apis`):

.. code-block:: python
markers_plugin = imviz.plugins["Markers"]
markers_table = markers_plugin.export_table()
22 changes: 22 additions & 0 deletions docs/imviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ parameters, shape, and orientation (if applicable) all update concurrently.

Angle is counter-clockwise rotation around the center in degrees.

.. _markers-plugin:

Markers
=======

This plugin allows for interactively creating markers in any viewer and logging information about
the location of that marker along with the applicable data and viewer labels into a table.

With the plugin open in the tray, mouse over any viewer and press the "m" key to log the information
displayed in the app toolbar into the table. The markers remain at that fixed pixel-position in
the viewer they were created (regardless of changes to the underlying data or linking) and are only
visible when the plugin is opened.

In Imviz, the table also exposed columns labeled "pixel:unreliable", "world:unreliable", and
"value:unreliable". These will be logged as ``True`` in cases where the information is outside
the bounds of the reference image's WCS (noted in the mouseover display by the information showing
as grayed).

To export the table into the notebook via the API, call
:meth:`~jdaviz.core.template_mixin.TableMixin.export_table`
(see :ref:`plugin-apis`).

.. _imviz-link-control:

Link Control
Expand Down
10 changes: 10 additions & 0 deletions docs/mosviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ Subset Tools
:ref:`Subset Tools <imviz-subset-plugin>`
Imviz documentation describing the concept of subsets in Jdaviz.

.. _imviz_export_markers:

Markers
=======

.. seealso::

:ref:`Markers <markers-plugin>`
Imviz documentation describing the markers plugin.

Gaussian Smooth
===============

Expand Down
3 changes: 3 additions & 0 deletions docs/reference/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ Plugins
.. automodapi:: jdaviz.configs.default.plugins.line_lists.line_lists
:no-inheritance-diagram:

.. automodapi:: jdaviz.configs.default.plugins.markers.markers
:no-inheritance-diagram:

.. automodapi:: jdaviz.configs.default.plugins.metadata_viewer.metadata_viewer
:no-inheritance-diagram:

Expand Down
4 changes: 4 additions & 0 deletions docs/specviz/displaying.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ cursor position as well as the spectral axis value, pixel, and flux of the close
to the cursor.
This information is displayed in the top bar of the UI, on the middle-right side.

By default, the cursor information will correspond to the closest data layer to the cursor.
To change to a specific data-layer, click the layer-icon in the top bar to cycle between
"auto", "cursor", or specific data layers.

Home
====

Expand Down
8 changes: 8 additions & 0 deletions docs/specviz/export_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,11 @@ To extract all of the model parameters:
myparams
where the ``model_label`` parameter identifies which model should be returned.
.. _specviz-export-markers:

Markers Table
=============

All mouseover information in the :ref:`markers plugin <markers-plugin>` can be exported to an
:ref:`astropy table <astropy:astropy-table>`
by calling :meth:`~jdaviz.core.template_mixin.TableMixin.export_table` (see :ref:`plugin-apis`).
8 changes: 8 additions & 0 deletions docs/specviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ Subset Tools
:ref:`Subset Tools <imviz-subset-plugin>`
Imviz documentation describing the concept of subsets in Jdaviz.

Markers
=======

.. seealso::

:ref:`Markers <markers-plugin>`
Imviz documentation describing the markers plugin.

.. _gaussian-smooth:

Gaussian Smooth
Expand Down
8 changes: 8 additions & 0 deletions docs/specviz2d/export_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ An instance of Specviz can also be accessed, which exposes some helper methods f

:ref:`Specviz: Export Data <specviz-export-data>`
Specviz documentation on exporting spectra.


Markers Table
=============

All mouseover information in the :ref:`markers plugin <markers-plugin>` can be exported to an
:ref:`astropy table <astropy:astropy-table>`
by calling :meth:`~jdaviz.core.template_mixin.TableMixin.export_table` (see :ref:`plugin-apis`).
8 changes: 8 additions & 0 deletions docs/specviz2d/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ Subset Tools

:ref:`Subset Tools <imviz-subset-plugin>`
Imviz documentation describing the concept of subsets in Jdaviz.

Markers
=======

.. seealso::

:ref:`Markers <markers-plugin>`
Imviz documentation describing the markers plugin.

.. _specviz2d-spectral-extraction:

Expand Down
11 changes: 8 additions & 3 deletions jdaviz/components/layer_viewer_icon.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<template>
<span v-if="icon !== undefined" :class="prevent_invert_if_dark ? '' : 'invert-if-dark'" :style="span_style+'; color: '+color+'; '+borderStyle">
{{String(icon).toUpperCase()}}
<span v-if="icon !== undefined">
<v-icon v-if="String(icon).startsWith('mdi-')" size="16">
{{icon}}
</v-icon>
<span v-else :class="prevent_invert_if_dark ? 'layer-viewer-icon' : 'invert-if-dark layer-viewer-icon'" :style="span_style+'; color: '+color+'; '+borderStyle">
{{String(icon).toUpperCase()}}
</span>
</span>
</template>

Expand All @@ -19,7 +24,7 @@ module.exports = {
</script>

<style scoped>
span {
.layer-viewer-icon {
width: 20px;
height: 20px;
line-height: 10px;
Expand Down
13 changes: 12 additions & 1 deletion jdaviz/components/plugin_table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<v-row style="margin: 0px 0px 8px 0px !important">
<v-data-table
dense
:headers="headers_visible.map(item => {return {'text': item, 'value': item}})"
:headers="headers_visible_sorted.map(item => {return {'text': item, 'value': item}})"
:items="items"
class="elevation-1 width-100"
></v-data-table>
Expand All @@ -64,6 +64,17 @@
</div>
</template>

<script>
module.exports = {
computed: {
headers_visible_sorted() {
return this.headers_avail.filter(item => this.headers_visible.indexOf(item) !== -1);
},
}
};
</script>


<style scoped>
.v-data-table {
width: 100% !important
Expand Down
1 change: 1 addition & 0 deletions jdaviz/components/tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const tooltips = {
'Use the same display parameters for all images and spectra',
'create-image-viewer':
'Create new image viewer',
'coords-info-cycle': 'Cycle selected layer used for mouseover information and markers plugin',
// viewer toolbars
'viewer-toolbar-data': 'Select dataset(s) to display in this viewer',
Expand Down
1 change: 1 addition & 0 deletions jdaviz/configs/cubeviz/cubeviz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tray:
- g-metadata-viewer
- g-plot-options
- g-subset-plugin
- g-markers
- cubeviz-slice
- g-gaussian-smooth
- g-collapse
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, *args, **kwargs):

self.moment = None

self.dataset.add_filter('is_image')
self.dataset.add_filter('is_cube')
self.add_results.viewer.filters = ['is_image_viewer']

@property
Expand Down
1 change: 1 addition & 0 deletions jdaviz/configs/default/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
from .metadata_viewer.metadata_viewer import * # noqa
from .export_plot.export_plot import * # noqa
from .plot_options.plot_options import * # noqa
from .markers.markers import * # noqa
2 changes: 1 addition & 1 deletion jdaviz/configs/default/plugins/collapse/collapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, *args, **kwargs):
selected='function_selected',
manual_options=['Mean', 'Median', 'Min', 'Max', 'Sum']) # noqa

self.dataset.add_filter('is_image')
self.dataset.add_filter('is_cube')
self.add_results.viewer.filters = ['is_image_viewer']

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def test_linking_after_spectral_smooth(cubeviz_helper, spectrum1d_cube):

label_mouseover._viewer_mouse_event(spec_viewer,
{'event': 'mousemove', 'domain': {'x': 4.6236e-7, 'y': 60}})
assert label_mouseover.as_text() == ('', '', '')
assert label_mouseover.icon == ''
assert label_mouseover.as_text() == ('Cursor 4.62360e-07, 6.00000e+01', '', '')
assert label_mouseover.icon == 'mdi-cursor-default'


def test_spatial_convolution(cubeviz_helper, spectrum1d_cube):
Expand Down Expand Up @@ -153,11 +153,11 @@ def test_spectrum1d_smooth(specviz_helper, spectrum1d):
'Flux 5.34688e+00 Jy')
assert label_mouseover.icon == 'b'

# Out-of-bounds shows nothing.
# Out-of-bounds shows only cursor info.
label_mouseover._viewer_mouse_event(spec_viewer,
{'event': 'mousemove', 'domain': {'x': 5500, 'y': 120}})
assert label_mouseover.as_text() == ('', '', '')
assert label_mouseover.icon == ''
assert label_mouseover.as_text() == ('Cursor 5.50000e+03, 1.20000e+02', '', '')
assert label_mouseover.icon == 'mdi-cursor-default'


def test_spectrum2d_smooth(specviz2d_helper, spectrum2d):
Expand Down
1 change: 1 addition & 0 deletions jdaviz/configs/default/plugins/markers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .markers import * # noqa
Loading

0 comments on commit e158ca5

Please sign in to comment.