Skip to content

Commit

Permalink
Merge branch 'develop' into feature/rename_condition_to_state
Browse files Browse the repository at this point in the history
  • Loading branch information
HCookie authored Oct 17, 2024
2 parents 5f6021b + 73caf96 commit e01abc2
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 25 deletions.
9 changes: 3 additions & 6 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# CODEOWNERS file

# Protect workflow files
/.github/ @theissenhelen @jesperdramsch @gmertes
/.pre-commit-config.yaml @theissenhelen @jesperdramsch @gmertes
/pyproject.toml @theissenhelen @jesperdramsch @gmertes

# Protect package exemptions
/src/anemoi/inference/checkpoint/package_exemptions.py @gmertes @hcookie @theissenhelen @jesperdramsch
/.github/ @theissenhelen @jesperdramsch @gmertes @b8raoult @floriankrb @anaprietonem @HCookie @JPXKQX @mchantry
/.pre-commit-config.yaml @theissenhelen @jesperdramsch @gmertes @b8raoult @floriankrb @anaprietonem @HCookie @JPXKQX @mchantry
/pyproject.toml @theissenhelen @jesperdramsch @gmertes @b8raoult @floriankrb @anaprietonem @HCookie @JPXKQX @mchantry
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ repos:
- id: clear-notebooks-output
name: clear-notebooks-output
files: tools/.*\.ipynb$
stages: [commit]
stages: [pre-commit]
language: python
entry: jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace
additional_dependencies: [jupyter]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml # Check YAML files for syntax errors only
args: [--unsafe, --allow-multiple-documents]
Expand Down Expand Up @@ -40,11 +40,11 @@ repos:
- --force-single-line-imports
- --profile black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
rev: v0.6.9
hooks:
- id: ruff
# Next line if for documenation cod snippets
exclude: '^[^_].*_\.py$'
exclude: '.*/[^_].*_\.py$'
args:
- --line-length=120
- --fix
Expand All @@ -66,11 +66,11 @@ repos:
- id: docconvert
args: ["numpy"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.2.3"
rev: "2.2.4"
hooks:
- id: pyproject-fmt
- repo: https://github.com/jshwi/docsig # Check docstrings against function sig
rev: v0.60.1
rev: v0.64.0
hooks:
- id: docsig
args:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ Please add your functional changes to the appropriate section in the PR.
Keep it human-readable, your future self will thank you!

## [Unreleased]

### Added
- Fix: Enable inference when no constant forcings are used

- Add anemoi-transform link to documentation

### Changed

Expand Down
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
"https://anemoi-registry.readthedocs.io/en/latest/",
("../../anemoi-registry/docs/_build/html/objects.inv", None),
),
"anemoi-transform": (
"https://anemoi-transform.readthedocs.io/en/latest/",
("../../anemoi-transform/docs/_build/html/objects.inv", None),
),
}


Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ of the *Anemoi* packages.
*****************

- :ref:`anemoi-utils <anemoi-utils:index-page>`
- :ref:`anemoi-transform <anemoi-transform:index-page>`
- :ref:`anemoi-datasets <anemoi-datasets:index-page>`
- :ref:`anemoi-models <anemoi-models:index-page>`
- :ref:`anemoi-graphs <anemoi-graphs:index-page>`
Expand Down
2 changes: 1 addition & 1 deletion src/anemoi/inference/checkpoint/metadata/version_0_2_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def param_level_ml_pairs(self):

@property
def param_step_sfc_pairs(self):
return self.request["param_step"].get("sfc", [])
return self.request.get("param_step", {}).get("sfc", [])

@property
def variables_with_nans(self):
Expand Down
27 changes: 15 additions & 12 deletions src/anemoi/inference/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def run(
input_fields = input_fields.sel(**self.checkpoint.select)
input_fields = input_fields.order_by(**self.checkpoint.order_by)

number_of_grid_points = len(input_fields[0].grid_points()[0])
number_of_grid_points = len(input_fields[0].values)

LOGGER.info("Loading input: %d fields (lagged=%d)", len(input_fields), len(self.lagged))

Expand Down Expand Up @@ -240,9 +240,10 @@ def run(

input_tensor_numpy[:, prognostic_input_mask] = input_fields_numpy[:, prognostic_data_from_retrieved_fields_mask]

input_tensor_numpy[:, constant_from_input_mask] = input_fields_numpy[
:, constant_data_from_retrieved_fields_mask
]
if len(constant_from_input_mask) > 0:
input_tensor_numpy[:, constant_from_input_mask] = input_fields_numpy[
:, constant_data_from_retrieved_fields_mask
]

constants = forcing_and_constants(
source=input_fields[:1],
Expand All @@ -253,13 +254,14 @@ def run(
for i in range(len(self.lagged)):
input_tensor_numpy[i, computed_constant_mask] = constants

for i in range(len(self.lagged)):
forcings = forcing_and_constants(
source=input_fields[:1],
param=self.checkpoint.computed_forcings,
date=start_datetime + datetime.timedelta(hours=self.lagged[i]),
)
input_tensor_numpy[i, computed_forcing_mask] = forcings
if len(constant_from_input_mask) > 0:
for i in range(len(self.lagged)):
forcings = forcing_and_constants(
source=input_fields[:1],
param=self.checkpoint.computed_forcings,
date=start_datetime + datetime.timedelta(hours=self.lagged[i]),
)
input_tensor_numpy[i, computed_forcing_mask] = forcings

LOGGER.info("Input tensor shape: %s", input_tensor_numpy.shape)

Expand Down Expand Up @@ -409,7 +411,8 @@ def get_most_recent_datetime(input_fields):
# Update dynamic tensor for next iteration
input_tensor_torch = input_tensor_torch.roll(-1, dims=1)
input_tensor_torch[:, -1, :, prognostic_input_mask] = prognostic_fields
input_tensor_torch[:, -1, :, computed_forcing_mask] = forcing
if computed_forcing_mask:
input_tensor_torch[:, -1, :, computed_forcing_mask] = forcing

# progress_callback(i)

Expand Down

0 comments on commit e01abc2

Please sign in to comment.