Skip to content

Commit

Permalink
POC: Annulus support in Imviz
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Apr 25, 2023
1 parent ae82864 commit 9ea914e
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions notebooks/concepts/imviz_annulus_region.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "d9570264",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from glue_astronomy.translators.regions import _annulus_to_subset_state\n",
"from regions import CircleAnnulusPixelRegion, PixCoord\n",
"\n",
"from jdaviz import Imviz"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "070974fc",
"metadata": {},
"outputs": [],
"source": [
"a = np.arange(100).reshape((10, 10))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "048d90d3",
"metadata": {},
"outputs": [],
"source": [
"imviz = Imviz()\n",
"imviz.load_data(a)\n",
"imviz.show()"
]
},
{
"cell_type": "markdown",
"id": "5bf8cb48",
"metadata": {},
"source": [
"Add annulus region to Imviz. Maybe turn this into a plugin?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c38c2d2",
"metadata": {},
"outputs": [],
"source": [
"data = imviz.app.data_collection[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b02e7ee0",
"metadata": {},
"outputs": [],
"source": [
"reg = CircleAnnulusPixelRegion(center=PixCoord(x=4.5, y=4.5), inner_radius=2, outer_radius=3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "58717669",
"metadata": {},
"outputs": [],
"source": [
"sbst = _annulus_to_subset_state(reg, data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "77e2a17b",
"metadata": {},
"outputs": [],
"source": [
"imviz.app.data_collection.new_subset_group(subset_state=sbst)"
]
},
{
"cell_type": "markdown",
"id": "139850a2",
"metadata": {},
"source": [
"Get annulus region back."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ad53d98b",
"metadata": {},
"outputs": [],
"source": [
"data.get_selection_definition(subset_id='Subset 1', format='astropy-regions')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e1c374a4",
"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.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 9ea914e

Please sign in to comment.