Skip to content

Commit

Permalink
Add WFC3 notebook 'uvis_timedep_phot.ipynb' (#113)
Browse files Browse the repository at this point in the history
* updated _toc.yml and _config.yml files

* uvis_timedep_phot.ipynb: cleared notebook outputs.

* Refactor file path handling for improved clarity

* Fix code style and photutils deprecation

* Remove codestyle command

---------

Co-authored-by: Hatice Karatay <haticekaraty@gmail.com>
  • Loading branch information
dulude and haticekaratay authored Jan 8, 2024
1 parent 14ec9f5 commit 36e096f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 40 deletions.
1 change: 0 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ exclude_patterns: [notebooks/DrizzlePac/align_mosaics/align_mosaics.ipynb,
notebooks/WFC3/ir_scattered_light_manual_corrections/Correcting_for_Scattered_Light_in_IR_Exposures_by_Manually_Subtracting_Bad_Reads.ipynb,
notebooks/WFC3/photometry_examples/phot_examples.ipynb,
notebooks/WFC3/tvb_flattenramp/TVB_flattenramp_notebook.ipynb,
notebooks/WFC3/uvis_time_dependent_photometry/uvis_timedep_phot.ipynb,
notebooks/WFC3/zeropoints/zeropoints.ipynb]
2 changes: 1 addition & 1 deletion _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ parts:
- file: notebooks/WFC3/tvb_flattenramp/TVB_flattenramp_notebook.ipynb
- file: notebooks/WFC3/photometry_examples/phot_examples.ipynb
- file: notebooks/WFC3/uvis_pam_corrections/WFC3_UVIS_Pixel_Area_Map_Corrections_for_Subarrays.ipynb
# - file: notebooks/WFC3/uvis_time_dependent_photometry/uvis_timedep_phot.ipynb
- file: notebooks/WFC3/uvis_time_dependent_photometry/uvis_timedep_phot.ipynb
# - file: notebooks/WFC3/zeropoints/zeropoints.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import os\n",
"import glob\n",
"import shutil\n",
Expand All @@ -96,16 +94,13 @@
"\n",
"from astropy.io import fits\n",
"from astropy.stats import sigma_clipped_stats\n",
"from astropy.coordinates import SkyCoord\n",
"from astropy import wcs\n",
"from astroquery.mast import Observations\n",
"\n",
"from drizzlepac import photeq\n",
"from drizzlepac import astrodrizzle\n",
"\n",
"from photutils import aperture_photometry, CircularAperture, CircularAnnulus\n",
"\n",
"from stwcs import updatewcs"
"from photutils.aperture import aperture_photometry, CircularAperture, CircularAnnulus\n",
"%matplotlib inline"
]
},
{
Expand All @@ -124,16 +119,17 @@
"metadata": {},
"outputs": [],
"source": [
"data_list = Observations.query_criteria(obs_id=['IBCDA4010','ICH3040F0','IDBHA6040'])\n",
" \n",
"data_list = Observations.query_criteria(obs_id=['IBCDA4010', 'ICH3040F0', 'IDBHA6040'])\n",
"\n",
"Observations.download_products(data_list['obsid'], project='CALWF3',\n",
" mrp_only=False,download_dir='./data',productSubGroupDescription=['FLC','ASN'])\n",
" mrp_only=False, download_dir='./data', productSubGroupDescription=['FLC', 'ASN'])\n",
"\n",
"science_files = glob.glob('data/mastDownload/HST/*/*fits')\n",
"\n",
"for im in science_files:\n",
" root = im.split('/')[-1]\n",
" os.rename(im,'./'+root)\n",
" root = os.path.basename(im)\n",
" new_path = os.path.join(\"./\", root)\n",
" os.rename(im, new_path)\n",
"shutil.rmtree('data/')"
]
},
Expand All @@ -151,7 +147,6 @@
"outputs": [],
"source": [
"df = pd.read_csv('GD153_F606W_public.csv')\n",
"\n",
"df"
]
},
Expand Down Expand Up @@ -230,14 +225,14 @@
" mask = annulus_masks.data\n",
" annulus_data_1d = annulus_data[mask > 0]\n",
" mean_sigclip, _, _ = sigma_clipped_stats(annulus_data_1d)\n",
" \n",
"\n",
" apers = [aperture, annulus_aperture]\n",
" phot_table = aperture_photometry(data,apers)\n",
" phot_table = aperture_photometry(data, apers)\n",
"\n",
" background = mean_sigclip * aperture.area\n",
" final_sum = phot_table['aperture_sum_0'] - background\n",
" phots.append(final_sum[0])\n",
" mjds.append(mjd) \n",
" mjds.append(mjd)\n",
" dates.append(date)"
]
},
Expand Down Expand Up @@ -279,7 +274,12 @@
"outputs": [],
"source": [
"EE_r10 = 0.91\n",
"df['STMags'] = -21.1 -2.5*np.log10(df['PHOTFLAM']) -2.5*np.log10(df['Countrate']) - 2.5 * np.log10(1./EE_r10)"
"df[\"STMags\"] = (\n",
" - 21.1\n",
" - 2.5 * np.log10(df[\"PHOTFLAM\"])\n",
" - 2.5 * np.log10(df[\"Countrate\"])\n",
" - 2.5 * np.log10(1.0 / EE_r10)\n",
")"
]
},
{
Expand Down Expand Up @@ -406,9 +406,9 @@
" annulus_data_1d = annulus_data[mask > 0]\n",
" mean_sigclip, _, _ = sigma_clipped_stats(annulus_data_1d)\n",
" background = mean_sigclip * aperture.area\n",
" \n",
"\n",
" apers = [aperture, annulus_aperture]\n",
" phot_table = aperture_photometry(data,apers)\n",
" phot_table = aperture_photometry(data, apers)\n",
"\n",
" final_sum = phot_table['aperture_sum_0'] - background\n",
" phots.append(final_sum[0])\n",
Expand Down Expand Up @@ -490,20 +490,22 @@
},
"outputs": [],
"source": [
"for asn in glob.glob('*asn.fits'):\n",
" astrodrizzle.AstroDrizzle(asn,\n",
" skymethod= 'match',\n",
" skystat='mean',\n",
" driz_sep_bits='80',\n",
" combine_type='median',\n",
" combine_nhigh=1,\n",
" driz_cr_snr= '3.5 3.0', \n",
" driz_cr_scale= '2.0 1.5',\n",
" final_bits= '80', \n",
" build=True,\n",
" clean=True,\n",
" preserve=False,\n",
" num_cores=1)"
"for asn in glob.glob(\"*asn.fits\"):\n",
" astrodrizzle.AstroDrizzle(\n",
" asn,\n",
" skymethod=\"match\",\n",
" skystat=\"mean\",\n",
" driz_sep_bits=\"80\",\n",
" combine_type=\"median\",\n",
" combine_nhigh=1,\n",
" driz_cr_snr=\"3.5 3.0\",\n",
" driz_cr_scale=\"2.0 1.5\",\n",
" final_bits=\"80\",\n",
" build=True,\n",
" clean=True,\n",
" preserve=False,\n",
" num_cores=1,\n",
" )"
]
},
{
Expand Down Expand Up @@ -537,7 +539,7 @@
"pfls = []\n",
"for i, drc in enumerate(drcs):\n",
" data = fits.getdata(drc, ext=1)\n",
" \n",
"\n",
" mjds.append(np.mean(df.query('Epoch == {}'.format(i+1))['MJD']))\n",
" pfls.append(df.query('Epoch == {}'.format(i+1))['PHOTFLAM'].values[0])\n",
"\n",
Expand All @@ -550,9 +552,9 @@
" annulus_data_1d = annulus_data[mask > 0]\n",
" mean_sigclip, _, _ = sigma_clipped_stats(annulus_data_1d)\n",
" background = mean_sigclip * aperture.area\n",
" \n",
" \n",
" apers = [aperture, annulus_aperture]\n",
" phot_table = aperture_photometry(data,apers)\n",
" phot_table = aperture_photometry(data, apers)\n",
"\n",
" final_sum = phot_table['aperture_sum_0'] - background\n",
" phots.append(final_sum[0])"
Expand Down Expand Up @@ -675,7 +677,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -689,7 +691,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 36e096f

Please sign in to comment.