iris.experimental.ugrid#
Infra-structure for unstructured mesh support.
Based on CF UGRID Conventions (v1.0), https://ugrid-conventions.github.io/ugrid-conventions/.
Note
For the docstring of PARSE_UGRID_ON_LOAD: see the original
definition at iris.experimental.ugrid.load.PARSE_UGRID_ON_LOAD.
- class iris.experimental.ugrid.Connectivity(indices, cf_role, standard_name=None, long_name=None, var_name=None, units=None, attributes=None, start_index=0, location_axis=0)[source]#
Bases:
_DimensionalMetadataCF-UGRID topology.
A CF-UGRID topology connectivity, describing the topological relationship 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
Construct a single connectivity.
- Parameters:
indices (
numpy.ndarrayornumpy.ma.core.MaskedArrayordask.array.Array) – 2D array giving the topological connection relationship betweenlocationelements andconnectedelements. Thelocation_axisdimension indexes over thelocationdimension of the mesh - i.e. its length matches the total number oflocationelements in the mesh. Theconnected_axisdimension can be any length, corresponding to the highest number ofconnectedelements connected to alocationelement. The array values are indices into theconnecteddimension of the mesh. If the number ofconnectedelements varies betweenlocationelements: use anumpy.ma.core.MaskedArrayand mask thelocationelements’ unused index ‘slots’. Use adask.array.Arrayto keep indices ‘lazy’.cf_role (str) – Denotes the topological relationship that this connectivity describes. Made up of this array’s
location, and theconnectedelement type that is indexed by the array. SeeUGRID_CF_ROLESfor valid arguments.standard_name (str, optional) – CF standard name of the connectivity. (NOTE: this is not expected by the UGRID conventions, but will be handled in Iris’ standard way if provided).
long_name (str, optional) – Descriptive name of the connectivity.
var_name (str, optional) – The NetCDF variable name for the connectivity.
units (cf_units.Unit, optional) – The
Unitof the connectivity’s values. Can be a string, which will be converted to a Unit object. (NOTE: this is not expected by the UGRID conventions, but will be handled in Iris’ standard way if provided).attributes (dict, optional) – A dictionary containing other cf and user-defined attributes.
start_index (int, optional) – Either
0or1. Default is0. Denotes whetherindicesuses 0-based or 1-based indexing (allows support for Fortran and legacy NetCDF files).location_axis (int, optional) – Either
0or1. Default is0. Denotes which axis ofindicesvaries over thelocationelements (the alternate axis therefore varying overconnectedelements). (This parameter allows support for fastest varying index being either first or last). E.g. forface_node_connectivity, for 10 faces:indices.shape[location_axis] == 10.
- UGRID_CF_ROLES = ['edge_node_connectivity', 'face_node_connectivity', 'face_edge_connectivity', 'face_face_connectivity', 'edge_face_connectivity', 'boundary_node_connectivity', 'volume_node_connectivity', 'volume_edge_connectivity', 'volume_face_connectivity', 'volume_volume_connectivity']#
- property cf_role#
The category of topological relationship that this connectivity describes.
Read-only - validity of
indicesis dependent oncf_role. A newConnectivitymust therefore be defined if a differentcf_roleis needed.
- property connected#
Derived from the connectivity’s
cf_role.Derived from the connectivity’s
cf_role- the second part, e.g.nodeinface_node_connectivity. Refers to the elements indexed by the values in the connectivity’sindicesarray.
- property connected_axis#
Derived as the alternate value of
location_axis.Derived as the alternate value of
location_axis- each must equal either0or1. The axis of the connectivity’sindicesarray that varies over theconnectedelements associated with eachlocationelement.
- core_indices()[source]#
Return the indices array at the core of this connectivity.
The indices array at the core of this connectivity, which may be a NumPy array or a Dask array.
- Return type:
numpy.ndarrayornumpy.ma.core.MaskedArrayordask.array.Array
- cube_dims(cube)[source]#
Not available on
Connectivity.
- has_lazy_indices()[source]#
Check if the connectivity’s
indicesarray is a lazy Dask array or not.- Return type:
- property indices#
The index values describing the topological relationship of the connectivity.
The index values describing the topological relationship of the connectivity, as a NumPy array. Masked points indicate a
locationelement with fewerconnectedelements than otherlocationelements described in this array - unused index ‘slots’ are masked.Read-only - index values are only meaningful when combined with an appropriate
cf_role,start_indexandlocation_axis. A newConnectivitymust therefore be defined if different indices are needed.
- indices_by_location(indices=None)[source]#
Return a view of the indices array.
Return a view of the indices array with
location_axisalways 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 fromcore_indices()orlazy_indices()).- Parameters:
indices (array) – The array on which to operate. If
None, will operate onindices. Default isNone.- Returns:
A view of the indices array Transposed - if necessary - to put
location_axisfirst.- Return type:
result
- lazy_indices()[source]#
Return a lazy array representing the connectivity’s indices.
Accessing this method will never cause the
indicesvalues to be loaded. Similarly, calling methods on, or indexing, the returned Array will not cause the connectivity to have loadedindices.If the
indiceshave already been loaded for the connectivity, the returned Array will be a new lazy array wrapper.- Return type:
A lazy array, representing the connectivity indices array.
- lazy_location_lengths()[source]#
Return a lazy array representing the number of
connectedelements.Return a lazy array representing the number of
connectedelements associated with each of the connectivity’slocationelements, accounting for masks if present.Accessing this method will never cause the
indicesvalues to be loaded. Similarly, calling methods on, or indexing, the returned Array will not cause the connectivity to have loadedindices.The returned Array will be lazy regardless of whether the
indiceshave already been loaded.
- property location#
Derived from the connectivity’s
cf_role.Derived from the connectivity’s
cf_role- the first part, e.g.faceinface_node_connectivity. Refers to the elements that vary along thelocation_axisof the connectivity’sindicesarray.
- property location_axis#
The axis of the connectivity’s
indicesarray.The axis of the connectivity’s
indicesarray that varies over the connectivity’slocationelements. Either0or1. Read-only - validity ofindicesis dependent onlocation_axis. Usetranspose()to create a new, transposedConnectivityif a differentlocation_axisis needed.
- location_lengths()[source]#
Return a NumPy array representing the number of
connectedelements.Return a NumPy array representing the number of
connectedelements associated with each of the connectivity’slocationelements, accounting for masks if present.
- property start_index#
The base value of the connectivity’s
indicesarray; either0or1.Read-only - validity of
indicesis dependent onstart_index. A newConnectivitymust therefore be defined if a differentstart_indexis needed.
- transpose()[source]#
Transpose
Connectivity.Create a new
Connectivity, identical to this one but with theindicesarray transposed and thelocation_axisvalue flipped.- Returns:
A new
Connectivitythat is the transposed equivalent of the original.- Return type:
- validate_indices()[source]#
Perform a thorough validity check of this connectivity’s
indices.Perform a thorough validity check of this connectivity’s
indices. Includes checking the number ofconnectedelements associated with eachlocationelement (specified using masks on theindicesarray) against thecf_role.Raises a
ValueErrorif any problems are encountered, otherwise passes silently.Note
While this uses lazy computation, it will still be a high resource demand for a large
indicesarray.
- class iris.experimental.ugrid.Mesh(topology_dimension, node_coords_and_axes, connectivities, edge_coords_and_axes=None, face_coords_and_axes=None, standard_name=None, long_name=None, var_name=None, units=None, attributes=None, node_dimension=None, edge_dimension=None, face_dimension=None)[source]#
Bases:
CFVariableMixinA container representing the UGRID
cf_rolemesh_topology.A container representing the UGRID
cf_rolemesh_topology, supporting 1D network, 2D triangular, and 2D flexible mesh topologies.Note
The 3D layered and fully 3D unstructured mesh topologies are not supported at this time.
See also
The UGRID Conventions, https://ugrid-conventions.github.io/ugrid-conventions/
Mesh initialise.
Note
The purpose of the
node_dimension,edge_dimensionandface_dimensionproperties are to preserve the original NetCDF variable dimension names. Note that, onlyedge_dimensionandface_dimensionare UGRID attributes, and are only present fortopology_dimension>=2.- AXES = ('x', 'y')#
The supported mesh axes.
- ELEMENTS = ('edge', 'node', 'face')#
Valid mesh elements.
- TOPOLOGY_DIMENSIONS = (1, 2)#
Valid range of values for
topology_dimension.
- add_connectivities(*connectivities)[source]#
Add one or more
Connectivityinstances to theMesh.- Parameters:
*connectivities (iterable of object) – A collection of one or more
Connectivityinstances to add to theMesh.
- property all_connectivities#
All the
Connectivityinstances of theMesh.
- property boundary_node_connectivity#
The optional UGRID
boundary_node_connectivityConnectivity.The optional UGRID
boundary_node_connectivityConnectivityof theMesh.
- connectivities(item=None, standard_name=None, long_name=None, var_name=None, attributes=None, cf_role=None, contains_node=None, contains_edge=None, contains_face=None)[source]#
Return all
Connectivity.Return all
Connectivityinstances from theMeshthat match the provided criteria.Criteria can be either specific properties or other objects with metadata to be matched.
See also
Mesh.connectivity()for matching exactly one connectivity.- Parameters:
Either,
a
standard_name,long_name, orvar_namewhich is compared against thename().a connectivity or metadata instance equal to that of the desired objects e.g.,
ConnectivityorConnectivityMetadata.
standard_name (str, optional, default=None) – The CF standard name of the desired
Connectivity. IfNone, does not check forstandard_name.long_name (str, optional, default=None) – An unconstrained description of the
Connectivity. IfNone, does not check forlong_name.var_name (str, optional, default=None) – The NetCDF variable name of the desired
Connectivity. IfNone, does not check forvar_name.attributes (dict, optional, default=None) – A dictionary of attributes desired on the
Connectivity. IfNone, does not check forattributes.cf_role (str, optional, default=None) – The UGRID
cf_roleof the desiredConnectivity.contains_node (bool, optional) – Contains the
nodeelement as part of thecf_rolein the list of objects to be matched.contains_edge (bool, optional) – Contains the
edgeelement as part of thecf_rolein the list of objects to be matched.contains_face (bool, optional) – Contains the
faceelement as part of thecf_rolein the list of objects to be matched.
- Returns:
A list of
Connectivityinstances from theMeshthat matched the given criteria.- Return type:
list of
Connectivity
- connectivity(item=None, standard_name=None, long_name=None, var_name=None, attributes=None, cf_role=None, contains_node=None, contains_edge=None, contains_face=None)[source]#
Return a single
Connectivity.Return a single
Connectivityfrom theMeshthat matches the provided criteria.Criteria can be either specific properties or other objects with metadata to be matched.
Note
If the given criteria do not return precisely one
Connectivity, then aConnectivityNotFoundErroris raised.See also
Mesh.connectivities()for matching zero or more connectivities.- Parameters:
Either,
a
standard_name,long_name, orvar_namewhich is compared against thename().a connectivity or metadata instance equal to that of the desired object e.g.,
ConnectivityorConnectivityMetadata.
standard_name (str, optional, default=None) – The CF standard name of the desired
Connectivity. IfNone, does not check forstandard_name.long_name (str, optional, default=None) – An unconstrained description of the
Connectivity. IfNone, does not check forlong_name.var_name (str, optional, default=None) – The NetCDF variable name of the desired
Connectivity. IfNone, does not check forvar_name.attributes (dict, optional, default=None) – A dictionary of attributes desired on the
Connectivity. IfNone, does not check forattributes.cf_role (str, optional, default=None) – The UGRID
cf_roleof the desiredConnectivity.contains_node (bool, optional) – Contains the
nodeelement as part of thecf_rolein the list of objects to be matched.contains_edge (bool, optional) – Contains the
edgeelement as part of thecf_rolein the list of objects to be matched.contains_face (bool, optional) – Contains the
faceelement as part of thecf_rolein the list of objects to be matched.
- Returns:
The
Connectivityfrom theMeshthat matched the given criteria.- Return type:
- coord(item=None, standard_name=None, long_name=None, var_name=None, attributes=None, axis=None, include_nodes=None, include_edges=None, include_faces=None)[source]#
Return a single
AuxCoordcoordinate.Return a single
AuxCoordcoordinate from theMeshthat matches the provided criteria.Criteria can be either specific properties or other objects with metadata to be matched.
Note
If the given criteria do not return precisely one coordinate, then a
CoordinateNotFoundErroris raised.See also
Mesh.coords()for matching zero or more coordinates.- Parameters:
item (str or object, optional, default=None) –
Either,
a
standard_name,long_name, orvar_namewhich is compared against thename().a coordinate or metadata instance equal to that of the desired coordinate e.g.,
AuxCoordorCoordMetadata.
standard_name (str, optional, default=None) – The CF standard name of the desired coordinate. If
None, does not check forstandard_name.long_name (str, optional, default=None) – An unconstrained description of the coordinate. If
None, does not check forlong_name.var_name (str, optional, default=None) – The NetCDF variable name of the desired coordinate. If
None, does not check forvar_name.attributes (dict, optional, default=None) – A dictionary of attributes desired on the coordinates. If
None, does not check forattributes.axis (str, optional, default=None) – The desired coordinate axis, see
guess_coord_axis(). IfNone, does not check foraxis. Accepts the valuesX,Y,ZandT(case-insensitive).include_node (bool, optional) – Include all
nodecoordinates in the list of objects to be matched.include_edge (bool, optional) – Include all
edgecoordinates in the list of objects to be matched.include_face (bool, optional) – Include all
facecoordinates in the list of objects to be matched.
- Returns:
The
AuxCoordcoordinate from theMeshthat matched the given criteria.- Return type:
- coords(item=None, standard_name=None, long_name=None, var_name=None, attributes=None, axis=None, include_nodes=None, include_edges=None, include_faces=None)[source]#
Return all
AuxCoordcoordinates from theMesh.Return all
AuxCoordcoordinates from theMeshthat match the provided criteria.Criteria can be either specific properties or other objects with metadata to be matched.
See also
Mesh.coord()for matching exactly one coordinate.- Parameters:
item (str or object, optional, default=None) –
Either,
a
standard_name,long_name, orvar_namewhich is compared against thename().a coordinate or metadata instance equal to that of the desired coordinates e.g.,
AuxCoordorCoordMetadata.
standard_name (str, optional, default=None) – The CF standard name of the desired coordinate. If
None, does not check forstandard_name.long_name (str, optional, default=None) – An unconstrained description of the coordinate. If
None, does not check forlong_name.var_name (str, optional, default=None) – The NetCDF variable name of the desired coordinate. If
None, does not check forvar_name.attributes (dict, optional, default=None) – A dictionary of attributes desired on the coordinates. If
None, does not check forattributes.axis (str, optional, default=None) – The desired coordinate axis, see
guess_coord_axis(). IfNone, does not check foraxis. Accepts the valuesX,Y,ZandT(case-insensitive).include_node (bool, optional) – Include all
nodecoordinates in the list of objects to be matched.include_edge (bool, optional) – Include all
edgecoordinates in the list of objects to be matched.include_face (bool, optional) – Include all
facecoordinates in the list of objects to be matched.
- Returns:
A list of
AuxCoordcoordinates from theMeshthat matched the given criteria.- Return type:
list of
AuxCoord
- dimension_names(node=None, edge=None, face=None)[source]#
Assign the name to be used for the NetCDF variable.
Assign the name to be used for the NetCDF variable representing the
node,edgeandfacedimension.The default value of
Nonewill not be assigned to clear the associatednode,edgeorface. Instead useMesh.dimension_names_reset().- Parameters:
node (str, optional, default=None) – The name to be used for the NetCDF variable representing the
nodedimension.edge (str, optional, default=None) – The name to be used for the NetCDF variable representing the
edgedimension.face (str, optional, default=None) – The name to be used for the NetCDF variable representing the
facedimension.
- dimension_names_reset(node=False, edge=False, face=False)[source]#
Reset the name used for the NetCDF variable.
Reset the name used for the NetCDF variable representing the
node,edgeand/orfacedimension toNone.- Parameters:
node (bool, optional, default=False) – Reset the name of the
nodedimension ifTrue. Default isFalse.edge (bool, optional, default=False) – Reset the name of the
edgedimension ifTrue. Default isFalse.face (bool, optional, default=False) – Reset the name of the
facedimension ifTrue. Default isFalse.
- property edge_dimension#
The optionally required UGRID NetCDF variable name for the
edgedimension.
- property edge_face_connectivity#
The optional UGRID
edge_face_connectivityConnectivity.The optional UGRID
edge_face_connectivityConnectivityof theMesh.
- property edge_node_connectivity#
The UGRID
edge_node_connectivityConnectivity.The UGRID
edge_node_connectivityConnectivityof theMesh, which is required forMesh.topology_dimensionof1, and optionally required forMesh.topology_dimension>=2.
- property face_dimension#
The optional UGRID NetCDF variable name for the
facedimension.
- property face_edge_connectivity#
The optional UGRID
face_edge_connectivityConnectivity.The optional UGRID
face_edge_connectivityConnectivityof theMesh.
- property face_face_connectivity#
The optional UGRID
face_face_connectivityConnectivity.The optional UGRID
face_face_connectivityConnectivityof theMesh.
- property face_node_connectivity#
Return
face_node_connectivityConnectivity.The UGRID
face_node_connectivityConnectivityof theMesh, which is required forMesh.topology_dimensionof2, and optionally required forMesh.topology_dimensionof3.
- classmethod from_coords(*coords)[source]#
Construct a
Meshby derivation from one or moreCoord\ s.The
topology_dimension,Coordmembership andConnectivitymembership are all determined based on the shape of the firstbounds:Noneor(n, <2):Not supported
(n, 2):topology_dimension=1.node_coordsandedge_node_connectivityconstructed frombounds.edge_coordsconstructed frompoints.
(n, >=3):topology_dimension=2.node_coordsandface_node_connectivityconstructed frombounds.face_coordsconstructed frompoints.
- Parameters:
*coords (Iterable of
Coord) – Coordinates to pass into theMesh. Allpointsmust have the same shapes; allboundsmust have the same shapes, and must not beNone.- Return type:
Notes
Note
Any resulting duplicate nodes are not currently removed, due to the computational intensity.
Note
Meshcurrently requiresXandYCoord\ s specifically.iris.util.guess_coord_axis()is therefore attempted, else the first twoCoord\ s are taken.Examples
# Reconstruct a cube-with-mesh after subsetting it. >>> print(cube_w_mesh.mesh.name()) Topology data of 2D unstructured mesh >>> mesh_coord_names = [ ... coord.name() for coord in cube_w_mesh.coords(mesh_coords=True) ... ] >>> print(f"MeshCoords: {mesh_coord_names}") MeshCoords: ['latitude', 'longitude'] # Subsetting converts MeshCoords to AuxCoords. >>> slices = [slice(None)] * cube_w_mesh.ndim >>> slices[cube_w_mesh.mesh_dim()] = slice(-1) >>> cube_sub = cube_w_mesh[tuple(slices)] >>> print(cube_sub.mesh) None >>> orig_coords = [cube_sub.coord(c_name) for c_name in mesh_coord_names] >>> for coord in orig_coords: ... print(f"{coord.name()}: {type(coord).__name__}") latitude: AuxCoord longitude: AuxCoord >>> new_mesh = Mesh.from_coords(*orig_coords) >>> new_coords = new_mesh.to_MeshCoords(location=cube_w_mesh.location) # Replace the AuxCoords with MeshCoords. >>> for ix in range(2): ... cube_sub.remove_coord(orig_coords[ix]) ... cube_sub.add_aux_coord(new_coords[ix], cube_w_mesh.mesh_dim()) >>> print(cube_sub.mesh.name()) Topology data of 2D unstructured mesh >>> for coord_name in mesh_coord_names: ... coord = cube_sub.coord(coord_name) ... print(f"{coord_name}: {type(coord).__name__}") latitude: MeshCoord longitude: MeshCoord
- property node_dimension#
The NetCDF variable name for the
nodedimension.
- remove_connectivities(item=None, standard_name=None, long_name=None, var_name=None, attributes=None, cf_role=None, contains_node=None, contains_edge=None, contains_face=None)[source]#
Remove one or more
Connectivity.Remove one or more
Connectivityfrom theMeshthat match the provided criteria.Criteria can be either specific properties or other objects with metadata to be matched.
- Parameters:
item (str or object, optional, default=None) –
Either,
a
standard_name,long_name, orvar_namewhich is compared against thename().a connectivity or metadata instance equal to that of the desired objects e.g.,
ConnectivityorConnectivityMetadata.
standard_name (str, optional, default=None) – The CF standard name of the desired
Connectivity. IfNone, does not check forstandard_name.long_name (str, optional, default=None) – An unconstrained description of the
Connectivity. IfNone, does not check forlong_name.var_name (str, optional, default=None) – The NetCDF variable name of the desired
Connectivity. IfNone, does not check forvar_name.attributes (dict, optional, default=None) – A dictionary of attributes desired on the
Connectivity. IfNone, does not check forattributes.cf_role (str, optional, default=None) – The UGRID
cf_roleof the desiredConnectivity.contains_node (bool, optional) – Contains the
nodeelement as part of thecf_rolein the list of objects to be matched for potential removal.contains_edge (bool, optional) – Contains the
edgeelement as part of thecf_rolein the list of objects to be matched for potential removal.contains_face (bool, optional) – Contains the
faceelement as part of thecf_rolein the list of objects to be matched for potential removal.
- Returns:
A list of
Connectivityinstances removed from theMeshthat matched the given criteria.- Return type:
list of
Connectivity
- remove_coords(item=None, standard_name=None, long_name=None, var_name=None, attributes=None, axis=None, include_nodes=None, include_edges=None, include_faces=None)[source]#
Remove one or more
AuxCoordfrom theMesh.Remove one or more
AuxCoordfrom theMeshthat match the provided criteria.Criteria can be either specific properties or other objects with metadata to be matched.
- Parameters:
item (str or object, optional, default=None) –
Either,
a
standard_name,long_name, orvar_namewhich is compared against thename().a coordinate or metadata instance equal to that of the desired coordinates e.g.,
AuxCoordorCoordMetadata.
standard_name (str, optional, default=None) – The CF standard name of the desired coordinate. If
None, does not check forstandard_name.long_name (str, optional, default=None) – An unconstrained description of the coordinate. If
None, does not check forlong_name.var_name (str, optional, default=None) – The NetCDF variable name of the desired coordinate. If
None, does not check forvar_name.attributes (dict, optional, default=None) – A dictionary of attributes desired on the coordinates. If
None, does not check forattributes.axis (str, optional, default=None) – The desired coordinate axis, see
guess_coord_axis(). IfNone, does not check foraxis. Accepts the valuesX,Y,ZandT(case-insensitive).include_node (bool, optional) – Include all
nodecoordinates in the list of objects to be matched for potential removal.include_edge (bool, optional) – Include all
edgecoordinates in the list of objects to be matched for potential removal.include_face (bool, optional) – Include all
facecoordinates in the list of objects to be matched for potential removal.
- Returns:
A list of
AuxCoordcoordinates removed from theMeshthat matched the given criteria.- Return type:
list of
AuxCoord
- to_MeshCoord(location, axis)[source]#
Generate a
MeshCoord.Generate a
MeshCoordthat references the currentMesh, and passing through thelocationandaxisarguments.See also
to_MeshCoords()for generating a series of mesh coords.
- to_MeshCoords(location)[source]#
Generate a tuple of
MeshCoord\ s.Generate a tuple of
MeshCoord\ s, each referencing the currentMesh, one for eachAXESvalue, passing through thelocationargument.See also
to_MeshCoord()for generating a single mesh coord.
- property topology_dimension#
UGRID
topology_dimensionattribute.The UGRID
topology_dimensionattribute represents the highest dimensionality of all the geometric elements (node, edge, face) represented within theMesh.
- class iris.experimental.ugrid.MeshCoord(mesh, location, axis)[source]#
Bases:
AuxCoordGeographic coordinate values of data on an unstructured mesh.
A MeshCoord references a ~iris.experimental.ugrid.mesh.Mesh. When contained in a ~iris.cube.Cube it connects the cube to the Mesh. It records (a) which 1-D cube dimension represents the unstructured mesh, and (b) which mesh ‘location’ the cube data is mapped to – i.e. is it data on ‘face’s, ‘edge’s or ‘node’s.
A MeshCoord also specifies its ‘axis’ : ‘x’ or ‘y’. Its values are then, accordingly, longitudes or latitudes. The values are taken from the appropriate coordinates and connectivities in the Mesh, determined by its ‘location’ and ‘axis’.
Any cube with data on a mesh will have a MeshCoord for each axis, i.e. an ‘X’ and a ‘Y’.
The points and bounds contain coordinate values for the mesh elements, which depends on location. For ‘node’, the
.pointscontains node locations. For ‘edge’, the.boundscontains edge endpoints, and the.pointscontain edge locations (typically centres), if the Mesh contains them (optional). For ‘face’, the.boundscontain the face corners, and the.pointscontain the face locations (typically centres), if the Mesh contains them (optional).Note
As described above, it is possible for a MeshCoord to have bounds but no points. This is not possible for a regular
AuxCoordorDimCoord.Note
A MeshCoord can not yet actually be created with bounds but no points. This is intended in future, but for now it raises an error.
Create a coordinate with mutable points and bounds.
- Parameters:
points – The values (or value in the case of a scalar coordinate) for each cell of the coordinate.
standard_name (optional) – CF standard name of the coordinate.
long_name (optional) – Descriptive name of the coordinate.
var_name (optional) – The netCDF variable name for the coordinate.
unit (
Unit, optional) – TheUnitof the coordinate’s values. Can be a string, which will be converted to a Unit object.bounds (optional) – An array of values describing the bounds of each cell. Given n bounds for each cell, the shape of the bounds array should be points.shape + (n,). For example, a 1D coordinate with 100 points and two bounds per cell would have a bounds array of shape (100, 2) Note if the data is a climatology, climatological should be set.
attributes (optional) – A dictionary containing other CF and user-defined attributes.
coord_system (
CoordSystem, optional) – ACoordSystemrepresenting the coordinate system of the coordinate, e.g., aGeogCSfor a longitude coordinate.bool (climatological) – When True: the coordinate is a NetCDF climatological time axis. When True: saving in NetCDF will give the coordinate variable a ‘climatology’ attribute and will create a boundary variable called ‘<coordinate-name>_climatology’ in place of a standard bounds attribute and bounds variable. Will set to True when a climatological time axis is loaded from NetCDF. Always False if no bounds exist.
optional – When True: the coordinate is a NetCDF climatological time axis. When True: saving in NetCDF will give the coordinate variable a ‘climatology’ attribute and will create a boundary variable called ‘<coordinate-name>_climatology’ in place of a standard bounds attribute and bounds variable. Will set to True when a climatological time axis is loaded from NetCDF. Always False if no bounds exist.
- __deepcopy__(memo)[source]#
Make this equivalent to “shallow” copy.
Returns a new MeshCoord based on the same Mesh.
Required to prevent cube copying from copying the Mesh, which would prevent “cube.copy() == cube” : see notes for
copy().
- property axis#
- property climatological#
The ‘climatological’ of a MeshCoord is always ‘False’.
- property coord_system#
The coordinate-system of a MeshCoord is always ‘None’.
- property location#
- property mesh#
- summary(*args, **kwargs)[source]#
Make a printable text summary.
- Parameters:
shorten (bool, default = False) – If True, produce an abbreviated one-line summary. If False, produce a multi-line summary, with embedded newlines.
max_values (int or None, default = None) – If more than this many data values, print truncated data arrays instead of full contents. If 0, print only the shape. The default is 5 if
shorten=True, or 15 otherwise. This overridesnumpy.get_printoptions['threshold'].linewidth (int or None, default = None) – Character-width controlling line splitting of array outputs. If unset, defaults to
numpy.get_printoptions['linewidth'].edgeitems (int, default=2) – Controls truncated array output. Overrides
numpy.getprintoptions['edgeitems'].precision (int or None, default = None) – Controls number decimal formatting. When
shorten=True this is defaults to 3, in which case it overridesnumpy.get_printoptions()['precision'].convert_dates (bool, default = True) – If the units has a calendar, then print array values as date strings instead of the actual numbers.
- Returns:
result – Output text, with embedded newlines when
shorten=False.- Return type:
Notes
Note
Arrays are formatted using
numpy.array2string(). Some aspects of the array formatting are controllable in the usual way, vianumpy.printoptions(), but others are overridden as detailed above. Control of those aspects is still available, but only via the call arguments.
- iris.experimental.ugrid.load_mesh(uris, var_name=None)[source]#
Load a single
Meshobject from one or more NetCDF files.Raises an error if more/less than one
Meshis found.- Parameters:
- Return type:
- iris.experimental.ugrid.load_meshes(uris, var_name=None)[source]#
Load
Meshobjects from one or more NetCDF files.- Parameters:
- Returns:
- A dictionary mapping each mesh-containing file path/URL in the input
uristo a list of theMesh\ es returned from each.
- Return type:
- iris.experimental.ugrid.recombine_submeshes(mesh_cube, submesh_cubes, index_coord_name='i_mesh_index')[source]#
Put data from sub-meshes back onto the original full mesh.
The result is a cube like
mesh_cube, but with its data replaced by a combination of the data in thesubmesh_cubes.- Parameters:
mesh_cube (Cube) – Describes the mesh and mesh-location onto which the all the
submesh-cubes’ data are mapped, and acts as a template for the result. Must have aMesh.submesh_cubes (iterable of Cube, or Cube) – Cubes, each with data on a _subset_ of the
mesh_cubedatapoints (within the mesh dimension). The submesh cubes do not need to have a mesh. There must be at least 1 of them, to determine the result phenomenon. Their metadata (names, units and attributes) must all be the same, _except_ that ‘var_name’ is ignored. Their dtypes must all be the same. Their shapes and dimension-coords must all match those ofmesh_cube, except in the mesh dimension, which can have different sizes between the submeshes, and from themesh_cube. The mesh dimension of each must have a 1-D coord named byindex_coord_name. These “index coords” can vary in length, but they must all have matching metadata (units, attributes and names except ‘var_name’), and must also match the coord of that name inmesh_cube, if there is one. The “.points” values of the index coords specify, for each datapoint, its location in the original mesh – i.e. they are indices into the relevant mesh-location dimension.index_coord_name (Cube) – Coord name of an index coord containing the mesh location indices, in every submesh cube.
- Returns:
A cube with the same mesh, location, and shape as
mesh_cube, but with its data replaced by that from the``submesh_cubes``. The result phenomeon identity is also that of the``submesh_cubes``, i.e. units, attributes and names (except ‘var_name’, which is None).- Return type:
result_cube
Notes
Where regions overlap, the result data comes from the submesh cube containing that location which appears _last_ in
submesh_cubes.Where no region contains a datapoint, it will be masked in the result. HINT: alternatively, values covered by no region can be set to the original ‘full_mesh_cube’ data value, if ‘full_mesh_cube’ is also passed as the first of the ‘region_cubes’.
The
result_cubedtype is that of thesubmesh_cubes.
- iris.experimental.ugrid.save_mesh(mesh, filename, netcdf_format='NETCDF4')[source]#
Save mesh(es) to a netCDF file.
Args:
- mesh (
iris.experimental.ugrid.Meshor iterable): mesh(es) to save.
- mesh (
- filename (string):
Name of the netCDF file to create.
Kwargs:
- netcdf_format (string):
Underlying netCDF file format, one of ‘NETCDF4’, ‘NETCDF4_CLASSIC’, ‘NETCDF3_CLASSIC’ or ‘NETCDF3_64BIT’. Default is ‘NETCDF4’ format.
Submodules#
- iris.experimental.ugrid.cf
- iris.experimental.ugrid.load
- iris.experimental.ugrid.mesh
ConnectivityConnectivity.UGRID_CF_ROLESConnectivity.cf_roleConnectivity.connectedConnectivity.connected_axisConnectivity.core_indices()Connectivity.cube_dims()Connectivity.has_lazy_indices()Connectivity.indicesConnectivity.indices_by_location()Connectivity.lazy_indices()Connectivity.lazy_location_lengths()Connectivity.locationConnectivity.location_axisConnectivity.location_lengths()Connectivity.start_indexConnectivity.transpose()Connectivity.validate_indices()Connectivity.xml_element()
MeshMesh.AXESMesh.ELEMENTSMesh.TOPOLOGY_DIMENSIONSMesh.add_connectivities()Mesh.add_coords()Mesh.all_connectivitiesMesh.all_coordsMesh.boundary_node_connectivityMesh.cf_roleMesh.connectivities()Mesh.connectivity()Mesh.coord()Mesh.coords()Mesh.dimension_names()Mesh.dimension_names_reset()Mesh.edge_coordsMesh.edge_dimensionMesh.edge_face_connectivityMesh.edge_node_connectivityMesh.face_coordsMesh.face_dimensionMesh.face_edge_connectivityMesh.face_face_connectivityMesh.face_node_connectivityMesh.from_coords()Mesh.node_coordsMesh.node_dimensionMesh.remove_connectivities()Mesh.remove_coords()Mesh.summary()Mesh.to_MeshCoord()Mesh.to_MeshCoords()Mesh.topology_dimensionMesh.xml_element()
Mesh1DConnectivitiesMesh1DCoordsMesh1DNamesMesh2DConnectivitiesMesh2DCoordsMesh2DNamesMeshCoordMeshEdgeCoordsMeshFaceCoordsMeshNodeCoordsNP_PRINTOPTIONS_EDGEITEMSNP_PRINTOPTIONS_THRESHOLD
- iris.experimental.ugrid.metadata
- iris.experimental.ugrid.save
- iris.experimental.ugrid.utils