diff --git a/notebooks/CubevizExample.ipynb b/notebooks/CubevizExample.ipynb index 73ef66238f..48e89d593c 100644 --- a/notebooks/CubevizExample.ipynb +++ b/notebooks/CubevizExample.ipynb @@ -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" ] }, { @@ -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}')" ] }, { @@ -225,7 +235,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.8" + "version": "3.10.10" } }, "nbformat": 4, diff --git a/notebooks/Specviz2dExample.ipynb b/notebooks/Specviz2dExample.ipynb index 32d7990d1a..69c56c9e60 100644 --- a/notebooks/Specviz2dExample.ipynb +++ b/notebooks/Specviz2dExample.ipynb @@ -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" ] }, { @@ -94,7 +74,7 @@ "metadata": {}, "outputs": [], "source": [ - "specviz2d.load_data(f'{data_dir}/{fn}')" + "jdaviz.open(f'{data_dir}/{fn}')" ] } ], @@ -114,7 +94,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.10.10" } }, "nbformat": 4, diff --git a/notebooks/SpecvizExample.ipynb b/notebooks/SpecvizExample.ipynb index 5f671b4864..c21c221acf 100644 --- a/notebooks/SpecvizExample.ipynb +++ b/notebooks/SpecvizExample.ipynb @@ -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", @@ -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\")" ] }, { @@ -293,7 +264,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.10.10" } }, "nbformat": 4,