@@ -204,6 +204,8 @@ def operator_value(criterion: Dict[str, object]) -> (str, object):
204
204
collection = None
205
205
metadata = None
206
206
207
+ netcdf_with_time_dimension = False
208
+
207
209
backend_config = get_backend_config ()
208
210
poll_interval_seconds = backend_config .job_dependencies_poll_interval_seconds
209
211
max_poll_delay_seconds = backend_config .job_dependencies_max_poll_delay_seconds
@@ -277,6 +279,7 @@ def operator_value(criterion: Dict[str, object]) -> (str, object):
277
279
intersecting_items = [item ] if intersects_spatiotemporally (item ) else []
278
280
elif isinstance (stac_object , pystac .Collection ) and supports_item_search (stac_object ):
279
281
collection = stac_object
282
+ netcdf_with_time_dimension = contains_netcdf_with_time_dimension (collection )
280
283
collection_id = collection .id
281
284
metadata = GeopysparkCubeMetadata (
282
285
metadata = collection .to_dict (include_self_link = False , transform_hrefs = False )
@@ -319,7 +322,7 @@ def operator_value(criterion: Dict[str, object]) -> (str, object):
319
322
limit = 20 ,
320
323
datetime = (
321
324
None
322
- if temporal_extent is DEFAULT_TEMPORAL_EXTENT
325
+ if temporal_extent is ( DEFAULT_TEMPORAL_EXTENT or netcdf_with_time_dimension )
323
326
else f"{ from_date .isoformat ().replace ('+00:00' , 'Z' )} /"
324
327
f"{ to_date .isoformat ().replace ('+00:00' , 'Z' )} " # end is inclusive
325
328
),
@@ -347,6 +350,7 @@ def operator_value(criterion: Dict[str, object]) -> (str, object):
347
350
348
351
if isinstance (catalog , pystac .Collection ):
349
352
collection = catalog
353
+ netcdf_with_time_dimension = contains_netcdf_with_time_dimension (collection )
350
354
351
355
band_names = [b ["name" ] for b in (catalog .summaries .lists if isinstance (catalog , pystac .Collection )
352
356
else catalog .extra_fields .get ("summaries" , {})).get ("eo:bands" , [])]
@@ -417,14 +421,6 @@ def intersects_temporally(interval) -> bool:
417
421
band_cell_size : Dict [str , Tuple [float , float ]] = {} # assumes a band has the same resolution across features/assets
418
422
band_epsgs : Dict [str , Set [int ]] = {}
419
423
420
- netcdf_with_time_dimension = False
421
- if collection is not None :
422
- # we found some collection level metadata
423
- item_assets = collection .extra_fields .get ("item_assets" , {})
424
- dimensions = set ([tuple (v .get ("dimensions" )) for i in item_assets .values () if "cube:variables" in i for v in
425
- i .get ("cube:variables" , {}).values ()])
426
- # this is one way to determine if a time dimension is used, but it does depend on the use of item_assets and datacube extension.
427
- netcdf_with_time_dimension = len (dimensions ) == 1 and "time" in dimensions .pop ()
428
424
429
425
for itm in intersecting_items :
430
426
items_found = True
@@ -702,6 +698,23 @@ def intersects_temporally(interval) -> bool:
702
698
return GeopysparkDataCube (pyramid = gps .Pyramid (levels ), metadata = metadata )
703
699
704
700
701
+ def contains_netcdf_with_time_dimension (collection ):
702
+ """
703
+ Checks if the STAC collection contains netcdf files with multiple time stamps.
704
+ This collection organization is used for storing small patches of EO data, and requires special loading because the
705
+ default readers will not handle this case properly.
706
+
707
+ """
708
+ if collection is not None :
709
+ # we found some collection level metadata
710
+ item_assets = collection .extra_fields .get ("item_assets" , {})
711
+ dimensions = set ([tuple (v .get ("dimensions" )) for i in item_assets .values () if "cube:variables" in i for v in
712
+ i .get ("cube:variables" , {}).values ()])
713
+ # this is one way to determine if a time dimension is used, but it does depend on the use of item_assets and datacube extension.
714
+ return len (dimensions ) == 1 and "time" in dimensions .pop ()
715
+ return False
716
+
717
+
705
718
def get_best_url (asset : pystac .Asset ):
706
719
"""
707
720
Relevant doc: https://github.com/stac-extensions/alternate-assets
0 commit comments