Skip to content

Commit 0d68338

Browse files
committed
pre-release
1 parent 493d0e0 commit 0d68338

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

cf/test/test_regrid_mesh.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def _remove_tmpfiles():
6464
meshloc = {
6565
"face": esmpy.MeshLoc.ELEMENT,
6666
"node": esmpy.MeshLoc.NODE,
67-
None: None,
6867
}
6968

7069

@@ -91,16 +90,14 @@ def esmpy_regrid(coord_sys, method, src, dst, **kwargs):
9190

9291
src_meshloc = None
9392
dst_meshloc = None
94-
src_domain_topology = src.domain_topology(default=None)
95-
dst_domain_topology = dst.domain_topology(default=None)
96-
if src_domain_topology is not None:
97-
src_meshloc = src_domain_topology.get_cell()
9893

99-
if dst_domain_topology is not None:
100-
dst_meshloc = dst_domain_topology.get_cell()
94+
domain_topology = src.domain_topology(default=None)
95+
if domain_topology is not None:
96+
src_meshloc = meshloc[domain_topology.get_cell()]
10197

102-
src_meshloc = meshloc[src_meshloc]
103-
dst_meshloc = meshloc[dst_meshloc]
98+
domain_topology = dst.domain_topology(default=None)
99+
if domain_topology is not None:
100+
dst_meshloc = meshloc[domain_topology.get_cell()]
104101

105102
src_field = esmpy.Field(
106103
esmpy_regrid.srcfield.grid, meshloc=src_meshloc, name="src"
@@ -292,6 +289,26 @@ def test_Field_regrid_grid_to_mesh(self):
292289
with self.assertRaises(ValueError):
293290
src.regrids(dst, method="nearest_dtos")
294291

292+
@unittest.skipUnless(esmpy_imported, "Requires esmpy/ESMF package.")
293+
def test_Field_regrid_mesh_cartesian(self):
294+
self.assertFalse(cf.regrid_logging())
295+
296+
# Cartesian regridding involving meshes is not currently
297+
# supported
298+
src = self.src_mesh
299+
dst = self.dst_mesh
300+
with self.assertRaises(ValueError):
301+
src.regridc(dst, method="linear")
302+
303+
dst = self.grid
304+
with self.assertRaises(ValueError):
305+
src.regridc(dst, method="linear")
306+
307+
src = self.grid
308+
dst = self.dst_mesh
309+
with self.assertRaises(ValueError):
310+
src.regridc(dst, method="linear")
311+
295312

296313
if __name__ == "__main__":
297314
print("Run date:", datetime.datetime.now())

0 commit comments

Comments
 (0)