Skip to content

Commit

Permalink
Merge pull request #240 from camipacifici/nbmos
Browse files Browse the repository at this point in the history
Update and add screenshots in MOS notebook
  • Loading branch information
camipacifici authored Aug 28, 2024
2 parents cf40b9c + 96af61e commit 8c46ac2
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 14 deletions.
75 changes: 61 additions & 14 deletions notebooks/NIRSpec/mos_spectroscopy_advanced/MOSspec_advanced.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Check versions. Should be:\n",
"## Check versions. Latest working environment is:\n",
"\n",
"Numpy: 1.25.2<br>\n",
"Astropy: 5.3.2<br>\n",
"Specutils: 1.11.0<br>\n",
"Jdaviz: 3.7"
"Numpy: 2.1.0<br>\n",
"Astropy: 6.1.2<br>\n",
"Specutils: 1.16.0<br>\n",
"Jdaviz: 3.10.3"
]
},
{
Expand Down Expand Up @@ -257,9 +257,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Use Specviz2d to extract a better 1D spectrum\n",
"\n",
"We open the Spectral Extraction plugin and select the appropriate trace (Polynomial, order 3, on pixel 2), background (Manual, on pixel 8, width 2, statistic average), and extraction (From Plugin, Horne). We then click Extract and inspect the extracted spectrum in the 1D viewer."
"## Use Specviz2d to extract a better 1D spectrum"
]
},
{
Expand Down Expand Up @@ -290,6 +288,19 @@
"This is being worked on."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We open the Spectral Extraction plugin and select the appropriate trace (Polynomial, order 3, on pixel 2), background (Manual, on pixel 8, width 2, statistic average), and extraction (From Plugin, Horne). We then click Extract and inspect the extracted spectrum in the 1D viewer.\n",
"\n",
"<img src='./trace.png' alt=\"Specviz2d with spectral extraction plugin open showing the trace parameters.\" width=\"500\"/>\n",
"\n",
"<img src='./background.png' alt=\"Specviz2d with spectral extraction plugin open showing the background parameters.\" width=\"500\"/>\n",
"\n",
"<img src='./extraction.png' alt=\"Specviz2d with spectral extraction plugin open showing the extraction parameters.\" width=\"500\"/>"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -330,7 +341,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"There are still some artifacts in the data, but we can select a subset masking the artifacts and get out a spectrum without unwanted spikes. We can do so using the tool to select a subset with the \"add\" option (in the top bar) to select multiple regions as part of a single subset."
"There are still some artifacts in the data, but we can select a subset masking the artifacts and get out a spectrum without unwanted spikes. We can do so using the tool to select a subset with the \"add\" option (in the top bar) to select multiple regions as part of a single subset.\n",
"\n",
"<img src='./subset_add.png' alt=\"Specviz showing how to select a subset and choose the add option.\" width=\"600\"/>"
]
},
{
Expand All @@ -348,11 +361,11 @@
" print(\"There are no subsets selected.\")\n",
" region1_exists = False\n",
" \n",
"# Spectral region for masking artifacts\n",
"# Spectral region for masking artifacts just around [OII]\n",
"if not region1_exists:\n",
" sv = specviz.app.get_viewer('spectrum-viewer')\n",
" sv.toolbar_active_subset.selected = []\n",
" sv.apply_roi(XRangeROI(1., 1.58)) "
" sv.apply_roi(XRangeROI(1., 1.27)) "
]
},
{
Expand Down Expand Up @@ -421,6 +434,13 @@
"I can do some analysis on the spectrum using the plugins in the GUI. For reproducibility, I can do the same thing from the API, changing the parameters in the plugins programmatically."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Select regions"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -453,6 +473,15 @@
"sv.apply_roi(XRangeROI(1.05, 1.25)) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Line analysis\n",
"\n",
"<img src='./line_analysis.png' alt=\"Specviz showing the region on the [OII] line and the line analysis plugin.\" width=\"600\"/>"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -493,7 +522,7 @@
"source": [
"# Input the values for the continuum\n",
"plugin_la.continuum = 'Surrounding'\n",
"plugin_la.width = 7"
"plugin_la.continuum_width = 7"
]
},
{
Expand All @@ -506,6 +535,15 @@
"plugin_la.get_results()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Line lists\n",
"\n",
"<img src='./line_lists.png' alt=\"Specviz showing the line list plugin and the redshift identified with the [OII] doublet.\" width=\"600\"/>"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -540,6 +578,15 @@
"Open line list plugin. Select the SDSS IV line list. Load the Oxygen II lines and Hb. Go back to line analysis plugin and associate the Oxygen II line with the line we just analyzed."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Model fitting\n",
"\n",
"<img src='./model_fitting.png' alt=\"Specviz showing a model fit to the continuum and the [OII] line.\" width=\"600\"/>"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -1104,7 +1151,7 @@
"metadata": {},
"source": [
"Notebook created by Camilla Pacifici (cpacifici@stsci.edu)<br>\n",
"Updated on September 14, 2023"
"Updated on August 28, 2024"
]
}
],
Expand All @@ -1124,7 +1171,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8c46ac2

Please sign in to comment.