Skip to content

Commit 8b89072

Browse files
Merge branch 'SciTools:main' into cell-method-parse
2 parents 85a8dbd + 83905e9 commit 8b89072

File tree

89 files changed

+1688
-1612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1688
-1612
lines changed

benchmarks/benchmarks/cperf/__init__.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
from iris import load_cube
1616

17-
# TODO: remove uses of PARSE_UGRID_ON_LOAD once UGRID parsing is core behaviour.
18-
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
19-
2017
from ..generate_data import BENCHMARK_DATA
2118
from ..generate_data.ugrid import make_cubesphere_testfile
2219

@@ -92,5 +89,4 @@ def setup(self, file_type, three_d, three_times):
9289
self.file_type = file_type
9390

9491
def load(self):
95-
with PARSE_UGRID_ON_LOAD.context():
96-
return load_cube(str(self.file_path))
92+
return load_cube(str(self.file_path))

benchmarks/benchmarks/generate_data/stock.py

+14-17
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import iris
1616
from iris import cube
17-
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD, load_mesh
17+
from iris.mesh import load_mesh
1818

1919
from . import BENCHMARK_DATA, REUSE_DATA, load_realised, run_function_elsewhere
2020

@@ -90,7 +90,7 @@ def sample_mesh(n_nodes=None, n_faces=None, n_edges=None, lazy_values=False):
9090
"""Sample mesh wrapper for :meth:iris.tests.stock.mesh.sample_mesh`."""
9191

9292
def _external(*args, **kwargs):
93-
from iris.experimental.ugrid import save_mesh
93+
from iris.mesh import save_mesh
9494
from iris.tests.stock.mesh import sample_mesh
9595

9696
save_path_ = kwargs.pop("save_path")
@@ -104,21 +104,20 @@ def _external(*args, **kwargs):
104104
save_path = (BENCHMARK_DATA / f"sample_mesh_{args_hash}").with_suffix(".nc")
105105
if not REUSE_DATA or not save_path.is_file():
106106
_ = run_function_elsewhere(_external, *arg_list, save_path=str(save_path))
107-
with PARSE_UGRID_ON_LOAD.context():
108-
if not lazy_values:
109-
# Realise everything.
110-
with load_realised():
111-
mesh = load_mesh(str(save_path))
112-
else:
107+
if not lazy_values:
108+
# Realise everything.
109+
with load_realised():
113110
mesh = load_mesh(str(save_path))
111+
else:
112+
mesh = load_mesh(str(save_path))
114113
return mesh
115114

116115

117116
def sample_meshcoord(sample_mesh_kwargs=None, location="face", axis="x"):
118117
"""Sample meshcoord wrapper for :meth:`iris.tests.stock.mesh.sample_meshcoord`.
119118
120119
Parameters deviate from the original as cannot pass a
121-
:class:`iris.experimental.ugrid.Mesh to the separate Python instance - must
120+
:class:`iris.mesh.Mesh to the separate Python instance - must
122121
instead generate the Mesh as well.
123122
124123
MeshCoords cannot be saved to file, so the _external method saves the
@@ -127,7 +126,7 @@ def sample_meshcoord(sample_mesh_kwargs=None, location="face", axis="x"):
127126
"""
128127

129128
def _external(sample_mesh_kwargs_, save_path_):
130-
from iris.experimental.ugrid import save_mesh
129+
from iris.mesh import save_mesh
131130
from iris.tests.stock.mesh import sample_mesh, sample_meshcoord
132131

133132
if sample_mesh_kwargs_:
@@ -147,9 +146,8 @@ def _external(sample_mesh_kwargs_, save_path_):
147146
sample_mesh_kwargs_=sample_mesh_kwargs,
148147
save_path_=str(save_path),
149148
)
150-
with PARSE_UGRID_ON_LOAD.context():
151-
with load_realised():
152-
source_mesh = load_mesh(str(save_path))
149+
with load_realised():
150+
source_mesh = load_mesh(str(save_path))
153151
# Regenerate MeshCoord from its Mesh, which we saved.
154152
return source_mesh.to_MeshCoord(location=location, axis=axis)
155153

@@ -180,7 +178,6 @@ def _external(w_mesh_: str, save_path_: str):
180178
)
181179
if not REUSE_DATA or not save_path.is_file():
182180
_ = run_function_elsewhere(_external, w_mesh_=w_mesh, save_path_=str(save_path))
183-
with PARSE_UGRID_ON_LOAD.context():
184-
context = nullcontext() if lazy else load_realised()
185-
with context:
186-
return iris.load_cube(save_path, "air_potential_temperature")
181+
context = nullcontext() if lazy else load_realised()
182+
with context:
183+
return iris.load_cube(save_path, "air_potential_temperature")

benchmarks/benchmarks/generate_data/ugrid.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""Scripts for generating supporting data for UGRID-related benchmarking."""
66

77
from iris import load_cube as iris_loadcube
8-
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
98

109
from . import BENCHMARK_DATA, REUSE_DATA, load_realised, run_function_elsewhere
1110
from .stock import (
@@ -85,8 +84,7 @@ def make_cube_like_2d_cubesphere(n_cube: int, with_mesh: bool):
8584
)
8685

8786
# File now *should* definitely exist: content is simply the desired cube.
88-
with PARSE_UGRID_ON_LOAD.context():
89-
cube = iris_loadcube(str(filepath))
87+
cube = iris_loadcube(str(filepath))
9088

9189
# Ensure correct laziness.
9290
_ = cube.data
@@ -155,9 +153,8 @@ def _external(xy_dims_, save_path_):
155153
)
156154
if not REUSE_DATA or not save_path.is_file():
157155
_ = run_function_elsewhere(_external, xy_dims, str(save_path))
158-
with PARSE_UGRID_ON_LOAD.context():
159-
with load_realised():
160-
cube = iris_loadcube(str(save_path))
156+
with load_realised():
157+
cube = iris_loadcube(str(save_path))
161158

162159
return cube
163160

benchmarks/benchmarks/load/ugrid.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"""Mesh data loading benchmark tests."""
66

77
from iris import load_cube as iris_load_cube
8-
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
9-
from iris.experimental.ugrid import load_mesh as iris_load_mesh
8+
from iris.mesh import load_mesh as iris_load_mesh
109

1110
from ..generate_data.stock import create_file__xios_2d_face_half_levels
1211

@@ -18,13 +17,11 @@ def synthetic_data(**kwargs):
1817

1918

2019
def load_cube(*args, **kwargs):
21-
with PARSE_UGRID_ON_LOAD.context():
22-
return iris_load_cube(*args, **kwargs)
20+
return iris_load_cube(*args, **kwargs)
2321

2422

2523
def load_mesh(*args, **kwargs):
26-
with PARSE_UGRID_ON_LOAD.context():
27-
return iris_load_mesh(*args, **kwargs)
24+
return iris_load_mesh(*args, **kwargs)
2825

2926

3027
class BasicLoading:

benchmarks/benchmarks/experimental/__init__.py renamed to benchmarks/benchmarks/mesh/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#
33
# This file is part of Iris and is released under the BSD license.
44
# See LICENSE in the root of the repository for full licensing details.
5-
"""Benchmark tests for the experimental module."""
5+
"""Benchmark tests for the iris.mesh module."""

benchmarks/benchmarks/experimental/ugrid/__init__.py renamed to benchmarks/benchmarks/mesh/utils/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#
33
# This file is part of Iris and is released under the BSD license.
44
# See LICENSE in the root of the repository for full licensing details.
5-
"""Benchmark tests for the experimental.ugrid module."""
5+
"""Benchmark tests for the iris.mesh.utils module."""

benchmarks/benchmarks/experimental/ugrid/regions_combine.py renamed to benchmarks/benchmarks/mesh/utils/regions_combine.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""Benchmarks stages of operation.
66
77
Benchmarks stages of operation of the function
8-
:func:`iris.experimental.ugrid.utils.recombine_submeshes`.
8+
:func:`iris.mesh.utils.recombine_submeshes`.
99
1010
"""
1111

@@ -15,8 +15,7 @@
1515
import numpy as np
1616

1717
from iris import load, load_cube, save
18-
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
19-
from iris.experimental.ugrid.utils import recombine_submeshes
18+
from iris.mesh.utils import recombine_submeshes
2019

2120
from ... import TrackAddedMemoryAllocation
2221
from ...generate_data.ugrid import make_cube_like_2d_cubesphere
@@ -103,13 +102,12 @@ def setup(self, n_cubesphere, imaginary_data=True, create_result_cube=True):
103102
104103
"""
105104
# Load source cubes (full-mesh and regions)
106-
with PARSE_UGRID_ON_LOAD.context():
107-
self.full_mesh_cube = load_cube(
108-
self._parametrised_cache_filename(n_cubesphere, "meshcube")
109-
)
110-
self.region_cubes = load(
111-
self._parametrised_cache_filename(n_cubesphere, "regioncubes")
112-
)
105+
self.full_mesh_cube = load_cube(
106+
self._parametrised_cache_filename(n_cubesphere, "meshcube")
107+
)
108+
self.region_cubes = load(
109+
self._parametrised_cache_filename(n_cubesphere, "regioncubes")
110+
)
113111

114112
# Remove all var-names from loaded cubes, which can otherwise cause
115113
# problems. Also implement 'imaginary' data.

benchmarks/benchmarks/save.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""File saving benchmarks."""
66

77
from iris import save
8-
from iris.experimental.ugrid import save_mesh
8+
from iris.mesh import save_mesh
99

1010
from . import TrackAddedMemoryAllocation, on_demand_benchmark
1111
from .generate_data.ugrid import make_cube_like_2d_cubesphere

benchmarks/benchmarks/sperf/__init__.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
from iris import load_cube
1212

13-
# TODO: remove uses of PARSE_UGRID_ON_LOAD once UGRID parsing is core behaviour.
14-
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
15-
1613
from ..generate_data.ugrid import make_cubesphere_testfile
1714

1815

@@ -38,5 +35,4 @@ def setup(self, c_size, n_levels, n_times):
3835
)
3936

4037
def load_cube(self):
41-
with PARSE_UGRID_ON_LOAD.context():
42-
return load_cube(str(self.file_path))
38+
return load_cube(str(self.file_path))

benchmarks/benchmarks/sperf/combine_regions.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
import numpy as np
1111

1212
from iris import load, load_cube, save
13-
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
14-
from iris.experimental.ugrid.utils import recombine_submeshes
13+
from iris.mesh.utils import recombine_submeshes
1514

1615
from .. import TrackAddedMemoryAllocation, on_demand_benchmark
1716
from ..generate_data.ugrid import BENCHMARK_DATA, make_cube_like_2d_cubesphere
@@ -102,13 +101,12 @@ def setup(self, n_cubesphere, imaginary_data=True, create_result_cube=True):
102101
103102
"""
104103
# Load source cubes (full-mesh and regions)
105-
with PARSE_UGRID_ON_LOAD.context():
106-
self.full_mesh_cube = load_cube(
107-
self._parametrised_cache_filename(n_cubesphere, "meshcube")
108-
)
109-
self.region_cubes = load(
110-
self._parametrised_cache_filename(n_cubesphere, "regioncubes")
111-
)
104+
self.full_mesh_cube = load_cube(
105+
self._parametrised_cache_filename(n_cubesphere, "meshcube")
106+
)
107+
self.region_cubes = load(
108+
self._parametrised_cache_filename(n_cubesphere, "regioncubes")
109+
)
112110

113111
# Remove all var-names from loaded cubes, which can otherwise cause
114112
# problems. Also implement 'imaginary' data.

benchmarks/benchmarks/sperf/equality.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CubeEquality(FileMixin):
1313
r"""Benchmark time and memory costs.
1414
1515
Benchmark time and memory costs of comparing :class:`~iris.cube.Cube`\\ s
16-
with attached :class:`~iris.experimental.ugrid.mesh.MeshXY`\\ es.
16+
with attached :class:`~iris.mesh.MeshXY`\\ es.
1717
1818
Uses :class:`FileMixin` as the realistic case will be comparing
1919
:class:`~iris.cube.Cube`\\ s that have been loaded from file.

benchmarks/benchmarks/sperf/save.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os.path
88

99
from iris import save
10-
from iris.experimental.ugrid import save_mesh
10+
from iris.mesh import save_mesh
1111

1212
from .. import TrackAddedMemoryAllocation, on_demand_benchmark
1313
from ..generate_data.ugrid import make_cube_like_2d_cubesphere

benchmarks/benchmarks/unit_style/ugrid.py renamed to benchmarks/benchmarks/unit_style/mesh.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
#
33
# This file is part of Iris and is released under the BSD license.
44
# See LICENSE in the root of the repository for full licensing details.
5-
"""Benchmark tests for the experimental.ugrid module."""
5+
"""Benchmark tests for the iris.mesh module."""
66

77
from copy import deepcopy
88

99
import numpy as np
1010

11-
from iris.experimental import ugrid
11+
from iris import mesh
1212

1313
from .. import disable_repeat_between_setup
1414
from ..generate_data.stock import sample_mesh
1515

1616

1717
class UGridCommon:
18-
"""Run a generalised suite of benchmarks for any ugrid object.
18+
"""Run a generalised suite of benchmarks for any mesh object.
1919
20-
A base class running a generalised suite of benchmarks for any ugrid object.
20+
A base class running a generalised suite of benchmarks for any mesh object.
2121
Object to be specified in a subclass.
2222
2323
ASV will run the benchmarks within this class for any subclasses.
@@ -53,7 +53,7 @@ def setup(self, n_faces):
5353
super().setup(n_faces)
5454

5555
def create(self):
56-
return ugrid.Connectivity(indices=self.array, cf_role="face_node_connectivity")
56+
return mesh.Connectivity(indices=self.array, cf_role="face_node_connectivity")
5757

5858
def time_indices(self, n_faces):
5959
_ = self.object.indices
@@ -123,7 +123,7 @@ def get_coords_and_axes(location):
123123
self.eq_object = deepcopy(self.object)
124124

125125
def create(self):
126-
return ugrid.MeshXY(**self.mesh_kwargs)
126+
return mesh.MeshXY(**self.mesh_kwargs)
127127

128128
def time_add_connectivities(self, n_faces):
129129
self.object.add_connectivities(self.face_node)
@@ -170,7 +170,7 @@ def setup(self, n_faces, lazy=False):
170170
super().setup(n_faces)
171171

172172
def create(self):
173-
return ugrid.MeshCoord(mesh=self.mesh, location="face", axis="x")
173+
return mesh.MeshCoord(mesh=self.mesh, location="face", axis="x")
174174

175175
def time_points(self, n_faces):
176176
_ = self.object.points

0 commit comments

Comments
 (0)