Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 4c2f655

Browse files
authored
Merge pull request #63 from rubin-dp0/tickets/PREOPS-1174
add extent S.4.1
2 parents 32c4377 + 1845901 commit 4c2f655

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

03_Image_Display_and_Manipulation.ipynb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@
270270
"cell_type": "markdown",
271271
"metadata": {},
272272
"source": [
273-
"To see the image axes in sky coordinates instead of pixel coordinates, a simple option is to use astropy's World Coordinate System (WCS) package, along with matplotlib.pyplot's ``subplot``, ``imshow``, and ``grid`` functions. \n",
274-
"Recall that we imported ``matplotlib.pyplot`` as ``plt`` already, and that we imported the ``astropy.wcs.WCS`` function as simply ``WCS``.\n",
275-
"Find more information about [imshow](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html) and [colormaps](https://matplotlib.org/stable/tutorials/colors/colormaps.html) (``cmap``)."
273+
"To see the image axes in sky coordinates instead of pixel coordinates, a simple option is to use astropy's World Coordinate System (WCS) package, along with matplotlib.pyplot's `subplot`, `imshow`, and `grid` functions. \n",
274+
"Recall that we imported `matplotlib.pyplot` as `plt` already, and that we imported the `astropy.wcs.WCS` function as simply `WCS`.\n",
275+
"Find more information about [imshow](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html) and [colormaps](https://matplotlib.org/stable/tutorials/colors/colormaps.html) (`cmap`)."
276276
]
277277
},
278278
{
@@ -282,17 +282,27 @@
282282
"outputs": [],
283283
"source": [
284284
"fig = plt.figure()\n",
285+
"\n",
285286
"# Set the figure's projection to be the WCS of the calexp\n",
286287
"plt.subplot(projection=WCS(calexp.getWcs().getFitsMetadata()))\n",
288+
"\n",
289+
"# Define the extent in pixel coordinates using the bounding box\n",
290+
"calexp_extent = (calexp.getBBox().beginX, calexp.getBBox().endX, \n",
291+
" calexp.getBBox().beginY, calexp.getBBox().endY)\n",
292+
"\n",
287293
"# Display the calexp image data array using the gray colormap (cmap)\n",
288294
"# and use approximately the same min and max scale values as above\n",
289-
"im = plt.imshow(calexp.image.array, cmap='gray', vmin=-200.0, vmax=400, origin='lower')\n",
295+
"im = plt.imshow(calexp.image.array, cmap='gray', vmin=-200.0, vmax=400, \n",
296+
" extent=calexp_extent, origin='lower')\n",
297+
"\n",
290298
"# Add solid white grid lines\n",
291299
"plt.grid(color='white', ls='solid')\n",
300+
"\n",
292301
"# Label axes\n",
293302
"plt.xlabel('Right Ascension')\n",
294303
"plt.ylabel('Declination')\n",
295304
"plt.show()\n",
305+
"\n",
296306
"# Clean up memory\n",
297307
"remove_figure(fig)"
298308
]

0 commit comments

Comments
 (0)