|
51 | 51 | "metadata": {}, |
52 | 52 | "outputs": [], |
53 | 53 | "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", |
55 | 58 | "import matplotlib.pyplot as plt\n", |
56 | 59 | "%matplotlib inline" |
57 | 60 | ] |
|
69 | 72 | "metadata": {}, |
70 | 73 | "outputs": [], |
71 | 74 | "source": [ |
72 | | - "import tarfile\n", |
73 | | - "from astropy.utils.data import download_file\n", |
74 | 75 | "url = 'http://data.astropy.org/tutorials/UVES/data_UVES.tar.gz'\n", |
75 | 76 | "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", |
77 | 78 | "f.extractall(path=working_dir_path)" |
78 | 79 | ] |
79 | 80 | }, |
|
135 | 136 | "from astropy.io import fits\n", |
136 | 137 | "\n", |
137 | 138 | "# 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", |
139 | 140 | "\n", |
140 | 141 | "print(globpath)\n", |
| 142 | + "\n", |
141 | 143 | "# glob searches through directories similar to the Unix shell\n", |
142 | | - "filelist = glob(globpath)\n", |
| 144 | + "filelist = list(globpath.glob(\"*.fits\"))\n", |
143 | 145 | "\n", |
144 | 146 | "# sort alphabetically - given the way the filenames are\n", |
145 | 147 | "# this also sorts in time\n", |
|
0 commit comments