Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malformed exception does not include variable information #340

Closed
BorjaEst opened this issue Jun 21, 2022 · 1 comment · Fixed by #350
Closed

Malformed exception does not include variable information #340

BorjaEst opened this issue Jun 21, 2022 · 1 comment · Fixed by #350

Comments

@BorjaEst
Copy link

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.

@dcherian
Copy link
Contributor

With #350, there should be a warning instead of an error and it should print the variable name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants