Repository: ioos/compliance-checker

Issue:
Remove anything from 5.1
> When each of a variable’s spatiotemporal dimensions is a latitude, longitude, vertical, or time dimension, then each axis is identified by a coordinate variable.

This is guidance for software writers trying to find the axis. There is no check here or assertions, or recommendations for how to create.



Discussion:
@mbiddle-nodc @daf @benjwadams heads up.

Maybe a better way to write this issue is to say that after checks from 5.0 have been done, there is nothing to do here. 5.0 already states that all dimensions that are latitude, longitude, vertical or time dimensions must have corresponding coordinate variables. 

And even so, I don't know that you could reliably check this at all. Dimensions are just names and a size, and names are completely subjective. There's no reliable way to determine from a name that it corresponds to a lat/lon/time coordinate without a coordinate type (coordinate variable or auxiliary coordinate variable). So all of the checks are not really plausible, that I can see.

> All of a variable’s dimensions that are latitude, longitude, vertical, or time dimensions (see Section 1.2, "Terminology") must have corresponding coordinate variables, i.e., one-dimensional variables with the same name as the dimension (see examples in Chapter 4, Coordinate Types). This is the only method of associating dimensions with coordinates that is supported by [COARDS].

Here's section 1.2's definitions

http://cfconventions.org/cf-conventions/v1.6.0/cf-conventions.html#terminology

A time dimension is a dimension that is associated with a time coordinate variable. Therefore the statement above, is a tautology. "A coordinate variable must be a coordinate variable". 


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
@@ -1932,98 +1932,6 @@ def _get_coord_vars(self, ds):
                 coord_vars.append(name)
         return coord_vars
 
-    # def check_coordinate_systems(self, ds):
-        """
-        5 All of a variable's spatiotemporal dimensions that are not latitude,
-        longitude, vertical, or time dimensions are required to be associated
-        with the relevant latitude, longitude, vertical, or time coordinates via
-        the new coordinates attribute of the variable. The value of the
-        coordinates attribute is a blank separated list of the names of
-        auxiliary coordinate variables.
-
-        The dimensions of an auxiliary coordinate variable must be a subset of
-        the dimensions of the variable with which the coordinate is associated,
-        with two exceptions:
-        - String-valued coordinates (Section 6.1, "Labels") have a dimension for
-          maximum string length
-        - In the ragged array representations of data (Section 9, Discrete
-          Sampling Geometries), special methods are needed to connect the data
-          and coordinates
-
-        Recommend that the name of a multidimensional coordinate variable should
-        not match the name of any of its dimensions because that precludes
-        supplying a coordinate variable for the dimension.
-
-        Auxiliary coordinate variables may not be used as the only way to
-        identify latitude and longitude coordinates that could be identified
-        using coordinate variables.
-
-        An application that is trying to find the latitude coordinate of a
-        variable should always look first to see if any of the variable's
-        dimensions correspond to a latitude coordinate variable. If the latitude
-        coordinate is not found this way, then the auxiliary coordinate
-        variables listed by the coordinates attribute should be checked. Note
-        that it is permissible, but optional, to list coordinate variables as
-        well as auxiliary coordinate variables in the coordinates attribute.
-
-        It is not permissible for a data variable to have both a coordinate
-        variable and an auxiliary coordinate variable, or more than one of
-        either type of variable, having an axis attribute with any given value
-        e.g. there must be no more than one axis attribute for X for any data
-        variable.
-
-        """
-
-        # pass
-
-    def check_independent_axis_dimensions(self, ds):
-        '''
-        CF §5.1 When each of a variable's spatiotemporal dimensions is a latitude,
-        longitude, vertical, or time dimension, then each axis is identified by
-        a coordinate variable.
-        '''
-        ret_val = []
-
-        space_time_dim = []
-        # Check to find all space-time dimension (Lat/Lon/Time/Height)
-        for dimension in ds.dimensions:
-            if dimension in _possibleaxis:
-                space_time_dim.append(dimension)
-
-        space_time_coord_var = []
-        # Check to find all space-time coordinate variables (Lat/Lon/Time/Height)
-        for coord_name in self._find_coord_vars(ds):
-            coord_var = ds.variables[coord_name]
-
-            if coord_name in _possibleaxis \
-               or (hasattr(coord_var, 'units') and (coord_var.units in _possibleaxisunits or coord_var.units.split(" ")[0] in _possibleaxisunits)) \
-               or hasattr(coord_var, 'positive'):
-                space_time_coord_var.append(coord_name)
-
-        # Looks to ensure that every dimension of each variable that is a space-time dimension has associated coordinate variables
-        for name, var in ds.variables.items():
-            valid = ''
-            for each in var.dimensions:
-                if each in space_time_dim:
-                    if each in space_time_coord_var:
-                        valid = True
-                    else:
-                        valid = False
-                        dim_name = each
-                        break
-
-            if valid is False :
-                ret_val.append(Result(BaseCheck.MEDIUM,
-                                      valid,
-                                      '§5.1 Geophysical variables contain valid dimensions', ['The %s dimension for the variable %s does not have an associated coordinate variable, but is a Lat/Lon/Time/Height dimension.' % (dim_name, name)]))
-
-            if valid is True and name not in space_time_coord_var:
-                ret_val.append(Result(BaseCheck.MEDIUM,
-                                      valid,
-                                      '§5.1 Geophysical variables contain valid dimensions'))
-
-        return ret_val
-
     def check_two_dimensional(self, ds):
         """
         5.2 The latitude and longitude coordinates of a horizontal grid that was


Test patch:
diff --git a/compliance_checker/tests/test_cf.py b/compliance_checker/tests/test_cf.py
--- a/compliance_checker/tests/test_cf.py
+++ b/compliance_checker/tests/test_cf.py
@@ -770,29 +770,6 @@ def test_self_referencing(self):
         assert scored == 4
         assert "Variable CD_310's coordinate references itself" not in messages
 
-    def test_check_independent_axis_dimensions(self):
-        dataset = self.load_dataset(STATIC_FILES['example-grid'])
-        results = self.cf.check_independent_axis_dimensions(dataset)
-        for r in results:
-            self.assertTrue(r.value)
-
-        dataset = self.load_dataset(STATIC_FILES['bad'])
-        results = self.cf.check_independent_axis_dimensions(dataset)
-
-        scored, out_of, messages = self.get_results(results)
-        assert 'The lev dimension for the variable lev1 does not have an associated coordinate variable, but is a Lat/Lon/Time/Height dimension.' \
-            in messages
-        assert 'The lev dimension for the variable lev2 does not have an associated coordinate variable, but is a Lat/Lon/Time/Height dimension.' \
-            in messages
-        assert 'The time dimension for the variable bad_time_1 does not have an associated coordinate variable, but is a Lat/Lon/Time/Height dimension.' \
-            in messages
-        assert 'The time dimension for the variable bad_time_2 does not have an associated coordinate variable, but is a Lat/Lon/Time/Height dimension.' \
-            in messages
-        assert 'The time dimension for the variable column_temp does not have an associated coordinate variable, but is a Lat/Lon/Time/Height dimension.' \
-            in messages
-        assert scored == 6
-        assert out_of == 11
-
     def test_check_two_dimensional(self):
         dataset = self.load_dataset(STATIC_FILES['2dim'])
         results = self.cf.check_two_dimensional(dataset)