Skip to content

Add loader for anemoi-inference projected grid (x/y) format#8

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-anemoi-inference-format
Draft

Add loader for anemoi-inference projected grid (x/y) format#8
Copilot wants to merge 2 commits intomainfrom
copilot/add-anemoi-inference-format

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 22, 2026

A second anemoi-inference output format exists in the wild where the spatial domain is a structured 2D projected grid (y, x dims) rather than a flat values dimension, and the forecast reference time is stored as an explicit scalar data variable (forecast_reference_time) rather than being inferred from time[0].

New loader: anemoi_inference_xy

src/mlwp_data_loaders/loaders/anemoi/anemoi_inference_xy.py

Handles the format:

Dimensions:  (time: 1, y: 1069, x: 1069)
Coordinates:
  * time                     (time) datetime64[ns]
  * y                        (y) float32
  * x                        (x) float32
    latitude                 (y, x) float64
    longitude                (y, x) float64
Data variables:
    forecast_reference_time  datetime64[ns]
    projection               int32
    2t                       (time, y, x) float32
    ...

Key transformations in _preprocess (applied per-file before concatenation):

  • Extracts forecast_reference_timereference_time dimension coordinate
  • Computes lead_time = time - forecast_reference_time and swaps it in for the time dimension
  • Promotes latitude/longitude to coordinates if they arrive as data variables
  • Drops forecast_reference_time and projection scalars

Output traits: forecast / grid / deterministic — consistent with the existing anemoi_inference loader.

Tests

tests/test_anemoi_inference_xy.py — 17 unit tests covering all _preprocess transformations and load_dataset behaviour (trait attrs, dimension structure, path coercion, variable preservation) using synthetic in-memory datasets.

Copilot AI linked an issue Apr 22, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add support for another anemoi-inference format Add loader for anemoi-inference projected grid (x/y) format Apr 22, 2026
Copilot AI requested a review from observingClouds April 22, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Another anemoi-inference format

2 participants