Using these values, we select a plate scale of 0.065\"/pix for the drizzled output frame, approximately half of the native plate scale (0.1283\"/pix). \n",
"\n",
"The mechanism by which the *drizzle* algorithm improves sampling in the output image is by shrinking the input pixels before adding them to the output pixel grid (see Figure 2 in [Fruchter and Hook (2002)](http://iopscience.iop.org/article/10.1086/338393/pdf)). In practice this process is controlled in the `AstroDrizzle` package by adjusting the `final_pixfrac` parameter, which is the fractional size of the pixel to be used. \n",
- "Below `AstroDrizzle` is called twice. The first time, no changes are made to the plate scale or the size of the drop. In the second call, the plate scale and pixfrac are reduced. For a four point dither stack, a `final_pixfrac` value of 0.8 is usually optimal.\n",
+ "Below `AstroDrizzle` is called twice. The first time, no changes are made to the plate scale or the size of the drop. In the second call, the plate scale and pixfrac are reduced. \n",
"\n",
"Next, we get some recommended values for drizzling from the MDRIZTAB reference file. The parameters in this file are different for each detector and are based on the number of input frames. These are a good starting point for drizzling and may be adjusted accordingly.\n",
"\n",
@@ -430,7 +483,7 @@
"metadata": {},
"source": [
"\n",
- "## 4. Results \n",
+ "## 4. Inspecting the Results \n",
"[Table of Contents](#toc)\n",
"\n",
"The drizzled science and weight images produced from the first call to AstroDrizzle with no optimization of the plate scale and pixfrac are plotted below. "
@@ -515,7 +568,7 @@
"\n",
"Below, a series of experiments will be run to determine the best `final_pixfrac` value for the selected output plate scale, by varying pixfrac in steps of 0.1 over a range of values from 0.1 to 1.0.\n",
"\n",
- " This cell may take a few minutes to execute.
"
+ " This cell may take a several minutes to execute.
"
]
},
{
@@ -533,9 +586,11 @@
" drizzlepac.astrodrizzle.AstroDrizzle(flt_files,\n",
" output=outname,\n",
" **selected_params,\n",
- " context=False, build=True, preserve=False, \n",
+ " context=False, \n",
+ " build=True, \n",
+ " preserve=False, \n",
" skymethod='match',\n",
- " driz_separate=False, median=False, blot=False, driz_cr=False,\n",
+ " driz_separate=False, median=False, blot=False, driz_cr=False, # CR-rej off\n",
" final_pixfrac=pixfrac,\n",
" final_wcs=True,\n",
" final_rot=0.,\n",
@@ -562,7 +617,7 @@
" sci1 = hdu1[1].data\n",
" wht1 = hdu1[2].data\n",
" \n",
- "with fits.open('f160w_0.8_drz.fits') as hdu2:\n",
+ "with fits.open('f160w_0.6_drz.fits') as hdu2:\n",
" sci2 = hdu2[1].data\n",
" wht2 = hdu2[2].data\n",
" \n",
@@ -577,7 +632,7 @@
"ax[0, 0].imshow(sci1, norm=norm2, cmap='gray')\n",
"ax[0, 0].text(1640, 1920, 'final_pixfrac=0.1', fontsize='20', color='maroon')\n",
"ax[0, 1].imshow(sci2, norm=norm2, cmap='gray')\n",
- "ax[0, 1].text(1640, 1920, 'final_pixfrac=0.8', fontsize='20', color='maroon')\n",
+ "ax[0, 1].text(1640, 1920, 'final_pixfrac=0.6', fontsize='20', color='maroon')\n",
"ax[0, 2].imshow(sci3, norm=norm2, cmap='gray')\n",
"ax[0, 2].text(1640, 1920, 'final_pixfrac=1.0', fontsize='20', color='maroon')\n",
"ax[1, 0].imshow(wht1, norm=norm3, cmap='gray')\n",
@@ -591,7 +646,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "This figure above shows the central region of the science and weight images produced by `final_pixfrac` values (left to right) of 0.1, 0.8 and 1.0. The top row is the science frame, the bottom is the weight image. The science image with the smallest `final_pixfrac` value of 0.1 shows a noisy background and holes in the image where no input pixels fall into the output grid because pixfrac is too small. Inspection of the weight map corresponding to the smallest `final_pixfrac` value shows many places with weights of zero, indicating that a `final_pixfrac` value of 0.1 is clearly too small and was only included in this example for illustrative purposes."
+ "This figure above shows the central region of the science and weight images produced by `final_pixfrac` values (left to right) of 0.1, 0.8 and 1.0. The top row is the science frame, the bottom is the weight image. The science image with the smallest `final_pixfrac` value of 0.1 shows a noisy background and holes in the image where no input pixels fall into the output grid because pixfrac is too small. \n",
+ "\n",
+ "Inspection of the weight map corresponding to the smallest `final_pixfrac` value shows many places with weights of zero, indicating that a `final_pixfrac` value of 0.1 is clearly too small and was only included in this example for illustrative purposes."
]
},
{
@@ -600,6 +657,8 @@
"source": [
"Another piece of information that can be useful is the amount of noise in the weight image. As suggested in the [DrizzlePac Handbook](https://hst-docs.stsci.edu/drizzpac/chapter-7-data-quality-checks-and-trouble-shooting-problems/7-3-inspecting-drizzled-products-after-user-reprocessing) Section 7.3, statistics performed on the drizzled weight image should yield a RMS/median value less than ~0.2. This threshold controls the trade-off between improving image resolution versus increasing background noise due to pixel resampling.\n",
" \n",
+ "The final_pixfrac value should be small enough to avoid degrading the final drizzle-combined image, but large enough that when all images are \"dropped\" onto the final frame, coverage of the output frame is fairly uniform. In general, final_pixfrac should be slightly larger than the final output scale to allow some \"spillover\" to adjacent pixels. This will help avoid \"holes\" in the final product when a given pixel has been flagged as bad in several frames.\n",
+ " \n",
"The figure below shows the RMS/median as a function of `final_pixfrac`. One should take care to use the same region in the weight image as the region where the object of interest is located in the science image. If one is using the entire image for scientific analysis, then one should measure the statistics of the weight image where there is more variance. "
]
},
@@ -633,21 +692,23 @@
"# Plotting commands \n",
"plt.clf()\n",
"plt.xlim(1.025, -0.025)\n",
- "plt.ylim(0., 0.9)\n",
+ "plt.ylim(0., 0.3)\n",
"plt.scatter(fraclist, std_med, s=50)\n",
- "plt.axhline(0.2, ls='--', lw=3, c='r')\n",
+ "plt.axhline(0.2, ls='--', lw=3, c='g')\n",
"plt.xlabel('pixfrac', fontsize=18)\n",
"plt.ylabel('rms/median', fontsize=18)\n",
- "plt.text(1.0, 0.85, target, fontsize=16, horizontalalignment='left')\n",
- "plt.text(1.0, 0.80, 'Scale=' + str(scale) + '\"', fontsize=16, horizontalalignment='left')\n",
- "plt.text(1.0, 0.75, str(nimg) + ' images', fontsize=16, horizontalalignment='left')"
+ "plt.text(0.95, 0.28, target, fontsize=14, horizontalalignment='left')\n",
+ "plt.text(0.95, 0.26, 'Scale=' + str(scale) + '\"', fontsize=14, horizontalalignment='left')\n",
+ "plt.text(0.95, 0.24, str(nimg) + ' images', fontsize=14, horizontalalignment='left')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "The RMS/median increases steadily down to `final_pixfrac` value of 0.3, where there is a change in the slope of the function, indicating that something odd might be happening beyond that point. The RMS remains below 20% of the median all the way down to `final_pixfrac` of 0.8, but the science and weight images should be inspected at all values to ensure no quality degradation has occurred. "
+ "Note that none of the test images have RMS/median greater than 0.2, so this does not seem to be a good metric for WFC3/IR in which the PSF is undersampled. (We suspect that this recommendation from the DrizzlePac Handbook was based on WFC3/UVIS or ACS/WFC dithered frames.)\n",
+ "\n",
+ "The RMS/median increases steadily to a `final_pixfrac` value of 0.5, where there is a change in the slope of the function. For an output scale of 0.065\"/pix (0.5 times the native plate scale) thus select the pixfrac 0.6 for the final drizzled image. "
]
},
{
@@ -663,7 +724,7 @@
"## 6. Final thoughts \n",
"[Table of Contents](#toc)\n",
"\n",
- "The `final_pixfrac` value has to be small enough to avoid degrading the combined output image, but large enough that when all images are \"dropped\" onto the final frame, coverage of the output frame is fairly uniform. In general, `final_pixfrac` should be slightly larger than the final output scale to allow some \"spillover\" to adjacent pixels. This will help avoid \"holes\" in the final product when a given pixel has been flagged as \"bad\" in several frames. As a rule of thumb, statistics performed on the drizzled weight image in the region of interest should yield an RMS value (standard deviation) that is less than 20% of the median value. This threshold is a balance between the benefits of improving the image resolution at the expense of increasing noise in the background."
+ "The `final_pixfrac` value has to be small enough to avoid degrading the combined output image, but large enough that when all images are \"dropped\" onto the final frame, coverage of the output frame is fairly uniform. In general, `final_pixfrac` should be slightly larger than the final output scale to allow some \"spillover\" to adjacent pixels. This will help avoid \"holes\" in the final product when a given pixel has been flagged as \"bad\" in several frames. Optimizing the final drizzle parameters is a balance between the benefits of improving the image resolution and PSFs at the expense of increasing noise in the background."
]
},
{
@@ -674,7 +735,7 @@
"## About this Notebook\n",
"\n",
" Created: 12 Dec 2018; R. Avila\n",
- " Updated: 29 Apr 2024; R. Avila & J. Mack\n",
+ " Updated: 30 Dec 2024; R. Avila & J. Mack\n",
"\n",
"**Source:** GitHub [spacetelescope/hst_notebooks](https://github.com/spacetelescope/hst_notebooks)\n",
"\n",
@@ -710,13 +771,6 @@
"source": [
"[Top of Page](#top)"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {