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:
EnumOptions for what is returned when a
MeshCoordis indexed.See the module docstring for usage instructions:
mesh_coord_indexing.- MESH_INDEX_SET = 3[source]#
EXPERIMENTAL. Produce a
iris.mesh.components._MeshIndexSetinstance that references the originalMeshXYinstance, then return a newMeshCoordinstance based on that new index set._MeshIndexSetis a read-only indexed ‘view’ onto its originalMeshXY; behaviour of this class may change from release to release while the design is finalised.
- NEW_MESH = 2[source]#
Index the
meshof theMeshCoordto produce a newMeshXYinstance, then return a newMeshCoordinstance based on that new mesh. The returnedMeshXYis generated via the experimental_MeshIndexSetclass. While_MeshIndexSetremains experimental, the properties of the returnedMeshXYinstance are liable to change.
- iris.experimental.mesh_coord_indexing.SETTING = <iris.experimental.mesh_coord_indexing._Setting object>[source]#
Run-time setting for alternative modes of indexing a
MeshCoord. See the module docstring for usage instructions:mesh_coord_indexing.