From 3ceed3ef6b54a7eb8b8a68a3e6c38902b8f14524 Mon Sep 17 00:00:00 2001 From: Amy Defnet <74691675+amy-defnet@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:25:16 -0500 Subject: [PATCH] fix "climate_response_network" network list (#152) * fix variable name associated with network list * increment version --- pyproject.toml | 2 +- src/hf_hydrodata/point.py | 2 +- tests/hf_hydrodata/test_point.py | 72 ++++++++++++++++++++++++++++++-- 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c3f4d27..be8281d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/src/hf_hydrodata/point.py b/src/hf_hydrodata/point.py index 0767896..cf313ed 100644 --- a/src/hf_hydrodata/point.py +++ b/src/hf_hydrodata/point.py @@ -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"], } } diff --git a/tests/hf_hydrodata/test_point.py b/tests/hf_hydrodata/test_point.py index 44090ff..d7d855a 100644 --- a/tests/hf_hydrodata/test_point.py +++ b/tests/hf_hydrodata/test_point.py @@ -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", @@ -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", @@ -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", @@ -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", @@ -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( @@ -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(