anemoi-datasets 0.5.25__py3-none-any.whl → 0.5.26__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.
- anemoi/datasets/_version.py +2 -2
- anemoi/datasets/commands/grib-index.py +1 -1
- anemoi/datasets/create/filter.py +22 -24
- anemoi/datasets/create/input/step.py +2 -16
- anemoi/datasets/create/sources/planetary_computer.py +44 -0
- anemoi/datasets/create/sources/xarray_support/__init__.py +6 -22
- anemoi/datasets/create/sources/xarray_support/coordinates.py +8 -0
- anemoi/datasets/create/sources/xarray_support/field.py +1 -4
- anemoi/datasets/create/sources/xarray_support/flavour.py +44 -6
- anemoi/datasets/create/sources/xarray_support/patch.py +44 -1
- anemoi/datasets/create/sources/xarray_support/variable.py +6 -2
- anemoi/datasets/data/complement.py +44 -10
- anemoi/datasets/data/forwards.py +8 -2
- anemoi/datasets/data/stores.py +7 -56
- anemoi/datasets/grids.py +6 -3
- {anemoi_datasets-0.5.25.dist-info → anemoi_datasets-0.5.26.dist-info}/METADATA +3 -2
- {anemoi_datasets-0.5.25.dist-info → anemoi_datasets-0.5.26.dist-info}/RECORD +21 -40
- anemoi/datasets/create/filters/__init__.py +0 -33
- anemoi/datasets/create/filters/empty.py +0 -37
- anemoi/datasets/create/filters/legacy.py +0 -93
- anemoi/datasets/create/filters/noop.py +0 -37
- anemoi/datasets/create/filters/orog_to_z.py +0 -58
- anemoi/datasets/create/filters/pressure_level_relative_humidity_to_specific_humidity.py +0 -83
- anemoi/datasets/create/filters/pressure_level_specific_humidity_to_relative_humidity.py +0 -84
- anemoi/datasets/create/filters/rename.py +0 -205
- anemoi/datasets/create/filters/rotate_winds.py +0 -105
- anemoi/datasets/create/filters/single_level_dewpoint_to_relative_humidity.py +0 -78
- anemoi/datasets/create/filters/single_level_relative_humidity_to_dewpoint.py +0 -84
- anemoi/datasets/create/filters/single_level_relative_humidity_to_specific_humidity.py +0 -163
- anemoi/datasets/create/filters/single_level_specific_humidity_to_relative_humidity.py +0 -451
- anemoi/datasets/create/filters/speeddir_to_uv.py +0 -95
- anemoi/datasets/create/filters/sum.py +0 -68
- anemoi/datasets/create/filters/transform.py +0 -51
- anemoi/datasets/create/filters/unrotate_winds.py +0 -105
- anemoi/datasets/create/filters/uv_to_speeddir.py +0 -94
- anemoi/datasets/create/filters/wz_to_w.py +0 -98
- anemoi/datasets/create/testing.py +0 -76
- {anemoi_datasets-0.5.25.dist-info → anemoi_datasets-0.5.26.dist-info}/WHEEL +0 -0
- {anemoi_datasets-0.5.25.dist-info → anemoi_datasets-0.5.26.dist-info}/entry_points.txt +0 -0
- {anemoi_datasets-0.5.25.dist-info → anemoi_datasets-0.5.26.dist-info}/licenses/LICENSE +0 -0
- {anemoi_datasets-0.5.25.dist-info → anemoi_datasets-0.5.26.dist-info}/top_level.txt +0 -0
anemoi/datasets/grids.py
CHANGED
|
@@ -605,6 +605,7 @@ def nearest_grid_points(
|
|
|
605
605
|
target_latitudes: NDArray[Any],
|
|
606
606
|
target_longitudes: NDArray[Any],
|
|
607
607
|
max_distance: float = None,
|
|
608
|
+
k: int = 1,
|
|
608
609
|
) -> NDArray[Any]:
|
|
609
610
|
"""Find the nearest grid points from source to target coordinates.
|
|
610
611
|
|
|
@@ -621,6 +622,8 @@ def nearest_grid_points(
|
|
|
621
622
|
max_distance: float, optional
|
|
622
623
|
Maximum distance between nearest point and point to interpolate. Defaults to None.
|
|
623
624
|
For example, 1e-3 is 1 km.
|
|
625
|
+
k : int, optional
|
|
626
|
+
The number of k closest neighbors to consider for interpolation
|
|
624
627
|
|
|
625
628
|
Returns
|
|
626
629
|
-------
|
|
@@ -637,10 +640,10 @@ def nearest_grid_points(
|
|
|
637
640
|
target_xyz = latlon_to_xyz(target_latitudes, target_longitudes)
|
|
638
641
|
target_points = np.array(target_xyz).transpose()
|
|
639
642
|
if max_distance is None:
|
|
640
|
-
|
|
643
|
+
distances, indices = cKDTree(source_points).query(target_points, k=k)
|
|
641
644
|
else:
|
|
642
|
-
|
|
643
|
-
return indices
|
|
645
|
+
distances, indices = cKDTree(source_points).query(target_points, k=k, distance_upper_bound=max_distance)
|
|
646
|
+
return distances, indices
|
|
644
647
|
|
|
645
648
|
|
|
646
649
|
if __name__ == "__main__":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: anemoi-datasets
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.26
|
|
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
|
|
@@ -226,7 +226,7 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
226
226
|
Requires-Python: >=3.9
|
|
227
227
|
License-File: LICENSE
|
|
228
228
|
Requires-Dist: anemoi-transform>=0.1.10
|
|
229
|
-
Requires-Dist: anemoi-utils[provenance]>=0.4.
|
|
229
|
+
Requires-Dist: anemoi-utils[provenance]>=0.4.26
|
|
230
230
|
Requires-Dist: cfunits
|
|
231
231
|
Requires-Dist: numcodecs<0.16
|
|
232
232
|
Requires-Dist: numpy
|
|
@@ -262,6 +262,7 @@ Requires-Dist: requests; extra == "remote"
|
|
|
262
262
|
Provides-Extra: tests
|
|
263
263
|
Requires-Dist: anemoi-datasets[xarray]; extra == "tests"
|
|
264
264
|
Requires-Dist: pytest; extra == "tests"
|
|
265
|
+
Requires-Dist: pytest-xdist; extra == "tests"
|
|
265
266
|
Provides-Extra: xarray
|
|
266
267
|
Requires-Dist: adlfs; extra == "xarray"
|
|
267
268
|
Requires-Dist: gcsfs; extra == "xarray"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
anemoi/datasets/__init__.py,sha256=i_wsAT3ezEYF7o5dpqGrpoG4wmLS-QIBug18uJbSYMs,1065
|
|
2
2
|
anemoi/datasets/__main__.py,sha256=ErwAqE3rBc7OaNO2JRsEOhWpB8ldjAt7BFSuRhbnlqQ,936
|
|
3
|
-
anemoi/datasets/_version.py,sha256=
|
|
3
|
+
anemoi/datasets/_version.py,sha256=Yk8LV8Lu80AtsqyYb-tECJmugSSgoanvPUOHGqIfkwA,513
|
|
4
4
|
anemoi/datasets/check.py,sha256=hbEMUurl2IjZbp56dBgOfAEsAmmgymgRM5ySaMJSTdk,2755
|
|
5
|
-
anemoi/datasets/grids.py,sha256=
|
|
5
|
+
anemoi/datasets/grids.py,sha256=_i5hgtFvT8Un7etkSTPYnrudLf2otz5iNqSRSl3_oDI,18271
|
|
6
6
|
anemoi/datasets/testing.py,sha256=fy_JzavUwLlK_2rtXAT-UGUyo5gjyQW2y826zf334Wg,2645
|
|
7
7
|
anemoi/datasets/commands/__init__.py,sha256=O5W3yHZywRoAqmRUioAr3zMCh0hGVV18wZYGvc00ioM,698
|
|
8
8
|
anemoi/datasets/commands/check.py,sha256=zEJqE5XkNLsebemg5XIvvZTv2bA6R49zVaka9HRySKU,2655
|
|
@@ -13,7 +13,7 @@ anemoi/datasets/commands/copy.py,sha256=hP7BSqkGzK8-n3BA2vlpFcbO3INHmShPZ75Aw_K_
|
|
|
13
13
|
anemoi/datasets/commands/create.py,sha256=3myohTCLsM6oUuZHIfLaTlDaq-DOcJZRM4Vks007fZg,6543
|
|
14
14
|
anemoi/datasets/commands/finalise-additions.py,sha256=GXjGAJILFORXXkE_wfgnk5w4jYug18Q2TpwVah5Ctto,1982
|
|
15
15
|
anemoi/datasets/commands/finalise.py,sha256=cZIiqpJsaN1rqBKOStOA6pJh5n1tisrMFcGGT2UGpKY,1706
|
|
16
|
-
anemoi/datasets/commands/grib-index.py,sha256=
|
|
16
|
+
anemoi/datasets/commands/grib-index.py,sha256=0_cISIRw0Iwf6NX5VasxlGbPWX1p7xDMciLglS9G1Yg,3075
|
|
17
17
|
anemoi/datasets/commands/init-additions.py,sha256=wIsintXpf3aG2VhuBJJYI8ZZGXLrum7sM05IX8ImRXk,1928
|
|
18
18
|
anemoi/datasets/commands/init.py,sha256=5IKyJ_hJA4lLIbpT88XtcGzXccHLSGwSoqVSvVJGxPg,2852
|
|
19
19
|
anemoi/datasets/commands/inspect.py,sha256=kaDHXP8Cv8PsGqEXUF5Yruf5OQHwOIkjCS0SNxMs6eg,26578
|
|
@@ -28,35 +28,15 @@ anemoi/datasets/create/__init__.py,sha256=LAa-e6TnH5eHmHEpkMk9_a24wlpTFEKWllPgSl
|
|
|
28
28
|
anemoi/datasets/create/check.py,sha256=xqobSfh3655ZoKs-CjHWBiEpIfrHU_vkqwiIsAOrqvs,10795
|
|
29
29
|
anemoi/datasets/create/chunks.py,sha256=kZV3dWoCuv3Bttc0wysJB7OPbXsD99exKyrrj4HGFwQ,4025
|
|
30
30
|
anemoi/datasets/create/config.py,sha256=xrSlaY2p5zssfLIt8A1CP9WwJReSXVWBMQM7bT1aFbU,13448
|
|
31
|
-
anemoi/datasets/create/filter.py,sha256=
|
|
31
|
+
anemoi/datasets/create/filter.py,sha256=LadfjHmDUc01eadLKAX8aeFXXZVfZ7BCHbxhRzEsYn4,1380
|
|
32
32
|
anemoi/datasets/create/patch.py,sha256=u4CeIuo3Ncrbhu9CTyaUbcmaJfBfMrrFVpgEikM9pE4,5398
|
|
33
33
|
anemoi/datasets/create/persistent.py,sha256=XkEBjymXrR-y9KPVLtz9xdd0IB14wSEhcANUhUUzGVw,7832
|
|
34
34
|
anemoi/datasets/create/size.py,sha256=nHjX1manYhQIrcQWDCgBBBiAVDbfoMAG6ybVjytSaKI,1454
|
|
35
35
|
anemoi/datasets/create/source.py,sha256=xoV8uH_y6aBSE4_PWuy5w7Q7cX-tGm8e-2xC9flSAT4,1336
|
|
36
|
-
anemoi/datasets/create/testing.py,sha256=FzTSsbv_JBGViGrD1jT6z_T2yaA0KCrbJ3SCgp-rFPQ,2406
|
|
37
36
|
anemoi/datasets/create/typing.py,sha256=Hs2uDG8ZVtQ-Q-5I9-W0Pik2p1hZH5-JPVjpJXRXP7M,484
|
|
38
37
|
anemoi/datasets/create/utils.py,sha256=94JKPYcNSurA62yFAytW5dUFVz-r-fdwiPOkmu121pM,5572
|
|
39
38
|
anemoi/datasets/create/writer.py,sha256=nZBJvYZ63g_c9FfL65bAeG10Y6bX2R7CgtZvY0kW3fI,2203
|
|
40
39
|
anemoi/datasets/create/zarr.py,sha256=N9PGGD-dYvcc97BZjLVWm5XQeYTiK9gwvhtreRiQzBI,9437
|
|
41
|
-
anemoi/datasets/create/filters/__init__.py,sha256=rhetUFPZKe-vwDIfMY33SbYrJMq909dUJRgBzuX6Q6E,901
|
|
42
|
-
anemoi/datasets/create/filters/empty.py,sha256=Dw1kUnAlFt6b5ds0kmrw9Gak09XjSqF8m1_MpHZNV9I,1013
|
|
43
|
-
anemoi/datasets/create/filters/legacy.py,sha256=6JY6uX7m-8NZjoZ1sqs0EAqT-uorvnZ-eFOwMU3LmRU,2536
|
|
44
|
-
anemoi/datasets/create/filters/noop.py,sha256=WHl-k3NojGJMX4iNYxQ6Ln21pM8ERP4z8pQ5zLRDvXs,1019
|
|
45
|
-
anemoi/datasets/create/filters/orog_to_z.py,sha256=vnZ1hD9LXoOfHCIbzkurMuBl_NSfXSiiHS2yZt8ndeQ,1784
|
|
46
|
-
anemoi/datasets/create/filters/pressure_level_relative_humidity_to_specific_humidity.py,sha256=dBAQFNAc3GEZ_HwyDrcctFaKZQYddh2ldnDA2XSfSRg,2646
|
|
47
|
-
anemoi/datasets/create/filters/pressure_level_specific_humidity_to_relative_humidity.py,sha256=51t6kbNZsXK87H0HVR9j0a54siokID47ve9r1a8rOLE,2663
|
|
48
|
-
anemoi/datasets/create/filters/rename.py,sha256=pKi3CU6fvox2sPH7szXdA79NjdIcSz59IB7HsiS_9Co,5779
|
|
49
|
-
anemoi/datasets/create/filters/rotate_winds.py,sha256=fVyAbypO_EsENHjQCujbEXp2gUEb97sMoG0s4YiPXfc,3102
|
|
50
|
-
anemoi/datasets/create/filters/single_level_dewpoint_to_relative_humidity.py,sha256=hCS3yiN9nZf-P6shQmBm5Or9rMOwU1fTwHw_qFIjT9s,2378
|
|
51
|
-
anemoi/datasets/create/filters/single_level_relative_humidity_to_dewpoint.py,sha256=pGwu6YprJ6PwJ8ZRD5k4Mz_wqSXz52jvXP13WDIGOTw,2642
|
|
52
|
-
anemoi/datasets/create/filters/single_level_relative_humidity_to_specific_humidity.py,sha256=a9QVOG8hTVqkDtX4MJ5NB0y-huOKsOm_K4ujakQ36fg,5160
|
|
53
|
-
anemoi/datasets/create/filters/single_level_specific_humidity_to_relative_humidity.py,sha256=bXgm5nKgBZaP1E4tcjSLqJsEl6BlJaNLr3MsR8V9sJ4,14682
|
|
54
|
-
anemoi/datasets/create/filters/speeddir_to_uv.py,sha256=8NXsus1LaYOzAAr7XCHKCh8HAz8BI0A1ZZz_RNDB0-w,2762
|
|
55
|
-
anemoi/datasets/create/filters/sum.py,sha256=aGT6JkdHJ3i2SKzklqiyJ4ZFV3bVMYhHOSoxkdYuzp8,2151
|
|
56
|
-
anemoi/datasets/create/filters/transform.py,sha256=gIDLvaJlnn3Nc6P29aPOvNYM6yBWcIGrR2e_1bM6_Nw,1418
|
|
57
|
-
anemoi/datasets/create/filters/unrotate_winds.py,sha256=3AJf0crnVVySLlXLIdfEUxRRlQeKgheUuD-UCrSrgo8,2798
|
|
58
|
-
anemoi/datasets/create/filters/uv_to_speeddir.py,sha256=Zdc34AG5Bsz-Z7JGuznyRJr6F-BnWKXPiI3mjmOpbek,2883
|
|
59
|
-
anemoi/datasets/create/filters/wz_to_w.py,sha256=slOiX5RibG48Zrkss8Qjpb-8ZTnvSvmKlk1Hy45_wzU,2812
|
|
60
40
|
anemoi/datasets/create/input/__init__.py,sha256=vsB_whJG87IWnjaGgIMCCg8v9pfuC_vQk8BB3u5j33o,2886
|
|
61
41
|
anemoi/datasets/create/input/action.py,sha256=pc_2RPbs3laF8vBhNkbFdib40kTcF5QW6QL0p8VLNzA,7778
|
|
62
42
|
anemoi/datasets/create/input/concat.py,sha256=bU8SWfBVfK8bRAmmN4UO9zpIGxwQvRUk9_vwrKPOTE4,5355
|
|
@@ -70,7 +50,7 @@ anemoi/datasets/create/input/misc.py,sha256=FVaH_ym52RZI_fnLSMM_dKTQmWTrInucP780
|
|
|
70
50
|
anemoi/datasets/create/input/pipe.py,sha256=-tCz161IwXoI8pl1hilA9T_j5eHSr-sgbijFLp9HHNc,2083
|
|
71
51
|
anemoi/datasets/create/input/repeated_dates.py,sha256=HaPzDCNHQBY1VVp6gvd3drwjWjYpSBh-GLgHqBRJTz0,12012
|
|
72
52
|
anemoi/datasets/create/input/result.py,sha256=BmeZVN63ZnUkiOwT0mkE4DdB06OmVwdRZkiV4ACPNrI,24309
|
|
73
|
-
anemoi/datasets/create/input/step.py,sha256=
|
|
53
|
+
anemoi/datasets/create/input/step.py,sha256=NkmJ4cD9sURy_hwaeQN8kkdOfVtIW6xcxIClEWWdSvY,5376
|
|
74
54
|
anemoi/datasets/create/input/template.py,sha256=Iycw9VmfA0WEIDP_Of8bp-8HsV0EUfwbnm0WjxiO4GA,4092
|
|
75
55
|
anemoi/datasets/create/input/trace.py,sha256=dakPYMmwKq6s17Scww1CN-xYBD3btJTGeDknOhAcnEM,3320
|
|
76
56
|
anemoi/datasets/create/sources/__init__.py,sha256=XNiiGaC6NbxnGfl6glPw-gTJASi3vsGKwVlfkMqYGk4,950
|
|
@@ -89,6 +69,7 @@ anemoi/datasets/create/sources/mars.py,sha256=tesQz7Ne6SLBChE_cNJU6Sxr6e0LXFlUKQ
|
|
|
89
69
|
anemoi/datasets/create/sources/netcdf.py,sha256=UnehMwEMJquqaOeU33zNyFUYfzqQx4Rg-GRmUcgMcbE,1222
|
|
90
70
|
anemoi/datasets/create/sources/opendap.py,sha256=sTm0wXE_BHk9q8vaNNE_Y6BhTOmhxPweS8RTjP4HYjU,1254
|
|
91
71
|
anemoi/datasets/create/sources/patterns.py,sha256=siTExxLY5HWdIgOsufyQuG7Qvkt38oElZOFwz9h0JFg,2283
|
|
72
|
+
anemoi/datasets/create/sources/planetary_computer.py,sha256=Erk6fKJt63gj_pgbklBWhAKjzjtAfq_DRizMfWdqPPU,1578
|
|
92
73
|
anemoi/datasets/create/sources/recentre.py,sha256=OtobkmaWzGD3UacjXfK_Oerjf7EnQi85LIs9xBYJK7A,4044
|
|
93
74
|
anemoi/datasets/create/sources/source.py,sha256=x8k---A2_3AglYqNsXLlv1ti4f9n_gVKmmqtyQGLPTs,2117
|
|
94
75
|
anemoi/datasets/create/sources/tendencies.py,sha256=saHGYl-MnvBEeZX-n1zgT8lehA7LC2G5dMNnxklI9-U,5590
|
|
@@ -97,27 +78,27 @@ anemoi/datasets/create/sources/xarray_kerchunk.py,sha256=vdFaFzze8VLjYUgIX8Lc39E
|
|
|
97
78
|
anemoi/datasets/create/sources/xarray_zarr.py,sha256=5eQOpB3sBD49RarTME81s0ynIVkha2pP0ymA4TNnLYY,1201
|
|
98
79
|
anemoi/datasets/create/sources/zenodo.py,sha256=KEetFEk5GzGFpoos8rbBQBTa2XElWG7oTYjfZXgbu0Q,2065
|
|
99
80
|
anemoi/datasets/create/sources/xarray_support/README.md,sha256=56olM9Jh0vI0_bU9GI-IqbBcz4DZXWONqvdzN_VeAFE,78
|
|
100
|
-
anemoi/datasets/create/sources/xarray_support/__init__.py,sha256=
|
|
101
|
-
anemoi/datasets/create/sources/xarray_support/coordinates.py,sha256=
|
|
102
|
-
anemoi/datasets/create/sources/xarray_support/field.py,sha256=
|
|
81
|
+
anemoi/datasets/create/sources/xarray_support/__init__.py,sha256=X-Th4__2fVciyLqCUQU2mwYt4dph3l1_VH837iDeuqI,4714
|
|
82
|
+
anemoi/datasets/create/sources/xarray_support/coordinates.py,sha256=dAwkIChEwhy7XY64BsXeRQOpcShQRufhsJROoUk68gY,11179
|
|
83
|
+
anemoi/datasets/create/sources/xarray_support/field.py,sha256=1iLAMPpsYxzGuB4pqXA0TwEJQCCZDPFiiojfzFjnkzU,6280
|
|
103
84
|
anemoi/datasets/create/sources/xarray_support/fieldlist.py,sha256=UyUljq2Ax-PpQ-bvG4Dsi_lkZucuPgCy120EadDeUMU,8271
|
|
104
|
-
anemoi/datasets/create/sources/xarray_support/flavour.py,sha256=
|
|
85
|
+
anemoi/datasets/create/sources/xarray_support/flavour.py,sha256=oA5pYwe9HUHwgH09PgTYhJFSMmsOfRVsIEQvlVfCfM4,33366
|
|
105
86
|
anemoi/datasets/create/sources/xarray_support/grid.py,sha256=lsE8bQwBH9pflzvsJ89Z6ExYPdHJd54xorMNzL2gTd0,6181
|
|
106
87
|
anemoi/datasets/create/sources/xarray_support/metadata.py,sha256=OJ35Y4m9BpPmnrabD9qiuHUEfejc6YfTIWPm8prHokk,10876
|
|
107
|
-
anemoi/datasets/create/sources/xarray_support/patch.py,sha256=
|
|
88
|
+
anemoi/datasets/create/sources/xarray_support/patch.py,sha256=8NHSDO2lLcRPBvmuPyQ5foAkYHFVFNWJhMVeXNs6x7o,3027
|
|
108
89
|
anemoi/datasets/create/sources/xarray_support/time.py,sha256=Y_lZTUOXWJH4jcSgyL4WTDwrtPXi7MUiumaXfRoqqAY,12486
|
|
109
|
-
anemoi/datasets/create/sources/xarray_support/variable.py,sha256=
|
|
90
|
+
anemoi/datasets/create/sources/xarray_support/variable.py,sha256=zNXTNh58BLg9atnZJauto9z0e_gNRjreo4eUntqlJP8,9245
|
|
110
91
|
anemoi/datasets/create/statistics/__init__.py,sha256=_BuPcuUrwQAEcMQVds93EV9M5ys2ao8jCWKV4OVoSSA,18291
|
|
111
92
|
anemoi/datasets/create/statistics/summary.py,sha256=JdtChTmsr1Y958_nka36HltTbeZkawuGbprbfZD7Ux8,4790
|
|
112
93
|
anemoi/datasets/data/__init__.py,sha256=wzhk_7VQImge12Xkg99xuiFOC7DAjBW1mu446y0Iq60,3057
|
|
113
|
-
anemoi/datasets/data/complement.py,sha256=
|
|
94
|
+
anemoi/datasets/data/complement.py,sha256=Sbn6ajVLcLOW_1xqPNCCteV7Et_1p2CLSZkQFT_oyYI,11991
|
|
114
95
|
anemoi/datasets/data/concat.py,sha256=eY5rujcdal00BJCv00mKSlxp0FKVvPQd7uqrBnL9fj4,8996
|
|
115
96
|
anemoi/datasets/data/dataset.py,sha256=it02CVYdzU9QXSkU9jVR9BTWv-JDMlnH0ujyIgf40pM,32326
|
|
116
97
|
anemoi/datasets/data/debug.css,sha256=z2X_ZDSnZ9C3pyZPWnQiEyAxuMxUaxJxET4oaCImTAQ,211
|
|
117
98
|
anemoi/datasets/data/debug.py,sha256=hVa1jAQ-TK7CoKJNyyUC0eZPobFG-FpkVXEaO_3B-MA,10796
|
|
118
99
|
anemoi/datasets/data/ensemble.py,sha256=-36kMjuT2y5jUeSnjCRTCyE4um6DLAADBVSKSTkHZZg,5352
|
|
119
100
|
anemoi/datasets/data/fill_missing.py,sha256=ceONpzD-PWLMTtG4WOw6USw-Cd1O55VYzfpAiEsROK8,8797
|
|
120
|
-
anemoi/datasets/data/forwards.py,sha256=
|
|
101
|
+
anemoi/datasets/data/forwards.py,sha256=pFGTBgUfaUvOtcBQVweDVNpmONYc-apk-Rq9U2lpVvc,20117
|
|
121
102
|
anemoi/datasets/data/grids.py,sha256=8fZSitKTStBT-fsQWwTXiTgyrmYjh_jQ5dJi1U3lRz0,22056
|
|
122
103
|
anemoi/datasets/data/indexing.py,sha256=DasVd1j0FB0iTw6eqvhiLka4ztf2zJcI5NgWxmtxzCw,7526
|
|
123
104
|
anemoi/datasets/data/interpolate.py,sha256=-kSYwdjKH7zJtfITdbqdH6KyOFGVZDyHg4TaFk9shEI,9279
|
|
@@ -130,7 +111,7 @@ anemoi/datasets/data/padded.py,sha256=BYTLDNRatjEB2lri9IlLcMsFgxnQT2F5rZ0XxExjE7
|
|
|
130
111
|
anemoi/datasets/data/rescale.py,sha256=nGfJ5tWCncMJ7NMXkLbmt6z0ELrD6FxpbjJreQ3W91g,7004
|
|
131
112
|
anemoi/datasets/data/select.py,sha256=Xs6uOzJL0CoOGeWA_E5_ukr8Jav2kXbZ41vhk7Vr8PE,8277
|
|
132
113
|
anemoi/datasets/data/statistics.py,sha256=Hi9tPtNPBFaD0jcBa5vxoZp1radEMS-1RXwA3RbWrK8,3173
|
|
133
|
-
anemoi/datasets/data/stores.py,sha256=
|
|
114
|
+
anemoi/datasets/data/stores.py,sha256=gQicl-VcvmxgWf8qtSpnCSwvatF8xv1lV_WFQRMpPWc,18282
|
|
134
115
|
anemoi/datasets/data/subset.py,sha256=hEYRSc1QOdtJJpIWy85ZuZ9a6UNk-Eo9vAYsgRg2UPs,8950
|
|
135
116
|
anemoi/datasets/data/unchecked.py,sha256=c7YIa9gFxOOjqyyOqrhGaFWQ1pN7_0W1Q8ABUTkI8e8,7311
|
|
136
117
|
anemoi/datasets/data/xy.py,sha256=-jWzYismrK3eI3YCKIBpU1BCmraRncmVn0_2IUY--lk,7579
|
|
@@ -142,9 +123,9 @@ anemoi/datasets/data/records/backends/__init__.py,sha256=KAbzMflpo9ZFAComabAdYTN
|
|
|
142
123
|
anemoi/datasets/dates/__init__.py,sha256=pEArHDQ7w5E0WC8Vvf9ypyKSdm6gnhoN9TmooITB7C4,13617
|
|
143
124
|
anemoi/datasets/dates/groups.py,sha256=IOveL6IyTXZwEdXZEnRAnpu9pINY95VN7LzcpLfJ09E,10105
|
|
144
125
|
anemoi/datasets/utils/__init__.py,sha256=hCW0QcLHJmE-C1r38P27_ZOvCLNewex5iQEtZqx2ckI,393
|
|
145
|
-
anemoi_datasets-0.5.
|
|
146
|
-
anemoi_datasets-0.5.
|
|
147
|
-
anemoi_datasets-0.5.
|
|
148
|
-
anemoi_datasets-0.5.
|
|
149
|
-
anemoi_datasets-0.5.
|
|
150
|
-
anemoi_datasets-0.5.
|
|
126
|
+
anemoi_datasets-0.5.26.dist-info/licenses/LICENSE,sha256=8HznKF1Vi2IvfLsKNE5A2iVyiri3pRjRPvPC9kxs6qk,11354
|
|
127
|
+
anemoi_datasets-0.5.26.dist-info/METADATA,sha256=o_5TIgYbXJxVZraRVkbPKqF6hRsI2Kkgmb4yL8I9lsk,16153
|
|
128
|
+
anemoi_datasets-0.5.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
129
|
+
anemoi_datasets-0.5.26.dist-info/entry_points.txt,sha256=yR-o-4uiPEA_GLBL81SkMYnUoxq3CAV3hHulQiRtGG0,66
|
|
130
|
+
anemoi_datasets-0.5.26.dist-info/top_level.txt,sha256=DYn8VPs-fNwr7fNH9XIBqeXIwiYYd2E2k5-dUFFqUz0,7
|
|
131
|
+
anemoi_datasets-0.5.26.dist-info/RECORD,,
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
#
|
|
10
|
-
|
|
11
|
-
from typing import Any
|
|
12
|
-
|
|
13
|
-
from anemoi.utils.registry import Registry
|
|
14
|
-
|
|
15
|
-
filter_registry = Registry(__name__)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def create_filter(context: Any, config: Any) -> Any:
|
|
19
|
-
"""Create a filter based on the provided configuration.
|
|
20
|
-
|
|
21
|
-
Parameters
|
|
22
|
-
----------
|
|
23
|
-
context : Any
|
|
24
|
-
The context in which the filter is created.
|
|
25
|
-
config : Any
|
|
26
|
-
The configuration for the filter.
|
|
27
|
-
|
|
28
|
-
Returns
|
|
29
|
-
-------
|
|
30
|
-
Any
|
|
31
|
-
The created filter.
|
|
32
|
-
"""
|
|
33
|
-
return filter_registry.from_config(config, context)
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
from typing import Any
|
|
12
|
-
|
|
13
|
-
import earthkit.data as ekd
|
|
14
|
-
from anemoi.transform.fields import new_empty_fieldlist
|
|
15
|
-
|
|
16
|
-
from .legacy import legacy_filter
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@legacy_filter(__file__)
|
|
20
|
-
def execute(context: Any, input: ekd.FieldList, **kwargs: Any) -> ekd.FieldList:
|
|
21
|
-
"""Create a pipeline that returns an empty result.
|
|
22
|
-
|
|
23
|
-
Parameters
|
|
24
|
-
----------
|
|
25
|
-
context : Any
|
|
26
|
-
The context in which the function is executed.
|
|
27
|
-
input : List[Any]
|
|
28
|
-
List of input fields.
|
|
29
|
-
**kwargs : Any
|
|
30
|
-
Additional keyword arguments.
|
|
31
|
-
|
|
32
|
-
Returns
|
|
33
|
-
-------
|
|
34
|
-
Any
|
|
35
|
-
An empty result.
|
|
36
|
-
"""
|
|
37
|
-
return new_empty_fieldlist()
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# (C) Copyright 2025- 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
|
-
|
|
10
|
-
|
|
11
|
-
import inspect
|
|
12
|
-
import logging
|
|
13
|
-
import os
|
|
14
|
-
from typing import Any
|
|
15
|
-
from typing import Callable
|
|
16
|
-
|
|
17
|
-
from ..filter import Filter
|
|
18
|
-
from . import filter_registry
|
|
19
|
-
|
|
20
|
-
LOG = logging.getLogger(__name__)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class LegacyFilter(Filter):
|
|
24
|
-
"""A legacy filter class.
|
|
25
|
-
|
|
26
|
-
Parameters
|
|
27
|
-
----------
|
|
28
|
-
context : Any
|
|
29
|
-
The context in which the filter is created.
|
|
30
|
-
*args : tuple
|
|
31
|
-
Positional arguments.
|
|
32
|
-
**kwargs : dict
|
|
33
|
-
Keyword arguments.
|
|
34
|
-
"""
|
|
35
|
-
|
|
36
|
-
def __init__(self, context: Any, *args: Any, **kwargs: Any) -> None:
|
|
37
|
-
super().__init__(context, *args, **kwargs)
|
|
38
|
-
self.args = args
|
|
39
|
-
self.kwargs = kwargs
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class legacy_filter:
|
|
43
|
-
"""A decorator class for legacy filters.
|
|
44
|
-
|
|
45
|
-
Parameters
|
|
46
|
-
----------
|
|
47
|
-
name : str
|
|
48
|
-
The name of the legacy filter.
|
|
49
|
-
"""
|
|
50
|
-
|
|
51
|
-
def __init__(self, name: str) -> None:
|
|
52
|
-
name, _ = os.path.splitext(os.path.basename(name))
|
|
53
|
-
self.name = name
|
|
54
|
-
|
|
55
|
-
def __call__(self, execute: Callable) -> Callable:
|
|
56
|
-
"""Call method to wrap the execute function.
|
|
57
|
-
|
|
58
|
-
Parameters
|
|
59
|
-
----------
|
|
60
|
-
execute : Callable
|
|
61
|
-
The execute function to be wrapped.
|
|
62
|
-
|
|
63
|
-
Returns
|
|
64
|
-
-------
|
|
65
|
-
Callable
|
|
66
|
-
The wrapped execute function.
|
|
67
|
-
"""
|
|
68
|
-
this = self
|
|
69
|
-
name = f"Legacy{self.name.title()}Filter"
|
|
70
|
-
source = ".".join([execute.__module__, execute.__name__])
|
|
71
|
-
|
|
72
|
-
def execute_wrapper(self, input) -> Any:
|
|
73
|
-
"""Wrapper method to call the execute function."""
|
|
74
|
-
try:
|
|
75
|
-
return execute(self.context, input, *self.args, **self.kwargs)
|
|
76
|
-
except TypeError:
|
|
77
|
-
LOG.error(f"Error executing filter {this.name} from {source}")
|
|
78
|
-
LOG.error(f"Function signature is: {inspect.signature(execute)}")
|
|
79
|
-
LOG.error(f"Arguments are: {self.args=}, {self.kwargs=}")
|
|
80
|
-
raise
|
|
81
|
-
|
|
82
|
-
klass = type(
|
|
83
|
-
name,
|
|
84
|
-
(LegacyFilter,),
|
|
85
|
-
{
|
|
86
|
-
"execute": execute_wrapper,
|
|
87
|
-
"_source": source,
|
|
88
|
-
},
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
filter_registry.register(self.name)(klass)
|
|
92
|
-
|
|
93
|
-
return execute
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
from typing import Any
|
|
11
|
-
|
|
12
|
-
import earthkit.data as ekd
|
|
13
|
-
|
|
14
|
-
from .legacy import legacy_filter
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@legacy_filter(__file__)
|
|
18
|
-
def execute(context: Any, input: ekd.FieldList, *args: Any, **kwargs: Any) -> ekd.FieldList:
|
|
19
|
-
"""No operation filter that returns the input as is.
|
|
20
|
-
|
|
21
|
-
Parameters
|
|
22
|
-
----------
|
|
23
|
-
context : Any
|
|
24
|
-
The context in which the function is executed.
|
|
25
|
-
input : ekd.FieldList
|
|
26
|
-
List of input fields.
|
|
27
|
-
*args : Any
|
|
28
|
-
Additional arguments.
|
|
29
|
-
**kwargs : Any
|
|
30
|
-
Additional keyword arguments.
|
|
31
|
-
|
|
32
|
-
Returns
|
|
33
|
-
-------
|
|
34
|
-
List[Any]
|
|
35
|
-
The input list of fields.
|
|
36
|
-
"""
|
|
37
|
-
return input
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
from collections import defaultdict
|
|
11
|
-
from typing import Any
|
|
12
|
-
from typing import Dict
|
|
13
|
-
|
|
14
|
-
import earthkit.data as ekd
|
|
15
|
-
from anemoi.transform.fields import new_field_from_numpy
|
|
16
|
-
from anemoi.transform.fields import new_fieldlist_from_list
|
|
17
|
-
|
|
18
|
-
from .legacy import legacy_filter
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@legacy_filter(__file__)
|
|
22
|
-
def execute(context: Any, input: ekd.FieldList, orog: str, z: str = "z") -> ekd.FieldList:
|
|
23
|
-
"""Convert orography [m] to z (geopotential height).
|
|
24
|
-
|
|
25
|
-
Parameters
|
|
26
|
-
----------
|
|
27
|
-
context : Any
|
|
28
|
-
The context in which the function is executed.
|
|
29
|
-
input : FieldList
|
|
30
|
-
List of input fields.
|
|
31
|
-
orog : str
|
|
32
|
-
Orography parameter.
|
|
33
|
-
z : str, optional
|
|
34
|
-
Geopotential height parameter. Defaults to "z".
|
|
35
|
-
|
|
36
|
-
Returns
|
|
37
|
-
-------
|
|
38
|
-
FieldList
|
|
39
|
-
List of fields with geopotential height.
|
|
40
|
-
"""
|
|
41
|
-
result = []
|
|
42
|
-
processed_fields: Dict[tuple, Dict[str, Any]] = defaultdict(dict)
|
|
43
|
-
|
|
44
|
-
for f in input:
|
|
45
|
-
key = f.metadata(namespace="mars")
|
|
46
|
-
param = key.pop("param")
|
|
47
|
-
if param == orog:
|
|
48
|
-
key = tuple(key.items())
|
|
49
|
-
|
|
50
|
-
if param in processed_fields[key]:
|
|
51
|
-
raise ValueError(f"Duplicate field {param} for {key}")
|
|
52
|
-
|
|
53
|
-
output = f.to_numpy(flatten=True) * 9.80665
|
|
54
|
-
result.append(new_field_from_numpy(f, output, param=z))
|
|
55
|
-
else:
|
|
56
|
-
result.append(f)
|
|
57
|
-
|
|
58
|
-
return new_fieldlist_from_list(result)
|
|
@@ -1,83 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
from collections import defaultdict
|
|
11
|
-
from typing import Any
|
|
12
|
-
from typing import Dict
|
|
13
|
-
from typing import Tuple
|
|
14
|
-
|
|
15
|
-
import earthkit.data as ekd
|
|
16
|
-
from anemoi.transform.fields import new_field_from_numpy
|
|
17
|
-
from anemoi.transform.fields import new_fieldlist_from_list
|
|
18
|
-
from earthkit.meteo import thermo
|
|
19
|
-
|
|
20
|
-
from .legacy import legacy_filter
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
@legacy_filter(__file__)
|
|
24
|
-
def execute(context: Any, input: ekd.FieldList, t: str, rh: str, q: str = "q") -> ekd.FieldList:
|
|
25
|
-
"""Convert relative humidity on pressure levels to specific humidity.
|
|
26
|
-
|
|
27
|
-
Parameters
|
|
28
|
-
----------
|
|
29
|
-
context : Any
|
|
30
|
-
The context in which the function is executed.
|
|
31
|
-
input : List[Any]
|
|
32
|
-
List of input fields.
|
|
33
|
-
t : str
|
|
34
|
-
Temperature parameter.
|
|
35
|
-
rh : str
|
|
36
|
-
Relative humidity parameter.
|
|
37
|
-
q : str, optional
|
|
38
|
-
Specific humidity parameter. Defaults to "q".
|
|
39
|
-
|
|
40
|
-
Returns
|
|
41
|
-
-------
|
|
42
|
-
ekd.FieldList
|
|
43
|
-
Array of fields with specific humidity.
|
|
44
|
-
"""
|
|
45
|
-
result = []
|
|
46
|
-
params: Tuple[str, str] = (t, rh)
|
|
47
|
-
pairs: Dict[Tuple[Any, ...], Dict[str, Any]] = defaultdict(dict)
|
|
48
|
-
|
|
49
|
-
# Gather all necessary fields
|
|
50
|
-
for f in input:
|
|
51
|
-
key = f.metadata(namespace="mars")
|
|
52
|
-
param = key.pop("param")
|
|
53
|
-
if param in params:
|
|
54
|
-
key = tuple(key.items())
|
|
55
|
-
|
|
56
|
-
if param in pairs[key]:
|
|
57
|
-
raise ValueError(f"Duplicate field {param} for {key}")
|
|
58
|
-
|
|
59
|
-
pairs[key][param] = f
|
|
60
|
-
if param == t:
|
|
61
|
-
result.append(f)
|
|
62
|
-
# all other parameters
|
|
63
|
-
else:
|
|
64
|
-
result.append(f)
|
|
65
|
-
|
|
66
|
-
for keys, values in pairs.items():
|
|
67
|
-
# some checks
|
|
68
|
-
|
|
69
|
-
if len(values) != 2:
|
|
70
|
-
raise ValueError("Missing fields")
|
|
71
|
-
|
|
72
|
-
t_pl = values[t].to_numpy(flatten=True)
|
|
73
|
-
rh_pl = values[rh].to_numpy(flatten=True)
|
|
74
|
-
pressure = next(
|
|
75
|
-
float(v) * 100 for k, v in keys if k in ["level", "levelist"]
|
|
76
|
-
) # Looks first for "level" then "levelist" value
|
|
77
|
-
# print(f"Handling fields for pressure level {pressure}...")
|
|
78
|
-
|
|
79
|
-
# actual conversion from rh --> q_v
|
|
80
|
-
q_pl = thermo.specific_humidity_from_relative_humidity(t_pl, rh_pl, pressure)
|
|
81
|
-
result.append(new_field_from_numpy(values[rh], q_pl, param=q))
|
|
82
|
-
|
|
83
|
-
return new_fieldlist_from_list(result)
|
|
@@ -1,84 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
from collections import defaultdict
|
|
12
|
-
from typing import Any
|
|
13
|
-
from typing import Dict
|
|
14
|
-
|
|
15
|
-
import earthkit.data as ekd
|
|
16
|
-
from anemoi.transform.fields import new_field_from_numpy
|
|
17
|
-
from anemoi.transform.fields import new_fieldlist_from_list
|
|
18
|
-
from earthkit.data.indexing.fieldlist import FieldArray
|
|
19
|
-
from earthkit.meteo import thermo
|
|
20
|
-
|
|
21
|
-
from .legacy import legacy_filter
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@legacy_filter(__file__)
|
|
25
|
-
def execute(context: Any, input: ekd.FieldList, t: str, q: str, rh: str = "r") -> FieldArray:
|
|
26
|
-
"""Convert specific humidity on pressure levels to relative humidity.
|
|
27
|
-
|
|
28
|
-
Parameters
|
|
29
|
-
----------
|
|
30
|
-
context : Any
|
|
31
|
-
The context in which the function is executed.
|
|
32
|
-
input : List[Any]
|
|
33
|
-
List of input fields.
|
|
34
|
-
t : str
|
|
35
|
-
Temperature parameter.
|
|
36
|
-
q : str
|
|
37
|
-
Specific humidity parameter.
|
|
38
|
-
rh : str, optional
|
|
39
|
-
Relative humidity parameter. Defaults to "r".
|
|
40
|
-
|
|
41
|
-
Returns
|
|
42
|
-
-------
|
|
43
|
-
ekd.FieldList
|
|
44
|
-
Array of fields with relative humidity.
|
|
45
|
-
"""
|
|
46
|
-
result = []
|
|
47
|
-
params: tuple[str, str] = (t, q)
|
|
48
|
-
pairs: Dict[tuple, Dict[str, Any]] = defaultdict(dict)
|
|
49
|
-
|
|
50
|
-
# Gather all necessary fields
|
|
51
|
-
for f in input:
|
|
52
|
-
key = f.metadata(namespace="mars")
|
|
53
|
-
param = key.pop("param")
|
|
54
|
-
if param in params:
|
|
55
|
-
key = tuple(key.items())
|
|
56
|
-
|
|
57
|
-
if param in pairs[key]:
|
|
58
|
-
raise ValueError(f"Duplicate field {param} for {key}")
|
|
59
|
-
|
|
60
|
-
pairs[key][param] = f
|
|
61
|
-
if param == t:
|
|
62
|
-
result.append(f)
|
|
63
|
-
# all other parameters
|
|
64
|
-
else:
|
|
65
|
-
result.append(f)
|
|
66
|
-
|
|
67
|
-
for keys, values in pairs.items():
|
|
68
|
-
# some checks
|
|
69
|
-
|
|
70
|
-
if len(values) != 2:
|
|
71
|
-
raise ValueError("Missing fields")
|
|
72
|
-
|
|
73
|
-
t_pl = values[t].to_numpy(flatten=True)
|
|
74
|
-
q_pl = values[q].to_numpy(flatten=True)
|
|
75
|
-
pressure = next(
|
|
76
|
-
float(v) * 100 for k, v in keys if k in ["level", "levelist"]
|
|
77
|
-
) # Looks first for "level" then "levelist" value
|
|
78
|
-
# print(f"Handling fields for pressure level {pressure}...")
|
|
79
|
-
|
|
80
|
-
# actual conversion from rh --> q_v
|
|
81
|
-
rh_pl = thermo.relative_humidity_from_specific_humidity(t_pl, q_pl, pressure)
|
|
82
|
-
result.append(new_field_from_numpy(values[q], rh_pl, param=rh))
|
|
83
|
-
|
|
84
|
-
return new_fieldlist_from_list(result)
|