Skip to content

Commit 813c4e5

Browse files
committed
change where uves files are cached
1 parent 68044be commit 813c4e5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tutorials/UVES/UVES.ipynb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@
5151
"metadata": {},
5252
"outputs": [],
5353
"source": [
54-
"# Set up matplotlib\n",
54+
"import pathlib\n",
55+
"import tarfile\n",
56+
"\n",
57+
"from astropy.utils.data import download_file\n",
5558
"import matplotlib.pyplot as plt\n",
5659
"%matplotlib inline"
5760
]
@@ -69,11 +72,9 @@
6972
"metadata": {},
7073
"outputs": [],
7174
"source": [
72-
"import tarfile\n",
73-
"from astropy.utils.data import download_file\n",
7475
"url = 'http://data.astropy.org/tutorials/UVES/data_UVES.tar.gz'\n",
7576
"f = tarfile.open(download_file(url, cache=True), mode='r|*')\n",
76-
"working_dir_path = '.' # CHANGE TO WHEREVER YOU WANT THE DATA TO BE EXTRACTED\n",
77+
"working_dir_path = pathlib.Path('~/.astropy/cache/download').expanduser()\n",
7778
"f.extractall(path=working_dir_path)"
7879
]
7980
},
@@ -135,11 +136,12 @@
135136
"from astropy.io import fits\n",
136137
"\n",
137138
"# os.path.join is a platform-independent way to join two directories\n",
138-
"globpath = os.path.join(working_dir_path, 'UVES/*.fits')\n",
139+
"globpath = working_dir_path / 'UVES'\n",
139140
"\n",
140141
"print(globpath)\n",
142+
"\n",
141143
"# glob searches through directories similar to the Unix shell\n",
142-
"filelist = glob(globpath)\n",
144+
"filelist = list(globpath.glob(\"*.fits\"))\n",
143145
"\n",
144146
"# sort alphabetically - given the way the filenames are\n",
145147
"# this also sorts in time\n",

0 commit comments

Comments
 (0)