Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.
Merged
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
18 changes: 14 additions & 4 deletions 03_Image_Display_and_Manipulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"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",
"Recall that we imported ``matplotlib.pyplot`` as ``plt`` already, and that we imported the ``astropy.wcs.WCS`` function as simply ``WCS``.\n",
"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``)."
"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",
"Recall that we imported `matplotlib.pyplot` as `plt` already, and that we imported the `astropy.wcs.WCS` function as simply `WCS`.\n",
"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`)."
]
},
{
Expand All @@ -282,17 +282,27 @@
"outputs": [],
"source": [
"fig = plt.figure()\n",
"\n",
"# Set the figure's projection to be the WCS of the calexp\n",
"plt.subplot(projection=WCS(calexp.getWcs().getFitsMetadata()))\n",
"\n",
"# Define the extent in pixel coordinates using the bounding box\n",
"calexp_extent = (calexp.getBBox().beginX, calexp.getBBox().endX, \n",
" calexp.getBBox().beginY, calexp.getBBox().endY)\n",
"\n",
"# Display the calexp image data array using the gray colormap (cmap)\n",
"# and use approximately the same min and max scale values as above\n",
"im = plt.imshow(calexp.image.array, cmap='gray', vmin=-200.0, vmax=400, origin='lower')\n",
"im = plt.imshow(calexp.image.array, cmap='gray', vmin=-200.0, vmax=400, \n",
" extent=calexp_extent, origin='lower')\n",
"\n",
"# Add solid white grid lines\n",
"plt.grid(color='white', ls='solid')\n",
"\n",
"# Label axes\n",
"plt.xlabel('Right Ascension')\n",
"plt.ylabel('Declination')\n",
"plt.show()\n",
"\n",
"# Clean up memory\n",
"remove_figure(fig)"
]
Expand Down