Repository: ioos/compliance-checker (python)

Issue:
Climatology cell_methods check bug
**Version of compliance checker running:** latest develop code, commit bfdcf8bbe87cfe22de929b00511d18dac94001ba

**Describe the checker this affects:** CF

**Attach a minimal CDL or NetCDF file which is able to reproduce the issue**
```
netcdf bug {
dimensions:
	time = 1 ;
        nv = 2 ;
variables:
	float time(time) ;
		time:climatology = "climatology_bounds" ;
		time:units = "days since 1900-01-01" ;
                time:long_name = "time" ;
	float climatology_bounds(time, nv) ;
	float v(time) ;
                v:cell_methods = "time: mean within years time: mean over years" ;
                v:long_name = "v" ;

:Conventions = "CF-1.8" ;
:title = "bug" ;
:history = "none" ;

data:

 time = 35795 ;
 climatology_bounds = 35795, 43100 ;
}
```

**To Reproduce:**
`compliance-checker -t cf:1.8 bug.nc`

**Describe the issue below:**
This regexp in your code seems not handle well the CF spec: https://github.com/ioos/compliance-checker/blob/develop/compliance_checker/cf/cf_1_6.py#L3266

Pull request description:
Fix two argument form of climatology cell_methods
Fixes #1144 

Patch:
diff --git a/compliance_checker/cf/cf_1_6.py b/compliance_checker/cf/cf_1_6.py
index 2bdb5f5..2ca9fef 100644
--- a/compliance_checker/cf/cf_1_6.py
+++ b/compliance_checker/cf/cf_1_6.py
@@ -3265,8 +3265,8 @@ class CF1_6Check(CFNCCheck):
         )  # "or" comparison for the methods
         re_string = (
             rf"^time: {meth_regex} within (years|days)"  # regex string to test
-            rf" time: {meth_regex} over \1(?<=days)(?: time: {meth_regex} over years)?"
-            r"(?: \([^)]+\))?$"
+            rf" time: {meth_regex} over \1(:?(?<=days) time: {meth_regex} over years)?"
+            r"(?: \([^)]+\))?$"  # parenthesized comment section
         )
 
         # find any variables with a valid climatological cell_methods


Test patch:
diff --git a/compliance_checker/tests/test_cf.py b/compliance_checker/tests/test_cf.py
index f1a3ddd..187d7a7 100644
--- a/compliance_checker/tests/test_cf.py
+++ b/compliance_checker/tests/test_cf.py
@@ -742,6 +742,11 @@ class TestCF1_6(BaseTestCase):
         results = self.cf.check_climatological_statistics(dataset)
         score, out_of, messages = get_results(results)
         self.assertEqual(score, out_of)
+        # two time expression
+        temp_var.cell_methods = "time: mean within years time: mean over years"
+        results = self.cf.check_climatological_statistics(dataset)
+        score, out_of, messages = get_results(results)
+        self.assertEqual(score, out_of)
 
         # TEST CONFORMANCE 7.4 REQUIRED 5/6
         dataset.variables["climatology_bounds"] = MockVariable(