diff --git a/acs_saturation_trails/acs_saturation_trails.ipynb b/acs_saturation_trails/acs_saturation_trails.ipynb
index 1a214f1..895a0c3 100644
--- a/acs_saturation_trails/acs_saturation_trails.ipynb
+++ b/acs_saturation_trails/acs_saturation_trails.ipynb
@@ -10,19 +10,40 @@
"\n",
"***\n",
"\n",
- "This is an introduction\n",
+ "The ACS/WFC CCD becomes saturated around 80000 counts. When this occurs, excess charge from the source spills out lengthwise along the columns of the CCD. This can lead to issues with photometry when using very bright stars, since a significant portion of the star's flux may fall outside of a reasonable extraction radius.\n",
+ "\n",
+ "However, accurate relative photometry can be obtained as long as a large enough aperture is selected to contain the spilled flux (ACS ISR 2004-01). While one could simply use a larger circular aperture, that may introduce error when working with a crowded field (as bright stars often are).\n",
+ "\n",
+ "Here we present a method to identify and perform photometry on saturated sources by defining a custom aperture that is a combination of a standard 0.5\" arcsecond circular aperture and the pixels affected by saturation trails.\n",
"\n",
"### This tutorial will show you how to...\n",
"\n",
- "#### [Determine if your star is affected by saturation trails](#_postsm4) \n",
+ "#### [Prepare Images](#_prep) \n",
+ "\n",
+ "* Apply Pixel Area Map\n",
+ "* Separate by long and short exposure\n",
+ "* Make sure you have images of the same field\n",
+ "\n",
+ "#### [Identify Saturated Stars](#_identify)\n",
+ "\n",
+ "* Identify the saturated pixels using the data quality (DQ) array\n",
+ "* Determine whether or not the saturation trails extend significantly away from the target\n",
+ "\n",
+ "#### [Bleed the Saturation Mask](#_bleed)\n",
+ "\n",
+ "* Construct a convolution kernel\n",
+ "* Bleed the saturation mask with the convolution kernel\n",
"\n",
- "* Step one of thing one\n",
- "* Step two of thing one\n",
- "* Step three of thing one\n",
+ "#### [Define a Custom Aperture](#_define)\n",
"\n",
- "#### [Add saturation trails to photometry](#_custom)\n",
+ "* Isolate central clump from your saturation mask\n",
+ "* Obtain circular aperture as a boolean mask\n",
+ "* Combine circular aperture with saturation mask\n",
"\n",
- "* Step one of thing two"
+ "#### [Photometry with a Custom Aperture](#_phot)\n",
+ "\n",
+ "* Extract counts with the custom aperture\n",
+ "* Estimate background to be subtracted"
]
},
{
@@ -33,20 +54,21 @@
"\n",
"***\n",
"\n",
- "- `astroquery.mast.Observations`: download data from MAST\n",
- "\n",
- "- `os`: command line input and setting environments\n",
- "- `shutil`: Unix shell utilities\n",
- "- `glob`: searching for files based on Unix shell rules\n",
- "\n",
- "- `astropy.io.fits`: access and update fits files\n",
- "- `astropy.table.Table`: constructing and editing in a tabular format\n",
- "\n",
- "- `acs_pypack.notebook_tools`: convenience functions for the purpose of this notebook\n",
- "- `matplotlib.pyplot`: plotting functions\n",
- "- `numpy`: functions for array handling and operations\n",
+ "Here we list the Python packages used in this notebook. Links to the documentation for each module is provided for convenience.\n",
"\n",
- "- `stwcs.updatewcs`: update wcs solution"
+ "| Package Name | module | docs | used for |\n",
+ "|------------------|:-----------------|:-------------:|:------------|\n",
+ "| `os` | `system` | link|command line input|\n",
+ "|`glob` | `glob` | link| search for files based on Unix shell rules |\n",
+ "|`numpy` | `_s` | link| construct array slice object |\n",
+ "|`matplotlib` |`pyplot` | link| plotting |\n",
+ "|`astroquery.mast` |`Observations` | link| download data from MAST |\n",
+ "|`astropy.io` | `fits` | link| access and update fits files |\n",
+ "|`astropy.stats` |`sigma_clip`| link| sigma clipping image for background estimation |\n",
+ "|`scipy.signal` |`convolve2d`| link| convolve saturation mask with kernel |\n",
+ "|`stsci.skypac` |`pamutils`| link|obtain pixel area maps (PAM) |\n",
+ "|`photutils` |`CircularAperture`| link| aperture object for photometry |\n",
+ "|`matplotlib.patches`|`Circle`| link| draw circle on a plot |"
]
},
{
@@ -64,34 +86,30 @@
}
],
"source": [
- "from astroquery.mast import Observations\n",
"import os\n",
- "import shutil\n",
"import glob\n",
"\n",
- "from astropy.io import fits\n",
- "from astropy.table import Table\n",
- "from astropy.coordinates import SkyCoord\n",
- "from astropy import units as u\n",
- "\n",
"import numpy as np\n",
+ "import matplotlib.pyplot as plt\n",
"\n",
- "from p_module import plot\n",
+ "from astroquery.mast import Observations\n",
"\n",
+ "from astropy.io import fits\n",
"from astropy.stats import sigma_clip\n",
+ "\n",
"from scipy.signal import convolve2d\n",
- "from scipy import ndimage\n",
"from stsci.skypac import pamutils\n",
- "from astropy.wcs import WCS\n",
- "from astropy.wcs.utils import proj_plane_pixel_scales\n",
- "\n",
- "import matplotlib.pyplot as plt\n",
- "\n",
- "from photutils import (CircularAperture, CircularAnnulus, EllipticalAperture, EllipticalAnnulus, aperture_photometry)\n",
"\n",
- "from matplotlib.patches import (Circle, Ellipse)\n",
- "\n",
- "from astropy.wcs.utils import skycoord_to_pixel"
+ "from photutils import CircularAperture\n",
+ "from matplotlib.patches import Circle\n",
+ "from p_module import plot"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Setting environment variables for later use with the Calibration Reference Data System (CRDS)."
]
},
{
@@ -106,20 +124,6 @@
"os.environ['jref'] = './crds_cache/references/hst/acs/'"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "\n",
- "TO-DO:\n",
- " \n",
- " Remove unrelevant packages\n",
- " Find a way to use \"Table\" objects to simplify/clarify things\n",
- " Find the workflow for elliptical extraction\n",
- "\n",
- ""
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -132,8 +136,6 @@
"\n",
"#### [GO Proposal 14949](https://stdatu.stsci.edu/proposal_search.php?mission=hst&id=14949): \"ACS External CTE Monitor\"\n",
"\n",
- "Literally the least you could do.\n",
- "\n",
"Using the python package `astroquery`, we can download files from the [MAST](http://archive.stsci.edu) archive."
]
},
@@ -143,8 +145,8 @@
"metadata": {},
"outputs": [],
"source": [
- "# obs_table = Observations.query_criteria(proposal_id=14949, filters='F606W')\n",
- "# obs_table"
+ "obs_table = Observations.query_criteria(proposal_id=14949, filters='F606W')\n",
+ "obs_table"
]
},
{
@@ -153,11 +155,11 @@
"metadata": {},
"outputs": [],
"source": [
- "# dl_table = Observations.download_products(obs_table['obsid'],\n",
- "# productSubGroupDescription=['FLC'],\n",
- "# mrp_only=False)\n",
+ "dl_table = Observations.download_products(obs_table['obsid'],\n",
+ " productSubGroupDescription=['FLC'],\n",
+ " mrp_only=False)\n",
"\n",
- "# dl_table"
+ "dl_table"
]
},
{
@@ -195,22 +197,8 @@
"metadata": {},
"outputs": [],
"source": [
- "flc_files = glob.glob('mastDownload/HST/j*/*_flc.fits')\n",
- "flc_files = ('mastDownload/HST/jdg302clq/jdg302clq_flc.fits',\n",
- " 'mastDownload/HST/jdg302cnq/jdg302cnq_flc.fits',\n",
- " 'mastDownload/HST/jdg303d7q/jdg303d7q_flc.fits',\n",
- " 'mastDownload/HST/jdg303d5q/jdg303d5q_flc.fits',\n",
- " 'mastDownload/HST/jdg301bwq/jdg301bwq_flc.fits',\n",
- " 'mastDownload/HST/jdg301byq/jdg301byq_flc.fits')\n",
- "\n",
- "flc_files = ('mastDownload/HST/jdg302ctq/jdg302ctq_flc.fits',\n",
- " 'mastDownload/HST/jdg303dbq/jdg303dbq_flc.fits',\n",
- " 'mastDownload/HST/jdg303d9q/jdg303d9q_flc.fits',\n",
- " 'mastDownload/HST/jdg301c6q/jdg301c6q_flc.fits',\n",
- " 'mastDownload/HST/jdg301c4q/jdg301c4q_flc.fits')\n",
- "\n",
- "short_exposure = flc_files[0]\n",
- "long_exposure = flc_files[4]"
+ "short_exposure = 'mastDownload/HST/jdg302ctq/jdg302ctq_flc.fits'\n",
+ "long_exposure = 'mastDownload/HST/jdg301c4q/jdg301c4q_flc.fits'"
]
},
{
@@ -267,19 +255,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Identifying Saturated Stars\n",
+ "## Identify Saturated Stars\n",
"***"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "For more information on wcs, consult ___________.\n",
- "\n",
- "For more information on obtaining the pixel scale, consult ___________."
- ]
- },
{
"cell_type": "code",
"execution_count": 8,
@@ -316,7 +295,7 @@
},
{
"cell_type": "code",
- "execution_count": 55,
+ "execution_count": 10,
"metadata": {
"scrolled": false
},
@@ -334,7 +313,7 @@
},
{
"cell_type": "code",
- "execution_count": 56,
+ "execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -350,7 +329,7 @@
},
{
"cell_type": "code",
- "execution_count": 57,
+ "execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@@ -371,7 +350,7 @@
},
{
"cell_type": "code",
- "execution_count": 58,
+ "execution_count": 13,
"metadata": {},
"outputs": [
{
@@ -400,7 +379,7 @@
},
{
"cell_type": "code",
- "execution_count": 59,
+ "execution_count": 14,
"metadata": {},
"outputs": [
{
@@ -422,16 +401,16 @@
},
{
"cell_type": "code",
- "execution_count": 60,
+ "execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 60,
+ "execution_count": 15,
"metadata": {},
"output_type": "execute_result"
},
@@ -456,16 +435,16 @@
},
{
"cell_type": "code",
- "execution_count": 61,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 61,
+ "execution_count": 16,
"metadata": {},
"output_type": "execute_result"
},
@@ -490,16 +469,16 @@
},
{
"cell_type": "code",
- "execution_count": 62,
+ "execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 62,
+ "execution_count": 17,
"metadata": {},
"output_type": "execute_result"
},
@@ -531,16 +510,16 @@
},
{
"cell_type": "code",
- "execution_count": 63,
+ "execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 63,
+ "execution_count": 18,
"metadata": {},
"output_type": "execute_result"
},
@@ -581,7 +560,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Bleeding the Saturation Mask"
+ "## Bleed the Saturation Mask"
]
},
{
@@ -593,16 +572,16 @@
},
{
"cell_type": "code",
- "execution_count": 64,
+ "execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 64,
+ "execution_count": 19,
"metadata": {},
"output_type": "execute_result"
},
@@ -631,7 +610,7 @@
},
{
"cell_type": "code",
- "execution_count": 77,
+ "execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
@@ -644,16 +623,16 @@
},
{
"cell_type": "code",
- "execution_count": 78,
+ "execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 78,
+ "execution_count": 21,
"metadata": {},
"output_type": "execute_result"
},
@@ -687,7 +666,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Defining a Custom Aperture\n",
+ "## Define a Custom Aperture\n",
"\n",
"Now we want to create a new aperture which includes the pixels with the spilled charge. If we want to use the saturation mask we just created, we need to isolate only the clump associated with our star.\n",
"\n",
@@ -696,13 +675,15 @@
},
{
"cell_type": "code",
- "execution_count": 79,
+ "execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"# Isolate associated clump from saturation mask\n",
"\n",
"def find_central_clump(boolean_mask):\n",
+ " \n",
+ " from scipy import ndimage\n",
"\n",
" central_index = tuple((np.array(np.shape(boolean_mask))/2).astype(int))\n",
"\n",
@@ -739,16 +720,16 @@
},
{
"cell_type": "code",
- "execution_count": 80,
+ "execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 80,
+ "execution_count": 23,
"metadata": {},
"output_type": "execute_result"
},
@@ -780,16 +761,16 @@
},
{
"cell_type": "code",
- "execution_count": 81,
+ "execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 81,
+ "execution_count": 24,
"metadata": {},
"output_type": "execute_result"
},
@@ -822,7 +803,7 @@
},
{
"cell_type": "code",
- "execution_count": 82,
+ "execution_count": 25,
"metadata": {},
"outputs": [
{
@@ -831,7 +812,7 @@
"(200, 200)"
]
},
- "execution_count": 82,
+ "execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
@@ -842,16 +823,16 @@
},
{
"cell_type": "code",
- "execution_count": 83,
+ "execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 83,
+ "execution_count": 26,
"metadata": {},
"output_type": "execute_result"
},
@@ -892,16 +873,16 @@
},
{
"cell_type": "code",
- "execution_count": 84,
+ "execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 84,
+ "execution_count": 27,
"metadata": {},
"output_type": "execute_result"
},
@@ -927,14 +908,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Photometry with our Custom Aperture\n",
+ "## Photometry with a Custom Aperture\n",
"\n",
"To get the local background for each source, we will use sigma-clipped cutouts of the image to obtain the median background value. We will then estimate the background in our new aperture by multiplying the median by the area covered by the aperture."
]
},
{
"cell_type": "code",
- "execution_count": 86,
+ "execution_count": 29,
"metadata": {},
"outputs": [
{
@@ -950,7 +931,7 @@
"img_cutout = pamimage_l[cutter]\n",
"flux_sum = np.sum(img_cutout[combined_aperture])\n",
"\n",
- "bkg_data = sigma_clip(im_cutout, sigma=3, iters=5)\n",
+ "bkg_data = sigma_clip(img_cutout, sigma=3, iters=5)\n",
"\n",
"new_aperture_area = np.sum(combined_aperture)\n",
"bkg_sum = np.median(bkg_data) * new_aperture_area\n",
@@ -958,29 +939,6 @@
"final_sum = flux_sum - bkg_sum"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Adding more pixels to aperture"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "1. construct boolean mask for field\n",
- "2. bleed boolean mask\n",
- "3. clip boolean mask for star\n",
- "4. combine boolean mask with circular aperture\n",
- "5. contiguous pixels for saturated pixels\n",
- "\n",
- "1. show that a bigger aperture could work\n",
- "2. why different apertures may work \"better\"\n",
- "-ellipse\n",
- "-growth mask"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -995,13 +953,6 @@
"\n"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
{
"cell_type": "code",
"execution_count": null,