iris.experimental.mesh_coord_indexing#

Experimental module for alternative modes of indexing a MeshCoord.

API reference

Tags: topic_mesh

Options describes the available indexing modes.

Select the desired option using the run-time setting SETTING.

Examples

Here is a simple Cube with MeshCoord s:

>>> print(my_mesh_cube)
synthetic / (1)                     (-- : 96)
    Mesh coordinates:
        latitude                        x
        longitude                       x
    Mesh:
        name                        Topology data of 2D unstructured mesh
        location                    face
    Attributes:
        NCO                         'netCDF Operators version 4.7.5 (Homepage = http://nco.sf.net, Code = h ...'
        history                     'Mon Apr 12 01:44:41 2021: ncap2 -s synthetic=float(synthetic) mesh_C4_synthetic.nc ...'
        nco_openmp_thread_number    1
>>> print(my_mesh_cube.aux_coords)
(<MeshCoord: latitude / (degrees)  mesh(Topology data of 2D unstructured mesh) location(face)  [...]+bounds  shape(96,)>, <MeshCoord: longitude / (degrees)  mesh(Topology data of 2D unstructured mesh) location(face)  [...]+bounds  shape(96,)>)

Here is the default indexing behaviour:

>>> from iris.experimental import mesh_coord_indexing
>>> print(mesh_coord_indexing.SETTING.value)
Options.AUX_COORD
>>> indexed_cube = my_mesh_cube[:36]
>>> print(indexed_cube.aux_coords)
(<AuxCoord: latitude / (degrees)  [29.281, 33.301, ..., 33.301, 29.281]+bounds  shape(36,)>, <AuxCoord: longitude / (degrees)  [325.894, 348.621, ..., 191.379, 214.106]+bounds  shape(36,)>)

Set the indexing mode to return a new mesh:

>>> mesh_coord_indexing.SETTING.value = mesh_coord_indexing.Options.NEW_MESH
>>> indexed_cube = my_mesh_cube[:36]
>>> print(indexed_cube.aux_coords)
(<MeshCoord: latitude / (degrees)  mesh(<MeshXY object at ...>) location(face)  [...]+bounds  shape(36,)>, <MeshCoord: longitude / (degrees)  mesh(<MeshXY object at ...>) location(face)  [...]+bounds  shape(36,)>)

Or set via a context manager:

>>> with mesh_coord_indexing.SETTING.context(mesh_coord_indexing.Options.AUX_COORD):
...    indexed_cube = my_mesh_cube[:36]
...    print(indexed_cube.aux_coords)
(<AuxCoord: latitude / (degrees)  [29.281, 33.301, ..., 33.301, 29.281]+bounds  shape(36,)>, <AuxCoord: longitude / (degrees)  [325.894, 348.621, ..., 191.379, 214.106]+bounds  shape(36,)>)
class iris.experimental.mesh_coord_indexing.Options(*values)[source]#

Bases: Enum

Options for what is returned when a MeshCoord is indexed.

See the module docstring for usage instructions: mesh_coord_indexing.

AUX_COORD = 1#

The default. Convert the MeshCoord to a AuxCoord and index that AuxCoord.

MESH_INDEX_SET = 3#

EXPERIMENTAL. Produce a iris.mesh.components._MeshIndexSet instance that references the original MeshXY instance, then return a new MeshCoord instance based on that new index set. _MeshIndexSet is a read-only indexed ‘view’ onto its original MeshXY; behaviour of this class may change from release to release while the design is finalised.

NEW_MESH = 2#

Index the mesh of the MeshCoord to produce a new MeshXY instance, then return a new MeshCoord instance based on that new mesh. The returned MeshXY is generated via the experimental _MeshIndexSet class. While _MeshIndexSet remains experimental, the properties of the returned MeshXY instance are liable to change.

classmethod __contains__(value)#

Return True if value is in cls.

value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members. 3) value is a pseudo-member (flags)

classmethod __getitem__(name)#

Return the member matching name.

classmethod __iter__()#

Return members in definition order.

classmethod __len__()#

Return the number of members (no aliases)

iris.experimental.mesh_coord_indexing.SETTING = <iris.experimental.mesh_coord_indexing._Setting object>#

Run-time setting for alternative modes of indexing a MeshCoord. See the module docstring for usage instructions: mesh_coord_indexing.