cedadev/cf-checker

`chkCellMethods` regex could possibly be improved.

Opened this issue · 2 comments

bzah commented

Hello, it seemschkCellMethods initial regex (pr1) can reject some valid cell_methods.

  1. It validates only lower case methods but conventions document says:
    """Case is not significant in the method name. in chapter 7.3."""
    This is due to [a-z_] in the regex.

  2. After the name:method it expects one of the keywords ["where", "over", "within", "interval", "comment"] but I don't see in the conventions doc where it is specified that only these can be used. Beside, it tells:
    """For instance, an area-weighted mean over latitude could be indicated as lat: mean (area-weighted) or lat: mean (interval: 1 degree_north comment: area-weighted)."""
    But pr1 regex would raise an error with lat: mean (area-weighted)

Disclaimer:
I worked on a similar feature on Xclim but I never actually used cf-checker, so I might have misunderstood how chkCellMethods works. I just wanted to give you a feedback because I took some inspiration from the currentchkCellMethods.

We are now using the following regex on Xclim: (\s*\S+\s*:(\s+[\w()-]+)+)(?!\S*:) (see it in action).

Regards.

Hi,

Thanks for reporting this. It looks like (1) is missing from the conformance document so I will raise a correction and then fix the checker accordingly.

(2) I've just tried cell_methods = "lat: mean (area-weighted)" and that is perfectly valid by chkCellMethods. The keywords ["where", "over", "within", "interval", "comment"] are all optional in the regex.

Regards,
Ros.

bzah commented

I must have missed something when trying pr1 regex, I confirm that it actually works.
Sorry for the false alarm.