Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions dataretrieval/nwis.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def format_response(
if service == "peaks":
df = preformat_peaks_response(df)

if gpd is not None and "dec_lat_va" in list(df):
if gpd is not None and "dec_lat_va" in df.columns:
geoms = gpd.points_from_xy(df.dec_long_va.values, df.dec_lat_va.values)
df = gpd.GeoDataFrame(df, geometry=geoms, crs=_CRS)

Expand Down Expand Up @@ -993,10 +993,7 @@ def _read_json(json):
)
index_list.append(len(site_list))

for i in range(len(index_list) - 1):
start = index_list[i] # [0]
end = index_list[i + 1] # [21]

for start, end in zip(index_list[:-1], index_list[1:]):
# grab a block containing timeseries 0:21,
# which are all from the same site
site_block = json["value"]["timeSeries"][start:end]
Expand Down
10 changes: 5 additions & 5 deletions dataretrieval/waterdata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,8 @@ def _format_api_dates(
if len(datetime_input) <= 2:
# If the list is of length 1, first look for things like "P7D" or dates
# already formatted in ISO08601. Otherwise, try to coerce to datetime
if (
len(datetime_input) == 1
and re.search(r"P", datetime_input[0], re.IGNORECASE)
if len(datetime_input) == 1 and (
re.search(r"P", datetime_input[0], re.IGNORECASE)
or "/" in datetime_input[0]
):
return datetime_input[0]
Expand Down Expand Up @@ -291,12 +290,13 @@ def _check_ogc_requests(endpoint: str = "daily", req_type: str = "queryables"):

Raises
------
AssertionError
ValueError
If req_type is not "queryables" or "schema".
requests.HTTPError
If the HTTP request returns an unsuccessful status code.
"""
assert req_type in ["queryables", "schema"]
if req_type not in ("queryables", "schema"):
raise ValueError(f"req_type must be 'queryables' or 'schema', got {req_type!r}")
url = f"{OGC_API_URL}/collections/{endpoint}/{req_type}"
resp = requests.get(url, headers=_default_headers())
resp.raise_for_status()
Expand Down
Loading