diff --git a/cf/regrid/regrid.py b/cf/regrid/regrid.py index 952d338822..6861e9e340 100644 --- a/cf/regrid/regrid.py +++ b/cf/regrid/regrid.py @@ -988,14 +988,14 @@ def Cartesian_coords_to_domain(dst, dst_z=None, domain_class=None): if dst_z is not None: # Check that there are vertical coordinates, and replace - # 'dst_z' with its construct identifier. + # 'dst_z' with the identifier of its domain axis construct. z_key = d.coordinate(dst_z, key=True, default=None) if z_key is None: raise ValueError( f"Could not find destination {dst_z!r} vertical coordinates" ) - dst_z = z_key + dst_z = d.get_data_axes(z_key)[0] return d, axis_keys, dst_z @@ -2112,7 +2112,6 @@ def create_esmpy_grid(grid, mask=None): # masked/unmasked elements. grid_mask[...] = np.invert(mask).astype("int32") - # print(esmpy_grid) return esmpy_grid diff --git a/cf/test/test_regrid.py b/cf/test/test_regrid.py index fc429f2483..e3cfaa9b8f 100644 --- a/cf/test/test_regrid.py +++ b/cf/test/test_regrid.py @@ -157,6 +157,10 @@ class RegridTest(unittest.TestCase): dst = dst_src[0] src = dst_src[1] + filename_xyz = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "regrid_xyz.nc" + ) + @unittest.skipUnless(esmpy_imported, "Requires esmpy/ESMF package.") def test_Field_regrid_2d_field(self): """2-d regridding with Field destination grid.""" @@ -735,6 +739,17 @@ def test_Field_regridc_1d_field(self): with self.assertRaises(ValueError): src.regridc(dst, method=method, axes=axes) + @unittest.skipUnless(esmpy_imported, "Requires esmpy/ESMF package.") + def test_Field_regridc_1d_coordinates_z(self): + """1-d Z Cartesian regridding with coordinates destination grid.""" + src = cf.read(self.filename_xyz)[0] + dst = cf.DimensionCoordinate( + data=cf.Data([800, 705, 632, 510, 320.0], "hPa") + ) + d = src.regridc([dst], method="linear", axes="Z", z="Z", ln_z=True) + z = d.dimension_coordinate("Z") + self.assertTrue(z.data.equals(dst.data)) + @unittest.skipUnless(esmpy_imported, "Requires esmpy/ESMF package.") def test_Field_regrid_chunks(self): """Regridding of chunked axes"""