Repository: ioos/compliance-checker

Issue:
Ancillary variables check does not find existing variables
When running "-t cf:latest", it reports an error for all variables listed in my "ancillary_variables" variable attributes. It asserts that the ancillary variables do not exist in the dataset when in fact they do.

Example:
http://www.pacioos.hawaii.edu/archive/WQB04agg/WQB04agg.2010.nc

Snippet from cchecker.py output:

Â§3.4 Ancillary Variables defined by chl:3:     1/18 : instrument1 is not a
                                                      variable in this dataset,
                                                      platform1 is not a 
                                                      variable in this dataset,
                                                      chlorophyll_dm_qd is not a
                                                      variable in this dataset,
                                                      chlorophyll_qc_gap is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_syn is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_loc is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_rng is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_clm is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_spk is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_rtc is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_rtc is not
                                                      a variable in thist
                                                      dataset, 
                                                      chlorophyll_qc_flt is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_mvr is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_atn is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_nbr is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_crv is not
                                                      a variable in this
                                                      dataset,
                                                      chlorophyll_qc_din is not
                                                      a variable in this dataset



Discussion:

Resolving patch:
diff --git a/compliance_checker/cf/cf.py b/compliance_checker/cf/cf.py
--- a/compliance_checker/cf/cf.py
+++ b/compliance_checker/cf/cf.py
@@ -1178,7 +1178,7 @@ def check_ancillary_variables(self, ds):
                 continue
 
             for ancillary_variable in ancillary_variables.split():
-                valid_ancillary.assert_true(ancillary_variables in ds.variables,
+                valid_ancillary.assert_true(ancillary_variable in ds.variables,
                                             "{} is not a variable in this dataset".format(ancillary_variable))
 
             ret_val.append(valid_ancillary.to_result())


Test patch: