|
21 | 21 | "\n", |
22 | 22 | "<div style=\"float:right; width:250 px\"><img src=\"https://unidata.github.io/siphon/latest/_static/siphon_150x150.png\" alt=\"TDS\" style=\"height: 200px;\"></div>\n", |
23 | 23 | "\n", |
24 | | - "## Overview:\n", |
25 | | - "\n", |
26 | | - "* **Teaching:** 10 minutes\n", |
27 | | - "* **Exercises:** 10 minutes\n", |
28 | | - "\n", |
29 | 24 | "### Questions\n", |
30 | 25 | "1. What is a THREDDS Data Server (TDS)?\n", |
31 | 26 | "1. How can I use Siphon to access a TDS?\n", |
32 | 27 | "\n", |
33 | 28 | "### Objectives\n", |
34 | | - "1. <a href=\"#threddsintro\">Use siphon to access a THREDDS catalog</a>\n", |
35 | | - "1. <a href=\"#filtering\">Find data within the catalog that we wish to access</a>\n", |
36 | | - "1. <a href=\"#dataaccess\">Use siphon to perform remote data access</a>" |
| 29 | + "1. <a href=\"#threddsintro\">Use Siphon to Access a THREDDS Catalog</a>\n", |
| 30 | + "1. <a href=\"#filtering\">Filtering Data</a>\n", |
| 31 | + "1. <a href=\"#dataaccess\">Use Siphon to Perform Remote Data Access</a>" |
37 | 32 | ] |
38 | 33 | }, |
39 | 34 | { |
40 | 35 | "cell_type": "markdown", |
41 | 36 | "metadata": {}, |
42 | 37 | "source": [ |
43 | 38 | "<a name=\"threddsintro\"></a>\n", |
44 | | - "## 1. What is THREDDS?\n", |
| 39 | + "## 1. Use Siphon to Access a THREDDS Catalog\n", |
45 | 40 | "\n", |
46 | | - " * Server for providing remote access to datasets\n", |
47 | | - " * Variety of services for accesing data:\n", |
| 41 | + "THREDDS is a server for providing remote access to datasets and a variety of server-side services. THREDDS make data access more uniform regardless of the on-disk format.\n", |
| 42 | + " * Data Access Services:\n", |
48 | 43 | " - HTTP Download\n", |
49 | 44 | " - Web Mapping/Coverage Service (WMS/WCS)\n", |
50 | 45 | " - OPeNDAP\n", |
51 | 46 | " - NetCDF Subset Service\n", |
52 | 47 | " - CDMRemote\n", |
53 | | - " * Provides a more uniform way to access different types/formats of data" |
| 48 | + " \n", |
| 49 | + "There is a server with real-time data setup at [http://thredds.ucar.edu](http://thredds.ucar.edu) that we'll use to explore the capability of THREDDS and learn how to access data. Let's open that link and explore in the browser what's available on THREDDS. Explore the NEXRAD level 3 data specifically.\n", |
| 50 | + "\n", |
| 51 | + "### THREDDS Catalogs\n", |
| 52 | + "- XML descriptions of data and metadata\n", |
| 53 | + "- Access methods\n", |
| 54 | + "- Easily processed with `siphon.catalog.TDSCatalog`" |
54 | 55 | ] |
55 | 56 | }, |
56 | 57 | { |
57 | | - "cell_type": "markdown", |
58 | | - "metadata": { |
59 | | - "slideshow": { |
60 | | - "slide_type": "subslide" |
61 | | - } |
62 | | - }, |
| 58 | + "cell_type": "code", |
| 59 | + "execution_count": null, |
| 60 | + "metadata": {}, |
| 61 | + "outputs": [], |
63 | 62 | "source": [ |
64 | | - "## THREDDS Demo\n", |
65 | | - "http://thredds.ucar.edu" |
| 63 | + "from datetime import datetime, timedelta\n", |
| 64 | + "\n", |
| 65 | + "from siphon.catalog import TDSCatalog" |
66 | 66 | ] |
67 | 67 | }, |
68 | 68 | { |
69 | 69 | "cell_type": "markdown", |
70 | 70 | "metadata": {}, |
71 | 71 | "source": [ |
72 | | - "### THREDDS Catalogs\n", |
73 | | - "- XML descriptions of data and metadata\n", |
74 | | - "- Access methods\n", |
75 | | - "- Easily handled with `siphon.catalog.TDSCatalog`" |
| 72 | + "Let's get data from yesterday at this time. We'll use the timedelta object to do this in an easy way." |
76 | 73 | ] |
77 | 74 | }, |
78 | 75 | { |
|
81 | 78 | "metadata": {}, |
82 | 79 | "outputs": [], |
83 | 80 | "source": [ |
84 | | - "from datetime import datetime, timedelta\n", |
85 | | - "from siphon.catalog import TDSCatalog\n", |
86 | 81 | "date = datetime.utcnow() - timedelta(days=1)\n", |
| 82 | + "print(date)" |
| 83 | + ] |
| 84 | + }, |
| 85 | + { |
| 86 | + "cell_type": "markdown", |
| 87 | + "metadata": {}, |
| 88 | + "source": [ |
| 89 | + "We'll then go find the URL for the level 3 radar data. Let's get the N0Q (tilt 1 base reflectivity) for the LRX radar. Notice that we change the `html` extension to `xml`. Siphon will do that for us, but issue a warning." |
| 90 | + ] |
| 91 | + }, |
| 92 | + { |
| 93 | + "cell_type": "code", |
| 94 | + "execution_count": null, |
| 95 | + "metadata": {}, |
| 96 | + "outputs": [], |
| 97 | + "source": [ |
87 | 98 | "cat = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/nexrad/level3/'\n", |
88 | 99 | " f'N0Q/LRX/{date:%Y%m%d}/catalog.xml')" |
89 | 100 | ] |
90 | 101 | }, |
| 102 | + { |
| 103 | + "cell_type": "code", |
| 104 | + "execution_count": null, |
| 105 | + "metadata": {}, |
| 106 | + "outputs": [], |
| 107 | + "source": [ |
| 108 | + "cat.datasets" |
| 109 | + ] |
| 110 | + }, |
91 | 111 | { |
92 | 112 | "cell_type": "markdown", |
93 | 113 | "metadata": {}, |
|
101 | 121 | "metadata": {}, |
102 | 122 | "source": [ |
103 | 123 | "<a name=\"filtering\"></a>\n", |
104 | | - "## 2. Filtering data" |
| 124 | + "## 2. Filtering Data" |
105 | 125 | ] |
106 | 126 | }, |
107 | 127 | { |
108 | 128 | "cell_type": "markdown", |
109 | 129 | "metadata": {}, |
110 | 130 | "source": [ |
111 | | - "We *could* manually figure out what dataset we're looking for and generate that name (or index). Siphon provides some helpers to simplify this process, provided the names of the dataset follow a pattern with the timestamp in the name:" |
| 131 | + "We *could* manually look through that list above and figure out what dataset we're looking for and generate that name (or index). Siphon provides some helpers to simplify this process, provided the names of the dataset follow a pattern with the timestamp in the name:" |
112 | 132 | ] |
113 | 133 | }, |
114 | 134 | { |
|
143 | 163 | "cell_type": "markdown", |
144 | 164 | "metadata": {}, |
145 | 165 | "source": [ |
146 | | - "### Exercise\n", |
147 | | - "* Starting from http://thredds.ucar.edu/thredds/catalog/satellite/SFC-T/SUPER-NATIONAL_1km/catalog.html, find the composites for the previous day.\n", |
148 | | - "* Grab the URL and create a TDSCatalog instance.\n", |
149 | | - "* Using Siphon, find the data available in the catalog between 12Z and 18Z on the previous day." |
| 166 | + "<div class=\"alert alert-success\">\n", |
| 167 | + " <b>EXERCISE</b>:\n", |
| 168 | + " <ul>\n", |
| 169 | + " <li>Starting from http://thredds.ucar.edu/, find the level 2 radar data for the Tulsa, OK radar (KINX) for the previous day.</li>\n", |
| 170 | + " <li>Grab the URL and create a TDSCatalog instance.</li>\n", |
| 171 | + " <li>Using Siphon, find the data available in the catalog between 12Z and 18Z on the previous day.</li>\n", |
| 172 | + " </ul>\n", |
| 173 | + "</div>" |
150 | 174 | ] |
151 | 175 | }, |
152 | 176 | { |
|
155 | 179 | "metadata": {}, |
156 | 180 | "outputs": [], |
157 | 181 | "source": [ |
158 | | - "# YOUR CODE GOES HERE\n" |
| 182 | + "# YOUR CODE GOES HERE" |
159 | 183 | ] |
160 | 184 | }, |
161 | 185 | { |
162 | 186 | "cell_type": "markdown", |
163 | 187 | "metadata": {}, |
164 | 188 | "source": [ |
165 | | - "#### Solution" |
| 189 | + "<div class=\"alert alert-info\">\n", |
| 190 | + " <b>SOLUTION</b>\n", |
| 191 | + "</div>" |
166 | 192 | ] |
167 | 193 | }, |
168 | 194 | { |
|
171 | 197 | "metadata": {}, |
172 | 198 | "outputs": [], |
173 | 199 | "source": [ |
174 | | - "# %load solutions/datasets.py\n" |
| 200 | + "# %load solutions/datasets.py" |
175 | 201 | ] |
176 | 202 | }, |
177 | 203 | { |
|
187 | 213 | "metadata": {}, |
188 | 214 | "source": [ |
189 | 215 | "<a name=\"dataaccess\"></a>\n", |
190 | | - "## 3. Accessing data" |
| 216 | + "## 3. Use Siphon to Perform Remote Data Access\n", |
| 217 | + "\n", |
| 218 | + "Accessing catalogs is only part of the story; Siphon is much more useful if you're trying to access/download datasets.\n", |
| 219 | + "\n", |
| 220 | + "For instance, using our data that we just retrieved:" |
191 | 221 | ] |
192 | 222 | }, |
193 | 223 | { |
194 | | - "cell_type": "markdown", |
195 | | - "metadata": { |
196 | | - "slideshow": { |
197 | | - "slide_type": "subslide" |
198 | | - } |
199 | | - }, |
| 224 | + "cell_type": "code", |
| 225 | + "execution_count": null, |
| 226 | + "metadata": {}, |
| 227 | + "outputs": [], |
200 | 228 | "source": [ |
201 | | - "Accessing catalogs is only part of the story; Siphon is much more useful if you're trying to access/download datasets.\n", |
202 | | - "\n", |
203 | | - "For instance, using our data that we just retrieved:" |
| 229 | + "# Solution from above in case you had trouble\n", |
| 230 | + "date = datetime.utcnow() - timedelta(days=1)\n", |
| 231 | + "cat = TDSCatalog(f'https://thredds.ucar.edu/thredds/catalog/nexrad/level2/KINX/{date:%Y%m%d}/catalog.xml')\n", |
| 232 | + "request_time = date.replace(hour=12, minute=0, second=0, microsecond=0)\n", |
| 233 | + "datasets = cat.datasets.filter_time_range(request_time, request_time + timedelta(hours=6))" |
204 | 234 | ] |
205 | 235 | }, |
206 | 236 | { |
|
232 | 262 | "ds.download()" |
233 | 263 | ] |
234 | 264 | }, |
| 265 | + { |
| 266 | + "cell_type": "markdown", |
| 267 | + "metadata": {}, |
| 268 | + "source": [ |
| 269 | + "Look in your file explorer panel or run the cell below to verify that we did actually download the file!" |
| 270 | + ] |
| 271 | + }, |
235 | 272 | { |
236 | 273 | "cell_type": "code", |
237 | 274 | "execution_count": null, |
|
294 | 331 | "cell_type": "markdown", |
295 | 332 | "metadata": {}, |
296 | 333 | "source": [ |
297 | | - "By default this uses CDMRemote (if available), but it's also possible to ask for OPeNDAP (using netCDF4-python)." |
| 334 | + "By default this uses CDMRemote (if available), but it's also possible to ask for OPeNDAP (using netCDF4-python). There is even XArray support which is great with the declarative plotting interface - more on that later." |
298 | 335 | ] |
299 | 336 | }, |
300 | 337 | { |
|
331 | 368 | "name": "python", |
332 | 369 | "nbconvert_exporter": "python", |
333 | 370 | "pygments_lexer": "ipython3", |
334 | | - "version": "3.7.3" |
| 371 | + "version": "3.7.6" |
335 | 372 | } |
336 | 373 | }, |
337 | 374 | "nbformat": 4, |
338 | | - "nbformat_minor": 2 |
| 375 | + "nbformat_minor": 4 |
339 | 376 | } |
0 commit comments