forked from spacetelescope/jdaviz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
that needs glue-viz/glue-astronomy#90
- Loading branch information
Showing
1 changed file
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |