Skip to content

Commit

Permalink
Update demo notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
duytnguyendtn committed May 31, 2023
1 parent a937636 commit cc513b3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 84 deletions.
30 changes: 20 additions & 10 deletions notebooks/CubevizExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@
"from photutils.aperture import CircularAperture\n",
"from regions import PixCoord, CirclePixelRegion\n",
"\n",
"from jdaviz import Cubeviz"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We create a Cubeviz instance and show it."
"import jdaviz"
]
},
{
Expand Down Expand Up @@ -80,9 +73,26 @@
"fn = \"jw02732-o004_t004_miri_ch1-shortmediumlong_s3d.fits\"\n",
"result = Observations.download_file(f\"mast:JWST/product/{fn}\", local_path=f'{data_dir}/{fn}')\n",
"\n",
"with warnings.catch_warnings():\n",
" warnings.simplefilter('ignore')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we can ask Jdaviz to automatically load the data. Jdaviz will automatically detect Cubeviz as the most appropriate configuration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with warnings.catch_warnings():\n",
" warnings.simplefilter('ignore')\n",
" cubeviz.load_data(f'{data_dir}/{fn}')"
" cubeviz = jdaviz.open(f'{data_dir}/{fn}')"
]
},
{
Expand Down Expand Up @@ -225,7 +235,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down
26 changes: 3 additions & 23 deletions notebooks/Specviz2dExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,7 @@
"\n",
"from astroquery.mast import Observations\n",
"\n",
"from jdaviz import Specviz2d\n",
"\n",
"specviz2d = Specviz2d()"
]
},
{
"cell_type": "markdown",
"id": "0ed07713",
"metadata": {},
"source": [
"## Display Specviz2d"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "45802673",
"metadata": {},
"outputs": [],
"source": [
"specviz2d.show()"
"import jdaviz"
]
},
{
Expand Down Expand Up @@ -94,7 +74,7 @@
"metadata": {},
"outputs": [],
"source": [
"specviz2d.load_data(f'{data_dir}/{fn}')"
"jdaviz.open(f'{data_dir}/{fn}')"
]
}
],
Expand All @@ -114,7 +94,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down
73 changes: 22 additions & 51 deletions notebooks/SpecvizExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,60 +26,16 @@
"\n",
"# Suppress warnings\n",
"with warnings.catch_warnings():\n",
" warnings.simplefilter(\"ignore\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create Specviz via Helper"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from jdaviz import Specviz\n",
"specviz = Specviz()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Display Specviz\n",
" warnings.simplefilter(\"ignore\")\n",
"\n",
"Note: you probably want to pick one of the three options below depending on preference. Also not the latter two will only work in JupyterLab, not the \"classic\" notebook interface."
"import jdaviz"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This will show Specviz inline in the notebook"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"specviz.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load a file to Specviz\n",
"## Download Data\n",
"\n",
"Here we download a JWST spectrum from [MAST](https://masttest.stsci.edu/) using `astroquery`. \n",
"By default the downloaded file goes to your temp directory, and thus may eventually be \n",
Expand All @@ -106,9 +62,24 @@
"#data_dir = \"/User/username/Data/\"\n",
"\n",
"fn = \"jw02732-o004_t004_miri_ch1-shortmediumlong_x1d.fits\"\n",
"result = Observations.download_file(f\"mast:JWST/product/{fn}\", local_path=f'{data_dir}/{fn}')\n",
"\n",
"specviz.load_spectrum(f'{data_dir}/{fn}', \"myfile\")"
"result = Observations.download_file(f\"mast:JWST/product/{fn}\", local_path=f'{data_dir}/{fn}')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Open in Jdaviz\n",
"Jdaviz can automatically detect the correct configuration and load the data by using `jdaviz.open`. By default, jdaviz will display the application automatically. To only return the helper, set `show=False`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"specviz = jdaviz.open(f'{data_dir}/{fn}', show=True, data_label=\"myfile\")"
]
},
{
Expand Down Expand Up @@ -293,7 +264,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down

0 comments on commit cc513b3

Please sign in to comment.