Skip to content

Conversation

@ehinman
Copy link
Collaborator

@ehinman ehinman commented Jan 7, 2026

Built off the PR that adds reference table functions.

Adds a demo of the waterdata functions to drpy. Addresses: #200

Also adds a few query parameters to the get_time_series_metadata() function.

@ehinman ehinman requested a review from jzemmels January 13, 2026 20:44
@ehinman ehinman marked this pull request as ready for review January 13, 2026 22:09
Copy link
Collaborator

@jzemmels jzemmels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! I appreciate the consistent throughline example. I've just a few comments that you might consider, but I'm only requesting changes on the errors I ran into (the double monitoring_location_id error + the GeoPandas-dependent code).

"metadata": {},
"source": [
"# Using the `waterdata` module to pull data from the USGS Water Data APIs\n",
"The `waterdata` module will eventually replace the `nwis` module for accessing USGS water data. It leverages the [Water Data APIs](https://api.waterdata.usgs.gov/) to download metadata, daily values, and instantaneous values. \n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially saves you from updating verb tenses once nwis is officially gone.

Suggested change
"The `waterdata` module will eventually replace the `nwis` module for accessing USGS water data. It leverages the [Water Data APIs](https://api.waterdata.usgs.gov/) to download metadata, daily values, and instantaneous values. \n",
"The `waterdata` module replaces the `nwis` module for accessing USGS water data. It leverages the [Water Data APIs](https://api.waterdata.usgs.gov/) to download metadata, daily values, and instantaneous values. \n",

"id": "4a2b3f0f",
"metadata": {},
"source": [
"## Lay of the Land\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart to start high-level!

"metadata": {},
"source": [
"## Lay of the Land\n",
"Now that your API key is configured, it's time to take a 10,000-ft view of the functions in the `waterdata` module.\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to link to the specific OGC API homepage somewhere -- maybe here? https://api.waterdata.usgs.gov/ogcapi

"id": "19b5aebf",
"metadata": {},
"source": [
"### A few key tips\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe link to the docs where there are more general tips? https://api.waterdata.usgs.gov/docs/ogcapi/

"id": "8f464470",
"metadata": {},
"source": [
"In the dataframe above, we are looking at 5 timeseries returned, ordered by monitoring location. You can also see that the first two rows show two different kinds of discharge for the same monitoring location: a mean daily discharge timeseries (with statistic id 00003, which represents \"mean\") and an instantaneous discharge timeseries (with statistic id 00011, which represents \"points\" or \"instantaneous\" values). Look closely and you may also notice that the `parent_timeseries_id` column for daily mean discharge matches the `time_series_id` for the instantaneous discharge. This is because once instantaneous measurements began at the site, they were used to calculate the daily mean."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe link to the statistic-codes reference table: https://api.waterdata.usgs.gov/ogcapi/v0/collections/statistic-codes/items

")\n",
"latest_instantaneous['datetime'] = latest_instantaneous['time'].astype(str)\n",
"\n",
"latest_instantaneous[['geometry', 'monitoring_location_id', 'datetime', 'value', 'unit_of_measure']].set_crs(crs=\"WGS84\").explore(column='value', cmap='YlOrRd', scheme=None, legend=True)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assumes you have GeoPandas installed. I'd either tell the reader that the remaining code requires GeoPandas or find a non-GeoPandas workaround.

"id": "c5c5881e",
"metadata": {},
"source": [
"Currently, users may only request 3 years or less of continuous data in one pull. For this example, let's pull the last 1 year of daily mean values and instantaneous values for these Missouri River sites. We'll skip pulling geometry in the `waterdata.get_daily()` function; the `waterdata.get_continuous()` function does not return geometry at all."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention why skipping geometry might be desired (reducing response size/repeated information)

"id": "ebc2c70d",
"metadata": {},
"outputs": [],
"source": [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an explanation for this code and/or interpretation of the output

"id": "87a397a4",
"metadata": {},
"outputs": [],
"source": [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honest question from not knowing matplotlib well: is there a way to save the plot above in an object (or something similar) so you can add on to it here, rather than re-writing all of the code again? Analogous to "plt + geom_point(...)"

]
}
],
"metadata": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End the vignette with a list of links/resources to learn more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants