Skip to content

Commit

Permalink
fix "climate_response_network" network list (#152)
Browse files Browse the repository at this point in the history
* fix variable name associated with network list

* increment version
  • Loading branch information
amy-defnet authored Mar 7, 2024
1 parent 481c2a9 commit 3ceed3e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hf_hydrodata"
version = "1.1.0"
version = "1.1.1"
description = "hydroframe tools and utilities"
authors = ["William M. Hasling", "Laura Condon", "Reed Maxwell", "George Artavanis", "Amy M. Johnson", "Amy C. Defnet"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/hf_hydrodata/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ def _get_network_site_list(dataset, variable, site_networks):
network_options = {
"usgs_nwis": {
"streamflow": ["camels", "gagesii_reference", "gagesii", "hcdn2009"],
"wtd": ["climate_response_network"],
"water_table_depth": ["climate_response_network"],
}
}

Expand Down
72 changes: 68 additions & 4 deletions tests/hf_hydrodata/test_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_check_inputs():
# Parameter provided for variable not in supported list (typo).
point.HYDRODATA = "/hydrodata"
with pytest.raises(Exception):
point.check_inputs(
point._check_inputs(
dataset="usgs_nwis",
variable="steamflow",
temporal_resolution="daily",
Expand All @@ -160,7 +160,7 @@ def test_check_inputs():

# Parameter provided for temporal_resolution not in supported list.
with pytest.raises(Exception):
point.check_inputs(
point._check_inputs(
dataset="usgs_nwis",
variable="streamflow",
temporal_resolution="monthly",
Expand All @@ -169,7 +169,7 @@ def test_check_inputs():

# Variable requested is soil moisture but no depth level provided.
with pytest.raises(Exception):
point.check_inputs(
point._check_inputs(
dataset="scan",
variable="soil_moisture",
temporal_resolution="daily",
Expand All @@ -178,7 +178,7 @@ def test_check_inputs():

# Variable requested is soil moisture with unsupported depth level provided.
with pytest.raises(Exception):
point.check_inputs(
point._check_inputs(
dataset="scan",
variable="soil_moisture",
temporal_resolution="daily",
Expand Down Expand Up @@ -823,6 +823,38 @@ def test_site_networks_filter_list():
assert len(metadata_df) == 60


def test_site_networks_filter_list_wtd():
"""Test for using site_networks filter as a list with water table depth variable"""
data_df = point.get_point_data(
dataset="usgs_nwis",
variable="water_table_depth",
temporal_resolution="daily",
aggregation="mean",
date_start="2002-01-01",
date_end="2002-01-05",
state="NJ",
latitude_range=(40, 41),
longitude_range=(-75, -74),
site_networks=["climate_response_network"],
)
assert len(data_df) == 5
assert "400232074213201" in data_df.columns

metadata_df = point.get_point_metadata(
dataset="usgs_nwis",
variable="water_table_depth",
temporal_resolution="daily",
aggregation="mean",
date_start="2002-01-01",
date_end="2002-01-05",
state="NJ",
latitude_range=(40, 41),
longitude_range=(-75, -74),
site_networks=["climate_response_network"],
)
assert len(metadata_df) == 9


def test_site_networks_filter_str():
"""Test for using site_networks filter as a str"""
data_df = point.get_point_data(
Expand Down Expand Up @@ -855,6 +887,38 @@ def test_site_networks_filter_str():
assert len(metadata_df) == 60


def test_site_networks_filter_str_wtd():
"""Test for using site_networks filter as a string with water table depth variable"""
data_df = point.get_point_data(
dataset="usgs_nwis",
variable="water_table_depth",
temporal_resolution="daily",
aggregation="mean",
date_start="2002-01-01",
date_end="2002-01-05",
state="NJ",
latitude_range=(40, 41),
longitude_range=(-75, -74),
site_networks="climate_response_network",
)
assert len(data_df) == 5
assert "400232074213201" in data_df.columns

metadata_df = point.get_point_metadata(
dataset="usgs_nwis",
variable="water_table_depth",
temporal_resolution="daily",
aggregation="mean",
date_start="2002-01-01",
date_end="2002-01-05",
state="NJ",
latitude_range=(40, 41),
longitude_range=(-75, -74),
site_networks="climate_response_network",
)
assert len(metadata_df) == 9


def test_get_data_min_num_obs_filter():
"""Test for using min_num_obs filter"""
df = point.get_point_data(
Expand Down

0 comments on commit 3ceed3e

Please sign in to comment.