Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 6 additions & 21 deletions dataretrieval/nwis.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,10 @@ def get_discharge_measurements(
Parameters
----------
sites: string or list of strings, optional, default is None
If the qwdata parameter site_no is supplied, it will overwrite the
sites parameter
start: string, optional, default is None
If the qwdata parameter begin_date is supplied, it will overwrite the
start parameter (YYYY-MM-DD)
start: string, optional, default is None
Supply date in the format: YYYY-MM-DD
end: string, optional, default is None
If the qwdata parameter end_date is supplied, it will overwrite the
end parameter (YYYY-MM-DD)
Supply date in the format: YYYY-MM-DD
ssl_check: bool, optional
If True, check SSL certificates, if False, do not check SSL,
default is True
Expand Down Expand Up @@ -1071,7 +1067,6 @@ def get_record(
service: string, default is 'iv'
- 'iv' : instantaneous data
- 'dv' : daily mean data
- 'qwdata' : discrete samples
- 'site' : site description
- 'measurements' : discharge measurements
- 'peaks': discharge peaks
Expand Down Expand Up @@ -1100,9 +1095,6 @@ def get_record(
>>> # Get latest daily mean data from site 01585200
>>> df = dataretrieval.nwis.get_record(sites="01585200", service="dv")

>>> # Get all discrete sample data from site 01585200
>>> df = dataretrieval.nwis.get_record(sites="01585200", service="qwdata")

>>> # Get site description for site 01585200
>>> df = dataretrieval.nwis.get_record(sites="01585200", service="site")

Expand Down Expand Up @@ -1169,16 +1161,9 @@ def get_record(
return df

elif service == "qwdata":
df, _ = get_qwdata(
site_no=sites,
begin_date=start,
end_date=end,
multi_index=multi_index,
wide_format=wide_format,
ssl_check=ssl_check,
**kwargs,
)
return df
return print("qw data are no longer available from" \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Raise an exception here. Something like:

raise ValueError(
    "qwdata endpoint was decomissioned.",
    "Please use `samples.get_usgs_samples()` instead."
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed as an option for a service. Put back in?

"NWIS. Please use `samples.get_usgs_samples()` instead." \
" If you have questions, please reach out to [email protected]")

elif service == "site":
df, _ = get_info(sites=sites, ssl_check=ssl_check, **kwargs)
Expand Down
60 changes: 0 additions & 60 deletions tests/waterservices_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
get_info,
get_iv,
get_pmcodes,
get_qwdata,
get_ratings,
get_record,
get_stats,
Expand Down Expand Up @@ -203,65 +202,6 @@ def test_get_info(requests_mock):
assert_metadata(requests_mock, request_url, md, site, [parameter_cd], format)


def test_get_qwdata(requests_mock):
"""Tests get_qwdata method correctly generates the request url and returns
the result in a DataFrame"""
format = "rdb"
site = "01491000%2C01645000"
request_url = (
"https://nwis.waterdata.usgs.gov/nwis/qwdata?site_no={}"
"&qw_sample_wide=qw_sample_wide&agency_cd=USGS&format={}&pm_cd_compare=Greater+than"
"&inventory_output=0&rdb_inventory_output=file&TZoutput=0&rdb_qw_attributes=expanded"
"&date_format=YYYY-MM-DD&rdb_compression=value&submitted_form=brief_list".format(
site, format
)
)
response_file_path = "data/waterdata_qwdata.txt"
mock_request(requests_mock, request_url, response_file_path)
with pytest.warns(DeprecationWarning):
df, md = get_qwdata(sites=["01491000", "01645000"])
if not isinstance(df, DataFrame):
raise AssertionError(f"{type(df)} is not DataFrame base class type")

if "geometry" in list(df):
if not isinstance(df, gpd.GeoDataFrame):
raise AssertionError(f"{type(df)} is not a GeoDataFrame")

geom_type = df.geom_type.unique()
if len(geom_type) > 1 or geom_type[0] != "Point":
raise AssertionError(
f"Geometry type {geom_type} not valid, expecting Point"
)

assert df.size == 1821472
assert_metadata(requests_mock, request_url, md, site, None, format)


@pytest.mark.parametrize("site_input_type_list", [True, False])
def test_get_qwdata_site_value_types(requests_mock, site_input_type_list):
"""Tests get_qwdata method for valid input types for the 'sites' parameter"""
_format = "rdb"
site = "01491000"
request_url = (
"https://nwis.waterdata.usgs.gov/nwis/qwdata?site_no={}"
"&qw_sample_wide=qw_sample_wide&agency_cd=USGS&format={}&pm_cd_compare=Greater+than"
"&inventory_output=0&rdb_inventory_output=file&TZoutput=0&rdb_qw_attributes=expanded"
"&date_format=YYYY-MM-DD&rdb_compression=value&submitted_form=brief_list".format(
site, _format
)
)
response_file_path = "data/waterdata_qwdata.txt"
mock_request(requests_mock, request_url, response_file_path)
if site_input_type_list:
sites = [site]
else:
sites = site
with pytest.warns(DeprecationWarning):
df, md = get_qwdata(sites=sites)
assert type(df) is DataFrame
assert df.size == 1821472


def test_get_gwlevels(requests_mock):
"""Tests get_gwlevels method correctly generates the request url and returns the result in a DataFrame."""
format = "rdb"
Expand Down