Skip to content

Commit

Permalink
Add acceptance test for duration_subdivision CLI.
Browse files Browse the repository at this point in the history
  • Loading branch information
bayliffe committed Dec 16, 2024
1 parent fa64ec5 commit a138358
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
4 changes: 4 additions & 0 deletions improver_tests/acceptance/SHA256SUMS
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ fee00437131d2367dc317e5b0fff44e65e03371b8f096bf1ac0d4cc7253693c9 ./create-grid-
bf7e42be7897606682c3ecdaeb27bf3d3b6ab13a9a88b46c88ae6e92801c6245 ./create-grid-with-halo/halo_size/kgo.nc
55ba8a8ca8b5eee667d37fe8ec4a653caddea27f19ea290397428a487eb13ca0 ./cubelist-extract/input_cubelist.nc
33c7e0cf46ac62ead74ffde502ee28076a59550474fb3872c3e22083c4bd3cc3 ./cubelist-extract/kgo.nc
368f3c0c658d1155399ad4bdbfe0f98e0c65f5c53a49ece105bba3758012c0e8 ./duration-subdivision/input.nc
2c8c4972ae2dca29a05ac62f982cdd5727546c19a1699f4366416a12640ed2f8 ./duration-subdivision/kgo_daymask.nc
fc87547220adc1326af0e484a826d8950a7acc6e3c2d76ce63b7beea6133bf73 ./duration-subdivision/kgo_nightmask.nc
f2fd4c7884e50ab90f0d085a66d7b3b41c9bf09508481ceaa409a9025fde8386 ./duration-subdivision/kgo_nomask.nc
fe00aadb6854f44d765b40bb6608c23f4eb4f10193c96f43f207db0590739dab ./enforce-consistent-forecasts/double_bound_percentile_kgo.nc
51f9ff2c8e6cad54d04d6323c654ce25b812bea3ba6b0d85df21c19731c580fc ./enforce-consistent-forecasts/percentile_forecast.nc
e210bf956dd3574eda3a64fdc3371ab16f85048ca120a3823e90d751d2325c46 ./enforce-consistent-forecasts/percentile_reference.nc
Expand Down
73 changes: 73 additions & 0 deletions improver_tests/acceptance/test_duration_subdivision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# (C) Crown Copyright, Met Office. All rights reserved.
#
# This file is part of 'IMPROVER' and is released under the BSD 3-Clause license.
# See LICENSE in the root of the repository for full licensing details.
"""
Tests for the duration_subdivision CLI
"""

import pytest

from . import acceptance as acc

pytestmark = [pytest.mark.acc, acc.skip_if_kgo_missing]
CLI = acc.cli_name_with_dashes(__file__)
run_cli = acc.run_cli(CLI)


def test_basic(tmp_path):
"""Test no mask application to duration is split evenly into shorter
periods."""
kgo_dir = acc.kgo_root() / "duration-subdivision"
kgo_path = kgo_dir / "kgo_nomask.nc"
input_path = kgo_dir / "input.nc"
output_path = tmp_path / "output.nc"
args = [
input_path,
"--target-period=10800",
"--fidelity=900",
"--output",
output_path,
]
run_cli(args)
acc.compare(output_path, kgo_path)


def test_nightmask(tmp_path):
"""Test night mask application to duration so period is unequally split
to ensure no daylight duration is spread into night time hours."""
kgo_dir = acc.kgo_root() / "duration-subdivision"
kgo_path = kgo_dir / "kgo_nightmask.nc"
input_path = kgo_dir / "input.nc"
output_path = tmp_path / "output.nc"
args = [
input_path,
"--target-period=10800",
"--fidelity=900",
"--night-mask",
"--output",
output_path,
]
run_cli(args)
acc.compare(output_path, kgo_path)


def test_daymask(tmp_path):
"""Test day mask application to duration. As we are working with a
sunshine duration diagnostic this effectively shows up the
disagreements between our night mask and the irradiation limit of the
radiation scheme used in generating the diagnostic."""
kgo_dir = acc.kgo_root() / "duration-subdivision"
kgo_path = kgo_dir / "kgo_daymask.nc"
input_path = kgo_dir / "input.nc"
output_path = tmp_path / "output.nc"
args = [
input_path,
"--target-period=10800",
"--fidelity=900",
"--day-mask",
"--output",
output_path,
]
run_cli(args)
acc.compare(output_path, kgo_path)

0 comments on commit a138358

Please sign in to comment.