Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WFC3 notebook 'phot_examples.ipynb' #110

Merged
merged 9 commits into from
Jan 5, 2024
1 change: 0 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ exclude_patterns: [notebooks/DrizzlePac/align_mosaics/align_mosaics.ipynb,
notebooks/WFC3/ir_ima_visualization/IR_IMA_Visualization_with_an_Example_of_Time_Variable_Background.ipynb,
notebooks/WFC3/ir_scattered_light_calwf3_corrections/Correcting_for_Scattered_Light_in_IR_Exposures_Using_calwf3_to_Mask_Bad_Reads.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]
Expand Down
2 changes: 1 addition & 1 deletion _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ parts:
# - file: notebooks/WFC3/ir_scattered_light_calwf3_corrections/Correcting_for_Scattered_Light_in_IR_Exposures_Using_calwf3_to_Mask_Bad_Reads.ipynb
# - file: notebooks/WFC3/ir_scattered_light_manual_corrections/Correcting_for_Scattered_Light_in_IR_Exposures_by_Manually_Subtracting_Bad_Reads.ipynb
- file: notebooks/WFC3/persistence/wfc3_ir_persistence.ipynb
# - file: notebooks/WFC3/photometry_examples/phot_examples.ipynb
- file: notebooks/WFC3/photometry_examples/phot_examples.ipynb
# - file: notebooks/WFC3/tvb_flattenramp/TVB_flattenramp_notebook.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
Expand Down
39 changes: 21 additions & 18 deletions notebooks/WFC3/photometry_examples/phot_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"- *os* for setting environment variables\n",
"\n",
"- *numpy* for handling array functions\n",
"- *pandas* for managing data\n",
"- *matplotlib.pyplot* for plotting data\n",
"\n",
"- *synphot* and *stsynphot* for evaluating synthetic photometry\n",
Expand All @@ -92,12 +91,12 @@
"metadata": {},
"outputs": [],
"source": [
"%matplotlib notebook\n",
"%matplotlib inline\n",
"\n",
"import os\n",
"import tarfile\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import synphot as syn\n",
Expand All @@ -113,7 +112,7 @@
"id": "06d98189",
"metadata": {},
"source": [
"This section obtains the WFC3 throughput component tables for use with `stsynphot`. If these reference files need to be downloaded, please uncomment and execute the code block below."
"This section obtains the WFC3 throughput component tables for use with `stsynphot`. This step only needs to be done once. If these reference files have already been downloaded, this section can be skipped."
]
},
{
Expand All @@ -123,16 +122,16 @@
"metadata": {},
"outputs": [],
"source": [
"# cmd_input = 'curl -O https://archive.stsci.edu/hlsps/reference-atlases/hlsp_reference-atlases_hst_multi_everything_multi_v11_sed.tar'\n",
"# os.system(cmd_input)"
"cmd_input = 'curl -O https://archive.stsci.edu/hlsps/reference-atlases/hlsp_reference-atlases_hst_multi_everything_multi_v11_sed.tar'\n",
"os.system(cmd_input)"
]
},
{
"cell_type": "markdown",
"id": "054629f8",
"metadata": {},
"source": [
"Once the downloaded is complete, unzip the files and consolidate the contents of the \"trds\" subdirectories. Set the environment variable `PYSYN_CDBS` to the path of this combined directory. That is, you should have a directory somewhere called `trds` that contains the `comp`, `mtab`, and `calspec` subdirectories, and set the environment variable to the path to this directory. To do so, uncomment and execute the relevant line from the code block below. "
"Once the downloaded is complete, extract the file and set the environment variable `PYSYN_CDBS` to the path of the `trds` subdirectory. The next cell will do this for you, as long as the `.tar` file downloaded above has not been moved."
]
},
{
Expand All @@ -142,16 +141,20 @@
"metadata": {},
"outputs": [],
"source": [
"os.environ['PYSYN_CDBS'] = '/Users/apidgeon/Desktop/grp/redcat/trds'\n",
"# os.environ['PYSYN_CDBS'] = '/path/to/location/of/trds'"
"tar_archive = 'hlsp_reference-atlases_hst_multi_everything_multi_v11_sed.tar'\n",
"extract_to = 'hlsp_reference-atlases_hst_multi_everything_multi_v11_sed'\n",
"with tarfile.open(tar_archive, 'r') as tar:\n",
" tar.extractall(path=extract_to)\n",
"\n",
"os.environ['PYSYN_CDBS'] = 'hlsp_reference-atlases_hst_multi_everything_multi_v11_sed/grp/redcat/trds/'"
]
},
{
"cell_type": "markdown",
"id": "ebbed337",
"metadata": {},
"source": [
"Now, after having set up `PYSYN_CDBS`, we import stsynphot."
"Now, after having set up `PYSYN_CDBS`, we import stsynphot. A warning regarding the Vega spectrum is expected here."
]
},
{
Expand Down Expand Up @@ -394,7 +397,7 @@
"\n",
"st_eecorr = st - st_04\n",
"\n",
"print('EE Correction (10 pixels -> infinity): {:.3f}'.format(st_eecorr),'mag')"
"print('EE Correction (10 pixels -> infinity): {:.3f}'.format(st_eecorr), 'mag')"
]
},
{
Expand Down Expand Up @@ -540,7 +543,7 @@
"outputs": [],
"source": [
"model = syn.models.BlackBody1D(5000.)\n",
"spec = syn.SourceSpectrum(model)"
"spec = syn.SourceSpectrum(model)"
]
},
{
Expand Down Expand Up @@ -637,7 +640,7 @@
"outputs": [],
"source": [
"spec_wd = syn.SourceSpectrum.from_file('example_spectra/gd153_stiswfcnic_003.fits') # GD153 (white dwarf)\n",
"spec_g = syn.SourceSpectrum.from_file('example_spectra/p330e_stiswfcnic_003.fits') # P330E (G-type)"
"spec_g = syn.SourceSpectrum.from_file('example_spectra/p330e_stiswfcnic_003.fits') # P330E (G-type)"
]
},
{
Expand Down Expand Up @@ -677,11 +680,11 @@
"metadata": {},
"outputs": [],
"source": [
"stim1_wd = obs1_wd.effstim(flux_unit = u.STmag)\n",
"stim2_wd = obs2_wd.effstim(flux_unit = u.STmag)\n",
"stim1_wd = obs1_wd.effstim(flux_unit=u.STmag)\n",
"stim2_wd = obs2_wd.effstim(flux_unit=u.STmag)\n",
"\n",
"stim1_g = obs1_g.effstim(flux_unit = u.STmag)\n",
"stim2_g = obs2_g.effstim(flux_unit = u.STmag)\n",
"stim1_g = obs1_g.effstim(flux_unit=u.STmag)\n",
"stim2_g = obs2_g.effstim(flux_unit=u.STmag)\n",
"\n",
"dstim_wd = stim1_wd - stim2_wd\n",
"dstim_g = stim1_g - stim2_g"
Expand Down Expand Up @@ -871,7 +874,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
1 change: 0 additions & 1 deletion notebooks/WFC3/photometry_examples/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
astropy==5.2.1
matplotlib==3.7.0
numpy==1.23.4
pandas==1.5.3
stsynphot==1.2.0
synphot==1.1.1
Loading