|
97 | 97 | "outputs": [], |
98 | 98 | "source": [ |
99 | 99 | "# Ask for just a few columns instead of the full ~40-column record.\n", |
100 | | - "site_info, _ = waterdata.get_monitoring_locations(\n", |
| 100 | + "sites_info, _ = waterdata.get_monitoring_locations(\n", |
101 | 101 | " monitoring_location_id=\"USGS-01491000\",\n", |
102 | 102 | " properties=[\n", |
103 | 103 | " \"monitoring_location_id\",\n", |
|
106 | 106 | " \"monitoring_location_name\",\n", |
107 | 107 | " ],\n", |
108 | 108 | ")\n", |
109 | | - "site_info.drop(columns=\"geometry\")" |
| 109 | + "sites_info.drop(columns=\"geometry\")" |
110 | 110 | ] |
111 | 111 | }, |
112 | 112 | { |
|
126 | 126 | "\n", |
127 | 127 | "The APIs accept [CQL2](https://www.loc.gov/standards/sru/cql/) expressions for\n", |
128 | 128 | "complex queries through the `filter` / `filter_lang` arguments. See the\n", |
129 | | - "[General retrieval and CQL2](#General-retrieval-and-CQL2) section below.\n", |
| 129 | + "[General retrieval and CQL2](#general-retrieval-and-cql2) section below.\n", |
130 | 130 | "\n", |
131 | 131 | "### Simple features\n", |
132 | 132 | "\n", |
|
176 | 176 | "metadata": {}, |
177 | 177 | "outputs": [], |
178 | 178 | "source": [ |
179 | | - "sites_information, _ = waterdata.get_monitoring_locations(\n", |
| 179 | + "sites_info, _ = waterdata.get_monitoring_locations(\n", |
180 | 180 | " monitoring_location_id=\"USGS-01491000\"\n", |
181 | 181 | ")\n", |
182 | | - "print(f\"{sites_information.shape[1]} columns returned\")\n", |
183 | | - "sites_information.drop(columns=\"geometry\").T" |
| 182 | + "print(f\"{sites_info.shape[1]} columns returned\")\n", |
| 183 | + "sites_info.drop(columns=\"geometry\").T" |
184 | 184 | ] |
185 | 185 | }, |
186 | 186 | { |
|
299 | 299 | "metadata": {}, |
300 | 300 | "outputs": [], |
301 | 301 | "source": [ |
302 | | - "daily_modern, _ = waterdata.get_daily(\n", |
| 302 | + "daily_data, _ = waterdata.get_daily(\n", |
303 | 303 | " monitoring_location_id=\"USGS-01491000\",\n", |
304 | 304 | " parameter_code=[\"00060\", \"00010\"],\n", |
305 | 305 | " statistic_id=\"00003\",\n", |
306 | 306 | " time=[\"2023-10-01\", \"2024-09-30\"],\n", |
307 | 307 | ")\n", |
308 | | - "daily_modern[[\"time\", \"parameter_code\", \"value\", \"approval_status\"]].head()" |
| 308 | + "daily_data[[\"time\", \"parameter_code\", \"value\", \"approval_status\"]].head()" |
309 | 309 | ] |
310 | 310 | }, |
311 | 311 | { |
|
324 | 324 | "metadata": {}, |
325 | 325 | "outputs": [], |
326 | 326 | "source": [ |
327 | | - "params = sorted(daily_modern[\"parameter_code\"].unique())\n", |
328 | | - "fig, axes = plt.subplots(len(params), 1, figsize=(7, 5), sharex=True, squeeze=False)\n", |
329 | | - "axes = axes[:, 0] # squeeze=False -> always a 2-D array, even for one param\n", |
| 327 | + "params = sorted(daily_data[\"parameter_code\"].unique())\n", |
| 328 | + "fig, axes = plt.subplots(len(params), 1, figsize=(7, 5), sharex=True)\n", |
330 | 329 | "for ax, pcode in zip(axes, params):\n", |
331 | | - " sub = daily_modern[daily_modern[\"parameter_code\"] == pcode]\n", |
| 330 | + " sub = daily_data[daily_data[\"parameter_code\"] == pcode]\n", |
332 | 331 | " ax.scatter(sub[\"time\"], sub[\"value\"], s=4)\n", |
333 | 332 | " ax.set_ylabel(pcode)\n", |
334 | 333 | "axes[0].set_title(\"Daily values at USGS-01491000 (water year 2024)\")\n", |
|
386 | 385 | "metadata": {}, |
387 | 386 | "outputs": [], |
388 | 387 | "source": [ |
389 | | - "field_modern, _ = waterdata.get_field_measurements(\n", |
| 388 | + "field_data, _ = waterdata.get_field_measurements(\n", |
390 | 389 | " monitoring_location_id=[\n", |
391 | 390 | " \"USGS-451605097071701\",\n", |
392 | 391 | " \"USGS-263819081585801\",\n", |
393 | 392 | " ],\n", |
394 | 393 | " time=[\"2023-10-01\", \"2024-09-30\"],\n", |
395 | 394 | ")\n", |
396 | | - "field_modern[[\"time\", \"monitoring_location_id\", \"parameter_code\", \"value\"]].head()" |
| 395 | + "field_data[[\"time\", \"monitoring_location_id\", \"parameter_code\", \"value\"]].head()" |
397 | 396 | ] |
398 | 397 | }, |
399 | 398 | { |
|
404 | 403 | "outputs": [], |
405 | 404 | "source": [ |
406 | 405 | "fig, ax = plt.subplots(figsize=(7, 4))\n", |
407 | | - "for site, sub in field_modern.groupby(\"monitoring_location_id\"):\n", |
| 406 | + "for site, sub in field_data.groupby(\"monitoring_location_id\"):\n", |
408 | 407 | " ax.scatter(sub[\"time\"], sub[\"value\"], s=12, label=site)\n", |
409 | 408 | "ax.set_ylabel(\"value\")\n", |
410 | 409 | "ax.set_title(\"Field measurements\")\n", |
|
499 | 498 | "metadata": {}, |
500 | 499 | "outputs": [], |
501 | 500 | "source": [ |
502 | | - "what_huc_sites, _ = waterdata.get_monitoring_locations(\n", |
| 501 | + "huc_sites, _ = waterdata.get_monitoring_locations(\n", |
503 | 502 | " filter=\"hydrologic_unit_code LIKE '02070010%'\",\n", |
504 | 503 | " filter_lang=\"cql-text\",\n", |
505 | 504 | ")\n", |
506 | | - "print(f\"{len(what_huc_sites)} sites in HUC 02070010\")\n", |
507 | | - "ax = what_huc_sites.plot(markersize=2, figsize=(7, 5))\n", |
| 505 | + "print(f\"{len(huc_sites)} sites in HUC 02070010\")\n", |
| 506 | + "ax = huc_sites.plot(markersize=2, figsize=(7, 5))\n", |
508 | 507 | "ax.set_title(\"Sites within HUC 02070010\")\n", |
509 | 508 | "plt.show()" |
510 | 509 | ] |
|
620 | 619 | "outputs": [], |
621 | 620 | "source": [ |
622 | 621 | "site = \"USGS-02238500\"\n", |
623 | | - "site_1, _ = waterdata.get_monitoring_locations(\n", |
| 622 | + "renamed, _ = waterdata.get_monitoring_locations(\n", |
624 | 623 | " monitoring_location_id=site,\n", |
625 | 624 | " properties=[\"monitoring_location_id\", \"state_name\", \"country_name\"],\n", |
626 | 625 | ")\n", |
627 | | - "site_2, _ = waterdata.get_monitoring_locations(\n", |
| 626 | + "raw_id, _ = waterdata.get_monitoring_locations(\n", |
628 | 627 | " monitoring_location_id=site,\n", |
629 | 628 | " properties=[\"id\", \"state_name\", \"country_name\"],\n", |
630 | 629 | ")\n", |
631 | | - "print(\"renamed:\", [c for c in site_1.columns if c != \"geometry\"])\n", |
632 | | - "print(\"raw id :\", [c for c in site_2.columns if c != \"geometry\"])" |
| 630 | + "print(\"renamed:\", [c for c in renamed.columns if c != \"geometry\"])\n", |
| 631 | + "print(\"raw id :\", [c for c in raw_id.columns if c != \"geometry\"])" |
633 | 632 | ] |
634 | 633 | }, |
635 | 634 | { |
|
647 | 646 | ], |
648 | 647 | "metadata": { |
649 | 648 | "kernelspec": { |
650 | | - "display_name": "Python 3", |
| 649 | + "display_name": "Python 3 (ipykernel)", |
651 | 650 | "language": "python", |
652 | 651 | "name": "python3" |
653 | 652 | }, |
654 | 653 | "language_info": { |
655 | | - "name": "python" |
| 654 | + "codemirror_mode": { |
| 655 | + "name": "ipython", |
| 656 | + "version": 3 |
| 657 | + }, |
| 658 | + "file_extension": ".py", |
| 659 | + "mimetype": "text/x-python", |
| 660 | + "name": "python", |
| 661 | + "nbconvert_exporter": "python", |
| 662 | + "pygments_lexer": "ipython3", |
| 663 | + "version": "3.12.10" |
656 | 664 | } |
657 | 665 | }, |
658 | 666 | "nbformat": 4, |
|
0 commit comments