diff --git a/lib/iris/common/metadata.py b/lib/iris/common/metadata.py index 29ae910e38..cb5f53f5f4 100644 --- a/lib/iris/common/metadata.py +++ b/lib/iris/common/metadata.py @@ -204,7 +204,7 @@ def func(field): lambda field: field not in ( "circular", - "src_dim", + "location_axis", "node_dimension", "edge_dimension", "face_dimension", diff --git a/lib/iris/experimental/ugrid/load.py b/lib/iris/experimental/ugrid/load.py index 5e42f2e606..6c802e00d4 100644 --- a/lib/iris/experimental/ugrid/load.py +++ b/lib/iris/experimental/ugrid/load.py @@ -280,7 +280,7 @@ def _build_aux_coord(coord_var, file_path): return coord, axis -def _build_connectivity(connectivity_var, file_path, location_dims): +def _build_connectivity(connectivity_var, file_path, element_dims): """ Construct a :class:`~iris.experimental.ugrid.mesh.Connectivity` from a given :class:`~iris.experimental.ugrid.cf.CFUGridConnectivityVariable`, @@ -301,10 +301,10 @@ def _build_connectivity(connectivity_var, file_path, location_dims): dim_names = connectivity_var.dimensions # Connectivity arrays must have two dimensions. assert len(dim_names) == 2 - if dim_names[1] in location_dims: - src_dim = 1 + if dim_names[1] in element_dims: + location_axis = 1 else: - src_dim = 0 + location_axis = 0 standard_name, long_name, var_name = get_names( connectivity_var, None, attributes @@ -319,7 +319,7 @@ def _build_connectivity(connectivity_var, file_path, location_dims): units=attr_units, attributes=attributes, start_index=start_index, - src_dim=src_dim, + location_axis=location_axis, ) return connectivity, dim_names[0] @@ -423,20 +423,20 @@ def _build_mesh(cf, mesh_var, file_path): raise ValueError(message) # Used for detecting transposed connectivities. - location_dims = (edge_dimension, face_dimension) + element_dims = (edge_dimension, face_dimension) connectivity_args = [] for connectivity_var in mesh_var.cf_group.connectivities.values(): connectivity, first_dim_name = _build_connectivity( - connectivity_var, file_path, location_dims + connectivity_var, file_path, element_dims ) assert connectivity.var_name == getattr(mesh_var, connectivity.cf_role) connectivity_args.append(connectivity) # If the mesh_var has not supplied the dimension name, it is safe to # fall back on the connectivity's first dimension's name. - if edge_dimension is None and connectivity.src_location == "edge": + if edge_dimension is None and connectivity.location == "edge": edge_dimension = first_dim_name - if face_dimension is None and connectivity.src_location == "face": + if face_dimension is None and connectivity.location == "face": face_dimension = first_dim_name standard_name, long_name, var_name = get_names(mesh_var, None, attributes) @@ -480,12 +480,12 @@ def _build_mesh_coords(mesh, cf_var): """ # TODO: integrate with standard saving API when no longer 'experimental'. # Identify the cube's mesh dimension, for attaching MeshCoords. - locations_dimensions = { + element_dimensions = { "node": mesh.node_dimension, "edge": mesh.edge_dimension, "face": mesh.face_dimension, } - mesh_dim_name = locations_dimensions[cf_var.location] + mesh_dim_name = element_dimensions[cf_var.location] # (Only expecting 1 mesh dimension per cf_var). mesh_dim = cf_var.dimensions.index(mesh_dim_name) diff --git a/lib/iris/experimental/ugrid/mesh.py b/lib/iris/experimental/ugrid/mesh.py index 9e8074c83a..5cd4102f1b 100644 --- a/lib/iris/experimental/ugrid/mesh.py +++ b/lib/iris/experimental/ugrid/mesh.py @@ -94,8 +94,8 @@ class Connectivity(_DimensionalMetadata): """ A CF-UGRID topology connectivity, describing the topological relationship - between two lists of dimensional locations. One or more connectivities - make up a CF-UGRID topology - a constituent of a CF-UGRID mesh. + between two types of mesh element. One or more connectivities make up a + CF-UGRID topology - a constituent of a CF-UGRID mesh. See: https://ugrid-conventions.github.io/ugrid-conventions @@ -124,7 +124,7 @@ def __init__( units=None, attributes=None, start_index=0, - src_dim=0, + location_axis=0, ): """ Constructs a single connectivity. @@ -132,17 +132,23 @@ def __init__( Args: * indices (numpy.ndarray or numpy.ma.core.MaskedArray or dask.array.Array): - The index values describing a topological relationship. Constructed - of 2 dimensions - the list of locations, and within each location: - the indices of the 'target locations' it relates to. - Use a :class:`numpy.ma.core.MaskedArray` if :attr:`src_location` - lengths vary - mask unused index 'slots' within each - :attr:`src_location`. Use a :class:`dask.array.Array` to keep - indices 'lazy'. + 2D array giving the topological connection relationship between + :attr:`location` elements and :attr:`connected` elements. + The :attr:`location_axis` dimension indexes over the + :attr:`location` dimension of the mesh - i.e. its length matches + the total number of :attr:`location` elements in the mesh. The + :attr:`connected_axis` dimension can be any length, corresponding + to the highest number of :attr:`connected` elements connected to a + :attr:`location` element. The array values are indices into the + :attr:`connected` dimension of the mesh. If the number of + :attr:`connected` elements varies between :attr:`location` + elements: use a :class:`numpy.ma.core.MaskedArray` and mask the + :attr:`location` elements' unused index 'slots'. Use a + :class:`dask.array.Array` to keep indices 'lazy'. * cf_role (str): Denotes the topological relationship that this connectivity - describes. Made up of this array's locations, and the indexed - 'target location' within each location. + describes. Made up of this array's :attr:`location`, and the + :attr:`connected` element type that is indexed by the array. See :attr:`UGRID_CF_ROLES` for valid arguments. Kwargs: @@ -166,14 +172,14 @@ def __init__( Either ``0`` or ``1``. Default is ``0``. Denotes whether :attr:`indices` uses 0-based or 1-based indexing (allows support for Fortran and legacy NetCDF files). - * src_dim (int): - Either ``0`` or ``1``. Default is ``0``. Denotes which dimension - of :attr:`indices` varies over the :attr:`src_location`\\ s (the - alternate dimension therefore varying within individual - :attr:`src_location`\\ s). (This parameter allows support for fastest varying index being + * location_axis (int): + Either ``0`` or ``1``. Default is ``0``. Denotes which axis + of :attr:`indices` varies over the :attr:`location` elements (the + alternate axis therefore varying over :attr:`connected` elements). + (This parameter allows support for fastest varying index being either first or last). E.g. for ``face_node_connectivity``, for 10 faces: - ``indices.shape[src_dim] = 10``. + ``indices.shape[location_axis] == 10``. """ @@ -190,15 +196,15 @@ def validate_arg_vs_list(arg_name, arg, valid_list): validate_arg_vs_list("start_index", start_index, [0, 1]) # indices array will be 2-dimensional, so must be either 0 or 1. - validate_arg_vs_list("src_dim", src_dim, [0, 1]) + validate_arg_vs_list("location_axis", location_axis, [0, 1]) validate_arg_vs_list("cf_role", cf_role, Connectivity.UGRID_CF_ROLES) self._metadata_manager.start_index = start_index - self._metadata_manager.src_dim = src_dim + self._metadata_manager.location_axis = location_axis self._metadata_manager.cf_role = cf_role - self._tgt_dim = 1 - src_dim - self._src_location, self._tgt_location = cf_role.split("_")[:2] + self._connected_axis = 1 - location_axis + self._location, self._connected = cf_role.split("_")[:2] super().__init__( values=indices, @@ -233,25 +239,25 @@ def cf_role(self): return self._metadata_manager.cf_role @property - def src_location(self): + def location(self): """ Derived from the connectivity's :attr:`cf_role` - the first part, e.g. - ``face`` in ``face_node_connectivity``. Refers to the locations - listed by the :attr:`src_dim` of the connectivity's :attr:`indices` - array. + ``face`` in ``face_node_connectivity``. Refers to the elements that + vary along the :attr:`location_axis` of the connectivity's + :attr:`indices` array. """ - return self._src_location + return self._location @property - def tgt_location(self): + def connected(self): """ Derived from the connectivity's :attr:`cf_role` - the second part, e.g. - ``node`` in ``face_node_connectivity``. Refers to the locations indexed + ``node`` in ``face_node_connectivity``. Refers to the elements indexed by the values in the connectivity's :attr:`indices` array. """ - return self._tgt_location + return self._connected @property def start_index(self): @@ -266,47 +272,48 @@ def start_index(self): return self._metadata_manager.start_index @property - def src_dim(self): + def location_axis(self): """ - The dimension of the connectivity's :attr:`indices` array that varies - over the connectivity's :attr:`src_location`\\ s. Either ``0`` or ``1``. + The axis of the connectivity's :attr:`indices` array that varies + over the connectivity's :attr:`location` elements. Either ``0`` or ``1``. **Read-only** - validity of :attr:`indices` is dependent on - :attr:`src_dim`. Use :meth:`transpose` to create a new, transposed - :class:`Connectivity` if a different :attr:`src_dim` is needed. + :attr:`location_axis`. Use :meth:`transpose` to create a new, transposed + :class:`Connectivity` if a different :attr:`location_axis` is needed. """ - return self._metadata_manager.src_dim + return self._metadata_manager.location_axis @property - def tgt_dim(self): + def connected_axis(self): """ - Derived as the alternate value of :attr:`src_dim` - each must equal - either ``0`` or ``1``. - The dimension of the connectivity's :attr:`indices` array that varies - within the connectivity's individual :attr:`src_location`\\ s. + Derived as the alternate value of :attr:`location_axis` - each must + equal either ``0`` or ``1``. The axis of the connectivity's + :attr:`indices` array that varies over the :attr:`connected` elements + associated with each :attr:`location` element. """ - return self._tgt_dim + return self._connected_axis @property def indices(self): """ The index values describing the topological relationship of the connectivity, as a NumPy array. Masked points indicate a - :attr:`src_location` shorter than the longest :attr:`src_location` - described in this array - unused index 'slots' are masked. + :attr:`location` element with fewer :attr:`connected` elements than + other :attr:`location` elements described in this array - unused index + 'slots' are masked. **Read-only** - index values are only meaningful when combined with an appropriate :attr:`cf_role`, :attr:`start_index` and - :attr:`src_dim`. A new :class:`Connectivity` must therefore be + :attr:`location_axis`. A new :class:`Connectivity` must therefore be defined if different indices are needed. """ return self._values - def indices_by_src(self, indices=None): + def indices_by_location(self, indices=None): """ - Return a view of the indices array with :attr:`src_dim` **always** as - the first index - transposed if necessary. Can optionally pass in an + Return a view of the indices array with :attr:`location_axis` **always** as + the first axis - transposed if necessary. Can optionally pass in an identically shaped array on which to perform this operation (e.g. the output from :meth:`core_indices` or :meth:`lazy_indices`). @@ -318,7 +325,7 @@ def indices_by_src(self, indices=None): Returns: A view of the indices array, transposed - if necessary - to put - :attr:`src_dim` first. + :attr:`location_axis` first. """ if indices is None: @@ -330,20 +337,20 @@ def indices_by_src(self, indices=None): f"got shape={indices.shape} ." ) - if self.src_dim == 0: + if self.location_axis == 0: result = indices - elif self.src_dim == 1: + elif self.location_axis == 1: result = indices.transpose() else: - raise ValueError("Invalid src_dim.") + raise ValueError("Invalid location_axis.") return result def _validate_indices(self, indices, shapes_only=False): # Use shapes_only=True for a lower resource, less thorough validation # of indices by just inspecting the array shape instead of inspecting - # individual masks. So will not catch individual src_locations being - # unacceptably small. + # individual masks. So will not catch individual location elements + # having unacceptably low numbers of associated connected elements. def indices_error(message): raise ValueError("Invalid indices provided. " + message) @@ -372,43 +379,43 @@ def indices_error(message): len_req_fail = False if shapes_only: - src_shape = indices_shape[self.tgt_dim] + location_shape = indices_shape[self.connected_axis] # Wrap as lazy to allow use of the same operations below # regardless of shapes_only. - src_lengths = _lazy.as_lazy_data(np.asarray(src_shape)) + location_lengths = _lazy.as_lazy_data(np.asarray(location_shape)) else: # Wouldn't be safe to use during __init__ validation, since - # lazy_src_lengths requires self.indices to exist. Safe here since + # lazy_location_lengths requires self.indices to exist. Safe here since # shapes_only==False is only called manually, i.e. after # initialisation. - src_lengths = self.lazy_src_lengths() - if self.src_location in ("edge", "boundary"): - if (src_lengths != 2).any().compute(): + location_lengths = self.lazy_location_lengths() + if self.location in ("edge", "boundary"): + if (location_lengths != 2).any().compute(): len_req_fail = "len=2" else: - if self.src_location == "face": + if self.location == "face": min_size = 3 - elif self.src_location == "volume": - if self.tgt_location == "edge": + elif self.location == "volume": + if self.connected == "edge": min_size = 6 else: min_size = 4 else: raise NotImplementedError - if (src_lengths < min_size).any().compute(): + if (location_lengths < min_size).any().compute(): len_req_fail = f"len>={min_size}" if len_req_fail: indices_error( - f"Not all src_locations meet requirement: {len_req_fail} - " + f"Not all {self.location}s meet requirement: {len_req_fail} - " f"needed to describe '{self.cf_role}' ." ) def validate_indices(self): """ Perform a thorough validity check of this connectivity's - :attr:`indices`. Includes checking the sizes of individual - :attr:`src_location`\\ s (specified using masks on the - :attr:`indices` array) against the :attr:`cf_role`. + :attr:`indices`. Includes checking the number of :attr:`connected` + elements associated with each :attr:`location` element (specified using + masks on the :attr:`indices` array) against the :attr:`cf_role`. Raises a ``ValueError`` if any problems are encountered, otherwise passes silently. @@ -426,8 +433,8 @@ def __eq__(self, other): if isinstance(other, Connectivity): # Account for the fact that other could be the transposed equivalent # of self, which we consider 'safe' since the recommended - # interaction with the indices array is via indices_by_src, which - # corrects for this difference. (To enable this, src_dim does + # interaction with the indices array is via indices_by_location, which + # corrects for this difference. (To enable this, location_axis does # not participate in ConnectivityMetadata to ConnectivityMetadata # equivalence). if hasattr(other, "metadata"): @@ -436,22 +443,22 @@ def __eq__(self, other): if eq: eq = ( self.shape == other.shape - and self.src_dim == other.src_dim + and self.location_axis == other.location_axis ) or ( self.shape == other.shape[::-1] - and self.src_dim == other.tgt_dim + and self.location_axis == other.connected_axis ) if eq: eq = array_equal( - self.indices_by_src(self.core_indices()), - other.indices_by_src(other.core_indices()), + self.indices_by_location(self.core_indices()), + other.indices_by_location(other.core_indices()), ) return eq def transpose(self): """ Create a new :class:`Connectivity`, identical to this one but with the - :attr:`indices` array transposed and the :attr:`src_dim` value flipped. + :attr:`indices` array transposed and the :attr:`location_axis` value flipped. Returns: A new :class:`Connectivity` that is the transposed equivalent of @@ -467,7 +474,7 @@ def transpose(self): units=self.units, attributes=self.attributes, start_index=self.start_index, - src_dim=self.tgt_dim, + location_axis=self.connected_axis, ) return new_connectivity @@ -510,11 +517,11 @@ def has_lazy_indices(self): """ return super()._has_lazy_values() - def lazy_src_lengths(self): + def lazy_location_lengths(self): """ - Return a lazy array representing the lengths of each - :attr:`src_location` in the :attr:`src_dim` of the connectivity's - :attr:`indices` array, accounting for masks if present. + Return a lazy array representing the number of :attr:`connected` + elements associated with each of the connectivity's :attr:`location` + elements, accounting for masks if present. Accessing this method will never cause the :attr:`indices` values to be loaded. Similarly, calling methods on, or indexing, the returned Array @@ -524,26 +531,28 @@ def lazy_src_lengths(self): :attr:`indices` have already been loaded. Returns: - A lazy array, representing the lengths of each :attr:`src_location`. + A lazy array, representing the number of :attr:`connected` + elements associated with each :attr:`location` element. """ - src_mask_counts = da.sum( - da.ma.getmaskarray(self.indices), axis=self.tgt_dim + location_mask_counts = da.sum( + da.ma.getmaskarray(self.indices), axis=self.connected_axis ) - max_src_size = self.indices.shape[self.tgt_dim] - return max_src_size - src_mask_counts + max_location_size = self.indices.shape[self.connected_axis] + return max_location_size - location_mask_counts - def src_lengths(self): + def location_lengths(self): """ - Return a NumPy array representing the lengths of each - :attr:`src_location` in the :attr:`src_dim` of the connectivity's - :attr:`indices` array, accounting for masks if present. + Return a NumPy array representing the number of :attr:`connected` + elements associated with each of the connectivity's :attr:`location` + elements, accounting for masks if present. Returns: - A NumPy array, representing the lengths of each :attr:`src_location`. + A NumPy array, representing the number of :attr:`connected` + elements associated with each :attr:`location` element. """ - return self.lazy_src_lengths().compute() + return self.lazy_location_lengths().compute() def cube_dims(self, cube): """Not available on :class:`Connectivity`.""" @@ -556,7 +565,7 @@ def xml_element(self, doc): element.setAttribute("cf_role", self.cf_role) element.setAttribute("start_index", self.start_index) - element.setAttribute("src_dim", self.src_dim) + element.setAttribute("location_axis", self.location_axis) return element @@ -582,8 +591,8 @@ class Mesh(CFVariableMixin): AXES = ("x", "y") #: Valid range of values for ``topology_dimension``. TOPOLOGY_DIMENSIONS = (1, 2) - #: Valid mesh locations. - LOCATIONS = ("edge", "node", "face") + #: Valid mesh elements. + ELEMENTS = ("edge", "node", "face") def __init__( self, @@ -634,12 +643,12 @@ def __init__( self.attributes = attributes # based on the topology_dimension, create the appropriate coordinate manager - def normalise(location, axis): + def normalise(element, axis): result = str(axis).lower() if result not in self.AXES: - emsg = f"Invalid axis specified for {location} coordinate {coord.name()!r}, got {axis!r}." + emsg = f"Invalid axis specified for {element} coordinate {coord.name()!r}, got {axis!r}." raise ValueError(emsg) - return f"{location}_{result}" + return f"{element}_{result}" if not isinstance(node_coords_and_axes, Iterable): node_coords_and_axes = [node_coords_and_axes] @@ -1377,17 +1386,17 @@ def connectivities( :class:`~iris.experimental.ugrid.mesh.Connectivity`. * contains_node (bool): - Contains the ``node`` location as part of the + Contains the ``node`` element as part of the :attr:`~iris.experimental.ugrid.metadata.ConnectivityMetadata.cf_role` in the list of objects to be matched. * contains_edge (bool): - Contains the ``edge`` location as part of the + Contains the ``edge`` element as part of the :attr:`~iris.experimental.ugrid.metadata.ConnectivityMetadata.cf_role` in the list of objects to be matched. * contains_face (bool): - Contains the ``face`` location as part of the + Contains the ``face`` element as part of the :attr:`~iris.experimental.ugrid.metadata.ConnectivityMetadata.cf_role` in the list of objects to be matched. @@ -1478,17 +1487,17 @@ def connectivity( :class:`~iris.experimental.ugrid.mesh.Connectivity`. * contains_node (bool): - Contains the ``node`` location as part of the + Contains the ``node`` element as part of the :attr:`~iris.experimental.ugrid.metadata.ConnectivityMetadata.cf_role` in the list of objects to be matched. * contains_edge (bool): - Contains the ``edge`` location as part of the + Contains the ``edge`` element as part of the :attr:`~iris.experimental.ugrid.metadata.ConnectivityMetadata.cf_role` in the list of objects to be matched. * contains_face (bool): - Contains the ``face`` location as part of the + Contains the ``face`` element as part of the :attr:`~iris.experimental.ugrid.metadata.ConnectivityMetadata.cf_role` in the list of objects to be matched. @@ -1745,17 +1754,17 @@ def remove_connectivities( :class:`~iris.experimental.ugrid.mesh.Connectivity`. * contains_node (bool): - Contains the ``node`` location as part of the + Contains the ``node`` element as part of the :attr:`~iris.experimental.ugrid.metadata.ConnectivityMetadata.cf_role` in the list of objects to be matched for potential removal. * contains_edge (bool): - Contains the ``edge`` location as part of the + Contains the ``edge`` element as part of the :attr:`~iris.experimental.ugrid.metadata.ConnectivityMetadata.cf_role` in the list of objects to be matched for potential removal. * contains_face (bool): - Contains the ``face`` location as part of the + Contains the ``face`` element as part of the :attr:`~iris.experimental.ugrid.metadata.ConnectivityMetadata.cf_role` in the list of objects to be matched for potential removal. @@ -2091,12 +2100,12 @@ def _remove(self, **kwargs): return result - def _setter(self, location, axis, coord, shape): + def _setter(self, element, axis, coord, shape): axis = axis.lower() - member = f"{location}_{axis}" + member = f"{element}_{axis}" # enforce the UGRID minimum coordinate requirement - if location == "node" and coord is None: + if element == "node" and coord is None: emsg = ( f"{member!r} is a required coordinate, cannot set to 'None'." ) @@ -2123,22 +2132,22 @@ def _setter(self, location, axis, coord, shape): self._members[member] = coord - def _shape(self, location): - coord = getattr(self, f"{location}_x") + def _shape(self, element): + coord = getattr(self, f"{element}_x") shape = coord.shape if coord is not None else None if shape is None: - coord = getattr(self, f"{location}_y") + coord = getattr(self, f"{element}_y") if coord is not None: shape = coord.shape return shape @property def _edge_shape(self): - return self._shape(location="edge") + return self._shape(element="edge") @property def _node_shape(self): - return self._shape(location="node") + return self._shape(element="node") @property def all_members(self): @@ -2155,7 +2164,7 @@ def edge_x(self): @edge_x.setter def edge_x(self, coord): self._setter( - location="edge", axis="x", coord=coord, shape=self._edge_shape + element="edge", axis="x", coord=coord, shape=self._edge_shape ) @property @@ -2165,7 +2174,7 @@ def edge_y(self): @edge_y.setter def edge_y(self, coord): self._setter( - location="edge", axis="y", coord=coord, shape=self._edge_shape + element="edge", axis="y", coord=coord, shape=self._edge_shape ) @property @@ -2179,7 +2188,7 @@ def node_x(self): @node_x.setter def node_x(self, coord): self._setter( - location="node", axis="x", coord=coord, shape=self._node_shape + element="node", axis="x", coord=coord, shape=self._node_shape ) @property @@ -2189,7 +2198,7 @@ def node_y(self): @node_y.setter def node_y(self, coord): self._setter( - location="node", axis="y", coord=coord, shape=self._node_shape + element="node", axis="y", coord=coord, shape=self._node_shape ) def _add(self, coords): @@ -2365,7 +2374,7 @@ def __init__( @property def _face_shape(self): - return self._shape(location="face") + return self._shape(element="face") @property def all_members(self): @@ -2382,7 +2391,7 @@ def face_x(self): @face_x.setter def face_x(self, coord): self._setter( - location="face", axis="x", coord=coord, shape=self._face_shape + element="face", axis="x", coord=coord, shape=self._face_shape ) @property @@ -2392,7 +2401,7 @@ def face_y(self): @face_y.setter def face_y(self, coord): self._setter( - location="face", axis="y", coord=coord, shape=self._face_shape + element="face", axis="y", coord=coord, shape=self._face_shape ) def add( @@ -2512,24 +2521,20 @@ def add(self, *connectivities): # Validate shapes. proposed_members = {**self._members, **add_dict} - locations = set( - [ - c.src_location - for c in proposed_members.values() - if c is not None - ] + elements = set( + [c.location for c in proposed_members.values() if c is not None] ) - for location in locations: + for element in elements: counts = [ - len(c.indices_by_src(c.lazy_indices())) + len(c.indices_by_location(c.lazy_indices())) for c in proposed_members.values() - if c is not None and c.src_location == location + if c is not None and c.location == element ] # Check is list values are identical. if not counts.count(counts[0]) == len(counts): message = ( f"Invalid Connectivities provided - inconsistent " - f"{location} counts." + f"{element} counts." ) raise ValueError(message) @@ -2584,13 +2589,16 @@ def filters( instance for instance in members if instance.cf_role == cf_role ] - def location_filter(instances, loc_arg, loc_name): + def element_filter(instances, loc_arg, loc_name): if loc_arg is False: filtered = [ instance for instance in instances if loc_name - not in (instance.src_location, instance.tgt_location) + not in ( + instance.location, + instance.connected, + ) ] elif loc_arg is None: filtered = instances @@ -2599,8 +2607,7 @@ def location_filter(instances, loc_arg, loc_name): filtered = [ instance for instance in instances - if loc_name - in (instance.src_location, instance.tgt_location) + if loc_name in (instance.location, instance.connected) ] return filtered @@ -2610,7 +2617,7 @@ def location_filter(instances, loc_arg, loc_name): (contains_edge, "edge"), (contains_face, "face"), ): - members = location_filter(members, arg, loc) + members = element_filter(members, arg, loc) # No need to actually modify filtering behaviour - already won't return # any face cf-roles if none are present. @@ -2792,10 +2799,10 @@ def __init__( # NOTE: currently *not* included in metadata. In future it might be. self._mesh = mesh - if location not in Mesh.LOCATIONS: + if location not in Mesh.ELEMENTS: msg = ( f"'location' of {location} is not a valid Mesh location', " - f"must be one of {Mesh.LOCATIONS}." + f"must be one of {Mesh.ELEMENTS}." ) raise ValueError(msg) # Held in metadata, readable as self.location, but cannot set it. @@ -3037,7 +3044,7 @@ def _construct_access_arrays(self): # Data can be real or lazy, so operations must work in Dask, too. indices = bounds_connectivity.core_indices() # Normalise indices dimension order to [faces/edges, bounds] - indices = bounds_connectivity.indices_by_src(indices) + indices = bounds_connectivity.indices_by_location(indices) # Normalise the start index indices = indices - bounds_connectivity.start_index diff --git a/lib/iris/experimental/ugrid/metadata.py b/lib/iris/experimental/ugrid/metadata.py index 94128cdf50..ae0b787908 100644 --- a/lib/iris/experimental/ugrid/metadata.py +++ b/lib/iris/experimental/ugrid/metadata.py @@ -28,9 +28,9 @@ class ConnectivityMetadata(BaseMetadata): """ - # The "src_dim" member is stateful only, and does not participate in + # The "location_axis" member is stateful only, and does not participate in # lenient/strict equivalence. - _members = ("cf_role", "start_index", "src_dim") + _members = ("cf_role", "start_index", "location_axis") __slots__ = () @@ -53,7 +53,7 @@ def _combine_lenient(self, other): A list of combined metadata member values. """ - # Perform "strict" combination for "cf_role", "start_index", "src_dim". + # Perform "strict" combination for "cf_role", "start_index", "location_axis". def func(field): left = getattr(self, field) right = getattr(other, field) @@ -82,9 +82,10 @@ def _compare_lenient(self, other): """ # Perform "strict" comparison for "cf_role", "start_index". - # The "src_dim" member is not part of lenient equivalence. + # The "location_axis" member is not part of lenient equivalence. members = filter( - lambda member: member != "src_dim", ConnectivityMetadata._members + lambda member: member != "location_axis", + ConnectivityMetadata._members, ) result = all( [ @@ -112,7 +113,7 @@ def _difference_lenient(self, other): A list of difference metadata member values. """ - # Perform "strict" difference for "cf_role", "start_index", "src_dim". + # Perform "strict" difference for "cf_role", "start_index", "location_axis". def func(field): left = getattr(self, field) right = getattr(other, field) diff --git a/lib/iris/fileformats/netcdf.py b/lib/iris/fileformats/netcdf.py index 77134259ad..100ab29daa 100644 --- a/lib/iris/fileformats/netcdf.py +++ b/lib/iris/fileformats/netcdf.py @@ -972,9 +972,9 @@ def __setitem__(self, keys, arr): self.target[keys] = arr -# NOTE : this matches :class:`iris.experimental.ugrid.mesh.Mesh.LOCATIONS`, +# NOTE : this matches :class:`iris.experimental.ugrid.mesh.Mesh.ELEMENTS`, # but in the preferred order for coord/connectivity variables in the file. -MESH_LOCATIONS = ("node", "edge", "face") +MESH_ELEMENTS = ("node", "edge", "face") class Saver: @@ -1422,7 +1422,7 @@ def _add_mesh(self, cube_or_mesh): mesh_dims = self._mesh_dims[mesh] # Add all the element coordinate variables. - for location in MESH_LOCATIONS: + for location in MESH_ELEMENTS: coords_meshobj_attr = f"{location}_coords" coords_file_attr = f"{location}_coordinates" mesh_coords = getattr(mesh, coords_meshobj_attr, None) @@ -1460,7 +1460,7 @@ def _add_mesh(self, cube_or_mesh): last_dim = f"{cf_mesh_name}_{loc_from}_N_{loc_to}s" # Create if it does not already exist. if last_dim not in self._dataset.dimensions: - length = conn.shape[1 - conn.src_dim] + length = conn.shape[1 - conn.location_axis] self._dataset.createDimension(last_dim, length) # Create variable. @@ -1470,7 +1470,7 @@ def _add_mesh(self, cube_or_mesh): # when it is first created. loc_dim_name = mesh_dims[loc_from] conn_dims = (loc_dim_name, last_dim) - if conn.src_dim == 1: + if conn.location_axis == 1: # Has the 'other' dimension order, =reversed conn_dims = conn_dims[::-1] if iris.util.is_masked(conn.core_indices()): @@ -1494,7 +1494,7 @@ def _add_mesh(self, cube_or_mesh): _setncattr(cf_mesh_var, cf_conn_attr_name, cf_conn_name) # If the connectivity had the 'alternate' dimension order, add the # relevant dimension property - if conn.src_dim == 1: + if conn.location_axis == 1: loc_dim_attr = f"{loc_from}_dimension" # Should only get here once. assert loc_dim_attr not in cf_mesh_var.ncattrs() @@ -1813,7 +1813,7 @@ def record_dimension(names_list, dim_name, length, matching_coords=[]): # NOTE: one of these will be a cube dimension, but that one does not # get any special handling. We *do* want to list/create them in a # definite order (node,edge,face), and before non-mesh dimensions. - for location in MESH_LOCATIONS: + for location in MESH_ELEMENTS: # Find if this location exists in the mesh, and a characteristic # coordinate to identify it with. # To use only _required_ UGRID components, we use a location @@ -1850,7 +1850,9 @@ def record_dimension(names_list, dim_name, length, matching_coords=[]): (dim_length,) = dim_element.shape else: # extract source dim, respecting dim-ordering - dim_length = dim_element.shape[dim_element.src_dim] + dim_length = dim_element.shape[ + dim_element.location_axis + ] # Name it for the relevant mesh dimension location_dim_attr = f"{location}_dimension" dim_name = getattr(mesh, location_dim_attr) diff --git a/lib/iris/tests/unit/common/mixin/test_CFVariableMixin.py b/lib/iris/tests/unit/common/mixin/test_CFVariableMixin.py index 1fa579ef94..88a88be567 100644 --- a/lib/iris/tests/unit/common/mixin/test_CFVariableMixin.py +++ b/lib/iris/tests/unit/common/mixin/test_CFVariableMixin.py @@ -286,13 +286,15 @@ def test_class_cellmeasuremetadata(self): ) def test_class_connectivitymetadata(self): - self.args.update(dict(cf_role=None, start_index=None, src_dim=None)) + self.args.update( + dict(cf_role=None, start_index=None, location_axis=None) + ) metadata = ConnectivityMetadata(**self.args) self.item.metadata = metadata expected = metadata._asdict() del expected["cf_role"] del expected["start_index"] - del expected["src_dim"] + del expected["location_axis"] self.assertEqual(self.item._metadata_manager.values, expected) self.assertIsNot( self.item._metadata_manager.attributes, metadata.attributes diff --git a/lib/iris/tests/unit/coords/test__DimensionalMetadata.py b/lib/iris/tests/unit/coords/test__DimensionalMetadata.py index d403b6c4e2..9a09c4e807 100644 --- a/lib/iris/tests/unit/coords/test__DimensionalMetadata.py +++ b/lib/iris/tests/unit/coords/test__DimensionalMetadata.py @@ -821,7 +821,7 @@ def test_cellmeasure(self): def test_connectivity(self): # Check we can print a Connectivity - # Like a Coord, but always print : cf_role, src_dim, start_index + # Like a Coord, but always print : cf_role, location_axis, start_index data = self.sample_data(shape=(3, 2), datatype=int) conn = Connectivity( data, cf_role="edge_node_connectivity", long_name="enc", units="1" @@ -839,13 +839,13 @@ def test_connectivity(self): " long_name: 'enc'", " cf_role: 'edge_node_connectivity'", " start_index: 0", - " src_dim: 0", + " location_axis: 0", ] self.assertLines(expected, result) def test_connectivity__start_index(self): # Check we can print a Connectivity - # Like a Coord, but always print : cf_role, src_dim, start_index + # Like a Coord, but always print : cf_role, location_axis, start_index data = self.sample_data(shape=(3, 2), datatype=int) conn = Connectivity( data + 1, @@ -867,17 +867,17 @@ def test_connectivity__start_index(self): " long_name: 'enc'", " cf_role: 'edge_node_connectivity'", " start_index: 1", - " src_dim: 0", + " location_axis: 0", ] self.assertLines(expected, result) - def test_connectivity__src_dim(self): + def test_connectivity__location_axis(self): # Check we can print a Connectivity - # Like a Coord, but always print : cf_role, src_dim, start_index + # Like a Coord, but always print : cf_role, location_axis, start_index data = self.sample_data(shape=(3, 2), datatype=int) conn = Connectivity( data.transpose(), - src_dim=1, + location_axis=1, cf_role="edge_node_connectivity", long_name="enc", units="1", @@ -894,7 +894,7 @@ def test_connectivity__src_dim(self): " long_name: 'enc'", " cf_role: 'edge_node_connectivity'", " start_index: 0", - " src_dim: 1", + " location_axis: 1", ] self.assertLines(expected, result) diff --git a/lib/iris/tests/unit/experimental/ugrid/mesh/test_Connectivity.py b/lib/iris/tests/unit/experimental/ugrid/mesh/test_Connectivity.py index c0117ffc79..d447957918 100644 --- a/lib/iris/tests/unit/experimental/ugrid/mesh/test_Connectivity.py +++ b/lib/iris/tests/unit/experimental/ugrid/mesh/test_Connectivity.py @@ -29,28 +29,30 @@ def setUp(self): "var_name": "face_nodes", "attributes": {"notes": "this is a test"}, "start_index": 1, - "src_dim": 1, + "location_axis": 1, } self.connectivity = Connectivity(**self.kwargs) def test_cf_role(self): self.assertEqual(self.kwargs["cf_role"], self.connectivity.cf_role) - def test_src_location(self): + def test_location(self): expected = self.kwargs["cf_role"].split("_")[0] - self.assertEqual(expected, self.connectivity.src_location) + self.assertEqual(expected, self.connectivity.location) - def test_tgt_location(self): + def test_connected(self): expected = self.kwargs["cf_role"].split("_")[1] - self.assertEqual(expected, self.connectivity.tgt_location) + self.assertEqual(expected, self.connectivity.connected) def test_start_index(self): self.assertEqual( self.kwargs["start_index"], self.connectivity.start_index ) - def test_src_dim(self): - self.assertEqual(self.kwargs["src_dim"], self.connectivity.src_dim) + def test_location_axis(self): + self.assertEqual( + self.kwargs["location_axis"], self.connectivity.location_axis + ) def test_indices(self): self.assertArrayEqual( @@ -58,7 +60,7 @@ def test_indices(self): ) def test_read_only(self): - attributes = ("indices", "cf_role", "start_index", "src_dim") + attributes = ("indices", "cf_role", "start_index", "location_axis") for attribute in attributes: self.assertRaisesRegex( AttributeError, @@ -70,10 +72,10 @@ def test_read_only(self): ) def test_transpose(self): - expected_dim = 1 - self.kwargs["src_dim"] + expected_dim = 1 - self.kwargs["location_axis"] expected_indices = self.kwargs["indices"].transpose() new_connectivity = self.connectivity.transpose() - self.assertEqual(expected_dim, new_connectivity.src_dim) + self.assertEqual(expected_dim, new_connectivity.location_axis) self.assertArrayEqual(expected_indices, new_connectivity.indices) def test_lazy_indices(self): @@ -87,12 +89,14 @@ def test_core_indices(self): def test_has_lazy_indices(self): self.assertFalse(self.connectivity.has_lazy_indices()) - def test_lazy_src_lengths(self): - self.assertTrue(is_lazy_data(self.connectivity.lazy_src_lengths())) + def test_lazy_location_lengths(self): + self.assertTrue( + is_lazy_data(self.connectivity.lazy_location_lengths()) + ) - def test_src_lengths(self): + def test_location_lengths(self): expected = [4, 4, 4] - self.assertArrayEqual(expected, self.connectivity.src_lengths()) + self.assertArrayEqual(expected, self.connectivity.location_lengths()) def test___str__(self): expected = "\n".join( @@ -110,7 +114,7 @@ def test___str__(self): " attributes: {'notes': 'this is a test'}", " cf_role: 'face_node_connectivity'", " start_index: 1", - " src_dim: 1", + " location_axis: 1", ] ) self.assertEqual(expected, self.connectivity.__str__()) @@ -123,13 +127,13 @@ def test_xml_element(self): doc = minidom.Document() connectivity_element = self.connectivity.xml_element(doc) self.assertEqual(connectivity_element.tagName, "connectivity") - for attribute in ("cf_role", "start_index", "src_dim"): + for attribute in ("cf_role", "start_index", "location_axis"): self.assertIn(attribute, connectivity_element.attributes) def test___eq__(self): equivalent_kwargs = self.kwargs equivalent_kwargs["indices"] = self.kwargs["indices"].transpose() - equivalent_kwargs["src_dim"] = 1 - self.kwargs["src_dim"] + equivalent_kwargs["location_axis"] = 1 - self.kwargs["location_axis"] equivalent = Connectivity(**equivalent_kwargs) self.assertFalse( np.array_equal(equivalent.indices, self.connectivity.indices) @@ -160,16 +164,18 @@ def test_copy(self): copy_connectivity = self.connectivity.copy(new_indices) self.assertArrayEqual(new_indices, copy_connectivity.indices) - def test_indices_by_src(self): + def test_indices_by_location(self): expected = self.kwargs["indices"].transpose() - self.assertArrayEqual(expected, self.connectivity.indices_by_src()) + self.assertArrayEqual( + expected, self.connectivity.indices_by_location() + ) - def test_indices_by_src_input(self): + def test_indices_by_location_input(self): expected = as_lazy_data(self.kwargs["indices"].transpose()) - by_src = self.connectivity.indices_by_src( + by_location = self.connectivity.indices_by_location( self.connectivity.lazy_indices() ) - self.assertArrayEqual(expected, by_src) + self.assertArrayEqual(expected, by_location) class TestAltIndices(tests.IrisTest): @@ -220,14 +226,14 @@ def test_start_index(self): ValueError, "Invalid start_index .", Connectivity, **kwargs ) - def test_src_dim(self): + def test_location_axis(self): kwargs = { "indices": np.linspace(1, 9, 9, dtype=int).reshape((-1, 3)), "cf_role": "face_node_connectivity", - "src_dim": 2, + "location_axis": 2, } self.assertRaisesRegex( - ValueError, "Invalid src_dim .", Connectivity, **kwargs + ValueError, "Invalid location_axis .", Connectivity, **kwargs ) def test_cf_role(self): @@ -285,7 +291,7 @@ def test_indices_locations_edge(self): } self.assertRaisesRegex( ValueError, - "Not all src_locations meet requirement: len=2", + "Not all edges meet requirement: len=2", Connectivity, **kwargs, ) @@ -297,7 +303,7 @@ def test_indices_locations_face(self): } self.assertRaisesRegex( ValueError, - "Not all src_locations meet requirement: len>=3", + "Not all faces meet requirement: len>=3", Connectivity, **kwargs, ) @@ -309,7 +315,7 @@ def test_indices_locations_volume_face(self): } self.assertRaisesRegex( ValueError, - "Not all src_locations meet requirement: len>=4", + "Not all volumes meet requirement: len>=4", Connectivity, **kwargs, ) @@ -321,7 +327,7 @@ def test_indices_locations_volume_edge(self): } self.assertRaisesRegex( ValueError, - "Not all src_locations meet requirement: len>=6", + "Not all volumes meet requirement: len>=6", Connectivity, **kwargs, ) @@ -331,11 +337,11 @@ def test_indices_locations_alt_dim(self): kwargs = { "indices": np.linspace(1, 9, 9, dtype=int).reshape((3, -1)), "cf_role": "volume_face_connectivity", - "src_dim": 1, + "location_axis": 1, } self.assertRaisesRegex( ValueError, - "Not all src_locations meet requirement: len>=4", + "Not all volumes meet requirement: len>=4", Connectivity, **kwargs, ) @@ -352,7 +358,7 @@ def test_indices_locations_masked(self): connectivity = Connectivity(**kwargs) self.assertRaisesRegex( ValueError, - "Not all src_locations meet requirement: len>=3", + "Not all faces meet requirement: len>=3", connectivity.validate_indices, ) diff --git a/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh.py b/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh.py index 1df67deb66..6bd7ea5466 100644 --- a/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh.py +++ b/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh.py @@ -210,7 +210,7 @@ def test_connectivities(self): for kwargs in negative_kwargs: self.assertEqual([], func(**kwargs)) - def test_connectivities_locations(self): + def test_connectivities_elements(self): # topology_dimension-specific results. Method intended to be overridden. positive_kwargs = ( {"contains_node": True}, @@ -270,7 +270,7 @@ def test_coords(self): for kwargs in negative_kwargs: self.assertNotIn(self.NODE_LON, func(**kwargs)) - def test_coords_locations(self): + def test_coords_elements(self): # topology_dimension-specific results. Method intended to be overridden. all_expected = { "node_x": self.NODE_LON, @@ -522,7 +522,7 @@ def test_connectivity(self): contains_face=False, ) - def test_connectivities_locations(self): + def test_connectivities_elements(self): kwargs_expected = ( ( {"contains_node": True}, @@ -578,7 +578,7 @@ def test_connectivities_locations(self): for item in expected: self.assertIn(item, result) - def test_coords_locations(self): + def test_coords_elements(self): all_expected = { "node_x": self.NODE_LON, "node_y": self.NODE_LAT, @@ -732,7 +732,7 @@ def setUp(self): @staticmethod def new_connectivity(connectivity, new_len=False): """Provide a new connectivity recognisably different from the original.""" - # NOTE: assumes non-transposed connectivity (src_dim=0). + # NOTE: assumes non-transposed connectivity (location_axis=0). if new_len: shape = (connectivity.shape[0] + 1, connectivity.shape[1]) else: diff --git a/lib/iris/tests/unit/experimental/ugrid/mesh/test_MeshCoord.py b/lib/iris/tests/unit/experimental/ugrid/mesh/test_MeshCoord.py index 8c2e652c31..8f4222ca7b 100644 --- a/lib/iris/tests/unit/experimental/ugrid/mesh/test_MeshCoord.py +++ b/lib/iris/tests/unit/experimental/ugrid/mesh/test_MeshCoord.py @@ -61,7 +61,7 @@ def test_fail_bad_mesh(self): sample_meshcoord(mesh=mock.sentinel.odd) def test_valid_locations(self): - for loc in Mesh.LOCATIONS: + for loc in Mesh.ELEMENTS: meshcoord = sample_meshcoord(location=loc) self.assertEqual(meshcoord.location, loc) @@ -536,12 +536,12 @@ def _make_test_meshcoord( lazy_sources=False, location="face", inds_start_index=0, - inds_src_dim=0, + inds_location_axis=0, facenodes_changes=None, ): # Construct a miniature face-nodes mesh for testing. # NOTE: we will make our connectivity arrays with standard - # start_index=0 and src_dim=0 : We only adjust that (if required) when + # start_index=0 and location_axis=0 : We only adjust that (if required) when # creating the actual connectivities. face_nodes_array = np.array( [ @@ -626,26 +626,26 @@ def lazify(arr): inds_start_index + ( face_nodes_array.transpose() - if inds_src_dim == 1 + if inds_location_axis == 1 else face_nodes_array ), cf_role="face_node_connectivity", long_name="face_nodes", start_index=inds_start_index, - src_dim=inds_src_dim, + location_axis=inds_location_axis, ) edge_node_conn = Connectivity( inds_start_index + ( edge_nodes_array.transpose() - if inds_src_dim == 1 + if inds_location_axis == 1 else edge_nodes_array ), cf_role="edge_node_connectivity", long_name="edge_nodes", start_index=inds_start_index, - src_dim=inds_src_dim, + location_axis=inds_location_axis, ) self.mesh = Mesh( @@ -729,9 +729,9 @@ def test_edge_bounds(self): # NB simpler than faces : no possibility of missing points self.assertArrayAlmostEqual(result, expected) - def test_bounds_connectivity__src_dim_1(self): + def test_bounds_connectivity__location_axis_1(self): # Test with a transposed indices array. - self._make_test_meshcoord(inds_src_dim=1) + self._make_test_meshcoord(inds_location_axis=1) self._check_expected_bounds_values() def test_bounds_connectivity__start_index_1(self): diff --git a/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh__from_coords.py b/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh__from_coords.py index aee5018e5b..edd34f94a1 100644 --- a/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh__from_coords.py +++ b/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh__from_coords.py @@ -217,7 +217,7 @@ def test_mixed_shapes(self): mesh = self.create() self.assertArrayEqual( - mesh.face_node_connectivity.src_lengths(), [4, 4, 3] + mesh.face_node_connectivity.location_lengths(), [4, 4, 3] ) self.assertEqual(mesh.node_coords.node_x.points[-1], 0.0) self.assertEqual(mesh.node_coords.node_y.points[-1], 0.0) diff --git a/lib/iris/tests/unit/experimental/ugrid/metadata/test_ConnectivityMetadata.py b/lib/iris/tests/unit/experimental/ugrid/metadata/test_ConnectivityMetadata.py index f119f53729..af92e69b08 100644 --- a/lib/iris/tests/unit/experimental/ugrid/metadata/test_ConnectivityMetadata.py +++ b/lib/iris/tests/unit/experimental/ugrid/metadata/test_ConnectivityMetadata.py @@ -29,7 +29,7 @@ def setUp(self): self.attributes = mock.sentinel.attributes self.cf_role = mock.sentinel.cf_role self.start_index = mock.sentinel.start_index - self.src_dim = mock.sentinel.src_dim + self.location_axis = mock.sentinel.location_axis self.cls = ConnectivityMetadata def test_repr(self): @@ -41,12 +41,12 @@ def test_repr(self): attributes=self.attributes, cf_role=self.cf_role, start_index=self.start_index, - src_dim=self.src_dim, + location_axis=self.location_axis, ) fmt = ( "ConnectivityMetadata(standard_name={!r}, long_name={!r}, " "var_name={!r}, units={!r}, attributes={!r}, cf_role={!r}, " - "start_index={!r}, src_dim={!r})" + "start_index={!r}, location_axis={!r})" ) expected = fmt.format( self.standard_name, @@ -56,7 +56,7 @@ def test_repr(self): self.attributes, self.cf_role, self.start_index, - self.src_dim, + self.location_axis, ) self.assertEqual(expected, repr(metadata)) @@ -69,7 +69,7 @@ def test__fields(self): "attributes", "cf_role", "start_index", - "src_dim", + "location_axis", ) self.assertEqual(self.cls._fields, expected) @@ -87,14 +87,14 @@ def setUp(self): attributes=sentinel.attributes, cf_role=sentinel.cf_role, start_index=sentinel.start_index, - src_dim=sentinel.src_dim, + location_axis=sentinel.location_axis, ) self.dummy = sentinel.dummy self.cls = ConnectivityMetadata - # The "src_dim" member is stateful only, and does not participate in + # The "location_axis" member is stateful only, and does not participate in # lenient/strict equivalence. - self.members_no_src_dim = filter( - lambda member: member != "src_dim", self.cls._members + self.members_no_location_axis = filter( + lambda member: member != "location_axis", self.cls._members ) def test_wraps_docstring(self): @@ -140,7 +140,7 @@ def test_op_lenient_same_none(self): self.assertTrue(rmetadata.__eq__(lmetadata)) def test_op_lenient_same_members_none(self): - for member in self.members_no_src_dim: + for member in self.members_no_location_axis: lmetadata = self.cls(**self.values) right = self.values.copy() right[member] = None @@ -152,10 +152,10 @@ def test_op_lenient_same_members_none(self): self.assertFalse(lmetadata.__eq__(rmetadata)) self.assertFalse(rmetadata.__eq__(lmetadata)) - def test_op_lenient_same_src_dim_none(self): + def test_op_lenient_same_location_axis_none(self): lmetadata = self.cls(**self.values) right = self.values.copy() - right["src_dim"] = None + right["location_axis"] = None rmetadata = self.cls(**right) with mock.patch("iris.common.metadata._LENIENT", return_value=True): @@ -173,7 +173,7 @@ def test_op_lenient_different(self): self.assertFalse(rmetadata.__eq__(lmetadata)) def test_op_lenient_different_members(self): - for member in self.members_no_src_dim: + for member in self.members_no_location_axis: lmetadata = self.cls(**self.values) right = self.values.copy() right[member] = self.dummy @@ -185,10 +185,10 @@ def test_op_lenient_different_members(self): self.assertFalse(lmetadata.__eq__(rmetadata)) self.assertFalse(rmetadata.__eq__(lmetadata)) - def test_op_lenient_different_src_dim(self): + def test_op_lenient_different_location_axis(self): lmetadata = self.cls(**self.values) right = self.values.copy() - right["src_dim"] = self.dummy + right["location_axis"] = self.dummy rmetadata = self.cls(**right) with mock.patch("iris.common.metadata._LENIENT", return_value=True): @@ -214,7 +214,7 @@ def test_op_strict_different(self): self.assertFalse(rmetadata.__eq__(lmetadata)) def test_op_strict_different_members(self): - for member in self.members_no_src_dim: + for member in self.members_no_location_axis: lmetadata = self.cls(**self.values) right = self.values.copy() right[member] = self.dummy @@ -226,10 +226,10 @@ def test_op_strict_different_members(self): self.assertFalse(lmetadata.__eq__(rmetadata)) self.assertFalse(rmetadata.__eq__(lmetadata)) - def test_op_strict_different_src_dim(self): + def test_op_strict_different_location_axis(self): lmetadata = self.cls(**self.values) right = self.values.copy() - right["src_dim"] = self.dummy + right["location_axis"] = self.dummy rmetadata = self.cls(**right) with mock.patch("iris.common.metadata._LENIENT", return_value=False): @@ -247,7 +247,7 @@ def test_op_strict_different_none(self): self.assertFalse(rmetadata.__eq__(lmetadata)) def test_op_strict_different_members_none(self): - for member in self.members_no_src_dim: + for member in self.members_no_location_axis: lmetadata = self.cls(**self.values) right = self.values.copy() right[member] = None @@ -259,10 +259,10 @@ def test_op_strict_different_members_none(self): self.assertFalse(lmetadata.__eq__(rmetadata)) self.assertFalse(rmetadata.__eq__(lmetadata)) - def test_op_strict_different_src_dim_none(self): + def test_op_strict_different_location_axis_none(self): lmetadata = self.cls(**self.values) right = self.values.copy() - right["src_dim"] = None + right["location_axis"] = None rmetadata = self.cls(**right) with mock.patch("iris.common.metadata._LENIENT", return_value=False): @@ -311,7 +311,7 @@ def setUp(self): attributes=sentinel.attributes, cf_role=sentinel.cf_role, start_index=sentinel.start_index, - src_dim=sentinel.src_dim, + location_axis=sentinel.location_axis, ) self.dummy = sentinel.dummy self.cls = ConnectivityMetadata @@ -508,7 +508,7 @@ def setUp(self): attributes=sentinel.attributes, cf_role=sentinel.cf_role, start_index=sentinel.start_index, - src_dim=sentinel.src_dim, + location_axis=sentinel.location_axis, ) self.dummy = sentinel.dummy self.cls = ConnectivityMetadata diff --git a/lib/iris/tests/unit/fileformats/netcdf/test_Saver__ugrid.py b/lib/iris/tests/unit/fileformats/netcdf/test_Saver__ugrid.py index 87c2df7d45..a914dd3314 100644 --- a/lib/iris/tests/unit/fileformats/netcdf/test_Saver__ugrid.py +++ b/lib/iris/tests/unit/fileformats/netcdf/test_Saver__ugrid.py @@ -184,7 +184,7 @@ def mesh_location_size(mesh, location): if conn is None: result = 0 else: - result = conn.shape[conn.src_dim] + result = conn.shape[conn.location_axis] return result @@ -705,7 +705,7 @@ def test_connectivity_dim_order(self): # Get the face-node and edge-node connectivities face_nodes_conn = mesh.face_node_connectivity edge_nodes_conn = mesh.edge_node_connectivity - # Transpose them : N.B. this sets src_dim=1, as it should be. + # Transpose them : N.B. this sets location_axis=1, as it should be. nodesfirst_faces_conn = face_nodes_conn.transpose() nodesfirst_edges_conn = edge_nodes_conn.transpose() # Make a new mesh with both face and edge connectivities 'transposed'.