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

evaluate regular expressions #98

Open
sol1105 opened this issue Jun 19, 2024 · 4 comments
Open

evaluate regular expressions #98

sol1105 opened this issue Jun 19, 2024 · 4 comments

Comments

@sol1105
Copy link

sol1105 commented Jun 19, 2024

There is a typo in the CV attribute driving_variant_label. It is currently called driving_variant_labelin the required_global_attributes, but missing the driving_ prefix in the actual CV entry (so just being called variant_label).

:1438        "variant_label": [
:1439            "r[[:digit:]]\\{1,\\}i[[:digit:]]\\{1,\\}p[[:digit:]]\\{1,\\}f[[:digit:]]\\{1,\\}$"
@sol1105
Copy link
Author

sol1105 commented Jun 19, 2024

version_realization does not have an entry, it could have an entry similar to driving_variant_label.

        "version_realization": [
            "v[[:digit:]]\\{1,\\}-r[[:digit:]]\\{1,\\}$"

Since 0 is not allowed(?!), maybe this example would have to be modified, eg.

 "version_realization": [
            "v[1-9]\\{1,\\}[[:digit:]]\\{0,\\}-r[1-9]\\{1,\\}[[:digit:]]\\{0,\\}$"

@larsbuntemeyer
Copy link
Contributor

larsbuntemeyer commented Jun 19, 2024

Thanks for pointin this out. That's another relict from the original CMIP6 CV. We did not really change the convention on the variant label so keepin the original regex should be fine. However, i could not really figure out how to evaluate these regex, e.g., have the same questions as in PCMDI/cmip6-cmor-tables#281. Do you know, if cmor actually evaluates regex during cmorization?

@larsbuntemeyer
Copy link
Contributor

My closest approach to evaluate regex is this:
https://github.com/euro-cordex/cmor-check/blob/2eb19b36bf39cc1dd1f1a6c93b993a37a1b27331/cmor_check/cmor_check.py#L11-L14

However, that won't work for most of the regular expressions, e.g., in the CMIP6_CV.

@sol1105
Copy link
Author

sol1105 commented Jul 15, 2024

The problem seems to be that the re module in python doesn't know [[:digit:]]. It also seems to not like all the backslashes. Without those, and with [[:digit:]] replaced by \d it works.

@larsbuntemeyer larsbuntemeyer changed the title Typo in CV attribute driving_variant_label evaluate regular expressions Jul 15, 2024
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

No branches or pull requests

2 participants