Skip to content

Commit 6debbcc

Browse files
authored
Merge pull request #474 from spacetelescope/bjkuhn-patch-1
Update slitlessutils_IR_extraction.ipynb
2 parents 0aefa8d + 3e3ce71 commit 6debbcc

1 file changed

Lines changed: 33 additions & 27 deletions

File tree

notebooks/WFC3/slitlessutils_IR_extraction/slitlessutils_IR_extraction.ipynb

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"metadata": {},
9090
"source": [
9191
"<a id=\"env\"></a>\n",
92-
"## 1.1 Environment \n",
92+
"### 1.1 Environment \n",
9393
"\n",
9494
"This notebook requires users to install the packages listed in the `requirements.txt` file located in the notebook's <br>\n",
9595
"sub-folder on the GitHub repository. We will use the `conda` package manager to build the necessary virtual environment. <br>\n",
@@ -124,7 +124,7 @@
124124
},
125125
"source": [
126126
"<a id=\"import\"></a>\n",
127-
"## 1.2 Imports \n",
127+
"### 1.2 Imports \n",
128128
" \n",
129129
"For this notebook we import:\n",
130130
"\n",
@@ -228,7 +228,7 @@
228228
"metadata": {},
229229
"source": [
230230
"<a id=\"config\"></a>\n",
231-
"## 1.3 `Slitlessutils` Configuration \n",
231+
"### 1.3 `Slitlessutils` Configuration \n",
232232
"\n",
233233
"In order to extract or simulate grism spectra with `slitlessutils`, you must have the necessary reference files. <br>\n",
234234
"Below, we provide a table of file descriptions, example filenames, and file types for the different reference files <br>\n",
@@ -299,7 +299,9 @@
299299
"outputs": [],
300300
"source": [
301301
"# Initialize configuration \n",
302-
"cfg = su.config.Config()"
302+
"cfg = su.config.Config()\n",
303+
"# Download latest reffile version\n",
304+
"cfg.retrieve_reffiles(update=True)"
303305
]
304306
},
305307
{
@@ -411,9 +413,9 @@
411413
" \n",
412414
"We download G102 `_raw.fits` and F105W `_flt.fits` images of the galactic planetary nebula, [VY2-2](https://simbad.cds.unistra.fr/simbad/sim-id?Ident=%402707077&Name=PN%20Vy%20%202-2&submit=submit), from CAL<br>\n",
413415
"program [17687](https://www.stsci.edu/hst-program-info/program/?program=17687). This target is a well-established calibration source routinely used by the WFC3 instrument team to <br>\n",
414-
"derive and validate the wavelength solution for the IR grisms (WFC3 ISR [2016-15](https://www.stsci.edu/files/live/sites/www/files/home/hst/instrumentation/wfc3/documentation/instrument-science-reports-isrs/_documents/2016/WFC3-2016-15.pdf)).\n",
415-
"After downloading the images, we <br>\n",
416-
"move them to a subdirectory within the current working directory. "
416+
"derive and validate the wavelength solution for the IR grisms ([WFC3 ISR 2016-15](https://www.stsci.edu/files/live/sites/www/files/home/hst/instrumentation/wfc3/documentation/instrument-science-reports-isrs/_documents/2016/WFC3-2016-15.pdf) (Pirzkal et al.)).\n",
417+
"After downloading the <br>\n",
418+
"images, we move them to a subdirectory within the current working directory. "
417419
]
418420
},
419421
{
@@ -1045,9 +1047,7 @@
10451047
{
10461048
"cell_type": "code",
10471049
"execution_count": null,
1048-
"metadata": {
1049-
"scrolled": true
1050-
},
1050+
"metadata": {},
10511051
"outputs": [],
10521052
"source": [
10531053
"os.chdir('../output')\n",
@@ -1064,8 +1064,10 @@
10641064
"### 6.1 Display a Region File\n",
10651065
"\n",
10661066
"Below, we display a grism FLT file and the associated region file. The region files are useful for quickly inspecting which part <br>\n",
1067-
"of the grism image contribute to each object’s spectrum. The 0, <span style=\"color: blue;\">+1</span>, <span style=\"color: orange;\">+2</span>, and <span style=\"color: green;\">+3</span> spectral orders for the observations are outlined <br>\n",
1068-
"in white, blue, orange, and green, respectively. More information about the `slitlessutils` region files can be found in the <br>[documentation](https://slitlessutils.readthedocs.io/en/latest/regions.html). "
1067+
"of the grism image contribute to each object’s spectrum. The 0, <span style=\"color: blue;\"><b>+1</b></span>, <span style=\"color: orange;\"><b>+2</b></span>, and <span style=\"color: green;\"><b>+3</b></span> spectral orders for the observations are outlined <br>\n",
1068+
"in white, blue, orange, and green, respectively. More information about the `slitlessutils` region files can be found in the <br>[documentation](https://slitlessutils.readthedocs.io/en/latest/regions.html). \n",
1069+
"\n",
1070+
"<b>Note</b>: if the figure below does not display correctly, try switching to `%matplotlib inline`. "
10691071
]
10701072
},
10711073
{
@@ -1074,6 +1076,7 @@
10741076
"metadata": {},
10751077
"outputs": [],
10761078
"source": [
1079+
"# %matplotlib inline\n",
10771080
"i = 0 # which FLT image to display\n",
10781081
"fig, axs = plt.subplots(1, 1, figsize=(9, 9))\n",
10791082
"\n",
@@ -1115,9 +1118,13 @@
11151118
"source and grism image. Those spectra are then combined into a single one-dimensional spectrum for each source and saved as a<br>\n",
11161119
"`x1d.fits` file. In this example, we only have one source, so there is a single spectrum.<br>\n",
11171120
"\n",
1118-
"The `x1d` file is a binary table with columns for the wavelength (`lamb`), flux (`flam`), uncertainty (`func`), contamination (`cont`), <br>\n",
1119-
"and number of pixels (`npix`). By default [configuration](https://slitlessutils.readthedocs.io/en/latest/configure.html#global-variables-config), the flux and uncertainty values are in units of <em>erg s<sup>-1</sup> cm<sup>-2</sup> · Å<sup>-1</sup></em> and scaled by <br>\n",
1120-
"10<sup>-17</sup> (`cfg.fluxunits` and `cfg.fluxscale`).\n"
1121+
"The `x1d` file is a binary table with columns for the wavelength (`WAVELENGTH`), flux (`FLUX`), uncertainty (`UNCERTAINTY`), contamination<br>\n",
1122+
"(`CONTAMINATION`), and number of pixels (`NMEASUREMENTS`). By default [configuration](https://slitlessutils.readthedocs.io/en/latest/configure.html#global-variables-config), the flux and uncertainty values are in units of <br>\n",
1123+
"<em>erg s<sup>-1</sup> cm<sup>-2</sup> · Å<sup>-1</sup></em> and scaled by 10<sup>-17</sup> (`cfg.fluxunits` and `cfg.fluxscale`).\n",
1124+
"\n",
1125+
"There are several emission lines in VY2-2's spectrum. A list of emission lines is provided in Table 2 of [WFC3 ISR 2015-10](https://www.stsci.edu/files/live/sites/www/files/home/hst/instrumentation/wfc3/documentation/instrument-science-reports-isrs/_documents/2015/WFC3-2015-10.pdf) (Bohlin et al.), <br>\n",
1126+
"which has been copied over to this notebook in the cell below.\n",
1127+
"\n"
11211128
]
11221129
},
11231130
{
@@ -1143,20 +1150,19 @@
11431150
"\n",
11441151
"# create wavelength mask\n",
11451152
"lrange = (8000, 11550) \n",
1146-
"wav = (lrange[0] < dat['lamb']) & (dat['lamb'] < lrange[1])\n",
1153+
"wav = (lrange[0] < dat['WAVELENGTH']) & (dat['WAVELENGTH'] < lrange[1])\n",
11471154
"\n",
11481155
"# plot spectrum\n",
1149-
"ax.errorbar(dat['lamb'][wav], \n",
1150-
" dat['flam'][wav]*cfg.fluxscale/1e-13, \n",
1151-
" yerr=dat['func'][wav]*cfg.fluxscale/1e-13, \n",
1156+
"ax.errorbar(dat['WAVELENGTH'][wav], \n",
1157+
" dat['FLUX'][wav]*cfg.fluxscale/1e-13, \n",
1158+
" yerr=dat['UNCERTAINTY'][wav]*cfg.fluxscale/1e-13, \n",
11521159
" marker='.', markersize=5)\n",
11531160
"\n",
1154-
"# overlay known emission lines (vacuum)\n",
1155-
"ax.axvline(9069, ls='--', c='k', lw=1) # [SIII]; S²⁺\n",
1156-
"ax.axvline(9531, ls='--', c='k', lw=1) # [SIII]; S²⁺ blended with H I\n",
1157-
"# ax.axvline(9546, ls='--', c='k', lw=1) # H I Pε; n = 8 → 3 blended with [SIII] \n",
1158-
"ax.axvline(10049, ls='--', c='k', lw=1) # H I P7; n = 7 → 3\n",
1159-
"ax.axvline(10830, ls='--', c='k', lw=1) # He I; 2³S → 2³P\n",
1161+
"# overlay known emission lines\n",
1162+
"ax.axvline(9070, ls='--', c='k', lw=1) # [SIII]; S²⁺\n",
1163+
"ax.axvline(9535, ls='--', c='k', lw=1) # [SIII]; S²⁺ blended with H I Pε\n",
1164+
"ax.axvline(10060, ls='--', c='k', lw=1) # H I P7; n = 7 → 3\n",
1165+
"ax.axvline(10834, ls='--', c='k', lw=1) # He I; 2³S → 2³P\n",
11601166
"\n",
11611167
"# matplotlib formatting\n",
11621168
"ax.minorticks_on()\n",
@@ -1204,7 +1210,7 @@
12041210
"## About this Notebook \n",
12051211
"\n",
12061212
"**Author:** Benjamin Kuhn, WFC3 Team <br>\n",
1207-
"**Last Updated:** 2026-03-19<br>\n",
1213+
"**Last Updated:** 2026-03-25<br>\n",
12081214
"**Created** 2026-01-15\n",
12091215
"\n",
12101216
"<a id=\"cite\"></a>\n",
@@ -1246,7 +1252,7 @@
12461252
"name": "python",
12471253
"nbconvert_exporter": "python",
12481254
"pygments_lexer": "ipython3",
1249-
"version": "3.11.0"
1255+
"version": "3.12.0"
12501256
}
12511257
},
12521258
"nbformat": 4,

0 commit comments

Comments
 (0)