Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for sdswrf and sdlwrf #187

Merged
merged 12 commits into from
Oct 15, 2024
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# --- PROJECT CONFIGURATION --- #


[build-system]
requires = ["setuptools>=67", "wheel", "setuptools-git-versioning>=1.13.3"]
build-backend = "setuptools.build_meta"
Expand Down
11 changes: 11 additions & 0 deletions src/nwp_consumer/internal/inputs/metoffice/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ def mapCachedRaw(self, *, p: pathlib.Path) -> xr.Dataset: # noqa: D102
{currentName: internal.OCFParameter.WindSpeedSurfaceAdjustedAGL.value},
)

# There is some weird behaviour with the radiation parameters, and different setups
# this is a catch all situation (hopefully)
case "sdswrf", 7:
parameterDataset = parameterDataset.rename(
{currentName: 'dswrf'},
)
case "sdlwrf", 3:
parameterDataset = parameterDataset.rename(
{currentName: 'dlwrf'},
)

# Map the data to the internal dataset representation
# * Transpose the Dataset so that the dimensions are correctly ordered
# * Rechunk the data to a more optimal size
Expand Down
7 changes: 4 additions & 3 deletions src/nwp_consumer/internal/inputs/metoffice/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def test_errorsWhenVariablesAreNotSet(self) -> None:
class TestClient(unittest.TestCase):
"""Tests for the MetOfficeClient."""

@unittest.skip("Broken on github ci")
def test_mapCachedRaw(self) -> None:

tests = [
Expand All @@ -55,9 +54,11 @@ def test_mapCachedRaw(self) -> None:

# Ensure the dimensions of the variables are correct
for data_var in out.data_vars:
self.assertEqual(list(out[data_var].dims), tst["expected_dims"])
self.assertEqual(list(out[data_var].dims), tst["expected_dims"],
msg=f'Dims "{list(out[data_var].dims)}" not as expected in {tst}')
# Ensure the correct variable is in the data_vars
self.assertTrue(tst["expected_var"] in list(out.data_vars.keys()))
self.assertTrue(tst["expected_var"] in list(out.data_vars.keys()),
msg=f'Variable "{list(out.data_vars.keys())}" not as expected in {tst}')
# Ensure no unknowns
self.assertNotIn("unknown", list(out.data_vars.keys()))

Expand Down
Loading