forked from SciTools/iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'HGWright/geo-bridge' into additions_5740
- Loading branch information
Showing
9 changed files
with
184 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright Iris contributors | ||
# | ||
# This file is part of Iris and is released under the BSD license. | ||
# See LICENSE in the root of the repository for full licensing details. | ||
"""Integration tests for the :mod:`iris.experimental.geovista` module.""" |
66 changes: 66 additions & 0 deletions
66
lib/iris/tests/integration/experimental/geovista/test_cube_to_poly.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright Iris contributors | ||
# | ||
# This file is part of Iris and is released under the BSD license. | ||
# See LICENSE in the root of the repository for full licensing details. | ||
"""Integration tests for the `iris.experimental.geovista.cube_to_polydata` function.""" | ||
|
||
import numpy as np | ||
|
||
from iris import load_cube | ||
from iris.experimental.geovista import cube_to_polydata | ||
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD | ||
from iris.tests import get_data_path | ||
|
||
|
||
def test_integration_2d(): | ||
file_path = get_data_path( | ||
[ | ||
"NetCDF", | ||
"ORCA2", | ||
"votemper.nc", | ||
] | ||
) | ||
with PARSE_UGRID_ON_LOAD.context(): | ||
global_cube = load_cube(file_path, "votemper") | ||
|
||
polydata = cube_to_polydata(global_cube[0, 1, :]) | ||
|
||
assert polydata.GetNumberOfCells() == 26640 | ||
assert polydata.GetNumberOfPoints() == 26969 | ||
|
||
|
||
def test_integration_1d(): | ||
file_path = get_data_path( | ||
[ | ||
"NetCDF", | ||
"global", | ||
"xyt", | ||
"SMALL_hires_wind_u_for_ipcc4.nc", | ||
] | ||
) | ||
with PARSE_UGRID_ON_LOAD.context(): | ||
global_cube = load_cube(file_path) | ||
|
||
polydata = cube_to_polydata(global_cube[0, :]) | ||
|
||
assert polydata.GetNumberOfCells() == 51200 | ||
assert polydata.GetNumberOfPoints() == 51681 | ||
|
||
|
||
def test_integration_mesh(): | ||
file_path = get_data_path( | ||
[ | ||
"NetCDF", | ||
"unstructured_grid", | ||
"lfric_ngvat_2D_72t_face_half_levels_main_conv_rain.nc", | ||
] | ||
) | ||
|
||
with PARSE_UGRID_ON_LOAD.context(): | ||
global_cube = load_cube(file_path, "conv_rain") | ||
|
||
polydata = cube_to_polydata(global_cube[0, :]) | ||
|
||
assert polydata.GetNumberOfCells() == 864 | ||
assert polydata.GetNumberOfPoints() == 866 | ||
np.testing.assert_array_equal(polydata.active_scalars, global_cube[0, :].data) |
34 changes: 34 additions & 0 deletions
34
lib/iris/tests/integration/experimental/geovista/test_extract_unstructured_region.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright Iris contributors | ||
# | ||
# This file is part of Iris and is released under the BSD license. | ||
# See LICENSE in the root of the repository for full licensing details. | ||
"""Integration tests for the `iris.experimental.geovista.extract_unstructured_region` function.""" | ||
|
||
from geovista.geodesic import BBox | ||
|
||
from iris import load_cube | ||
from iris.experimental.geovista import cube_to_polydata, extract_unstructured_region | ||
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD | ||
from iris.tests import get_data_path | ||
|
||
|
||
def test_face_region_extraction(): | ||
file_path = get_data_path( | ||
[ | ||
"NetCDF", | ||
"unstructured_grid", | ||
"lfric_ngvat_2D_72t_face_half_levels_main_conv_rain.nc", | ||
] | ||
) | ||
|
||
with PARSE_UGRID_ON_LOAD.context(): | ||
global_cube = load_cube(file_path, "conv_rain") | ||
polydata = cube_to_polydata(global_cube[0, :]) | ||
region = BBox(lons=[0, 70, 70, 0], lats=[-25, -25, 45, 45]) | ||
|
||
extracted_cube = extract_unstructured_region( | ||
global_cube, polydata, region, preference="center" | ||
) | ||
|
||
assert extracted_cube.ndim == 2 | ||
assert extracted_cube.shape == (72, 101) |
47 changes: 0 additions & 47 deletions
47
lib/iris/tests/integration/experimental/test_cube_to_poly.py
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.