anemoi-utils 0.4.19__py3-none-any.whl → 0.4.20__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of anemoi-utils might be problematic. Click here for more details.
- anemoi/utils/_version.py +2 -2
- anemoi/utils/grids.py +19 -3
- anemoi/utils/testing.py +5 -2
- {anemoi_utils-0.4.19.dist-info → anemoi_utils-0.4.20.dist-info}/METADATA +1 -1
- {anemoi_utils-0.4.19.dist-info → anemoi_utils-0.4.20.dist-info}/RECORD +9 -9
- {anemoi_utils-0.4.19.dist-info → anemoi_utils-0.4.20.dist-info}/WHEEL +0 -0
- {anemoi_utils-0.4.19.dist-info → anemoi_utils-0.4.20.dist-info}/entry_points.txt +0 -0
- {anemoi_utils-0.4.19.dist-info → anemoi_utils-0.4.20.dist-info}/licenses/LICENSE +0 -0
- {anemoi_utils-0.4.19.dist-info → anemoi_utils-0.4.20.dist-info}/top_level.txt +0 -0
anemoi/utils/_version.py
CHANGED
anemoi/utils/grids.py
CHANGED
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
import logging
|
|
14
14
|
import os
|
|
15
15
|
from io import BytesIO
|
|
16
|
+
from typing import List
|
|
17
|
+
from typing import Tuple
|
|
18
|
+
from typing import Union
|
|
16
19
|
|
|
17
20
|
import numpy as np
|
|
18
21
|
import requests
|
|
@@ -121,7 +124,7 @@ def nearest_grid_points(
|
|
|
121
124
|
|
|
122
125
|
|
|
123
126
|
@cached(collection="grids", encoding="npz")
|
|
124
|
-
def _grids(name: str) -> bytes:
|
|
127
|
+
def _grids(name: Union[str, List[float], Tuple[float, ...]]) -> bytes:
|
|
125
128
|
"""Get grid data by name.
|
|
126
129
|
|
|
127
130
|
Parameters
|
|
@@ -136,6 +139,15 @@ def _grids(name: str) -> bytes:
|
|
|
136
139
|
"""
|
|
137
140
|
from anemoi.utils.config import load_config
|
|
138
141
|
|
|
142
|
+
if isinstance(name, (tuple, list)):
|
|
143
|
+
assert len(name) == 2, "Grid name must be a list or a tuple of length 2"
|
|
144
|
+
assert all(isinstance(i, (int, float)) for i in name), "Grid name must be a list or a tuple of numbers"
|
|
145
|
+
if name[0] == name[1]:
|
|
146
|
+
name = str(float(name[0]))
|
|
147
|
+
else:
|
|
148
|
+
name = str(float(name[0])) + "x" + str(float(name[1]))
|
|
149
|
+
name = name.replace(".", "p")
|
|
150
|
+
|
|
139
151
|
user_path = load_config().get("utils", {}).get("grids_path")
|
|
140
152
|
if user_path:
|
|
141
153
|
path = os.path.expanduser(os.path.join(user_path, f"grid-{name}.npz"))
|
|
@@ -146,6 +158,10 @@ def _grids(name: str) -> bytes:
|
|
|
146
158
|
else:
|
|
147
159
|
LOG.warning("Custom user path %s does not exist", path)
|
|
148
160
|
|
|
161
|
+
# To add a grid
|
|
162
|
+
# anemoi-transform get-grid --source mars grid=o400,levtype=sfc,param=2t grid-o400.npz
|
|
163
|
+
# nexus-cli -u xxxx -p yyyy -s GET_INSTANCE --repository anemoi upload --remote-path grids --local-path grid-o400.npz
|
|
164
|
+
|
|
149
165
|
url = GRIDS_URL_PATTERN.format(name=name.lower())
|
|
150
166
|
LOG.warning("Downloading grids from %s", url)
|
|
151
167
|
response = requests.get(url)
|
|
@@ -153,7 +169,7 @@ def _grids(name: str) -> bytes:
|
|
|
153
169
|
return response.content
|
|
154
170
|
|
|
155
171
|
|
|
156
|
-
def grids(name: str) -> dict:
|
|
172
|
+
def grids(name: Union[str, List[float], Tuple[float, ...]]) -> dict:
|
|
157
173
|
"""Load grid data by name.
|
|
158
174
|
|
|
159
175
|
Parameters
|
|
@@ -166,7 +182,7 @@ def grids(name: str) -> dict:
|
|
|
166
182
|
dict
|
|
167
183
|
The grid data
|
|
168
184
|
"""
|
|
169
|
-
if name.endswith(".npz"):
|
|
185
|
+
if isinstance(name, str) and name.endswith(".npz"):
|
|
170
186
|
return dict(np.load(name))
|
|
171
187
|
|
|
172
188
|
data = _grids(name)
|
anemoi/utils/testing.py
CHANGED
|
@@ -19,6 +19,8 @@ from functools import lru_cache
|
|
|
19
19
|
import pytest
|
|
20
20
|
from multiurl import download
|
|
21
21
|
|
|
22
|
+
from anemoi.utils.humanize import list_to_human
|
|
23
|
+
|
|
22
24
|
LOG = logging.getLogger(__name__)
|
|
23
25
|
|
|
24
26
|
TEST_DATA_URL = "https://object-store.os-api.cci1.ecmwf.int/ml-tests/test-data/samples/"
|
|
@@ -253,11 +255,12 @@ skip_slow_tests = pytest.mark.skipif(not _run_slow_tests(), reason="Skipping slo
|
|
|
253
255
|
|
|
254
256
|
|
|
255
257
|
def skip_missing_packages(*names):
|
|
256
|
-
missing = _missing_packages(*names)
|
|
258
|
+
missing = [f"'{p}'" for p in _missing_packages(*names)]
|
|
259
|
+
|
|
257
260
|
if len(missing) == 0:
|
|
258
261
|
return lambda f: f
|
|
259
262
|
|
|
260
263
|
if len(missing) == 1:
|
|
261
264
|
return pytest.mark.skipif(True, reason=f"Package {missing[0]} is not installed")
|
|
262
265
|
|
|
263
|
-
return pytest.mark.skipif(True, reason=f"Packages {
|
|
266
|
+
return pytest.mark.skipif(True, reason=f"Packages {list_to_human(missing)} are not installed")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: anemoi-utils
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.20
|
|
4
4
|
Summary: A package to hold various functions to support training of ML models on ECMWF data.
|
|
5
5
|
Author-email: "European Centre for Medium-Range Weather Forecasts (ECMWF)" <software.support@ecmwf.int>
|
|
6
6
|
License: Apache License
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
anemoi/utils/__init__.py,sha256=uVhpF-VjIl_4mMywOVtgTutgsdIsqz-xdkwxeMhzuag,730
|
|
2
2
|
anemoi/utils/__main__.py,sha256=6LlE4MYrPvqqrykxXh7XMi50UZteUY59NeM8P9Zs2dU,910
|
|
3
|
-
anemoi/utils/_version.py,sha256=
|
|
3
|
+
anemoi/utils/_version.py,sha256=a0Lwyg5BR-wqrpFfOdiqEhJkQTdIGbZv9WA1aUNeyF0,513
|
|
4
4
|
anemoi/utils/caching.py,sha256=rXbeAmpBcMbbfN4EVblaHWKicsrtx1otER84FEBtz98,6183
|
|
5
5
|
anemoi/utils/checkpoints.py,sha256=N4WpAZXa4etrpSEKhHqUUtG2-x9w3FJMHcLO-dDAXPY,9600
|
|
6
6
|
anemoi/utils/cli.py,sha256=IyZfnSw0u0yYnrjOrzvm2RuuKvDk4cVb8pf8BkaChgA,6209
|
|
@@ -9,7 +9,7 @@ anemoi/utils/config.py,sha256=UtxlkSMhqZR0LAKi19aG6jaaNiSmsXCzE6v2AWHhx5E,16861
|
|
|
9
9
|
anemoi/utils/dates.py,sha256=CnY6JOdpk0T-waPEowMRTkcMzxcN0GcjPVtLkwH_byw,17196
|
|
10
10
|
anemoi/utils/devtools.py,sha256=W3OBu96MkXRIl7Qh1SE5Zd6aB1R0QlnmlrlpBYM0fVY,3527
|
|
11
11
|
anemoi/utils/grib.py,sha256=201WcxjjAl92Y2HX2kZ2S8Qr5dN-oG7nV-vQLaybzP4,3610
|
|
12
|
-
anemoi/utils/grids.py,sha256=
|
|
12
|
+
anemoi/utils/grids.py,sha256=uYgkU_KIg8FTUiuKV0Pho2swMMeXcSQ9CQe0MFlRr_I,5262
|
|
13
13
|
anemoi/utils/hindcasts.py,sha256=iYVIxSNFL2HJcc_k1abCFLkpJFGHT8WKRIR4wcAwA3s,2144
|
|
14
14
|
anemoi/utils/humanize.py,sha256=pjnFJAKHbEAOfcvn8c48kt-8eFy6FGW_U2ruJvfamrA,25189
|
|
15
15
|
anemoi/utils/logs.py,sha256=naTgrmPwWHD4eekFttXftS4gtcAGYHpCqG4iwYprNDA,1804
|
|
@@ -19,7 +19,7 @@ anemoi/utils/rules.py,sha256=xYCiUV_HXTGFe93diqMLQsMJCWGi5umd_bWEeYP8XFY,6318
|
|
|
19
19
|
anemoi/utils/s3.py,sha256=xMT48kbcelcjjqsaU567WI3oZ5eqo88Rlgyx5ECszAU,4074
|
|
20
20
|
anemoi/utils/sanitise.py,sha256=ZYGdSX6qihQANr3pHZjbKnoapnzP1KcrWdW1Ul1mOGk,3668
|
|
21
21
|
anemoi/utils/sanitize.py,sha256=43ZKDcfVpeXSsJ9TFEc9aZnD6oe2cUh151XnDspM98M,462
|
|
22
|
-
anemoi/utils/testing.py,sha256=
|
|
22
|
+
anemoi/utils/testing.py,sha256=7wDIpiNIhXhHv5rN-LjgTY9DqMMMVpwPbzvYpWTKfLg,6947
|
|
23
23
|
anemoi/utils/text.py,sha256=HkzIvi24obDceFLpJEwBJ9PmPrJUkQN2TrElJ-A87gU,14441
|
|
24
24
|
anemoi/utils/timer.py,sha256=_leKMYza2faM7JKlGE7LCNy13rbdPnwaCF7PSrI_NmI,3895
|
|
25
25
|
anemoi/utils/commands/__init__.py,sha256=5u_6EwdqYczIAgJfCwRSyQAYFEqh2ZuHHT57g9g7sdI,808
|
|
@@ -31,9 +31,9 @@ anemoi/utils/mars/requests.py,sha256=VFMHBVAAl0_2lOcMBa1lvaKHctN0lDJsI6_U4BucGew
|
|
|
31
31
|
anemoi/utils/remote/__init__.py,sha256=swPWHQoh-B6Xq9R489tPw0FykMue7f-bJ8enneFYSYE,20776
|
|
32
32
|
anemoi/utils/remote/s3.py,sha256=spQ8l0rwQjLZh9dZu5cOsYIvNwKihQfCJ6YsFYegeqI,17339
|
|
33
33
|
anemoi/utils/remote/ssh.py,sha256=xNtsawh8okytCKRehkRCVExbHZj-CRUQNormEHglfuw,8088
|
|
34
|
-
anemoi_utils-0.4.
|
|
35
|
-
anemoi_utils-0.4.
|
|
36
|
-
anemoi_utils-0.4.
|
|
37
|
-
anemoi_utils-0.4.
|
|
38
|
-
anemoi_utils-0.4.
|
|
39
|
-
anemoi_utils-0.4.
|
|
34
|
+
anemoi_utils-0.4.20.dist-info/licenses/LICENSE,sha256=8HznKF1Vi2IvfLsKNE5A2iVyiri3pRjRPvPC9kxs6qk,11354
|
|
35
|
+
anemoi_utils-0.4.20.dist-info/METADATA,sha256=3fUbrATAsi8f1GCjTqsfLS3ND00wSzfpfjmzOvqVljQ,15410
|
|
36
|
+
anemoi_utils-0.4.20.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
37
|
+
anemoi_utils-0.4.20.dist-info/entry_points.txt,sha256=LENOkn88xzFQo-V59AKoA_F_cfYQTJYtrNTtf37YgHY,60
|
|
38
|
+
anemoi_utils-0.4.20.dist-info/top_level.txt,sha256=DYn8VPs-fNwr7fNH9XIBqeXIwiYYd2E2k5-dUFFqUz0,7
|
|
39
|
+
anemoi_utils-0.4.20.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|