@@ -229,60 +229,10 @@ class GLAH06Dataset(Dataset):
229229 version : Literal ["034" ] = "034"
230230
231231
232- class BoundingBox (pydantic .BaseModel ):
233- lower_left_lon : float
234- lower_left_lat : float
235- upper_right_lon : float
236- upper_right_lat : float
237-
238- def __init__ (self , * args , ** kwargs ):
239- """Accept either named args, one arg for each coord, or an iterable of
240- `(lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat)`."""
241- if args :
242- if len (args ) == 1 and isinstance (args [0 ], list | tuple ):
243- # The first arg should be treated like a tuple of
244- # (lower_left_lon, lower_left_lat, upper_right_lon,
245- # upper_right_lat)
246- args = tuple (args [0 ])
247- # Each arg should be treated as one of (lower_left_lon,
248- # lower_left_lat, upper_right_lon, upper_right_lat).
249- if len (args ) != 4 :
250- raise ValueError (
251- "Expected four values for bounding box:"
252- " (lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat)"
253- )
254- # Set kwargs if args are given.
255- kwargs = {
256- "lower_left_lon" : args [0 ],
257- "lower_left_lat" : args [1 ],
258- "upper_right_lon" : args [2 ],
259- "upper_right_lat" : args [3 ],
260- }
261-
262- # Initialize the model.
263- super ().__init__ (** kwargs )
264-
265- def __iter__ (self ):
266- """Return bounding box as a iter (list/tuple)."""
267- return iter (
268- (
269- self .lower_left_lon ,
270- self .lower_left_lat ,
271- self .upper_right_lon ,
272- self .upper_right_lat ,
273- )
274- )
275-
276- def __getitem__ (self , idx ):
277- if isinstance (idx , int ):
278- return list (self .__iter__ ())[idx ]
279- elif isinstance (idx , str ):
280- return getattr (self , idx )
281- else :
282- raise TypeError (
283- "Getitem on BoundingBox must be int (e.g. 0)"
284- " or str (e.g., 'lower_left_lon')."
285- )
232+ # This mirrors the bounding box construct in `earthaccess` and `icepyx`: a
233+ # list/float of len 4:
234+ # (lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat)
235+ BoundingBoxLike = list [float ] | tuple [float , float , float , float ]
286236
287237
288238ALL_DATASETS : list [Dataset ] = [
@@ -295,10 +245,13 @@ def __getitem__(self, idx):
295245]
296246
297247
248+ TemporalRange = tuple [dt .datetime | dt .date , dt .datetime | dt .date ]
249+
250+
298251class DatasetSearchParameters (pydantic .BaseModel ):
299252 datasets : list [Dataset ] = ALL_DATASETS
300- bounding_box : BoundingBox
301- temporal : tuple [ dt . datetime | dt . date , dt . datetime | dt . date ]
253+ bounding_box : BoundingBoxLike
254+ temporal : TemporalRange
302255
303256
304257class IceflowSearchResult (pydantic .BaseModel ):
0 commit comments