Skip to content

Commit eb63372

Browse files
committed
Merge branch 'develop' of github.com:ecmwf/anemoi-datasets into develop
2 parents 72b266c + 1d96021 commit eb63372

24 files changed

+468
-101
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CODEOWNERS file
22

33
# Protect workflow files
4-
/.github/ @theissenhelen @jesperdramsch @gmertes @b8raoult @floriankrb
5-
/.pre-commit-config.yaml @theissenhelen @jesperdramsch @gmertes @b8raoult @floriankrb
6-
/pyproject.toml @theissenhelen @jesperdramsch @gmertes @b8raoult @floriankrb
4+
/.github/ @theissenhelen @jesperdramsch @gmertes @b8raoult @floriankrb @anaprietonem @HCookie @JPXKQX @mchantry
5+
/.pre-commit-config.yaml @theissenhelen @jesperdramsch @gmertes @b8raoult @floriankrb @anaprietonem @HCookie @JPXKQX @mchantry
6+
/pyproject.toml @theissenhelen @jesperdramsch @gmertes @b8raoult @floriankrb @anaprietonem @HCookie @JPXKQX @mchantry

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ assignees: ''
99
**Describe the bug**
1010
A clear and concise description of what the bug is.
1111

12+
** Version number **
13+
I am using the following versions/branch/sha1 of the anemoi packages
14+
(alternatively the output of `pip freeze`)
15+
1216
**To Reproduce**
1317
Steps to reproduce the behavior:
1418
1. Go to '...'
15-
2. Click on '....'
16-
3. Scroll down to '....'
17-
4. See error
19+
2. Run this '....'
20+
3. See error
1821

1922
**URL to sample input data**
2023
Provide a URL to a sample input data, or attach a file to that report if it is small enough.
@@ -25,16 +28,5 @@ A clear and concise description of what you expected to happen.
2528
**Screenshots**
2629
If applicable, add screenshots to help explain your problem.
2730

28-
**Desktop (please complete the following information):**
29-
- OS: [e.g. iOS]
30-
- Browser [e.g. chrome, safari]
31-
- Version [e.g. 22]
32-
33-
**Smartphone (please complete the following information):**
34-
- Device: [e.g. iPhone6]
35-
- OS: [e.g. iOS8.1]
36-
- Browser [e.g. stock browser, safari]
37-
- Version [e.g. 22]
38-
3931
**Additional context**
4032
Add any other context about the problem here.

.github/ci-config.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
dependencies: |
2-
ecmwf/ecbuild
3-
MathisRosenhauer/libaec@master
4-
ecmwf/eccodes
5-
ecmwf/eckit
6-
ecmwf/odc
71
dependency_branch: develop
82
parallelism_factor: 8
93
self_build: false # Only for python packages

.github/ci-hpc-config.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,8 @@ build:
22
python: '3.10'
33
modules:
44
- ninja
5-
dependencies:
6-
- ecmwf/ecbuild@develop
7-
- ecmwf/eccodes@develop
8-
- ecmwf/eckit@develop
9-
- ecmwf/odc@develop
105
python_dependencies:
116
- ecmwf/anemoi-utils@develop
12-
- ecmwf/earthkit-data@develop
13-
- ecmwf/earthkit-meteo@develop
14-
- ecmwf/earthkit-geo@develop
157
parallel: 64
16-
178
pytest_cmd: |
189
python -m pytest -vv -m 'not notebook and not no_cache_init' --cov=. --cov-report=xml

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,31 @@ Keep it human-readable, your future self will thank you!
1010

1111
## [Unreleased](https://github.com/ecmwf/anemoi-datasets/compare/0.5.7...HEAD)
1212

13+
14+
### Added
15+
16+
- Add anemoi-transform link to documentation
17+
- Various bug fixes
18+
- Control compatibility check in xy/zip
19+
- Add `merge` feature
20+
21+
### Changed
22+
23+
- Remove upstream dependencies from downstream-ci workflow (temporary) (#83)
24+
1325
## [0.5.7](https://github.com/ecmwf/anemoi-datasets/compare/0.5.6...0.5.7) - 2024-10-09
1426

27+
### Changed
28+
29+
- Add support to fill missing dates
30+
1531
## [Allow for unknown CF coordinates](https://github.com/ecmwf/anemoi-datasets/compare/0.5.5...0.5.6) - 2024-10-04
1632

17-
- Update documentation
33+
### Changed
1834

35+
- Add `variables_metadata` entry in the dataset metadata
1936
- Update documentation
37+
2038
### Changed
2139

2240
- Add `variables_metadata` entry in the dataset metadata

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@
107107
"https://anemoi-registry.readthedocs.io/en/latest/",
108108
("../../anemoi-registry/docs/_build/html/objects.inv", None),
109109
),
110+
"anemoi-transform": (
111+
"https://anemoi-transform.readthedocs.io/en/latest/",
112+
("../../anemoi-transform/docs/_build/html/objects.inv", None),
113+
),
110114
}
111115

112116

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ datasets <building-introduction>`.
121121
*****************
122122

123123
- :ref:`anemoi-utils <anemoi-utils:index-page>`
124+
- :ref:`anemoi-transform <anemoi-transform:index-page>`
124125
- :ref:`anemoi-datasets <anemoi-datasets:index-page>`
125126
- :ref:`anemoi-models <anemoi-models:index-page>`
126127
- :ref:`anemoi-graphs <anemoi-graphs:index-page>`
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ds = open_dataset(dataset, fill_missing_dates="interpolate")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ds = open_dataset(dataset, fill_missing_dates="closest")

docs/using/code/missing_dates_.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/using/code/set_missing_dates_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ds = open_dataset(dataset, set_missing_dates=["2010-01-01T12:00:00", "2010-02-01T12:00:00"])

docs/using/missing.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44
Managing missing dates
55
########################
66

7+
**************************************************
8+
Filling the missing dates with artificial values
9+
**************************************************
10+
11+
When you have missing dates in a dataset, you can fill them with
12+
artificial values. You can either fill them with values that are the
13+
result of a linear interpolation between the two closest dates:
14+
15+
.. literalinclude:: code/fill_missing_dates1_.py
16+
17+
Or you can select the copy the value of the closest date:
18+
19+
.. literalinclude:: code/fill_missing_dates2_.py
20+
21+
if the missing date is exactly in the middle of two dates, the library
22+
will choose that value of the largest date. You can change this behavior
23+
by setting the ``closest`` parameter to ``'down'`` or ``'up'``
24+
explicitly.
25+
726
************************************************
827
Skipping missing when iterating over a dataset
928
************************************************
@@ -72,7 +91,7 @@ the datasets to make the dates contiguous.
7291
Debugging
7392
***********
7493

75-
You can set missing dates using the ``missing_dates`` option. This
94+
You can set missing dates using the ``set_missing_dates`` option. This
7695
option is for debugging purposes only.
7796

78-
.. literalinclude:: code/missing_dates_.py
97+
.. literalinclude:: code/set_missing_dates_.py

pyproject.toml

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ dynamic = [
5050
"version",
5151
]
5252
dependencies = [
53-
"anemoi-utils[provenance]>=0.3.15",
53+
"anemoi-utils[provenance]>=0.3.18",
5454
"cfunits",
5555
"numpy",
5656
"pyyaml",
@@ -60,43 +60,20 @@ dependencies = [
6060
]
6161

6262
optional-dependencies.all = [
63-
"boto3",
64-
"earthkit-data[mars]>=0.9",
65-
"earthkit-geo>=0.2",
66-
"earthkit-meteo",
67-
"ecmwflibs>=0.6.3",
68-
"entrypoints",
69-
"gcsfs",
70-
"kerchunk",
71-
"pyproj",
72-
"requests",
63+
"anemoi-datasets[create,remote,xarray]",
7364
]
7465

7566
optional-dependencies.create = [
76-
"earthkit-data[mars]>=0.9",
67+
"earthkit-data[mars]>=0.10.7",
7768
"earthkit-geo>=0.2",
7869
"earthkit-meteo",
79-
"ecmwflibs>=0.6.3",
70+
"eccodes>=2.38.1",
8071
"entrypoints",
8172
"pyproj",
8273
]
8374

8475
optional-dependencies.dev = [
85-
"boto3",
86-
"earthkit-data[mars]>=0.9",
87-
"earthkit-geo>=0.2",
88-
"earthkit-meteo",
89-
"ecmwflibs>=0.6.3",
90-
"entrypoints",
91-
"gcsfs",
92-
"kerchunk",
93-
"nbsphinx",
94-
"pandoc",
95-
"pyproj",
96-
"pytest",
97-
"requests",
98-
"sphinx",
99-
"sphinx-rtd-theme",
76+
"anemoi-datasets[all,docs,tests]",
10077
]
10178

10279
optional-dependencies.docs = [

src/anemoi/datasets/create/functions/filters/rename.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ def __init__(self, field, format):
5656
self.format = format
5757
self.bits = re.findall(r"{(\w+)}", format)
5858

59-
def metadata(self, key, **kwargs):
60-
value = self.field.metadata(key, **kwargs)
61-
if "{" + key + "}" in self.format:
62-
bits = {b: self.field.metadata(b, **kwargs) for b in self.bits}
63-
return self.format.format(**bits)
59+
def metadata(self, *args, **kwargs):
60+
value = self.field.metadata(*args, **kwargs)
61+
if args:
62+
assert len(args) == 1
63+
key = args[0]
64+
if "{" + key + "}" in self.format:
65+
bits = {b: self.field.metadata(b, **kwargs) for b in self.bits}
66+
return self.format.format(**bits)
6467
return value
6568

6669
def __getattr__(self, name):

src/anemoi/datasets/create/functions/sources/accumulations.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,15 @@ def accumulations(context, dates, **request):
370370

371371
user_accumulation_period = request.pop("accumulation_period", 6)
372372

373+
# If `data_accumulation_period` is not set, this means that the accumulations are from the start
374+
# of the forecast.
375+
373376
KWARGS = {
374377
("od", "oper"): dict(patch=_scda),
375378
("od", "elda"): dict(base_times=(6, 18)),
376379
("ea", "oper"): dict(data_accumulation_period=1, base_times=(6, 18)),
377380
("ea", "enda"): dict(data_accumulation_period=3, base_times=(6, 18)),
378-
("rr", "oper"): dict(data_accumulation_period=3, base_times=(0, 3, 6, 9, 12, 15, 18, 21)),
381+
("rr", "oper"): dict(base_times=(0, 3, 6, 9, 12, 15, 18, 21)),
379382
("l5", "oper"): dict(data_accumulation_period=1, base_times=(0,)),
380383
}
381384

src/anemoi/datasets/create/input/__init__.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,9 @@
66
# granted to it by virtue of its status as an intergovernmental organisation
77
# nor does it submit to any jurisdiction.
88
#
9-
import datetime
10-
import itertools
9+
1110
import logging
12-
import math
13-
import time
14-
from collections import defaultdict
1511
from copy import deepcopy
16-
from functools import cached_property
17-
from functools import wraps
18-
19-
import numpy as np
20-
from anemoi.utils.dates import as_datetime as as_datetime
21-
from anemoi.utils.dates import frequency_to_timedelta as frequency_to_timedelta
22-
23-
from anemoi.datasets.dates import DatesProvider as DatesProvider
24-
from anemoi.datasets.fields import FieldArray as FieldArray
25-
from anemoi.datasets.fields import NewValidDateTimeField as NewValidDateTimeField
2612

2713
from .trace import trace_select
2814

src/anemoi/datasets/create/input/result.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,38 @@
3333
def _fields_metatata(variables, cube):
3434
assert isinstance(variables, tuple), variables
3535

36+
def _merge(md1, md2):
37+
assert set(md1.keys()) == set(md2.keys()), (set(md1.keys()), set(md2.keys()))
38+
result = {}
39+
for k in md1.keys():
40+
v1 = md1[k]
41+
v2 = md2[k]
42+
43+
if v1 == v2:
44+
result[k] = v1
45+
continue
46+
47+
if isinstance(v1, list):
48+
assert v2 not in v1, (v1, v2)
49+
result[k] = sorted(v1 + [v2])
50+
continue
51+
52+
if isinstance(v2, list):
53+
assert v1 not in v2, (v1, v2)
54+
result[k] = sorted(v2 + [v1])
55+
continue
56+
57+
result[k] = sorted([v1, v2])
58+
59+
return result
60+
3661
result = {}
37-
for i, c in enumerate(cube.iterate_cubelets()):
38-
assert c._coords_names[1] == variables[i], (c._coords_names[1], variables[i])
62+
i = -1
63+
for c in cube.iterate_cubelets():
64+
65+
if i == -1 or c._coords_names[1] != variables[i]:
66+
i += 1
67+
3968
f = cube[c.coords]
4069
md = f.metadata(namespace="mars")
4170
if not md:
@@ -49,7 +78,10 @@ def _fields_metatata(variables, cube):
4978
md["param"] = str(f.metadata("paramId", default="unknown"))
5079
# assert md['param'] != 'unknown', (md, f.metadata('param'))
5180

52-
result[variables[i]] = md
81+
if variables[i] in result:
82+
result[variables[i]] = _merge(md, result[variables[i]])
83+
else:
84+
result[variables[i]] = md
5385

5486
assert i + 1 == len(variables), (i + 1, len(variables))
5587
return result

src/anemoi/datasets/create/input/step.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def select(self, group_of_dates):
5959
)
6060

6161
def __repr__(self):
62+
# raise NotImplementedError(f"Not implemented in {self.__class__.__name__}")
6263
return super().__repr__(self.previous_step, _inline_=str(self.kwargs))
6364

6465

src/anemoi/datasets/data/concat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def concat_factory(args, kwargs):
148148

149149
datasets = kwargs.pop("concat")
150150
fill_missing_gaps = kwargs.pop("fill_missing_gaps", False)
151+
151152
assert isinstance(datasets, (list, tuple))
152153
assert len(args) == 0
153154

0 commit comments

Comments
 (0)