TNO Intern

Commit 97781891 authored by Arjo Segers's avatar Arjo Segers
Browse files

Merge branch 'fix' into 'master'

Check on different paths to `href` attribute in stac inquiry.

See merge request !30
parents 5cfc4686 d4fbcca1
Loading
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@
# 2026-04, Arjo Segers
#   Fixed definition of bounding box for global selection.
#   Added increasing delays to avoid rate limit errors from STAC catalogue inquiry.
#   Check on different paths to 'href' attribute in stac inquiry.
#


@@ -175,6 +176,17 @@ import utopya
#             }
#          }
#
# Idem for nrti data:
#           { ...,
#             "assets": {
#               "Product": {
#                 "href": "s3://eodata/Sentinel-5P/TROPOMI/L2__NO2___/2025/10/06/S5P_RPRO_L2__NO2____20251006T150410_20251006T164737_41360_03_020901_20260203T132453.nc",
#                  ...
#               }
#               ...
#             }
#          }
#

class CSO_DataSpace_Inquire(utopya.UtopyaRc):

@@ -374,7 +386,24 @@ class CSO_DataSpace_Inquire(utopya.UtopyaRc):
                            te = datetime.datetime.strptime(end_time, tfmt)

                            # extract download url:
                            href = item.assets['netcdf'].href
                            if "netcdf" in item.assets.keys():
                                if hasattr(item.assets["netcdf"],"href"):
                                    href = item.assets["netcdf"].href
                                else:
                                    logging.error(f"no `href` attribute in `netcdf` asset")
                                    raise Exception
                                #endif
                            elif "Product" in item.assets.keys():
                                if hasattr(item.assets["Product"],"href"):
                                    href = item.assets["Product"].href
                                else:
                                    logging.error(f"no `href` attribute in `netcdf` asset")
                                    raise Exception
                                #endif
                            else:
                                logging.error(f"no `netcdf` or `Product` asset")
                                raise Exception
                            #endif
                            # filename:
                            filename = f"{product_id}.nc"