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

Support name tokens #3399

Merged
merged 6 commits into from
Sep 20, 2019
Merged

Conversation

bjlittle
Copy link
Member

@bjlittle bjlittle commented Sep 13, 2019

This PR is the outcome of a side discussion regarding issue #3360.

In short, in iris we've allowed the use of long_name from a coordinate to be used in the construction of the CellMethod, but that causes issues when the long_name contains one or more space (" ") characters, as it then quickly becomes ambiguous to parse the grammar suggested in the CF Conventions for a cell_methods attribute on loading after saving the CellMethod to NetCDF. That's not a fault of the CF Conventions, more our interpretation and implementation of it (from a file format agnostic point of view).

Reference, Cell Methods, 2nd paragraph:

In the specification of this attribute, name can be a dimension of the variable, a scalar coordinate variable, a valid standard name, or the word "area"

That said, this PR attempts to resolve this issue by ensuring that the coord_names and method used within the construction of a CellMethod are valid NetCDF name tokens, and thus can be parsed within the rules suggested in the CF Conventions without ambiguity (or over-engineering 😉).

@bjlittle
Copy link
Member Author

@lbdreyer I still need to add some test coverage to the PR... just pushed this so that you can see the approach I'm taking 😉

@@ -19,15 +19,18 @@
from six.moves import (filter, input, map, range, zip) # noqa
import six

# TODO: Is this a mixin or a base class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Horse. Bolted.

@bjlittle
Copy link
Member Author

@lbdreyer Okay, I think that I'm pretty much there...

As it happens, there wasn't any unit test coverage of CellMethods (there is for parsing, but not construction and usage), but I've added the minimal test coverage for the changes in this PR.

Being a good citizen, I'll add test coverage in a separate PR.

I've also not updated the docs either, just so that this PR can get banked sooner rather than later, but happy to make a follow-up PR, if you think that's appropriate... 😄

Copy link
Member

@lbdreyer lbdreyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition and great to see much more test coverage!

lib/iris/_cube_coord_common.py Outdated Show resolved Hide resolved
lib/iris/coords.py Outdated Show resolved Hide resolved
lib/iris/_cube_coord_common.py Show resolved Hide resolved
@bjlittle
Copy link
Member Author

@lbdreyer I've actioned all your review comments, travis-ci is happy, over to you... 😺

@lbdreyer
Copy link
Member

All good 👍 👍 Thanks @bjlittle !

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

Successfully merging this pull request may close these issues.

2 participants