Skip to content

Commit

Permalink
updates for latest jdaviz, latest example roman data
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Feb 6, 2024
1 parent 31576fc commit fd6ac80
Showing 1 changed file with 58 additions and 30 deletions.
88 changes: 58 additions & 30 deletions notebooks/concepts/imviz_roman_asdf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@
"metadata": {},
"outputs": [],
"source": [
"from astropy.utils.data import get_pkg_data_filename\n",
"from astropy.utils.data import download_file\n",
"\n",
"image_model = get_pkg_data_filename('data/roman_wfi_image_model.asdf', package='jdaviz.configs.imviz.tests')"
"# # Each of these files is ~1 GB:\n",
"image_model1 = download_file('https://stsci.box.com/shared/static/be2nfy4jovdhw1cxru99kdwnfnqxxlgo.asdf', cache=True)\n",
"image_model2 = download_file('https://stsci.box.com/shared/static/ktpt4li627kq4mipi3er5yd4qw6hq7ll.asdf', cache=True)"
]
},
{
Expand All @@ -89,7 +91,8 @@
"\n",
"with warnings.catch_warnings():\n",
" warnings.simplefilter('ignore') # ErfaWarning\n",
" imviz.load_data(image_model, ext='data')"
" imviz.load_data(image_model1, ext='data', data_label='exposure 1')\n",
" imviz.load_data(image_model2, ext='data', data_label='exposure 2')"
]
},
{
Expand All @@ -107,7 +110,27 @@
"metadata": {},
"outputs": [],
"source": [
"imviz.show()"
"imviz.show('sidecar:split-right', height=1000)"
]
},
{
"cell_type": "markdown",
"id": "52adc3d4-7f44-43aa-af46-6acb390d56e2",
"metadata": {},
"source": [
"We have loaded two sequential exposures with the same pointing. Let's orient both images by their WCS:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8427d4f9-8ea3-4d60-a8b7-3f3f63e3f3e0",
"metadata": {},
"outputs": [],
"source": [
"orientation = imviz.plugins['Orientation']\n",
"\n",
"orientation.link_type = 'WCS'"
]
},
{
Expand All @@ -129,16 +152,20 @@
"metadata": {},
"outputs": [],
"source": [
"plot_options = imviz.plugins['Plot Options']\n",
"\n",
"for viewer_name in imviz.app.get_viewer_reference_names():\n",
" viewer = imviz.app.get_viewer(viewer_name)\n",
"\n",
" # set colormap and stretch:\n",
" viewer.stretch = 'log'\n",
" viewer.set_colormap('Viridis')\n",
" viewer.cuts = [1, 1e4]\n",
" plot_options.viewer = viewer_name\n",
" \n",
" # set zoom level\n",
" viewer.zoom(1.25)"
" for data in viewer.data():\n",
" plot_options.layer = data.label\n",
" \n",
" # set colormap and stretch for this layer:\n",
" plot_options.stretch_function = 'arcsinh'\n",
" plot_options.image_colormap = 'Viridis'\n",
" plot_options.stretch_vmin = 0\n",
" plot_options.stretch_vmax = 20"
]
},
{
Expand Down Expand Up @@ -192,7 +219,8 @@
"metadata": {},
"outputs": [],
"source": [
"mask = regions['Subset 1'].to_mask(mode='subpixels')"
"wcs = imviz.app.data_collection[-1].coords\n",
"mask = regions['Subset 1'].to_pixel(wcs).to_mask(mode='subpixels')"
]
},
{
Expand Down Expand Up @@ -223,6 +251,16 @@
"You can use Astrowidgets API."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f2ce00c9-093c-4bc0-8cb7-b7c8fe38ec64",
"metadata": {},
"outputs": [],
"source": [
"viewer = imviz.default_viewer"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -260,8 +298,7 @@
"metadata": {},
"outputs": [],
"source": [
"center = regions['Subset 1'].center\n",
"data.wcs.pixel_to_world([center.x], [center.y]).to_string('hmsdms')"
"center = regions['Subset 1'].center"
]
},
{
Expand All @@ -272,7 +309,7 @@
"outputs": [],
"source": [
"# Center the image on given sky coordinates.\n",
"sky = SkyCoord(ra=\"13h11m34.25069521s\", dec=\"-01d21m55.92127995s\")\n",
"sky = SkyCoord(ra=79.91038, dec=29.95529, unit=('deg', 'deg'))\n",
"viewer.center_on(sky)"
]
},
Expand Down Expand Up @@ -321,7 +358,7 @@
"outputs": [],
"source": [
"# Set the zoom level directly.\n",
"viewer.zoom_level = 1"
"viewer.zoom_level = 100"
]
},
{
Expand All @@ -332,7 +369,7 @@
"outputs": [],
"source": [
"# Set the relative zoom based on current zoom level.\n",
"viewer.zoom(2)"
"viewer.zoom(1.5)"
]
},
{
Expand All @@ -355,6 +392,7 @@
"image_shape = data.data.shape\n",
"t_xy = Table({'x': np.random.randint(0, image_shape[1], 20),\n",
" 'y': np.random.randint(0, image_shape[0], 20)})\n",
"\n",
"viewer.add_markers(t_xy)"
]
},
Expand All @@ -366,16 +404,6 @@
"You could customize marker color, alpha, size, and fill with values that Glue supports."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7c8edb6f-c928-4aee-8e64-73a34ab020d0",
"metadata": {},
"outputs": [],
"source": [
"viewer.marker = {'color': 'green', 'alpha': 0.8, 'markersize': 10, 'fill': False}"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -488,7 +516,7 @@
"outputs": [],
"source": [
"# Show the first image in the second viewer.\n",
"imviz.app.add_data_to_viewer(viewer_2_name, \"roman_wfi_image_model[DATA]\")"
"imviz.app.add_data_to_viewer(viewer_2_name, \"exposure 1[DATA]\")"
]
},
{
Expand Down Expand Up @@ -518,7 +546,7 @@
"metadata": {},
"outputs": [],
"source": [
"viewer_2.center_on((5, 1))"
"viewer_2.center_on((1500, 1000))"
]
},
{
Expand Down Expand Up @@ -564,7 +592,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down

0 comments on commit fd6ac80

Please sign in to comment.