|
6 | 6 |
|
7 | 7 | from __future__ import annotations |
8 | 8 |
|
9 | | -import json |
10 | | -from io import StringIO |
11 | 9 | from typing import TYPE_CHECKING, Literal, get_args |
12 | 10 |
|
13 | 11 | import pandas as pd |
14 | 12 | import warnings |
15 | | -import requests |
16 | | -from requests.models import PreparedRequest |
17 | 13 |
|
18 | 14 | from dataretrieval.utils import BaseMetadata, to_str |
19 | | -from dataretrieval.waterdata import get_codes, get_args, _check_profiles, _BASE_URL, _CODE_SERVICES, _PROFILES, _SERVICES, _PROFILE_LOOKUP |
| 15 | +from dataretrieval import waterdata |
20 | 16 |
|
21 | 17 | if TYPE_CHECKING: |
22 | 18 | from typing import Optional, Tuple, Union |
@@ -218,32 +214,34 @@ def get_usgs_samples( |
218 | 214 | " deprecated and will eventually be removed. Switch to the" \ |
219 | 215 | " waterdata module as soon as possible, thank you.") |
220 | 216 |
|
221 | | - _check_profiles(service, profile) |
222 | | - |
223 | | - params = { |
224 | | - k: v for k, v in locals().items() |
225 | | - if k not in ["ssl_check", "service", "profile"] |
226 | | - and v is not None |
227 | | - } |
228 | | - |
229 | | - |
230 | | - params.update({"mimeType": "text/csv"}) |
231 | | - |
232 | | - if "boundingBox" in params: |
233 | | - params["boundingBox"] = to_str(params["boundingBox"]) |
234 | | - |
235 | | - url = f"{_BASE_URL}/{service}/{profile}" |
236 | | - |
237 | | - req = PreparedRequest() |
238 | | - req.prepare_url(url, params=params) |
239 | | - print(f"Request: {req.url}") |
240 | | - |
241 | | - response = requests.get(url, params=params, verify=ssl_check) |
242 | | - |
243 | | - response.raise_for_status() |
244 | | - |
245 | | - df = pd.read_csv(StringIO(response.text), delimiter=",") |
246 | | - |
247 | | - return df, BaseMetadata(response) |
| 217 | + result = waterdata.get_samples( |
| 218 | + ssl_check=ssl_check, |
| 219 | + service=service, |
| 220 | + profile=profile, |
| 221 | + activityMediaName=activityMediaName, |
| 222 | + activityStartDateLower=activityStartDateLower, |
| 223 | + activityStartDateUpper=activityStartDateUpper, |
| 224 | + activityTypeCode=activityTypeCode, |
| 225 | + characteristicGroup=characteristicGroup, |
| 226 | + characteristic=characteristic, |
| 227 | + characteristicUserSupplied=characteristicUserSupplied, |
| 228 | + boundingBox=boundingBox, |
| 229 | + countryFips=countryFips, |
| 230 | + stateFips=stateFips, |
| 231 | + countyFips=countyFips, |
| 232 | + siteTypeCode=siteTypeCode, |
| 233 | + siteTypeName=siteTypeName, |
| 234 | + usgsPCode=usgsPCode, |
| 235 | + hydrologicUnit=hydrologicUnit, |
| 236 | + monitoringLocationIdentifier=monitoringLocationIdentifier, |
| 237 | + organizationIdentifier=organizationIdentifier, |
| 238 | + pointLocationLatitude=pointLocationLatitude, |
| 239 | + pointLocationLongitude=pointLocationLongitude, |
| 240 | + pointLocationWithinMiles=pointLocationWithinMiles, |
| 241 | + projectIdentifier=projectIdentifier, |
| 242 | + recordIdentifierUserSupplied=recordIdentifierUserSupplied, |
| 243 | + ) |
| 244 | + |
| 245 | + return result |
248 | 246 |
|
249 | 247 |
|
0 commit comments