Skip to content

Commit ada9a41

Browse files
committed
correct example documentation and add info about logging
1 parent 6a326ce commit ada9a41

2 files changed

Lines changed: 33 additions & 22 deletions

File tree

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## Latest Announcements
88

9-
:mega: **10/01/2025:** `dataretrieval` now features the new `waterdata` module,
9+
:mega: **11/24/2025:** `dataretrieval` now features the new `waterdata` module,
1010
which provides access to USGS's modernized [Water Data
1111
APIs](https://api.waterdata.usgs.gov/). The Water Data API endpoints include
1212
daily values, instantaneous values, field measurements, time series metadata,
@@ -65,6 +65,23 @@ locations, metadata = waterdata.get_monitoring_locations(
6565

6666
print(f"Found {len(locations)} stream monitoring locations in Maryland")
6767
```
68+
This new module implements
69+
[logging](https://docs.python.org/3/howto/logging.html#logging-basic-tutorial)
70+
in which users can view the URL requests sent to the USGS Water Data APIs
71+
and the number of requests they have remaining each hour. These messages can
72+
be helpful for troubleshooting and support. To enable logging in your python
73+
console or notebook:
74+
75+
```python
76+
import logging
77+
logging.basicConfig(level=logging.INFO)
78+
```
79+
To log messages to a file, you can specify a filename in the
80+
`basicConfig` call:
81+
82+
```python
83+
logging.basicConfig(filename='waterdata.log', level=logging.INFO)
84+
```
6885

6986
### NWIS Legacy Services (Deprecated but still functional)
7087

dataretrieval/waterdata/api.py

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ def get_daily(
188188
... time="2021-01-01T00:00:00Z/2022-01-01T00:00:00Z",
189189
... )
190190
191-
>>> # Get monitoring location info for specific sites
192-
>>> # and only specific properties
191+
>>> # Get approved daily flow data from multiple sites
193192
>>> df, md = dataretrieval.waterdata.get_daily(
194193
... monitoring_location_id = ["USGS-05114000", "USGS-09423350"],
195194
... approval_status = "Approved",
@@ -678,19 +677,18 @@ def get_time_series_metadata(
678677
--------
679678
.. code::
680679
681-
>>> # Get daily flow data from a single site
680+
>>> # Get timeseries metadata information from a single site
682681
>>> # over a yearlong period
683682
>>> df, md = dataretrieval.waterdata.get_time_series_metadata(
684-
... monitoring_location_id="USGS-02238500",
685-
... parameter_code="00060",
686-
... time="2021-01-01T00:00:00Z/2022-01-01T00:00:00Z",
683+
... monitoring_location_id="USGS-02238500"
687684
... )
688685
689-
>>> # Get monitoring location info for specific sites
690-
>>> # and only specific properties
686+
>>> # Get timeseries metadata information from multiple sites
687+
>>> # that begin after January 1, 1990.
691688
>>> df, md = dataretrieval.waterdata.get_time_series_metadata(
692689
... monitoring_location_id = ["USGS-05114000", "USGS-09423350"],
693-
... time = "2024-01-01/.."
690+
... begin = "1990-01-01/.."
691+
... )
694692
"""
695693
service = "time-series-metadata"
696694
output_id = "time_series_id"
@@ -856,14 +854,12 @@ def get_latest_continuous(
856854
--------
857855
.. code::
858856
859-
>>> # Get daily flow data from a single site
860-
>>> # over a yearlong period
857+
>>> # Get latest flow data from a single site
861858
>>> df, md = dataretrieval.waterdata.get_latest_continuous(
862859
... monitoring_location_id="USGS-02238500", parameter_code="00060"
863860
... )
864861
865-
>>> # Get monitoring location info for specific sites
866-
>>> # and only specific properties
862+
>>> # Get latest continuous measurements for multiple sites
867863
>>> df, md = dataretrieval.waterdata.get_latest_continuous(
868864
... monitoring_location_id=["USGS-05114000", "USGS-09423350"]
869865
... )
@@ -1034,14 +1030,12 @@ def get_latest_daily(
10341030
--------
10351031
.. code::
10361032
1037-
>>> # Get daily flow data from a single site
1038-
>>> # over a yearlong period
1033+
>>> # Get most recent daily flow data from a single site
10391034
>>> df, md = dataretrieval.waterdata.get_latest_daily(
10401035
... monitoring_location_id="USGS-02238500", parameter_code="00060"
10411036
... )
10421037
1043-
>>> # Get monitoring location info for specific sites
1044-
>>> # and only specific properties
1038+
>>> # Get most recent daily measurements for two sites
10451039
>>> df, md = dataretrieval.waterdata.get_latest_daily(
10461040
... monitoring_location_id=["USGS-05114000", "USGS-09423350"]
10471041
... )
@@ -1201,16 +1195,16 @@ def get_field_measurements(
12011195
--------
12021196
.. code::
12031197
1204-
>>> # Get daily flow data from a single site
1205-
>>> # over a yearlong period
1198+
>>> # Get field measurements from a single groundwater site
1199+
>>> # and parameter code, and do not return geometry
12061200
>>> df, md = dataretrieval.waterdata.get_field_measurements(
12071201
... monitoring_location_id="USGS-375907091432201",
12081202
... parameter_code="72019",
12091203
... skip_geometry=True,
12101204
... )
12111205
1212-
>>> # Get monitoring location info for specific sites
1213-
>>> # and only specific properties
1206+
>>> # Get field measurements from multiple sites and
1207+
>>> # parameter codes from the last 20 years
12141208
>>> df, md = dataretrieval.waterdata.get_field_measurements(
12151209
... monitoring_location_id = ["USGS-451605097071701",
12161210
"USGS-263819081585801"],

0 commit comments

Comments
 (0)