Skip to content

Commit dc24658

Browse files
committed
make a few small changes to names and documentation
1 parent b1436db commit dc24658

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

dataretrieval/waterdata_helpers.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
_cached_base_url = None
2222
def _base_url():
2323
"""
24-
Returns the base URL for the USGS Water Data OGC API.
24+
Returns the base URL for the USGS Water Data APIs.
2525
2626
Uses a cached value to avoid repeated string formatting. If the cached value
2727
is not set, it constructs the base URL using the BASE_API and API_VERSION constants.
@@ -222,7 +222,7 @@ def _default_headers():
222222
headers["X-Api-Key"] = token
223223
return headers
224224

225-
def _check_OGC_requests(endpoint: str = "daily", req_type: str = "queryables"):
225+
def _check_ogc_requests(endpoint: str = "daily", req_type: str = "queryables"):
226226
"""
227227
Sends an HTTP GET request to the specified OGC endpoint and request type, returning the JSON response.
228228
@@ -281,7 +281,7 @@ def _construct_api_requests(
281281
properties (Optional[List[str]], optional): List of property names to include in the request.
282282
bbox (Optional[List[float]], optional): Bounding box coordinates as a list of floats.
283283
limit (Optional[int], optional): Maximum number of results to return per request.
284-
max_results (Optional[int], optional): Maximum number of results allowed by the API.
284+
max_results (Optional[int], optional): Maximum number of rows to return.
285285
skipGeometry (bool, optional): Whether to exclude geometry from the response.
286286
**kwargs: Additional query parameters, including date/time filters and other API-specific options.
287287
Returns:
@@ -296,14 +296,6 @@ def _construct_api_requests(
296296
baseURL = _setup_api(service)
297297
# Single parameters can only have one value
298298
single_params = {"datetime", "last_modified", "begin", "end", "time"}
299-
# params = {k: v for k, v in kwargs.items() if k in single_params}
300-
# # Set skipGeometry parameter
301-
# params["skipGeometry"] = skipGeometry
302-
# # If limit is none and max_results is not none, then set limit to max results. Otherwise,
303-
# # if max_results is none, set it to 10000 (the API max).
304-
# params["limit"] = max_results if limit is None and max_results is not None else limit or 10000
305-
# if max_results is not None and limit is not None and limit > max_results:
306-
# raise ValueError("limit cannot be greater than max_result")
307299

308300
# Identify which parameters should be included in the POST content body
309301
post_params = {
@@ -384,6 +376,7 @@ def _get_resp_data(resp: httpx.Response, geopd: bool) -> pd.DataFrame:
384376
385377
Parameters:
386378
resp (httpx.Response): The HTTP response object expected to contain a JSON body with a "features" key.
379+
geopd (bool): Indicates whether geopandas is installed and should be used to handle geometries.
387380
388381
Returns:
389382
gpd.GeoDataFrame or pd.DataFrame: A geopandas GeoDataFrame if geometry is included, or a
@@ -423,10 +416,12 @@ def _walk_pages(geopd: bool, req: httpx.Request, max_results: Optional[int], cli
423416
424417
Parameters
425418
----------
419+
geopd : bool
420+
Indicates whether geopandas is installed and should be used for handling geometries.
426421
req : httpx.Request
427422
The initial HTTP request to send.
428423
max_results : Optional[int]
429-
The maximum number of results to retrieve. If None or NaN, retrieves all available pages.
424+
Maximum number of rows to return. If None or NaN, retrieves all available pages.
430425
client : Optional[httpx.Client], default None
431426
An optional HTTP client to use for requests. If not provided, a new client is created.
432427
@@ -501,12 +496,12 @@ def _deal_with_empty(return_list: pd.DataFrame, properties: Optional[List[str]],
501496
"""
502497
if return_list.empty:
503498
if not properties or all(pd.isna(properties)):
504-
schema = _check_OGC_requests(endpoint=service, req_type="schema")
499+
schema = _check_ogc_requests(endpoint=service, req_type="schema")
505500
properties = list(schema.get("properties", {}).keys())
506501
return pd.DataFrame(columns=properties)
507502
return return_list
508503

509-
def _rejigger_cols(df: pd.DataFrame, properties: Optional[List[str]], output_id: str) -> pd.DataFrame:
504+
def _arrange_cols(df: pd.DataFrame, properties: Optional[List[str]], output_id: str) -> pd.DataFrame:
510505
"""
511506
Rearranges and renames columns in a DataFrame based on provided properties and service's output id.
512507
@@ -613,7 +608,7 @@ def get_ogc_data(args: Dict[str, Any], output_id: str, service: str) -> pd.DataF
613608
return_list = _deal_with_empty(return_list, properties, service)
614609
if convertType:
615610
return_list = _cleanup_cols(return_list, service=service)
616-
return_list = _rejigger_cols(return_list, properties, output_id)
611+
return_list = _arrange_cols(return_list, properties, output_id)
617612
# Add metadata
618613
return_list.attrs.update(request=req.url, queryTime=pd.Timestamp.now())
619614
return return_list

0 commit comments

Comments
 (0)