Skip to content

Commit ff7d35d

Browse files
authored
Merge pull request #205 from CU-ESIIL/codex/update-repository-dependencies
Restore `aoi=` support in PRISM loader, sync GRIDMET AOI call, and add `download` pytest marker
2 parents b094885 + a0a382d commit ff7d35d

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
markers =
33
online: marks tests that require cubo/network access (deselect with '-m "not online"')
44
streaming: marks tests that exercise streaming-first code paths
5+
download: marks tests that exercise non-streaming download fallback code paths
56
integration: marks tests that hit external services or large data sources
67
pythonpath = src .
78
addopts = -p no:zarr

src/cubedynamics/data/gridmet.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ def load_gridmet_cube(
134134
)
135135
aoi_mapping = _coerce_legacy_gridmet_aoi(aoi)
136136
else:
137-
aoi_mapping = _coerce_aoi(lat=lat, lon=lon, bbox=bbox, aoi_geojson=aoi_geojson)
137+
aoi_mapping = _coerce_aoi(
138+
lat=lat,
139+
lon=lon,
140+
bbox=bbox,
141+
aoi=None,
142+
aoi_geojson=aoi_geojson,
143+
)
138144

139145
return _load_gridmet_cube_impl(
140146
normalized_variables,

src/cubedynamics/data/prism.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
import warnings
88

9-
import warnings
10-
119
import numpy as np
1210
import pandas as pd
1311
import 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

Comments
 (0)