Skip to content
Open
Show file tree
Hide file tree
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
36 changes: 25 additions & 11 deletions 09c-Ccdproc/01-ccdproc-overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"# Initial imports -- note the import of CCDData from astropy \n",
"from astropy.nddata import CCDData\n",
"from astropy import units as u\n",
"from astropy import visualization\n",
"import ccdproc as ccdp\n",
"\n",
"from matplotlib import pyplot as plt\n",
Expand All @@ -72,10 +73,7 @@
"\n",
"# Use this instead for interactive plots, but note that you may need \n",
"# to install ipympl for it to work\n",
"# %matplotlib widget\n",
"\n",
"# This function displays images reasonably nicely with minimal effort\n",
"from convenience_functions import show_image"
"# %matplotlib widget"
]
},
{
Expand Down Expand Up @@ -154,7 +152,7 @@
"source": [
"#### Displaying images\n",
"\n",
"Images from a telescope are typically very different, in terms of the histogram of values, than other images. The function `show_image`, included along with this notebook, scales and stretches the data to bring out some of the detail that is not visible using matplotlib defaults."
"Images from a telescope are typically very different, in terms of the histogram of values, than other images. The astropy sub-package `astropy.visualization` includes functions that scale and stretch the data to bring out some of the detail that is not visible using matplotlib defaults. We use the simple interface `imshow_norm()`, but see the [astropy.visualization docs](https://docs.astropy.org/en/stable/visualization/index.html) for more on what can be done here."
]
},
{
Expand All @@ -163,7 +161,11 @@
"metadata": {},
"outputs": [],
"source": [
"show_image(raw_stars)"
"plt.figure(figsize=(10,10))\n",
"im, _ = visualization.imshow_norm(raw_stars.data, \n",
" interval=visualization.PercentileInterval(99), \n",
" stretch=visualization.LinearStretch())\n",
"plt.colorbar(im);"
]
},
{
Expand Down Expand Up @@ -255,7 +257,11 @@
"metadata": {},
"outputs": [],
"source": [
"show_image(stars_minus_bias)"
"plt.figure(figsize=(10,10))\n",
"im, _ = visualization.imshow_norm(stars_minus_bias.data, \n",
" interval=visualization.PercentileInterval(99), \n",
" stretch=visualization.LinearStretch())\n",
"plt.colorbar(im);"
]
},
{
Expand Down Expand Up @@ -309,7 +315,11 @@
"metadata": {},
"outputs": [],
"source": [
"show_image(stars_minus_bias_minus_dark)"
"plt.figure(figsize=(10,10))\n",
"im, _ = visualization.imshow_norm(stars_minus_bias_minus_dark.data, \n",
" interval=visualization.PercentileInterval(99), \n",
" stretch=visualization.LinearStretch())\n",
"plt.colorbar(im);"
]
},
{
Expand Down Expand Up @@ -359,7 +369,11 @@
"metadata": {},
"outputs": [],
"source": [
"show_image(stars_calibrated)"
"plt.figure(figsize=(10,10))\n",
"im, _ = visualization.imshow_norm(stars_calibrated.data, \n",
" interval=visualization.PercentileInterval(99), \n",
" stretch=visualization.LinearStretch())\n",
"plt.colorbar(im);"
]
},
{
Expand Down Expand Up @@ -536,7 +550,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -550,7 +564,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.14.2"
}
},
"nbformat": 4,
Expand Down
25 changes: 13 additions & 12 deletions 09c-Ccdproc/02-image-combination.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"from astropy.nddata import CCDData\n",
"from astropy import units as u\n",
"from astropy.stats import mad_std\n",
"from astropy import visualization\n",
"\n",
"import ccdproc as ccdp\n",
"\n",
Expand All @@ -67,10 +68,7 @@
"# Use this instead for interactive plots, but note that you may need \n",
"# to install ipympl for it to work\n",
"\n",
"# %matplotlib widget\n",
"\n",
"# This function display reasonably nicely with minimal effort\n",
"from convenience_functions import show_image"
"# %matplotlib widget"
]
},
{
Expand Down Expand Up @@ -259,14 +257,17 @@
"source": [
"fig, axes = plt.subplots(1, 2, sharey=True, tight_layout=True, figsize=(20, 10))\n",
"\n",
"# Dsiplay the first of the bias images\n",
"show_image(images_to_combine[0].data, ax=axes[0], fig=fig)\n",
"im1, _ = visualization.imshow_norm(images_to_combine[0].data, ax=axes[0], \n",
" interval=visualization.PercentileInterval(99),\n",
" stretch=visualization.LinearStretch())\n",
"plt.colorbar(im1, ax=axes[0])\n",
"axes[0].set_title('Single bias images')\n",
"\n",
"# Display the combined image -- the perceintile for the low end of the color bar is set\n",
"# so as to make the range of the data the same in each case.\n",
"show_image(combined_images, ax=axes[1], fig=fig, percl=99.5)\n",
"axes[1].set_title('Combined biases')"
"im2, _ = visualization.imshow_norm(combined_images, ax=axes[1], \n",
" interval=visualization.PercentileInterval(99.5),\n",
" stretch=visualization.LinearStretch())\n",
"plt.colorbar(im2, ax=axes[1])\n",
"axes[1].set_title('Combined biases');"
]
},
{
Expand Down Expand Up @@ -310,7 +311,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -324,7 +325,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.14.2"
}
},
"nbformat": 4,
Expand Down
7 changes: 6 additions & 1 deletion 09c-Ccdproc/ccd_process_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
exposure_key='exposure', exposure_unit=u.second,
dark_scale=True,
master_flat=flat)
show_image(stars_calibrated) # this should look just like the previous version

plt.figure(figsize=(10,10))
im, _ = visualization.imshow_norm(stars_calibrated.data,
interval=visualization.PercentileInterval(99),
stretch=visualization.LinearStretch())
plt.colorbar(im);
Loading