Skip to content

Cloud mode missing in O3 products #9

@Johaney-s

Description

@Johaney-s

Describe the bug
This line of code requires cloud_mode property in the S5p metadata of O3 products:

product_metadata.py, line 556:
"o3:cloud_mode": str(self._root.cloud_mode),

but the cloud_mode is missing in some O3 data.

To reproduce
I get this error for example on product 5b2ec3d2-cfa5-4c2d-8b25-b1894d1ffdb5: S5P_NRTI_L2__O3__PR_20240726T024524_20240726T025024_35152_03_020600_20240726T042829.nc
Expected behavior
I guess skipping it if missing and not throwing an exception would be suitable.

Traceback

Traceback (most recent call last):
  File "/home/johaney/Projects/DhusPytools/register_stac.py", line 436, in main
    item = stactools.sentinel5p.stac.create_item(os.path.join(metadata_dir, title))
  File "/home/johaney/Projects/DhusPytools/.venv/lib/python3.10/site-packages/stactools/sentinel5p/stac.py", line 87, in create_item
    item.properties.update({**product_metadata.metadata_dict})
  File "/home/johaney/Projects/DhusPytools/.venv/lib/python3.10/site-packages/stactools/sentinel5p/product_metadata.py", line 556, in metadata_dict
    "o3:cloud_mode": str(self._root.cloud_mode),
  File "src/netCDF4/_netCDF4.pyx", line 3131, in netCDF4._netCDF4.Dataset.__getattr__
  File "src/netCDF4/_netCDF4.pyx", line 3076, in netCDF4._netCDF4.Dataset.getncattr
  File "src/netCDF4/_netCDF4.pyx", line 1617, in netCDF4._netCDF4._get_att
  File "src/netCDF4/_netCDF4.pyx", line 2113, in netCDF4._netCDF4._ensure_nc_success
AttributeError: NetCDF: Attribute not found

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions