def test_crop_cube_with_ne_file(ne_ocean_shapefile): """Test for cropping a cube by shape bounds.""" with fiona.open(ne_ocean_shapefile) as geometries: cube = _create_sample_full_cube() result = _crop_cube(cube, *geometries.bounds, cmor_coords=False) result = (result.coord("latitude").points[-1], result.coord("longitude").points[-1]) expected = (89., 359.) np.testing.assert_allclose(result, expected)
def test_crop_cube_with_ne_file_imitation(): """Test for cropping a cube by shape bounds.""" cube = _create_sample_full_cube() bounds = [-10., -99., 370., 100.] result = _crop_cube(cube, *tuple(bounds)) result = (result.coord("latitude").points[-1], result.coord("longitude").points[-1]) expected = (89., 359.) np.testing.assert_allclose(result, expected)
def test_crop_cube_with_ne_file(): """Test for cropping a cube by shape bounds.""" shp_file = "esmvalcore/preprocessor/ne_masks/ne_50m_ocean.shp" with fiona.open(shp_file) as geometries: cube = _create_sample_full_cube() result = _crop_cube(cube, *geometries.bounds, cmor_coords=False) result = (result.coord("latitude").points[-1], result.coord("longitude").points[-1]) expected = (89., 359.) np.testing.assert_allclose(result, expected)
def test_crop_cube(make_testcube, square_shape, tmp_path): """Test for cropping a cube by shape bounds.""" with fiona.open(tmp_path / 'test_shape.shp') as geometries: result = _crop_cube(make_testcube, *geometries.bounds) expected = square_shape.data np.testing.assert_array_equal(result.data, expected)