-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1014 from ibusko/specviz-load-and-combine
Specviz: load a SpectrumList and combine everything
- Loading branch information
Showing
6 changed files
with
238 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "17d43695", | ||
"metadata": {}, | ||
"source": [ | ||
"# SpectrumList reading by Specviz" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7d96dae3", | ||
"metadata": {}, | ||
"source": [ | ||
"This demonstrates the reading of a set of x1d files by specviz, using internally an instance of SpectrumList.\n", | ||
"\n", | ||
"The desired result is the combination (splicing) of all spectra in the list." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "96971b54", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import glob\n", | ||
"import tempfile\n", | ||
"import urllib\n", | ||
"import tarfile\n", | ||
"from zipfile import ZipFile\n", | ||
"\n", | ||
"from astropy.utils.data import download_file\n", | ||
"\n", | ||
"from specutils import SpectrumList\n", | ||
"\n", | ||
"from jdaviz import Specviz" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5dbebe90", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Unzip files if they haven't already been unzipped\n", | ||
"if os.path.exists(\"reduced/\"):\n", | ||
" print(\"Pipeline 3 Data Exists\")\n", | ||
"else:\n", | ||
" url = 'https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/MRS_Mstar_analysis/reduced.tar.gz'\n", | ||
" urllib.request.urlretrieve(url, './reduced.tar.gz')\n", | ||
"\n", | ||
" tar = tarfile.open('./reduced.tar.gz', \"r:gz\")\n", | ||
" tar.extractall()\n", | ||
" tar.close()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f5657b71", | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"specviz = Specviz()\n", | ||
"specviz.app" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4b3a8944", | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"specviz.load_spectrum('reduced/')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e03a3364", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |