22
33from __future__ import annotations
44
5- from typing import Any , Hashable , Iterable , Mapping , Sequence
5+ from typing import Hashable , Iterable , Mapping , Sequence
66
77import warnings
88
@@ -25,7 +25,6 @@ def load_prism_cube(
2525 lat : float | None = None ,
2626 lon : float | None = None ,
2727 bbox : Sequence [float ] | None = None ,
28- aoi : Mapping [str , Any ] | None = None ,
2928 aoi_geojson : Mapping [str , object ] | None = None ,
3029 start : str | pd .Timestamp | None = None ,
3130 end : str | pd .Timestamp | None = None ,
@@ -48,9 +47,6 @@ def load_prism_cube(
4847 fetched for the surrounding area.
4948 bbox : sequence of float, optional
5049 Bounding box defined as ``[min_lon, min_lat, max_lon, max_lat]``.
51- aoi : mapping, optional
52- Legacy mapping with ``min_lon``, ``min_lat``, ``max_lon``, and
53- ``max_lat`` keys. Deprecated in favor of ``bbox`` or ``aoi_geojson``.
5450 aoi_geojson : mapping, optional
5551 GeoJSON Feature/FeatureCollection describing the area of interest. A
5652 bounding box is derived from the geometry.
@@ -80,8 +76,7 @@ def load_prism_cube(
8076
8177 if legacy_args :
8278 if any (
83- value is not None
84- for value in (lat , lon , bbox , aoi , aoi_geojson , start , end , freq )
79+ value is not None for value in (lat , lon , bbox , aoi_geojson , start , end , freq )
8580 ) or variables is not None :
8681 raise TypeError (
8782 "Cannot mix positional PRISM arguments with the keyword-only API."
@@ -117,19 +112,6 @@ def load_prism_cube(
117112 variable_spec = variable
118113 normalized_variables = _normalize_variables (variable_spec )
119114
120- if aoi is not None :
121- warnings .warn (
122- "load_prism_cube(aoi=...) is deprecated; use bbox=(min_lon,min_lat,max_lon,max_lat) "
123- "or aoi_geojson=... instead." ,
124- DeprecationWarning ,
125- stacklevel = 2 ,
126- )
127- if any (value is not None for value in (lat , lon , bbox , aoi_geojson )):
128- raise ValueError (
129- "Specify only one AOI via lat/lon, bbox, aoi_geojson, or legacy aoi mapping."
130- )
131- bbox = _coerce_legacy_aoi_to_bbox (aoi )
132-
133115 aoi = _coerce_aoi (lat = lat , lon = lon , bbox = bbox , aoi_geojson = aoi_geojson )
134116
135117 return _load_prism_cube_impl (
@@ -276,28 +258,6 @@ def _normalize_variables(variable_spec: Iterable[str] | str) -> Sequence[str]:
276258 return [str (val ) for val in values ]
277259
278260
279- def _coerce_legacy_aoi_to_bbox (aoi : Mapping [str , Any ]) -> tuple [float , float , float , float ]:
280- if not isinstance (aoi , Mapping ):
281- raise ValueError ("Legacy PRISM AOI must be a mapping with bounding box keys." )
282- required_keys = {"min_lon" , "max_lon" , "min_lat" , "max_lat" }
283- if not required_keys .issubset (aoi .keys ()):
284- raise ValueError (
285- "Legacy AOI missing bounding box keys: {0}" .format (
286- ", " .join (sorted (required_keys - set (aoi .keys ())))
287- )
288- )
289- try :
290- min_lon = float (aoi ["min_lon" ])
291- min_lat = float (aoi ["min_lat" ])
292- max_lon = float (aoi ["max_lon" ])
293- max_lat = float (aoi ["max_lat" ])
294- except (TypeError , ValueError ) as exc :
295- raise ValueError ("Legacy PRISM AOI values must be numeric." ) from exc
296- if min_lon >= max_lon or min_lat >= max_lat :
297- raise ValueError ("Legacy PRISM AOI min values must be less than max values." )
298- return (min_lon , min_lat , max_lon , max_lat )
299-
300-
301261def _coerce_aoi (
302262 * ,
303263 lat : float | None ,
@@ -406,13 +366,14 @@ def _flatten_geojson_coords(coords: object) -> list[tuple[float, float]]:
406366def _coerce_legacy_aoi (aoi : object ) -> Mapping [str , float ]:
407367 if not isinstance (aoi , Mapping ):
408368 raise ValueError ("Legacy PRISM AOI must be a mapping with bounding box keys." )
409- min_lon , min_lat , max_lon , max_lat = _coerce_legacy_aoi_to_bbox (aoi )
410- return {
411- "min_lon" : min_lon ,
412- "min_lat" : min_lat ,
413- "max_lon" : max_lon ,
414- "max_lat" : max_lat ,
415- }
369+ required_keys = {"min_lon" , "max_lon" , "min_lat" , "max_lat" }
370+ if not required_keys .issubset (aoi .keys ()):
371+ raise ValueError (
372+ "Legacy AOI missing bounding box keys: {0}" .format (
373+ ", " .join (sorted (required_keys - set (aoi .keys ())))
374+ )
375+ )
376+ return {key : float (aoi [key ]) for key in required_keys }
416377
417378
418379def _open_prism_streaming (
0 commit comments