Skip to content
40 changes: 40 additions & 0 deletions csv_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,33 @@ def arctic_hydrology_csv(data, filename_prefix, source_metadata):
metadata += f"# The following hydrologic statistics are calculated from modeled daily streamflow data. {source_notes[source_metadata]}\n"
else:
metadata += "# The following hydrologic statistics are calculated from modeled daily streamflow data:\n"
metadata += "# dh1: Mean annual maximum 1-day average flow (cubic feet per second - temporal).\n"
metadata += "# dh2: Mean annual maximum 3-day average flow (cubic feet per second - temporal).\n"
metadata += "# dh3: Mean annual maximum 7-day average flow (cubic feet per second - temporal).\n"
metadata += "# dh4: Mean annual maximum 30-day average flow (cubic feet per second - temporal).\n"
metadata += "# dh5: Mean annual maximum 90-day average flow (cubic feet per second - temporal).\n"
metadata += "# dh15: Median annual average duration of high flow pulses above the 75th percentile (days/year - temporal).\n"
metadata += "# dl1: Mean annual minimum 1-day average flow (cubic feet per second - temporal).\n"
metadata += "# dl2: Mean annual minimum 3-day average flow (cubic feet per second - temporal).\n"
metadata += "# dl3: Mean annual minimum 7-day average flow (cubic feet per second - temporal).\n"
metadata += "# dl4: Mean annual minimum 30-day average flow (cubic feet per second - temporal).\n"
metadata += "# dl5: Mean annual minimum 90-day average flow (cubic feet per second - temporal).\n"
metadata += "# dl16: Median annual average duration of low flow pulses below the 25th percentile (days/year - temporal).\n"
metadata += "# lf1: Median annual number of days below a threshold of 0.1 cubic feet per second per square mile (days/year - temporal).\n"
metadata += "# spr_dur3: Median spring (April-June) maximum of 3-day moving average flows (cubic feet per second - temporal).\n"
metadata += "# spr_dur7: Median spring (April-June) maximum of 7-day moving average flows (cubic feet per second - temporal).\n"
metadata += "# sum_dur3: Median summer (July-September) minimum of 3-day moving average flow (cubic feet per second - temporal).\n"
metadata += "# sum_dur7: Median summer (July-September) minimum of 7-day moving average flow (cubic feet per second - temporal).\n"
metadata += "# fh1: Mean annual count of high flow pulses above the 75th percentile (number of events/year - temporal).\n"
metadata += "# fh5: Mean annual flood frequency above median flow (number of events/year - temporal).\n"
metadata += "# fh6: Mean annual flood frequency above 3 times median flow (number of events/year - temporal).\n"
metadata += "# fh7: Mean annual flood frequency above 7 times median flow (number of events/year - temporal).\n"
metadata += "# fl1: Mean annual count of low flow pulses below the 25th percentile (number of events/year - temporal).\n"
metadata += "# fl3: Mean annual count of events below 5 percent of mean flow (number of events/year - temporal).\n"
metadata += "# spr_freq: Median spring (April-June) count of flow events above the 10th percentile of the full record (number of events/year - temporal).\n"
metadata += "# sum_freq: Median summer (July-September) count of flow events below the 90th percentile of the full record (number of events/year - temporal).\n"
metadata += "# ma3: Coefficient of variation (standard deviation/mean) of annual daily flows; mean of annual CVs (percent - temporal).\n"
metadata += "# ma4: Standard deviation of percentiles of log-transformed flow divided by mean of those percentiles (percent - spatial).\n"
metadata += "# ma12: Mean of monthly flow values for January (cubic feet per second - temporal).\n"
metadata += "# ma13: Mean of monthly flow values for February (cubic feet per second - temporal).\n"
metadata += "# ma14: Mean of monthly flow values for March (cubic feet per second - temporal).\n"
Expand All @@ -1575,6 +1602,19 @@ def arctic_hydrology_csv(data, filename_prefix, source_metadata):
metadata += "# ma22: Mean of monthly flow values for November (cubic feet per second - temporal).\n"
metadata += "# ma23: Mean of monthly flow values for December (cubic feet per second - temporal).\n"
metadata += "# ma99: Mean of monthly flow values for the entire year. Compute the mean of the monthly mean flows for each month of the year. MA99 is the mean of these 12 values (cubic feet per second - temporal).\n"
metadata += "# mh14: Median of annual (maximum flow / median annual flow) ratios (dimensionless - temporal).\n"
metadata += "# mh20: Mean annual maximum flow divided by drainage area (cubic feet per second/square mile - temporal).\n"
metadata += "# ml17: Base flow index: mean of annual (7-day minimum flow / mean annual flow) ratios (dimensionless - temporal).\n"
metadata += "# spr_mag: Median spring (April-June) maximum flow divided by drainage area (cubic feet per second/square mile - temporal).\n"
metadata += "# sum_cv: Median annual coefficient of variation of summer (July-September) daily flows (percent - temporal).\n"
metadata += "# sum_mag: Median summer (July-September) minimum flow divided by drainage area (cubic feet per second/square mile - temporal).\n"
metadata += "# ra1: Mean rise rate: mean of positive daily flow changes (cubic feet per second/day - temporal).\n"
metadata += "# ra3: Mean fall rate: mean of negative daily flow changes (cubic feet per second/day - temporal).\n"
metadata += "# ra8: Median annual number of flow direction reversals (days - temporal).\n"
metadata += "# spr_ord: Median Julian date of spring (April-June) maximum flow (Julian day - temporal).\n"
metadata += "# sum_ord: Median Julian date of summer (July-September) minimum flow (Julian day - temporal).\n"
metadata += "# th1: Median Julian date of annual maximum flow (Julian day - temporal).\n"
metadata += "# tl1: Median Julian date of annual minimum flow (Julian day - temporal).\n"
else:
if isinstance(source_metadata, str) and source_metadata in source_notes:
metadata += f"# Climatologies are calculated from modeled daily streamflow data. {source_notes[source_metadata]}\n"
Expand Down
18 changes: 15 additions & 3 deletions generate_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,33 @@ def generate_wfs_conus_hydrology_url(stream_id):
def generate_wfs_arctic_hydrology_url(stream_id):
"""
Generate a WFS URL for fetching arctic hydrology data for a given stream ID. Returns both attributes and geometry for a single stream ID.
If the stream ID is an empty string, returns only attributes for all streams."""
If the stream ID is an empty string, returns only COMID attribute for all streams.
"""
if stream_id == "":
wfs_url = (
GS_BASE_URL
+ "wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=hydrology:arctic_segments&propertyName=(COMID)&outputFormat=application/json"
+ "wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=hydrology:arctic_rivers_segments_joined_3338_simplified&propertyName=(COMID)&outputFormat=application/json"
)
return wfs_url
else:
wfs_url = (
GS_BASE_URL
+ f"wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=hydrology:arctic_segments&propertyName=(COMID,the_geom)&outputFormat=application/json&cql_filter=(COMID={stream_id})"
+ f"wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=hydrology:arctic_rivers_segments_joined_3338_simplified&propertyName=(COMID,the_geom,Gauge_ID,ID_1,ID_2,Name,outlet)&outputFormat=application/json&cql_filter=(COMID={stream_id})"
)
return wfs_url


def generate_wfs_arctic_hydrology_stats_url(stream_id):
"""
Generate a WFS URL for fetching arctic hydrology summary stats for a given stream ID
from the arctic_rivers_segments_stats_simplified layer.
"""
return (
GS_BASE_URL
+ f"wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=hydrology:arctic_rivers_segments_stats_simplified&outputFormat=application/json&cql_filter=(COMID={stream_id})"
)


def generate_usgs_gauge_daily_streamflow_data_url(gauge_id, start_date, end_date):
"""
Generate a USGS OGC API URL for fetching daily streamflow data for a given gauge ID and date range.
Expand Down
Loading
Loading