Skip to content

Commit

Permalink
WIP: Early POC
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed May 23, 2022
1 parent af4c974 commit a02a380
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/imviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,16 @@ 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 ignore, so using this plugin on distorted data is
not recommended.

This plugins rotates an image North-up and East-left.
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
9 changes: 9 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,9 @@
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"
9 changes: 9 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,9 @@
<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>


</j-tray-plugin>
</template>
193 changes: 193 additions & 0 deletions notebooks/concepts/imviz_link_north_up_east_left.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "206e73ce",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from astropy.io import fits\n",
"from astropy.nddata import NDData\n",
"from astropy.wcs import WCS\n",
"\n",
"from jdaviz import Imviz"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6e816343",
"metadata": {},
"outputs": [],
"source": [
"# Image of interest (HST/ACS FLT)\n",
"a = np.random.random((2048, 4096))\n",
"w = WCS({'WCSAXES': 2,\n",
" 'CRPIX1': 2100.0,\n",
" 'CRPIX2': 1024.0,\n",
" 'PC1_1': -1.14852e-05,\n",
" 'PC1_2': 7.01477e-06,\n",
" 'PC2_1': 7.75765e-06,\n",
" 'PC2_2': 1.20927e-05,\n",
" 'CDELT1': 1.0,\n",
" 'CDELT2': 1.0,\n",
" 'CUNIT1': 'deg',\n",
" 'CUNIT2': 'deg',\n",
" 'CTYPE1': 'RA---TAN',\n",
" 'CTYPE2': 'DEC--TAN',\n",
" 'CRVAL1': 3.581704851882,\n",
" 'CRVAL2': -30.39197867265,\n",
" 'LONPOLE': 180.0,\n",
" 'LATPOLE': -30.39197867265,\n",
" 'MJDREF': 0.0,\n",
" 'RADESYS': 'ICRS'})\n",
"hdu = fits.ImageHDU(a, name='SCI')\n",
"hdu.header.update(w.to_header())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9a69e6b9",
"metadata": {},
"outputs": [],
"source": [
"print(w)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3069a91e",
"metadata": {},
"outputs": [],
"source": [
"# What about JWST GWCS?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b72a0049",
"metadata": {},
"outputs": [],
"source": [
"# Just a dummy array to hold the WCS.\n",
"a_dummy = fits.ImageHDU(np.ones((3, 3), dtype=np.int16))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a526d9a9",
"metadata": {},
"outputs": [],
"source": [
"# WCS with N-up/E-left\n",
"w_ref = WCS({'CTYPE1': 'RA---TAN',\n",
" 'CUNIT1': 'deg',\n",
" 'CDELT1': -0.0002777777778,\n",
" 'CRPIX1': 1,\n",
" 'NAXIS1': 3,\n",
" 'CTYPE2': 'DEC--TAN',\n",
" 'CUNIT2': 'deg',\n",
" 'CDELT2': 0.0002777777778,\n",
" 'CRPIX2': 1,\n",
" 'NAXIS2': 3}) \n",
"w_ref.wcs.crval = w.wcs.crval"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "55b2cc04",
"metadata": {},
"outputs": [],
"source": [
"w_ref"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "84d06406",
"metadata": {},
"outputs": [],
"source": [
"ndd = NDData(a_dummy.data, wcs=w_ref)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "93fcdb1b",
"metadata": {},
"outputs": [],
"source": [
"imviz = Imviz(verbosity='warning')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e3585cda",
"metadata": {},
"outputs": [],
"source": [
"imviz.load_data(ndd, data_label='wcs_ref')\n",
"imviz.load_data(hdu, data_label='jb5g05ubq_flt')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bc2cf21c",
"metadata": {},
"outputs": [],
"source": [
"imviz.link_data(link_type='wcs')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "022cc29f",
"metadata": {},
"outputs": [],
"source": [
"imviz.app"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "31fefe0a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit a02a380

Please sign in to comment.