Skip to content

Commit

Permalink
Merge branch 'develop' into feature/initial-state-output
Browse files Browse the repository at this point in the history
  • Loading branch information
dietervdb-meteo authored Nov 29, 2024
2 parents b6ad85d + ecfb2bc commit 1f1ec4d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Keep it human-readable, your future self will thank you!
- Update copyright notice
- Fix `__version__` import in init
- use earthkit-data 0.11.2
- Fix SimpleRunner

### Removed

Expand Down
3 changes: 3 additions & 0 deletions src/anemoi/inference/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def add_initial_forcings_to_input_state(self, input_state):
# TODO: Check for user provided forcings

for source in self.constant_forcings_inputs:
if source is None:
# When the constants are already in the input state
continue
LOG.info("Constant forcings input: %s %s (%s)", source, source.variables, dates)
arrays = source.load_forcings(input_state, dates)
for name, forcing in zip(source.variables, arrays):
Expand Down
31 changes: 31 additions & 0 deletions src/anemoi/inference/runners/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,46 @@

import logging

from ..forcings import ComputedForcings
from ..forcings import Forcings
from ..runner import Runner
from . import runner_registry

LOG = logging.getLogger(__name__)

# This is because forcings are assumed to already be in the
# state dictionary, so we don't need to load them from anywhere.


class NoForcings(Forcings):
"""No forcings."""

def __init__(self, context, variables, mask):
super().__init__(context)
self.variables = variables
self.mask = mask
self.kinds = dict(unknown=True)

def load_forcings(self, state, date):
pass


@runner_registry.register("simple")
class SimpleRunner(Runner):
"""Use that runner when using the low level API."""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def create_constant_computed_forcings(self, variables, mask):
result = ComputedForcings(self, variables, mask)
LOG.info("Constant computed forcing: %s", result)
return result

def create_dynamic_computed_forcings(self, variables, mask):
result = ComputedForcings(self, variables, mask)
LOG.info("Dynamic computed forcing: %s", result)
return result

def create_constant_coupled_forcings(self, variables, mask):
return None

0 comments on commit 1f1ec4d

Please sign in to comment.