Malformed exception does not include variable information
BorjaEst opened this issue · 1 comments
BorjaEst commented
I have the following dataset:
<xarray.Dataset>
Dimensions: (... time: 24)
Coordinates:
...
* time (time) datetime64[ns] 1960-01-16T12:00:00 ... 1961-12-16T12:...
Data variables:
...
zmo3 (time, lev, lat, lon) float32 dask.array<chunksize=(24, 31, 22, 1), meta=np.ndarray>
Attributes:
...
Conventions: CF-1.4
Where the attr cell_measures
is malformed:
dataset.cf.axes
Traceback (most recent call last):
...
ValueError: attrs['cell_measures'] = 'N/A' is malformed.
I know the malformed attr is inside the zmo3 variable, but the exception does not provide that info and makes handling the execption quite dificult:
try:
dataset.cf[variable_standard_name]
except ValueError as err:
# err => ValueError("attrs['cell_measures'] = 'N/A' is malformed.")
pass # How to del the malformed attr if I do not know the variable
It would be nice that the Value error includes the variables that raised the issue.