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

Adjustments required as part of ECMWF ML PP WP1 Task 1.3 #22

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Keep it human-readable, your future self will thank you!
### Added

MeraX marked this conversation as resolved.
Show resolved Hide resolved
### Changed
- use `PS` if `lsm` is not available as prognostic template

### Removed

Expand Down
24 changes: 20 additions & 4 deletions src/anemoi/inference/checkpoint/metadata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# (C) Copyright 2023 European Centre for Medium-Range Weather Forecasts.
# (C) Copyright 2024 Deutscher Wetterdienst.
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

# In applying this licence, the above institution do not waive the privileges
# and immunities granted to it by virtue of its status as an intergovernmental
# organisation nor does it submit to any jurisdiction.

import json
import logging
Expand Down Expand Up @@ -115,6 +115,22 @@ def hour_steps(self):

return int(n[:-1]) * {"h": 1, "d": 24}[n[-1]]

@cached_property
def max_refinement_level_c(self):
MeraX marked this conversation as resolved.
Show resolved Hide resolved
"""Returns refinement level of ICON input dataset, in [0,1,2,3,4,5,6,7].
If not defined it returns None.
"""

return (
self._metadata.get("dataset", {})
.get("specific", {})
.get("forward", {})
.get("forward", {})
.get("attrs", {})
.get("data_request", {})
.get("max_refinement_level_c")
)

###########################################################################
# Indices

Expand Down
12 changes: 8 additions & 4 deletions src/anemoi/inference/runner.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
# (C) Copyright 2024 Deutscher Wetterdienst.
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.
# In applying this licence, the above institution do not waive the privileges
# and immunities granted to it by virtue of its status as an intergovernmental
# organisation nor does it submit to any jurisdiction.


import datetime
Expand Down Expand Up @@ -312,7 +313,10 @@ 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:
prognostic_template = reference_fields[self.checkpoint.variable_to_index["PS"]]
MeraX marked this conversation as resolved.
Show resolved Hide resolved

accumulated_output = np.zeros(
shape=(len(diagnostic_output_mask), number_of_grid_points),
Expand Down