From cfd1d21b1813d0c576d25ee58ea8ce6b078d908b Mon Sep 17 00:00:00 2001 From: Baudouin Raoult Date: Thu, 17 Oct 2024 06:58:46 +0000 Subject: [PATCH 1/4] add grid_field_list --- pyproject.toml | 1 + src/anemoi/inference/runner.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 78374ed..6320738 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,7 @@ classifiers = [ dynamic = [ "version" ] dependencies = [ + "anemoi-transform", "anemoi-utils>=0.3", "aniso8601", "anytree", diff --git a/src/anemoi/inference/runner.py b/src/anemoi/inference/runner.py index 84652d9..2ffc649 100644 --- a/src/anemoi/inference/runner.py +++ b/src/anemoi/inference/runner.py @@ -73,6 +73,7 @@ def run( output_callback=ignore, autocast=None, progress_callback=ignore, + grid_field_list=None, ) -> None: """_summary_ @@ -92,6 +93,8 @@ def run( _description_, by default None progress_callback : _type_, optional _description_, by default ignore + grid_field_list: _type_, optional + _description_, by default None Raises ------ @@ -245,7 +248,7 @@ def run( ] constants = forcing_and_constants( - source=input_fields[:1], + source=grid_field_list if grid_field_list is not None else input_fields[:1], param=self.checkpoint.computed_constants, date=start_datetime, ) From e7011d85758209fe1055a3b7e86a6de851fd95c3 Mon Sep 17 00:00:00 2001 From: Baudouin Raoult Date: Thu, 17 Oct 2024 07:00:43 +0000 Subject: [PATCH 2/4] add dependency --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6320738..e917ce2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ classifiers = [ dynamic = [ "version" ] dependencies = [ - "anemoi-transform", + "anemoi-transform>=0.0.3", "anemoi-utils>=0.3", "aniso8601", "anytree", From 2257a8906b3907c317401806666ac97c00d3e9fc Mon Sep 17 00:00:00 2001 From: Baudouin Raoult Date: Thu, 17 Oct 2024 07:01:31 +0000 Subject: [PATCH 3/4] add dependency --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ca891a..ba5ea85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Keep it human-readable, your future self will thank you! ### Added - Add anemoi-transform link to documentation +- Add support for unstructured grids ### Changed From 5119ed5046bdf348ebb6aee728415bd6bda74f6c Mon Sep 17 00:00:00 2001 From: Baudouin Raoult Date: Thu, 17 Oct 2024 12:30:38 +0000 Subject: [PATCH 4/4] wip --- pyproject.toml | 2 +- .../inference/checkpoint/metadata/version_0_2_0.py | 10 +++++----- src/anemoi/inference/runner.py | 8 +++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e917ce2..c5295bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ classifiers = [ dynamic = [ "version" ] dependencies = [ - "anemoi-transform>=0.0.3", + "anemoi-transform>=0.0.4", "anemoi-utils>=0.3", "aniso8601", "anytree", diff --git a/src/anemoi/inference/checkpoint/metadata/version_0_2_0.py b/src/anemoi/inference/checkpoint/metadata/version_0_2_0.py index ba499e0..9da1b9b 100644 --- a/src/anemoi/inference/checkpoint/metadata/version_0_2_0.py +++ b/src/anemoi/inference/checkpoint/metadata/version_0_2_0.py @@ -113,23 +113,23 @@ def __init__(self, metadata): @property def grid(self): - return self.request["grid"] + return self.request.get("grid") @property def area(self): - return self.request["area"] + return self.request.get("area") @property def param_sfc(self): - return self.request["param_level"].get("sfc", []) + return self.request.get("param_level", {}).get("sfc", []) @property def param_level_pl_pairs(self): - return self.request["param_level"].get("pl", []) + return self.request.get("param_level", {}).get("pl", []) @property def param_level_ml_pairs(self): - return self.request["param_level"].get("ml", []) + return self.request.get("param_level", {}).get("ml", []) @property def param_step_sfc_pairs(self): diff --git a/src/anemoi/inference/runner.py b/src/anemoi/inference/runner.py index ae26ada..30a0fb6 100644 --- a/src/anemoi/inference/runner.py +++ b/src/anemoi/inference/runner.py @@ -321,7 +321,13 @@ def get_most_recent_datetime(input_fields): most_recent_datetime = get_most_recent_datetime(input_fields) reference_fields = [f for f in input_fields if f.datetime()["valid_time"] == most_recent_datetime] - prognostic_template = reference_fields[self.checkpoint.variable_to_index["lsm"]] + + if "lsm" in self.checkpoint.variable_to_index: + prognostic_template = reference_fields[self.checkpoint.variable_to_index["lsm"]] + else: + first = list(self.checkpoint.variable_to_index.keys()) + LOGGER.warning("No LSM found to use as a GRIB template, using %s", first[0]) + prognostic_template = reference_fields[0] accumulated_output = np.zeros( shape=(len(diagnostic_output_mask), number_of_grid_points),