Skip to content

Commit 8d51653

Browse files
committed
Merge branch 'develop' of github.com:ecmwf/anemoi-datasets into develop
2 parents 068a462 + 2bbcc3e commit 8d51653

File tree

121 files changed

+784
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+784
-212
lines changed

.github/workflows/python-publish.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ jobs:
1515
skip-hooks: "no-commit-to-branch"
1616

1717
checks:
18+
strategy:
19+
matrix:
20+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1821
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
1922
with:
20-
python-version: "3.9"
23+
python-version: ${{ matrix.python-version }}
2124

2225
deploy:
2326
needs: [checks, quality]

.github/workflows/python-pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
checks:
1818
strategy:
1919
matrix:
20-
python-version: ["3.9", "3.10"]
20+
python-version: ["3.9", "3.10", "3.11", "3.12"]
2121
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
2222
with:
2323
python-version: ${{ matrix.python-version }}

.pre-commit-config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ repos:
4343
rev: v0.6.9
4444
hooks:
4545
- id: ruff
46-
# Next line if for documenation cod snippets
47-
exclude: '.*/[^_].*_\.py$'
4846
args:
4947
- --line-length=120
5048
- --fix
5149
- --exit-non-zero-on-fix
5250
- --preview
51+
- --exclude=docs/**/*_.py
5352
- repo: https://github.com/sphinx-contrib/sphinx-lint
5453
rev: v1.0.0
5554
hooks:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ 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+
### Changed
14+
15+
- Bugfix in `auto_adjust`
1316

1417
### Added
1518

@@ -21,6 +24,7 @@ Keep it human-readable, your future self will thank you!
2124
### Changed
2225

2326
- Remove upstream dependencies from downstream-ci workflow (temporary) (#83)
27+
- ci: pin python versions to 3.9 ... 3.12 for checks (#93)
2428

2529
## [0.5.7](https://github.com/ecmwf/anemoi-datasets/compare/0.5.6...0.5.7) - 2024-10-09
2630

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $ pip install anemoi-datasets
2222
## License
2323

2424
```
25-
Copyright 2022, European Centre for Medium Range Weather Forecasts.
25+
Copyright 2024, Anemoi contributors.
2626
2727
Licensed under the Apache License, Version 2.0 (the "License");
2828
you may not use this file except in compliance with the License.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ dynamic = [
5050
"version",
5151
]
5252
dependencies = [
53-
"anemoi-utils[provenance]>=0.3.18",
53+
"anemoi-transform>=0.0.5",
54+
"anemoi-utils[provenance]>=0.4.1",
5455
"cfunits",
5556
"numpy",
5657
"pyyaml",

src/anemoi/datasets/commands/cleanup.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import logging
211
import time
312

src/anemoi/datasets/commands/compare.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#!/usr/bin/env python
2-
# (C) Copyright 2024 ECMWF.
1+
# (C) Copyright 2024 Anemoi contributors.
32
#
43
# This software is licensed under the terms of the Apache Licence Version 2.0
54
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
66
# In applying this licence, ECMWF does not waive the privileges and immunities
77
# granted to it by virtue of its status as an intergovernmental organisation
88
# nor does it submit to any jurisdiction.
9-
#
9+
1010

1111
import numpy as np
1212
import tqdm

src/anemoi/datasets/commands/copy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
# (C) Copyright 2023 European Centre for Medium-Range Weather Forecasts.
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
23
# This software is licensed under the terms of the Apache Licence Version 2.0
34
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
46
# In applying this licence, ECMWF does not waive the privileges and immunities
57
# granted to it by virtue of its status as an intergovernmental organisation
68
# nor does it submit to any jurisdiction.
79

10+
811
import logging
912
import os
1013
import shutil

src/anemoi/datasets/commands/create.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import datetime
211
import logging
312
import time
@@ -117,7 +126,9 @@ def parallel_create(self, args):
117126
opt["parts"] = f"{n+1}/{total}"
118127
futures.append(executor.submit(task, "load", opt))
119128

120-
for future in tqdm.tqdm(as_completed(futures), desc="Loading", total=len(futures), colour="green", position=parallel + 1): # fmt: skip
129+
for future in tqdm.tqdm(
130+
as_completed(futures), desc="Loading", total=len(futures), colour="green", position=parallel + 1
131+
):
121132
future.result()
122133

123134
with ExecutorClass(max_workers=1) as executor:
@@ -133,7 +144,13 @@ def parallel_create(self, args):
133144
for n in range(total):
134145
futures.append(executor.submit(task, "load-additions", opt))
135146

136-
for future in tqdm.tqdm(as_completed(futures), desc="Computing additions", total=len(futures), colour="green", position=parallel + 1): # fmt: skip
147+
for future in tqdm.tqdm(
148+
as_completed(futures),
149+
desc="Computing additions",
150+
total=len(futures),
151+
colour="green",
152+
position=parallel + 1,
153+
):
137154
future.result()
138155

139156
with ExecutorClass(max_workers=1) as executor:

src/anemoi/datasets/commands/finalise-additions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import logging
211
import time
312

src/anemoi/datasets/commands/finalise.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import logging
211
import time
312

src/anemoi/datasets/commands/init-additions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import logging
211
import time
312

src/anemoi/datasets/commands/init.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import logging
211
import time
312

src/anemoi/datasets/commands/inspect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# (C) Copyright 2023 European Centre for Medium-Range Weather Forecasts.
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
23
# This software is licensed under the terms of the Apache Licence Version 2.0
34
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
46
# In applying this licence, ECMWF does not waive the privileges and immunities
57
# granted to it by virtue of its status as an intergovernmental organisation
68
# nor does it submit to any jurisdiction.

src/anemoi/datasets/commands/load-additions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import logging
211
import time
312

src/anemoi/datasets/commands/load.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import logging
211
import time
312

src/anemoi/datasets/commands/patch.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import logging
211
import time
312

src/anemoi/datasets/commands/publish.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import logging
211

312
from . import Command

src/anemoi/datasets/commands/scan.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# (C) Copyright 2024 Anemoi contributors.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
110
import fnmatch
211
import os
312
import sys

src/anemoi/datasets/compute/recentre.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# (C) Copyright 2024 ECMWF.
1+
# (C) Copyright 2024 Anemoi contributors.
22
#
33
# This software is licensed under the terms of the Apache Licence Version 2.0
44
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
56
# In applying this licence, ECMWF does not waive the privileges and immunities
67
# granted to it by virtue of its status as an intergovernmental organisation
78
# nor does it submit to any jurisdiction.
8-
#
9+
910

1011
import logging
1112

src/anemoi/datasets/create/__init__.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import time
1515
import uuid
1616
import warnings
17-
from copy import deepcopy
1817
from functools import cached_property
1918

2019
import numpy as np
@@ -94,10 +93,6 @@ def build_statistics_dates(dates, start, end):
9493
return (start.isoformat(), end.isoformat())
9594

9695

97-
def _ignore(*args, **kwargs):
98-
pass
99-
100-
10196
def _path_readable(path):
10297
import zarr
10398

@@ -278,6 +273,16 @@ def run(self):
278273
metadata = compute_directory_sizes(self.path)
279274
self.update_metadata(**metadata)
280275

276+
# Look for constant fields
277+
ds = open_dataset(self.path)
278+
constants = ds.computed_constant_fields()
279+
280+
variables_metadata = self.dataset.zarr_metadata.get("variables_metadata", {}).copy()
281+
for k in constants:
282+
variables_metadata[k]["constant_in_time"] = True
283+
284+
self.update_metadata(constant_fields=constants, variables_metadata=variables_metadata)
285+
281286

282287
class HasRegistryMixin:
283288
@cached_property
@@ -328,7 +333,20 @@ def build_input_(main_config, output_config):
328333

329334
class Init(Actor, HasRegistryMixin, HasStatisticTempMixin, HasElementForDataMixin):
330335
dataset_class = NewDataset
331-
def __init__(self, path, config, check_name=False, overwrite=False, use_threads=False, statistics_temp_dir=None, progress=None, test=False, cache=None, **kwargs): # fmt: skip
336+
337+
def __init__(
338+
self,
339+
path,
340+
config,
341+
check_name=False,
342+
overwrite=False,
343+
use_threads=False,
344+
statistics_temp_dir=None,
345+
progress=None,
346+
test=False,
347+
cache=None,
348+
**kwargs,
349+
):
332350
if _path_readable(path) and not overwrite:
333351
raise Exception(f"{path} already exists. Use overwrite=True to overwrite.")
334352

@@ -513,7 +531,9 @@ def _run(self):
513531

514532

515533
class Load(Actor, HasRegistryMixin, HasStatisticTempMixin, HasElementForDataMixin):
516-
def __init__(self, path, parts=None, use_threads=False, statistics_temp_dir=None, progress=None, cache=None, **kwargs): # fmt: skip
534+
def __init__(
535+
self, path, parts=None, use_threads=False, statistics_temp_dir=None, progress=None, cache=None, **kwargs
536+
):
517537
super().__init__(path, cache=cache)
518538
self.use_threads = use_threads
519539
self.statistics_temp_dir = statistics_temp_dir

src/anemoi/datasets/create/check.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# (C) Copyright 2023 ECMWF.
1+
# (C) Copyright 2024 Anemoi contributors.
22
#
33
# This software is licensed under the terms of the Apache Licence Version 2.0
44
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
56
# In applying this licence, ECMWF does not waive the privileges and immunities
67
# granted to it by virtue of its status as an intergovernmental organisation
78
# nor does it submit to any jurisdiction.
8-
#
9+
910

1011
import logging
1112
import re

src/anemoi/datasets/create/chunks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# (C) Copyright 2024 ECMWF.
1+
# (C) Copyright 2024 Anemoi contributors.
22
#
33
# This software is licensed under the terms of the Apache Licence Version 2.0
44
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
#
56
# In applying this licence, ECMWF does not waive the privileges and immunities
67
# granted to it by virtue of its status as an intergovernmental organisation
78
# nor does it submit to any jurisdiction.
8-
#
9+
910
import logging
1011
import warnings
1112

0 commit comments

Comments
 (0)