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
20 changes: 20 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ env:
CONDA_CACHE_PACKAGES: "nox pip pyyaml"
# Use specific custom iris source feature branch.
IRIS_SOURCE: "github:mesh-data-model"
# Git commit hash for iris test data.
IRIS_TEST_DATA_VERSION: "2.2"
# Base directory for the iris-test-data.
IRIS_TEST_DATA_DIR: ${HOME}/iris-test-data
OVERRIDE_TEST_DATA_REPOSITORY: ${IRIS_TEST_DATA_DIR}/test_data


#
# YAML alias for the iris-test-data cache.
#
iris_test_data_template: &IRIS_TEST_DATA_TEMPLATE
data_cache:
folder: ${IRIS_TEST_DATA_DIR}
fingerprint_script:
- echo "iris-test-data v${IRIS_TEST_DATA_VERSION}"
populate_script:
- wget --quiet https://github.com/SciTools/iris-test-data/archive/v${IRIS_TEST_DATA_VERSION}.zip -O iris-test-data.zip
- unzip -q iris-test-data.zip
- mv iris-test-data-${IRIS_TEST_DATA_VERSION} ${IRIS_TEST_DATA_DIR}


#
Expand Down Expand Up @@ -97,6 +116,7 @@ test_task:
- echo "${CIRRUS_TASK_NAME}"
- echo "${NOX_CACHE_BUILD}"
- if [ -n "${IRIS_SOURCE}" ]; then echo "${IRIS_SOURCE}"; fi
<< : *IRIS_TEST_DATA_TEMPLATE
test_script:
- export CONDA_OVERRIDE_LINUX="$(uname -r | cut -d'+' -f1)"
- nox --session tests -- --verbose
1 change: 1 addition & 0 deletions esmf_regrid/tests/integration/experimental/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Integration tests for :mod:`esmf_regrid.experimental`."""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Integration tests for :mod:`esmf_regrid.experimental.unstructured_scheme`."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""Integration tests for :func:`esmf_regrid.experimental.unstructured_scheme.regrid_unstructured_to_rectilinear`."""


import os

import iris
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
import numpy as np

from esmf_regrid.experimental.unstructured_scheme import (
regrid_unstructured_to_rectilinear,
)


def test_real_data():
"""
Test for :func:`esmf_regrid.experimental.unstructured_scheme.regrid_unstructured_to_rectilinear`.

Tests with cubes derived from realistic data.
"""
# Load source cube.
test_data_dir = iris.config.TEST_DATA_DIR
src_fn = os.path.join(
test_data_dir, "NetCDF", "unstructured_grid", "lfric_surface_mean.nc"
)
with PARSE_UGRID_ON_LOAD.context():
src = iris.load_cube(src_fn, "rainfall_flux")

# Load target grid cube.
tgt_fn = os.path.join(
test_data_dir, "NetCDF", "global", "xyt", "SMALL_hires_wind_u_for_ipcc4.nc"
)
tgt = iris.load_cube(tgt_fn)

# Perform regridding.
result = regrid_unstructured_to_rectilinear(src, tgt)

# Check data.
assert result.shape == (1, 160, 320)
assert np.isclose(result.data.mean(), 2.93844e-5)
assert np.isclose(result.data.std(), 2.71724e-5)

# Check metadata.
assert result.metadata == src.metadata
assert result.coord("time") == src.coord("time")
assert result.coord("latitude") == tgt.coord("latitude")
assert result.coord("longitude") == tgt.coord("longitude")
assert result.coord_dims("time") == (0,)
assert result.coord_dims("latitude") == (1,)
assert result.coord_dims("longitude") == (2,)