Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ env:
# Pip package to be upgraded/installed.
PIP_CACHE_PACKAGES: "pip setuptools wheel nox"
# Git commit hash for iris test data.
IRIS_TEST_DATA_REF: "v2.1"
IRIS_TEST_DATA_REF: "v2.2"
# Base directory for the iris-test-data.
IRIS_TEST_DATA_DIR: ${HOME}/iris-test-data

Expand Down
117 changes: 86 additions & 31 deletions lib/iris/tests/integration/experimental/test_ugrid_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,105 @@
# importing anything else.
import iris.tests as tests

from iris import load, load_cube, NameConstraint
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
from collections.abc import Iterable

from iris import Constraint, load
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD

def ugrid_load(*args, **kwargs):
with PARSE_UGRID_ON_LOAD.context():
return load(*args, **kwargs)

def ugrid_load(uris, constraints=None, callback=None):
# TODO: remove constraint once files no longer have orphan connectivities.
orphan_connectivities = (
"Mesh2d_half_levels_edge_face_links",
"Mesh2d_half_levels_face_links",
"Mesh2d_half_levels_face_edges",
"Mesh2d_full_levels_edge_face_links",
"Mesh2d_full_levels_face_links",
"Mesh2d_full_levels_face_edges",
)
filter_orphan_connectivities = Constraint(
cube_func=lambda cube: cube.var_name not in orphan_connectivities
)
if constraints is None:
constraints = filter_orphan_connectivities
else:
if not isinstance(constraints, Iterable):
constraints = [constraints]
constraints.append(filter_orphan_connectivities)

def ugrid_load_cube(*args, **kwargs):
with PARSE_UGRID_ON_LOAD.context():
return load_cube(*args, **kwargs)
return load(uris, constraints, callback)


@tests.skip_data
class TestBasic(tests.IrisTest):
def test_2D_1t_face_half_levels(self):
# TODO: remove constraint once file no longer has orphan connectivities.
conv_rain = NameConstraint(var_name="conv_rain")
cube = ugrid_load_cube(
def common_test(self, load_filename, assert_filename):
cube_list = ugrid_load(
tests.get_data_path(
[
"NetCDF",
"unstructured_grid",
"lfric_ngvat_2D_1t_face_half_levels_main_conv_rain.nc",
]
["NetCDF", "unstructured_grid", load_filename]
),
constraint=conv_rain,
)
self.assertCML(
cube, ("experimental", "ugrid", "2D_1t_face_half_levels.cml")
self.assertEqual(1, len(cube_list))
cube = cube_list[0]
self.assertCML(cube, ["experimental", "ugrid", assert_filename])

def test_2D_1t_face_half_levels(self):
self.common_test(
"lfric_ngvat_2D_1t_face_half_levels_main_conv_rain.nc",
"2D_1t_face_half_levels.cml",
)

def test_3D_1t_face_half_levels(self):
self.common_test(
"lfric_ngvat_3D_1t_half_level_face_grid_derived_theta_in_w3.nc",
"3D_1t_face_half_levels.cml",
)

def test_3D_1t_face_full_levels(self):
self.common_test(
"lfric_ngvat_3D_1t_full_level_face_grid_main_area_fraction_unit1.nc",
"3D_1t_face_full_levels.cml",
)

def test_2D_72t_face_half_levels(self):
self.common_test(
"lfric_ngvat_2D_72t_face_half_levels_main_conv_rain.nc",
"2D_72t_face_half_levels.cml",
)

# def test_3D_1t_face_half_levels(self):
# pass
#
# def test_3D_1t_face_full_levels(self):
# pass
#
# def test_multiple_time_values(self):
# pass
#
# etc ...
def test_3D_snow_pseudo_levels(self):
self.common_test(
"lfric_ngvat_3D_snow_pseudo_levels_1t_face_half_levels_main_snow_layer_temp.nc",
"3D_snow_pseudo_levels.cml",
)

def test_3D_soil_pseudo_levels(self):
self.common_test(
"lfric_ngvat_3D_soil_pseudo_levels_1t_face_half_levels_main_soil_temperature.nc",
"3D_soil_pseudo_levels.cml",
)

def test_3D_tile_pseudo_levels(self):
self.common_test(
"lfric_ngvat_3D_tile_pseudo_levels_1t_face_half_levels_main_sw_up_tile.nc",
"3D_tile_pseudo_levels.cml",
)

def test_3D_veg_pseudo_levels(self):
self.common_test(
"lfric_ngvat_3D_veg_pseudo_levels_1t_face_half_levels_main_snowpack_density.nc",
"3D_veg_pseudo_levels.cml",
)


# class TestPseudoLevels(tests.IrisTest):
# pass
@tests.skip_data
class TestMultiplePhenomena(tests.IrisTest):
def test_multiple_phenomena(self):
cube_list = ugrid_load(
tests.get_data_path(
["NetCDF", "unstructured_grid", "lfric_surface_mean.nc"]
),
)
self.assertCML(
cube_list, ("experimental", "ugrid", "surface_mean.cml")
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" ?>
<cubes xmlns="urn:x-iris:cubeml-0.2">
<cube dtype="float64" long_name="surface_convective_rainfall_rate" units="kg m-2 s-1" var_name="conv_rain">
<attributes>
<attribute name="Conventions" value="UGRID"/>
<attribute name="description" value="Created by xios"/>
<attribute name="interval_operation" value="300 s"/>
<attribute name="interval_write" value="300 s"/>
<attribute name="name" value="lfric_ngvat_2D_72t_face_half_levels_main_conv_rain"/>
<attribute name="online_operation" value="instant"/>
<attribute name="timeStamp" value="2020-Oct-18 21:18:35 GMT"/>
<attribute name="title" value="Created by xios"/>
<attribute name="uuid" value="b3dc0fb4-9828-4663-a5ac-2a5763280159"/>
</attributes>
<coords>
<coord datadims="[1]">
<meshCoord bounds="[[28.4835, 31.3314, 38.4268, 35.2644],
[31.3314, 33.605, 40.8934, 38.4268],
[33.605, 35.3335, 42.7342, 40.8934],
...,
[-42.7342, -40.8934, -46.161, -48.912],
[-40.8934, -38.4268, -42.6612, -46.161],
[-38.4268, -35.2644, -38.4268, -42.6612]]" id="21594c35" long_name="Latitude of mesh nodes." points="[33.4328, 36.1226, 38.2012, ..., -44.791,
-42.1583, -38.815]" shape="(864,)" standard_name="latitude" units="Unit('degrees')" value_type="float32"/>
</coord>
<coord datadims="[1]">
<meshCoord bounds="[[-45.0, -37.5, -37.5, -45.0],
[-37.5, -30.0, -30.0, -37.5],
[-30.0, -22.5, -22.5, -30.0],
...,
[-112.5, -120.0, -126.958, -118.361],
[-120.0, -127.5, -135.0, -126.958],
[-127.5, -135.0, -142.5, -135.0]]" id="fac9555b" long_name="Longitude of mesh nodes." points="[-41.3152, -33.8068, -26.296, ..., -119.377,
-127.321, -135.0]" shape="(864,)" standard_name="longitude" units="Unit('degrees')" value_type="float32"/>
</coord>
<coord datadims="[0]">
<auxCoord bounds="[[300.0, 300.0],
[600.0, 600.0],
[900.0, 900.0],
...,
[21000.0, 21000.0],
[21300.0, 21300.0],
[21600.0, 21600.0]]" id="17a27d05" long_name="Time axis" points="[300.0, 600.0, 900.0, 1200.0, 1500.0, 1800.0,
2100.0, 2400.0, 2700.0, 3000.0, 3300.0, 3600.0,
3900.0, 4200.0, 4500.0, 4800.0, 5100.0, 5400.0,
5700.0, 6000.0, 6300.0, 6600.0, 6900.0, 7200.0,
7500.0, 7800.0, 8100.0, 8400.0, 8700.0, 9000.0,
9300.0, 9600.0, 9900.0, 10200.0, 10500.0,
10800.0, 11100.0, 11400.0, 11700.0, 12000.0,
12300.0, 12600.0, 12900.0, 13200.0, 13500.0,
13800.0, 14100.0, 14400.0, 14700.0, 15000.0,
15300.0, 15600.0, 15900.0, 16200.0, 16500.0,
16800.0, 17100.0, 17400.0, 17700.0, 18000.0,
18300.0, 18600.0, 18900.0, 19200.0, 19500.0,
19800.0, 20100.0, 20400.0, 20700.0, 21000.0,
21300.0, 21600.0]" shape="(72,)" standard_name="time" units="Unit('seconds since 2016-01-01 15:00:00', calendar='gregorian')" value_type="float64" var_name="time_instant">
<attributes>
<attribute name="time_origin" value="2016-01-01 15:00:00"/>
</attributes>
</auxCoord>
</coord>
</coords>
<cellMethods>
<cellMethod method="point">
<coord name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0x2d1c0056" dtype="float64" mask_checksum="no-masked-elements" shape="(72, 864)"/>
</cube>
</cubes>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" ?>
<cubes xmlns="urn:x-iris:cubeml-0.2">
<cube dtype="float64" long_name="area_fraction" units="1" var_name="area_fraction">
<attributes>
<attribute name="Conventions" value="UGRID"/>
<attribute name="description" value="Created by xios"/>
<attribute name="interval_operation" value="300 s"/>
<attribute name="interval_write" value="21600 s"/>
<attribute name="name" value="lfric_ngvat_3D_1t_full_level_face_grid_main_area_fraction_unit1"/>
<attribute name="online_operation" value="instant"/>
<attribute name="timeStamp" value="2020-Oct-18 21:20:19 GMT"/>
<attribute name="title" value="Created by xios"/>
<attribute name="uuid" value="e9218bc2-9665-4ee8-ac7c-b456c02ff9af"/>
</attributes>
<coords>
<coord datadims="[1]">
<dimCoord id="54e672a6" points="[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0,
33.0, 34.0, 35.0, 36.0, 37.0, 38.0]" shape="(39,)" units="Unit('unknown')" value_type="float32" var_name="full_levels">
<attributes>
<attribute name="name" value="full_levels"/>
</attributes>
</dimCoord>
</coord>
<coord datadims="[2]">
<meshCoord bounds="[[28.4835, 31.3314, 38.4268, 35.2644],
[31.3314, 33.605, 40.8934, 38.4268],
[33.605, 35.3335, 42.7342, 40.8934],
...,
[-42.7342, -40.8934, -46.161, -48.912],
[-40.8934, -38.4268, -42.6612, -46.161],
[-38.4268, -35.2644, -38.4268, -42.6612]]" id="21594c35" long_name="Latitude of mesh nodes." points="[33.4328, 36.1226, 38.2012, ..., -44.791,
-42.1583, -38.815]" shape="(864,)" standard_name="latitude" units="Unit('degrees')" value_type="float32"/>
</coord>
<coord datadims="[2]">
<meshCoord bounds="[[-45.0, -37.5, -37.5, -45.0],
[-37.5, -30.0, -30.0, -37.5],
[-30.0, -22.5, -22.5, -30.0],
...,
[-112.5, -120.0, -126.958, -118.361],
[-120.0, -127.5, -135.0, -126.958],
[-127.5, -135.0, -142.5, -135.0]]" id="fac9555b" long_name="Longitude of mesh nodes." points="[-41.3152, -33.8068, -26.296, ..., -119.377,
-127.321, -135.0]" shape="(864,)" standard_name="longitude" units="Unit('degrees')" value_type="float32"/>
</coord>
<coord datadims="[0]">
<auxCoord bounds="[[21600.0, 21600.0]]" id="17a27d05" long_name="Time axis" points="[21600.0]" shape="(1,)" standard_name="time" units="Unit('seconds since 2016-01-01 15:00:00', calendar='gregorian')" value_type="float64" var_name="time_instant">
<attributes>
<attribute name="time_origin" value="2016-01-01 15:00:00"/>
</attributes>
</auxCoord>
</coord>
</coords>
<cellMethods>
<cellMethod method="point">
<coord interval="300 s" name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0xcb144ae9" dtype="float64" mask_checksum="no-masked-elements" shape="(1, 39, 864)"/>
</cube>
</cubes>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" ?>
<cubes xmlns="urn:x-iris:cubeml-0.2">
<cube dtype="float64" long_name="air potential temperature on W3 points" standard_name="air_potential_temperature" units="K" var_name="theta_in_w3">
<attributes>
<attribute name="Conventions" value="UGRID"/>
<attribute name="description" value="Created by xios"/>
<attribute name="interval_operation" value="300 s"/>
<attribute name="interval_write" value="21600 s"/>
<attribute name="name" value="lfric_ngvat_3D_1t_half_level_face_grid_derived_theta_in_w3"/>
<attribute name="online_operation" value="instant"/>
<attribute name="timeStamp" value="2020-Oct-18 21:20:19 GMT"/>
<attribute name="title" value="Created by xios"/>
<attribute name="uuid" value="412ffe9b-6a55-420e-940b-051e7d9f24bb"/>
</attributes>
<coords>
<coord datadims="[1]">
<dimCoord id="f5e322b2" points="[0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5,
9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5,
17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5,
25.5, 26.5, 27.5, 28.5, 29.5, 30.5, 31.5, 32.5,
33.5, 34.5, 35.5, 36.5, 37.5]" shape="(38,)" units="Unit('unknown')" value_type="float32" var_name="half_levels">
<attributes>
<attribute name="name" value="half_levels"/>
</attributes>
</dimCoord>
</coord>
<coord datadims="[2]">
<meshCoord bounds="[[28.4835, 31.3314, 38.4268, 35.2644],
[31.3314, 33.605, 40.8934, 38.4268],
[33.605, 35.3335, 42.7342, 40.8934],
...,
[-42.7342, -40.8934, -46.161, -48.912],
[-40.8934, -38.4268, -42.6612, -46.161],
[-38.4268, -35.2644, -38.4268, -42.6612]]" id="21594c35" long_name="Latitude of mesh nodes." points="[33.4328, 36.1226, 38.2012, ..., -44.791,
-42.1583, -38.815]" shape="(864,)" standard_name="latitude" units="Unit('degrees')" value_type="float32"/>
</coord>
<coord datadims="[2]">
<meshCoord bounds="[[-45.0, -37.5, -37.5, -45.0],
[-37.5, -30.0, -30.0, -37.5],
[-30.0, -22.5, -22.5, -30.0],
...,
[-112.5, -120.0, -126.958, -118.361],
[-120.0, -127.5, -135.0, -126.958],
[-127.5, -135.0, -142.5, -135.0]]" id="fac9555b" long_name="Longitude of mesh nodes." points="[-41.3152, -33.8068, -26.296, ..., -119.377,
-127.321, -135.0]" shape="(864,)" standard_name="longitude" units="Unit('degrees')" value_type="float32"/>
</coord>
<coord datadims="[0]">
<auxCoord bounds="[[21600.0, 21600.0]]" id="17a27d05" long_name="Time axis" points="[21600.0]" shape="(1,)" standard_name="time" units="Unit('seconds since 2016-01-01 15:00:00', calendar='gregorian')" value_type="float64" var_name="time_instant">
<attributes>
<attribute name="time_origin" value="2016-01-01 15:00:00"/>
</attributes>
</auxCoord>
</coord>
</coords>
<cellMethods>
<cellMethod method="point">
<coord interval="300 s" name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0xd652c62c" dtype="float64" mask_checksum="no-masked-elements" shape="(1, 38, 864)"/>
</cube>
</cubes>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" ?>
<cubes xmlns="urn:x-iris:cubeml-0.2">
<cube dtype="float64" long_name="snow_layer_temperature" units="K" var_name="snow_layer_temp">
<attributes>
<attribute name="Conventions" value="UGRID"/>
<attribute name="description" value="Created by xios"/>
<attribute name="interval_operation" value="300 s"/>
<attribute name="interval_write" value="21600 s"/>
<attribute name="name" value="lfric_ngvat_3D_snow_pseudo_levels_1t_face_half_levels_main_snow_layer_temp"/>
<attribute name="online_operation" value="instant"/>
<attribute name="timeStamp" value="2020-Oct-18 21:20:18 GMT"/>
<attribute name="title" value="Created by xios"/>
<attribute name="uuid" value="798b1d5b-05e3-4380-a3b9-822709b0b74c"/>
</attributes>
<coords>
<coord datadims="[2]">
<meshCoord bounds="[[28.4835, 31.3314, 38.4268, 35.2644],
[31.3314, 33.605, 40.8934, 38.4268],
[33.605, 35.3335, 42.7342, 40.8934],
...,
[-42.7342, -40.8934, -46.161, -48.912],
[-40.8934, -38.4268, -42.6612, -46.161],
[-38.4268, -35.2644, -38.4268, -42.6612]]" id="21594c35" long_name="Latitude of mesh nodes." points="[33.4328, 36.1226, 38.2012, ..., -44.791,
-42.1583, -38.815]" shape="(864,)" standard_name="latitude" units="Unit('degrees')" value_type="float32"/>
</coord>
<coord datadims="[2]">
<meshCoord bounds="[[-45.0, -37.5, -37.5, -45.0],
[-37.5, -30.0, -30.0, -37.5],
[-30.0, -22.5, -22.5, -30.0],
...,
[-112.5, -120.0, -126.958, -118.361],
[-120.0, -127.5, -135.0, -126.958],
[-127.5, -135.0, -142.5, -135.0]]" id="fac9555b" long_name="Longitude of mesh nodes." points="[-41.3152, -33.8068, -26.296, ..., -119.377,
-127.321, -135.0]" shape="(864,)" standard_name="longitude" units="Unit('degrees')" value_type="float32"/>
</coord>
<coord datadims="[0]">
<auxCoord bounds="[[21600.0, 21600.0]]" id="17a27d05" long_name="Time axis" points="[21600.0]" shape="(1,)" standard_name="time" units="Unit('seconds since 2016-01-01 15:00:00', calendar='gregorian')" value_type="float64" var_name="time_instant">
<attributes>
<attribute name="time_origin" value="2016-01-01 15:00:00"/>
</attributes>
</auxCoord>
</coord>
</coords>
<cellMethods>
<cellMethod method="point">
<coord interval="300 s" name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0xb84aa0b6" dtype="float64" mask_checksum="no-masked-elements" shape="(1, 27, 864)"/>
</cube>
</cubes>
Loading