Skip to content

Commit

Permalink
Merge pull request #715 from MetOffice/708_convection_orography_tests
Browse files Browse the repository at this point in the history
Test higher dimentional orography handling in convection operators
  • Loading branch information
jfrost-mo committed Jul 2, 2024
2 parents 5e1c677 + 4e18a2f commit 9bf320d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/operators/test_convection.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ def orography_2D() -> iris.cube.Cube:
return iris.load_cube("tests/test_data/convection/Orography2D.nc")


@pytest.fixture
def orography_3D() -> iris.cube.Cube:
"""Get a 3D Orography cube (time)."""
return iris.load_cube("tests/test_data/convection/Orography3D.nc")


@pytest.fixture
def orography_3D_ens() -> iris.cube.Cube:
"""Get a 3D Orography cube (realization)."""
return iris.load_cube("tests/test_data/convection/Orography3D_ens.nc")


@pytest.fixture
def orography_4D() -> iris.cube.Cube:
"""Get a 4D Orography cube (time and realization)."""
return iris.load_cube("tests/test_data/convection/Orography4D.nc")


def test_cape_ratio(SBCAPE, MUCAPE, MUCIN):
"""Compare with precalculated ratio KGOs."""
# Calculate the diagnostic.
Expand Down Expand Up @@ -106,3 +124,30 @@ def test_inflow_layer_properties_non_masked_arrays(EIB, BLheight, orography_2D):
)
precalculated = iris.load_cube("tests/test_data/convection/ECFlagD.nc")
assert np.allclose(inflow_layer_properties.data, precalculated.data)


def test_inflow_layer_properties_3D_orography_time(EIB, BLheight, orography_3D):
"""Reduce a 3D orography (time) field down to 2D."""
inflow_layer_properties = convection.inflow_layer_properties(
EIB, BLheight, orography_3D
)
precalculated = iris.load_cube("tests/test_data/convection/ECFlagD.nc")
assert np.allclose(inflow_layer_properties.data, precalculated.data)


def test_inflow_layer_properties_3D_orography_ensemble(EIB, BLheight, orography_3D_ens):
"""Reduce a 3D orography (realisation) field down to 2D."""
inflow_layer_properties = convection.inflow_layer_properties(
EIB, BLheight, orography_3D_ens
)
precalculated = iris.load_cube("tests/test_data/convection/ECFlagD.nc")
assert np.allclose(inflow_layer_properties.data, precalculated.data)


def test_inflow_layer_properties_4D_orography(EIB, BLheight, orography_4D):
"""Reduce a 4D orography (time and realisation) field down to 2D."""
inflow_layer_properties = convection.inflow_layer_properties(
EIB, BLheight, orography_4D
)
precalculated = iris.load_cube("tests/test_data/convection/ECFlagD.nc")
assert np.allclose(inflow_layer_properties.data, precalculated.data)
Binary file added tests/test_data/convection/Orography3D.nc
Binary file not shown.
Binary file added tests/test_data/convection/Orography3D_ens.nc
Binary file not shown.
Binary file added tests/test_data/convection/Orography4D.nc
Binary file not shown.

0 comments on commit 9bf320d

Please sign in to comment.