Skip to content

Commit

Permalink
I have a cunning plan
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
pllim committed May 27, 2022
1 parent 70eb5f1 commit 3f98fa0
Show file tree
Hide file tree
Showing 9 changed files with 462 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Cubeviz
Imviz
^^^^^

- New Simple Image Rotation plugin to rotate the celestial axes of
images if they have valid WCS. [#1340]

Mosviz
^^^^^^

Expand Down
25 changes: 25 additions & 0 deletions docs/imviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,28 @@ 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`.


.. _rotate-image-simple:

Simple Image Rotation
=====================

.. warning::

Distortion is ignored, so using this plugin on distorted data is
not recommended.

.. note::

Zoom box in :ref:`imviz-compass` will not show when rotation mode is on.

This plugins rotates image(s) by its celestial axes by the given angle.
You can toggle the rotation mode on and off. When on, by default, it
will align image(s) to N-up and E-left orientation.
If rotation mode is on but an image does not have a valid WCS, it will
not be rotated.

Given that this plugin affects the linking of the entire data collection
in Imviz, it is not recommended to keep toggling this on and off
continuously. You might also notice some lag when a lot of images are loaded.
1 change: 1 addition & 0 deletions jdaviz/configs/imviz/imviz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tray:
- imviz-compass
- imviz-line-profile-xy
- imviz-aper-phot-simple
- imviz-rotate-image
- g-export-plot
viewer_area:
- container: col
Expand Down
1 change: 1 addition & 0 deletions jdaviz/configs/imviz/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
from .compass import * # noqa
from .aper_phot_simple import * # noqa
from .line_profile_xy import * # noqa
from .rotate_image import * # noqa
1 change: 1 addition & 0 deletions jdaviz/configs/imviz/plugins/rotate_image/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .rotate_image import * # noqa
40 changes: 40 additions & 0 deletions jdaviz/configs/imviz/plugins/rotate_image/rotate_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from traitlets import Bool, observe

from jdaviz.core.custom_traitlets import FloatHandleEmpty
from jdaviz.core.registries import tray_registry
from jdaviz.core.template_mixin import TemplateMixin

__all__ = ['RotateImageSimple']


@tray_registry('imviz-rotate-image', label="Simple Image Rotation")
class RotateImageSimple(TemplateMixin):
template_file = __file__, "rotate_image.vue"

rotate_mode_on = Bool(False).tag(sync=True)
angle = FloatHandleEmpty(0).tag(sync=True)

@observe('angle')
def vue_rotate_image(*args, **kwargs):
pass # TODO

# Create a small dummy image

# Create a fake WCS with desired orientation

# Add it into data collection

# Make it reference. Remember which one as old reference.
# If no API to make something reference, remove everything, readd
# with it first, and relink.

# When angle changes, is updating Data.coords with new WCS good enough?

# Find a way to hide this image from Data dropdown, blink, etc

# When toggle off, discard this from data_collection and restore old reference.

# Have compass hide zoom box when rotate_mode_on is True
# and un-hide it when False.

# Write tests.
28 changes: 28 additions & 0 deletions jdaviz/configs/imviz/plugins/rotate_image/rotate_image.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<j-tray-plugin>
<v-row>
<j-docs-link :link="'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#simple-image-rotation'">Rotate image N-up/E-left.</j-docs-link>
</v-row>

<v-row>
<v-switch
label="Rotate celestial axes"
hint="Toggle N-E axes rotation on or off"
v-model="rotate_mode_on"
persistent-hint>
</v-switch>
</v-row>

<v-row v-if="rotate_mode_on">
<v-col>
<v-text-field
v-model='angle'
type="number"
label="Angle"
hint="Rotation angle of N-axis in degree clockwise (0 is N-up)"
></v-text-field>
</v-col>
</v-row>

</j-tray-plugin>
</template>
28 changes: 28 additions & 0 deletions licenses/MPDAF_LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Copyright (c) 2010-2019 CNRS / Centre de Recherche Astrophysique de Lyon

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit 3f98fa0

Please sign in to comment.