Skip to content

Commit 24fc482

Browse files
committed
various last-minute tweaks, mostly for path that files end up in
1 parent b4666f1 commit 24fc482

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

tutorials/UVES/UVES.ipynb

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"astropy-tutorials": {
44
"author": "Hans Moritz G\u00fcnther <hguenther@cfa.harvard.edu>, Miguel de Val-Borro <valborro@princeton.edu>",
55
"date": "August 2014",
6+
"description": "This tutorial demonstrates the data analysis of MN Lup obtained with the UVES spectrograph on the VLT.",
67
"link_name": "Analyzing UVES Spectroscopy with Astropy",
78
"name": "",
8-
"published": true,
9-
"description" : "This tutorial demonstrates the data analysis of MN Lup obtained with the UVES spectrograph on the VLT."
9+
"published": true
1010
},
11-
"signature": "sha256:1f74796dfdd5b13d06d2a9bd9913a15fe6aa475e7967f8bd969ddcf17fb1e825"
11+
"signature": "sha256:fd9515822031a7a0d16c78263eb9a448fc057188c6f52dc3c59b33c2b20f3354"
1212
},
1313
"nbformat": 3,
1414
"nbformat_minor": 0,
@@ -78,13 +78,7 @@
7878
"cell_type": "markdown",
7979
"metadata": {},
8080
"source": [
81-
"Please download the tar file and extract\n",
82-
"the content by executing the python code below.\n",
83-
"Executing this block will download and extract a tar file with data\n",
84-
"necessary for this tutorial. By default it will run in whatever\n",
85-
"directory you have placed this notebook. If that's some place\n",
86-
"you don't want to fill with data files, change the\n",
87-
"location_for_data_file variable."
81+
"Please download the tar file and extract the content by executing the python code below. Executing this block will download and extract a tar file with data necessary for this tutorial. By default it will run in whatever directory you have placed this notebook. If that's some place you don't want to fill with data files, change the `working_dir_path` variable."
8882
]
8983
},
9084
{
@@ -95,13 +89,12 @@
9589
"from astropy.utils.data import download_file\n",
9690
"url = 'http://data.astropy.org/tutorials/UVES/data_UVES.tar.gz'\n",
9791
"f = tarfile.open(download_file(url, cache=True), mode='r|*')\n",
98-
"location_for_data_file = '.' # CHANGE TO WHEREVER YOU WANT THE DATA TO BE EXTRACTED\n",
99-
"f.extractall(path=location_for_data_file)"
92+
"working_dir_path = '.' # CHANGE TO WHEREVER YOU WANT THE DATA TO BE EXTRACTED\n",
93+
"f.extractall(path=working_dir_path)"
10094
],
10195
"language": "python",
10296
"metadata": {},
103-
"outputs": [],
104-
"prompt_number": 1
97+
"outputs": []
10598
},
10699
{
107100
"cell_type": "heading",
@@ -153,14 +146,20 @@
153146
"collapsed": false,
154147
"input": [
155148
"from glob import glob\n",
149+
"import os\n",
156150
"\n",
157151
"import numpy as np\n",
158152
"\n",
159153
"from astropy.wcs import WCS\n",
160154
"from astropy.io import fits\n",
161155
"\n",
156+
"# os.path.join is a platform-independent way to join two directories\n",
157+
"globpath = os.path.join(working_dir_path, 'UVES/*.fits')\n",
158+
"\n",
159+
"print globpath\n",
162160
"# glob searches through directories similar to the Unix shell\n",
163-
"filelist = glob('UVES/*.fits')\n",
161+
"filelist = glob(globpath)\n",
162+
"\n",
164163
"# sort alphabetically - given the way the filenames are\n",
165164
"# this also sorts in time\n",
166165
"filelist.sort()"
@@ -1055,7 +1054,7 @@
10551054
"ewcol = Column(name = 'EW', data = ew, format = '{:.1f}', unit = '\\\\AA')\n",
10561055
"tab = Table((datecol, pcol, ewcol))\n",
10571056
"# latexdicts['AA'] contains the style specifics for A&A (\\hline etc.)\n",
1058-
"tab.write('EWtab.tex', latexdict = ascii.latexdicts['AA'])"
1057+
"tab.write(os.path.join(working_dir, 'EWtab.tex'), latexdict = ascii.latexdicts['AA'])"
10591058
],
10601059
"language": "python",
10611060
"metadata": {},
@@ -1424,4 +1423,4 @@
14241423
"metadata": {}
14251424
}
14261425
]
1427-
}
1426+
}

0 commit comments

Comments
 (0)