Skip to content

Commit

Permalink
catch "unsupported datatype" exception from netCDF library when acces…
Browse files Browse the repository at this point in the history
…sing attributes
  • Loading branch information
danielfromearth committed Dec 10, 2024
1 parent 0e9558e commit 8f25bae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ncompare/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,15 @@ def _var_properties(group: Union[netCDF4.Dataset, netCDF4.Group], varname: str)
v_dtype = str(the_variable.dtype)
v_shape = str(the_variable.shape).strip()
v_chunking = str(the_variable.chunking()).strip()
v_attributes = {name: getattr(the_variable, name) for name in the_variable.ncattrs()}

v_attributes = {}
for name in the_variable.ncattrs():
try:
v_attributes[name] = the_variable.getncattr(name)
except KeyError as key_err:
# Added this check because of "unsupported datatype" error that prevented
# fully running comparisons on S5P_OFFL_L1B_IR_UVN collections.
v_attributes[name] = f"netCDF error: {str(key_err)}"
else:
the_variable = None
v_dtype = ""
Expand Down

0 comments on commit 8f25bae

Please sign in to comment.