Skip to content

Commit 03fdc50

Browse files
committed
Use download_file function to downlaod tar file with UVES data
1 parent 1b9fb60 commit 03fdc50

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tutorials/UVES/UVES.ipynb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@
5555
"cell_type": "code",
5656
"collapsed": false,
5757
"input": [
58-
"import urllib2, tarfile\n",
58+
"import tarfile\n",
59+
"from astropy.utils.data import download_file\n",
5960
"url = 'http://python4astronomers.github.io/_downloads/astropy_UVES.tar.gz'\n",
60-
"tarfile.open(fileobj=urllib2.urlopen(url), mode='r|*').extractall()\n",
61-
"cd UVES\n",
62-
"ls"
61+
"f = tarfile.open(download_file(url, cache=True), mode='r|*')\n",
62+
"location_for_data_file = '.' # CHANGE TO WHEREVER YOU WANT THE DATA TO BE EXTRACTED\n",
63+
"f.extractall(path=location_for_data_file)"
6364
],
6465
"language": "python",
6566
"metadata": {},
@@ -148,7 +149,7 @@
148149
"from astropy.io import fits\n",
149150
"\n",
150151
"# glob searches through directories similar to the Unix shell\n",
151-
"filelist = glob('*.fits')\n",
152+
"filelist = glob('UVES/*.fits')\n",
152153
"# sort alphabetically - given the way the filenames are\n",
153154
"# this also sorts in time\n",
154155
"filelist.sort()\n",
@@ -1475,4 +1476,4 @@
14751476
"metadata": {}
14761477
}
14771478
]
1478-
}
1479+
}

0 commit comments

Comments
 (0)