Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example notebooks to use in-flight JWST data #1680

Merged
merged 28 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1522a68
Update Cubeviz example data
rosteen Sep 13, 2022
6ee2dd6
Update Specviz example data
rosteen Sep 13, 2022
c337e5a
Updated example data for Cubeviz and Specviz
rosteen Sep 16, 2022
8fe6dc4
Update Imviz example notebook to use JWST data
rosteen Sep 27, 2022
a9166d2
Update Mosviz NIRISS example notebook
rosteen Sep 27, 2022
af02d2f
Dropped some unneeded imports, updated Specviz2d
rosteen Sep 28, 2022
24c8534
Working on MosvizExample update
rosteen Sep 29, 2022
29e679f
Explain and simplify downloads, revert marker color
rosteen Sep 30, 2022
0bb2362
Keep old ACS example in separate notebook, point there for smaller fi…
rosteen Oct 3, 2022
723f9a7
Update changelog
rosteen Oct 3, 2022
5d54a93
Update notebooks/ImvizExample.ipynb
rosteen Oct 3, 2022
2323cdc
Update notebooks/Specviz2dExample.ipynb
rosteen Oct 3, 2022
38623fb
Revert NIRSpec example
rosteen Oct 3, 2022
47915f1
Use reprocessed NIRISS data
rosteen Oct 6, 2022
e273e4a
Remove changes from local testing
rosteen Oct 6, 2022
0031dfd
Use Cartwheel images instead of Carina, decrease number of markers
rosteen Oct 7, 2022
6ed0283
Use local_path in MAST download
rosteen Oct 7, 2022
b64d9af
Update the rest of the MAST downloads
rosteen Oct 7, 2022
e4e0812
Set cache flag to True in NIRISS example
rosteen Oct 7, 2022
c7ab95d
Use tempdir by default but allow user to specify other directory
rosteen Oct 12, 2022
15f5265
Update notebooks/Specviz2dExample.ipynb
rosteen Oct 12, 2022
44abc78
Update changelog
rosteen Oct 12, 2022
e9b1590
Add center_on note and fix viewer2 cells
rosteen Oct 12, 2022
80febf4
Zoom to an area of interest
rosteen Oct 12, 2022
230749a
Update notebooks/Specviz2dExample.ipynb
rosteen Oct 12, 2022
27f906a
Update notebooks/MosvizNIRISSExample.ipynb
rosteen Oct 12, 2022
3af9331
Add warning about calibration updates
rosteen Oct 13, 2022
32c7e90
Fix path
rosteen Oct 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Specviz2d
Other Changes and Additions
---------------------------

- Updated example notebooks (except MosvizExample) to use in-flight JWST data. [#1680]

3.0.2 (unreleased)
==================

Expand Down
36 changes: 23 additions & 13 deletions notebooks/CubevizExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"outputs": [],
"source": [
"import warnings\n",
"import tempfile\n",
"\n",
"from astropy.utils.data import download_file\n",
"from astroquery.mast import Observations\n",
"from photutils import CircularAperture\n",
"from regions import PixCoord, CirclePixelRegion\n",
"\n",
Expand All @@ -41,7 +42,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"cubeviz = Cubeviz()\n",
Expand All @@ -52,7 +55,17 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This file is originally from https://data.sdss.org/sas/dr14/manga/spectro/redux/v2_1_2/7495/stack/manga-7495-12704-LOGCUBE.fits.gz but has been modified to correct some inconsistencies in the way units are parsed. We ignore some warnings that appear during parsing."
"Here we download a JWST MIRI cube from [MAST](https://masttest.stsci.edu/) using `astroquery`, \n",
"to use as our example data. By default the downloaded file goes to your\n",
"temp directory, and thus may eventually be garbage collected (deleted) by your system.\n",
"If you would like to have the file permanently, simply uncomment the second line below\n",
"and provide the directory path on your system where you would like the file stored.\n",
"\n",
"One other thing to note about retrieving MAST data through astroquery is that it caches\n",
"the data by default. It is possible for files to be updated in MAST with more recent calibrations\n",
"but remain the same size, in which case your local cached file would not be replaced by the new\n",
"version. You can turn off caching by setting `cache=False` in the `download_file` call to\n",
"force it to re-download the file if desired."
]
},
{
Expand All @@ -61,11 +74,15 @@
"metadata": {},
"outputs": [],
"source": [
"fn = download_file('https://stsci.box.com/shared/static/28a88k1qfipo4yxc4p4d40v4axtlal8y.fits', cache=True)\n",
"data_dir = tempfile.gettempdir()\n",
"#data_dir = \"/User/username/Data/\"\n",
Comment on lines +77 to +78
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not a big fan but it's a good compromise until we have the caching debate later. Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to cache by default, but at least we can get this in now and have the discussion on the HOW to cache not block this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think right now, by default it won't redownload if it detects the file is already there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache=True by default in download_file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, right. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would adding a note saying to add cache=False to force a download be helpful here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a double take when I saw @jdavies-st in my morning email digest! Good to see ya :)

I don't think this is a major concern for these example notebooks since these notebooks are just... well examples. I'd hope people aren't taking these notebooks and doing real science on them!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hope people aren't taking these notebooks and doing real science on them

😬 🙊

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of a note in the notebook, though, in case someone copies the logic for their own data from MAST and might not understand this... feature.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't cache invalidation be MAST's problem and not ours? 😉

This is actually a problem of astroquery, not specific to MAST. Basically to see if the file it wants to download is cached, it checks the size. It does not do a checksum or hash. But with FITS, two different files can have the same size, and we've actually seen precisely this for JWST _uncal.fits data (and some other data products), which have quite different calibrations. All FITS header cards are the same size, even if the content of the keyword is different.

Of course there's big overhead to doing checksums, and that's probably a good enough reason as any for astroquery to not being doing it routinely. But just something to be aware of. =)

"\n",
"fn = \"jw02732-c1001_t004_miri_ch1-longmediumshort-_s3d.fits\"\n",
"result = Observations.download_file(f\"mast:JWST/product/{fn}\", local_path=f'{data_dir}/{fn}')\n",
Copy link
Contributor

@pllim pllim Oct 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not have to include filename in the path?

Suggested change
"result = Observations.download_file(f\"mast:JWST/product/{fn}\", local_path=f'{data_dir}/{fn}')\n",
"result = Observations.download_file(f\"mast:JWST/product/{fn}\", local_path=data_dir)\n",

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that you shouldn't, but when I tested without it failed (contrary to the Observations docs).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, a known bug: astropy/astroquery#2501

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I think it's supposed to be a path rather than a filename.

"\n",
"with warnings.catch_warnings():\n",
" warnings.simplefilter('ignore')\n",
" cubeviz.load_data(fn)"
" cubeviz.load_data(f'{data_dir}/{fn}')"
]
},
{
Expand Down Expand Up @@ -183,13 +200,6 @@
"subset1_spec1d = spectra_dict['Subset 1']\n",
"subset1_spec1d"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -208,7 +218,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.10.6"
}
},
"nbformat": 4,
Expand Down
Loading