-
Notifications
You must be signed in to change notification settings - Fork 41
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
Drop missing variables #267
Conversation
Thanks @malmans2 I'd prefer a simple function that dropped nonexistent variables. It seems much easier to interpret and maintain. So something like |
cf_xarray/accessor.py
Outdated
_variables(_single(_must_exist(_get_bounds))), self._obj, key | ||
)[0] | ||
results = self.bounds.get(key, []) | ||
_raise_if_not_single(key, results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is right. For a staggered grid you could have multiple lat/lon with different bounds though I don't know that anyone ever does that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmm, not sure. I think we would have to change how we pare da.attrs['bounds']
, because I think right now we assume it's a single string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh actually you're right, for example key="longitude" could be associated to multiple bounds. The problem is that I think other functions use this and need a single DataArray. Maybe it's better to address this in a separate PR...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets open an issue for that. And here lets not raise_if_single...
This should be good to go! |
Thanks Mattia |
Closes #254
I haven't tried with other attributes, but it looks like introducing a decorator that only returns existing keys would work well.
Thoughts? If you think that this is the way to go, I'll try to implement it for
cell_measures
,formula_terms
, ...cc: @dcherian @tomvothecoder @huard