-
Notifications
You must be signed in to change notification settings - Fork 80
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
Changes from all commits
1522a68
6ee2dd6
c337e5a
8fe6dc4
a9166d2
af02d2f
24c8534
29e679f
0bb2362
723f9a7
5d54a93
2323cdc
38623fb
47915f1
e273e4a
0031dfd
6ed0283
b64d9af
e4e0812
c7ab95d
15f5265
44abc78
e9b1590
80febf4
230749a
27f906a
3af9331
32c7e90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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", | ||||||
|
@@ -41,7 +42,9 @@ | |||||
{ | ||||||
"cell_type": "code", | ||||||
"execution_count": null, | ||||||
"metadata": {}, | ||||||
"metadata": { | ||||||
"scrolled": false | ||||||
}, | ||||||
"outputs": [], | ||||||
"source": [ | ||||||
"cubeviz = Cubeviz()\n", | ||||||
|
@@ -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." | ||||||
] | ||||||
}, | ||||||
{ | ||||||
|
@@ -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", | ||||||
"\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", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should not have to include filename in the path?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmmm! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, a known bug: astropy/astroquery#2501 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}')" | ||||||
] | ||||||
}, | ||||||
{ | ||||||
|
@@ -183,13 +200,6 @@ | |||||
"subset1_spec1d = spectra_dict['Subset 1']\n", | ||||||
"subset1_spec1d" | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "code", | ||||||
"execution_count": null, | ||||||
"metadata": {}, | ||||||
"outputs": [], | ||||||
"source": [] | ||||||
} | ||||||
], | ||||||
"metadata": { | ||||||
|
@@ -208,7 +218,7 @@ | |||||
"name": "python", | ||||||
"nbconvert_exporter": "python", | ||||||
"pygments_lexer": "ipython3", | ||||||
"version": "3.9.7" | ||||||
"version": "3.10.6" | ||||||
} | ||||||
}, | ||||||
"nbformat": 4, | ||||||
|
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache=True
by default indownload_file
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, right. Thanks!
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😬 🙊
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. =)