Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 39 additions & 34 deletions notebooks/cross_instrument/rgb_imviz/imviz_rgb_carina.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"id": "035a23fd",
"metadata": {},
"source": [
"# RGB images with Imviz\n",
"# RGB images with Jdaviz\n",
"\n",
"**Use case**: create RGB images using Imviz programmatically.<br>\n",
"**Use case**: create RGB images using Jdaviz programmatically.<br>\n",
"**Data**: Carina Nebula, NIRCam observations<br>\n",
"**Tools**: jdaviz<br>\n",
"**Cross-intrument**: Any imager<br>\n",
"**Cross-instrument**: Any imager<br>\n",
"**Documentation**: This notebook is part of a STScI's larger [post-pipeline Data Analysis Tools Ecosystem](https://jwst-docs.stsci.edu/jwst-post-pipeline-data-analysis).<br>\n",
"\n",
"For additional resources, please review our provided full example notebooks maintained in the Jdaviz repository: https://github.com/spacetelescope/jdaviz/tree/main/notebooks"
Expand All @@ -33,9 +33,11 @@
"source": [
"import warnings\n",
"\n",
"from time import sleep\n",
"\n",
"from astroquery.mast import Observations\n",
"\n",
"from jdaviz import Imviz\n",
"import jdaviz as jd\n",
"\n",
"from IPython.display import Image"
]
Expand All @@ -45,19 +47,7 @@
"id": "aaf960cd",
"metadata": {},
"source": [
"## Download images and load Imviz\n",
"\n",
"We create an Imviz instance and grab the default viewer instance as well:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "409eedc4",
"metadata": {},
"outputs": [],
"source": [
"imviz = Imviz()"
"## Download images and load data into the Jdaviz App\n"
]
},
{
Expand All @@ -73,7 +63,6 @@
"execution_count": null,
"id": "7bddbc18",
"metadata": {
"scrolled": true,
"tags": [
"scroll-output"
]
Expand All @@ -96,7 +85,7 @@
"id": "e6108b52",
"metadata": {},
"source": [
"And load into Imviz."
"And load into Jdaviz."
]
},
{
Expand All @@ -108,17 +97,17 @@
"source": [
"with warnings.catch_warnings():\n",
" warnings.simplefilter('ignore')\n",
" with imviz.batch_load():\n",
" with jd.batch_load():\n",
" for fn in files:\n",
" imviz.load(f'{data_dir}/{fn}', data_label=fn[31:36])"
" jd.load(f'{data_dir}/{fn}', format='Image', data_label=fn[31:36])"
]
},
{
"cell_type": "markdown",
"id": "8a4b2e1a",
"metadata": {},
"source": [
"Now, we can display Imviz."
"Now, we can display Jdaviz."
]
},
{
Expand All @@ -128,7 +117,7 @@
"metadata": {},
"outputs": [],
"source": [
"imviz.show()"
"jd.show()"
]
},
{
Expand All @@ -137,7 +126,7 @@
"metadata": {},
"source": [
"## Align by WCS\n",
"https://jdaviz.readthedocs.io/en/latest/imviz/plugins.html#orientation\n",
"https://jdaviz.readthedocs.io/en/latest/plugins/orientation.html\n",
"\n",
"The first thing you will probably notice is that the image doesn't take up the entire viewer area. If you press the \"b\" key to blink to the next image, you will see that this image is zoomed correctly by default. The odd default zoom on the other is because the images are linked by pixel when loaded. We can instead link by WCS (world coordinates) so that the images will be properly aligned."
]
Expand All @@ -147,23 +136,23 @@
"id": "341145e7-e595-4a58-aab8-0e1e24c19c3d",
"metadata": {},
"source": [
"There are two ways to link in Imviz. Firstly, you can do it from within the UI through the Orientation plugin by selecting \"WCS\". Either open the plugin tray to the right and search for \"Orientation\", or execute the following cell to open it automatically:"
"There are two ways to link in Jdaviz. Firstly, you can do it from within the UI through the Orientation plugin by selecting \"WCS\". Either open the plugin tray to the left and search for \"Orientation\", or execute the following cell to open it automatically:"
]
},
{
"cell_type": "raw",
"id": "19216180-6a20-44cd-a384-981431eb6a3f",
"metadata": {},
"source": [
"imviz.plugins['Orientation'].open_in_tray()"
"jd.plugins['Orientation'].open_in_tray()"
]
},
{
"cell_type": "markdown",
"id": "75367551",
"metadata": {},
"source": [
"You can also set the link type from the API using the Imviz Helper:"
"You can also set the link type from the API using the Jdaviz Helper:"
]
},
{
Expand All @@ -173,8 +162,13 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"# If running cells in rapid succession, this cell may fail.\n",
"# We add a slight pause before aligning the images to avoid this.\n",
"sleep(1)\n",
"\n",
"# Link images by WCS (without affine approximation).\n",
"imviz.plugins['Orientation'].align_by = 'WCS'"
"jd.plugins['Orientation'].align_by = 'WCS'"
]
},
{
Expand Down Expand Up @@ -209,7 +203,7 @@
"metadata": {},
"outputs": [],
"source": [
"plot_options = imviz.plugins['Plot Options']"
"plot_options = jd.plugins['Plot Options']"
]
},
{
Expand Down Expand Up @@ -274,11 +268,13 @@
"cell_type": "code",
"execution_count": null,
"id": "e0b15d1a-7e12-4338-bf9f-c9ba0095e0a3",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"exporting = imviz.plugins['Export']\n",
"exporting.viewer = 'imviz-0'\n",
"exporting = jd.plugins['Export']\n",
"exporting.viewer = 'Image'\n",
"exporting.filename = 'carina_preset.png'\n",
"exporting.export()"
]
Expand Down Expand Up @@ -318,8 +314,17 @@
"id": "c08db0ba",
"metadata": {},
"source": [
"Notebook created by Kyle Conroy and adapted by Duy Nguyen and Camilla Pacifici."
"Notebook created by Kyle Conroy and adapted by Duy Nguyen and Camilla Pacifici.\n",
"last updated: 2026-05-05"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ee3921eb-596f-4382-87ce-ef7cefa4aa41",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -338,7 +343,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.12"
"version": "3.11.15"
}
},
"nbformat": 4,
Expand Down
Loading