66
77import warnings
88
9- import warnings
10-
119import numpy as np
1210import pandas as pd
1311import xarray as xr
@@ -51,6 +49,7 @@ def load_prism_cube(
5149 lat : float | None = None ,
5250 lon : float | None = None ,
5351 bbox : Sequence [float ] | None = None ,
52+ aoi : Mapping [str , float ] | None = None ,
5453 aoi_geojson : Mapping [str , object ] | None = None ,
5554 start : str | pd .Timestamp | None = None ,
5655 end : str | pd .Timestamp | None = None ,
@@ -73,6 +72,9 @@ def load_prism_cube(
7372 fetched for the surrounding area.
7473 bbox : sequence of float, optional
7574 Bounding box defined as ``[min_lon, min_lat, max_lon, max_lat]``.
75+ aoi : mapping, optional
76+ Backward-compatible alias for ``bbox`` as a mapping containing
77+ ``min_lon``, ``min_lat``, ``max_lon``, and ``max_lat``.
7678 aoi_geojson : mapping, optional
7779 GeoJSON Feature/FeatureCollection describing the area of interest. A
7880 bounding box is derived from the geometry.
@@ -103,7 +105,8 @@ def load_prism_cube(
103105
104106 if legacy_args :
105107 if any (
106- value is not None for value in (lat , lon , bbox , aoi_geojson , start , end , freq )
108+ value is not None
109+ for value in (lat , lon , bbox , aoi , aoi_geojson , start , end , freq )
107110 ) or variables is not None :
108111 raise TypeError (
109112 "Cannot mix positional PRISM arguments with the keyword-only API."
@@ -139,13 +142,19 @@ def load_prism_cube(
139142 variable_spec = variable
140143 normalized_variables = _normalize_variables (variable_spec )
141144
142- aoi = _coerce_aoi (lat = lat , lon = lon , bbox = bbox , aoi_geojson = aoi_geojson )
145+ aoi_mapping = _coerce_aoi (
146+ lat = lat ,
147+ lon = lon ,
148+ bbox = bbox ,
149+ aoi = aoi ,
150+ aoi_geojson = aoi_geojson ,
151+ )
143152
144153 ds = _load_prism_cube_impl (
145154 normalized_variables ,
146155 start_ts .isoformat (),
147156 end_ts .isoformat (),
148- aoi ,
157+ aoi_mapping ,
149158 freq_code ,
150159 chunks ,
151160 prefer_streaming ,
@@ -296,16 +305,18 @@ def _coerce_aoi(
296305 lat : float | None ,
297306 lon : float | None ,
298307 bbox : Sequence [float ] | None ,
308+ aoi : Mapping [str , float ] | None ,
299309 aoi_geojson : Mapping [str , object ] | None ,
300310) -> Mapping [str , float ]:
301311 specs = [
302312 lat is not None or lon is not None ,
303313 bbox is not None ,
314+ aoi is not None ,
304315 aoi_geojson is not None ,
305316 ]
306317 if sum (bool (spec ) for spec in specs ) != 1 :
307318 raise ValueError (
308- "Specify exactly one of (lat/lon), bbox, or aoi_geojson for PRISM requests."
319+ "Specify exactly one of (lat/lon), bbox, aoi, or aoi_geojson for PRISM requests."
309320 )
310321
311322 if lat is not None or lon is not None :
@@ -314,6 +325,8 @@ def _coerce_aoi(
314325 return _bbox_mapping_from_point (lat , lon )
315326 if bbox is not None :
316327 return _bbox_mapping_from_sequence (bbox )
328+ if aoi is not None :
329+ return _coerce_legacy_aoi (aoi )
317330 assert aoi_geojson is not None # for mypy/static
318331 return _bbox_mapping_from_geojson (aoi_geojson )
319332
0 commit comments