def test_basic_regrid(self): """Test default regridding arguments return expected dimensionality and updated grid-defining attributes""" expected_data = 282 * np.ones((12, 12), dtype=np.float32) expected_attributes = { "mosg__model_configuration": "gl_det", "title": MANDATORY_ATTRIBUTE_DEFAULTS["title"], } for attr in ["mosg__grid_domain", "mosg__grid_type", "mosg__grid_version"]: expected_attributes[attr] = self.target_grid.attributes[attr] result = RegridLandSea()(self.cube, self.target_grid.copy()) self.assertArrayAlmostEqual(result.data, expected_data) for axis in ["x", "y"]: self.assertEqual(result.coord(axis=axis), self.target_grid.coord(axis=axis)) self.assertDictEqual(result.attributes, expected_attributes)
def test_run_regrid_with_landmask(self): """Test masked regridding (same expected values as basic, since input points are all equal)""" expected_data = 282 * np.ones((12, 12), dtype=np.float32) expected_attributes = { "mosg__model_configuration": "gl_det", "title": MANDATORY_ATTRIBUTE_DEFAULTS["title"], } for attr in ["mosg__grid_domain", "mosg__grid_type", "mosg__grid_version"]: expected_attributes[attr] = self.target_grid.attributes[attr] result = RegridLandSea( regrid_mode="nearest-with-mask", landmask=self.landmask, landmask_vicinity=90000, )(self.cube, self.target_grid.copy()) self.assertArrayAlmostEqual(result.data, expected_data) for axis in ["x", "y"]: self.assertEqual(result.coord(axis=axis), self.target_grid.coord(axis=axis)) self.assertDictEqual(result.attributes, expected_attributes)