wrfrun 0.2.0__py3-none-any.whl → 0.3.1__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.
- wrfrun/__init__.py +8 -3
- wrfrun/cli.py +69 -29
- wrfrun/core/__init__.py +27 -10
- wrfrun/core/_config.py +308 -0
- wrfrun/core/_constant.py +236 -0
- wrfrun/core/_exec_db.py +105 -0
- wrfrun/core/_namelist.py +287 -0
- wrfrun/core/_record.py +178 -0
- wrfrun/core/_resource.py +172 -0
- wrfrun/core/base.py +132 -406
- wrfrun/core/core.py +196 -0
- wrfrun/core/error.py +28 -2
- wrfrun/core/replay.py +10 -96
- wrfrun/core/server.py +52 -27
- wrfrun/core/type.py +171 -0
- wrfrun/data.py +304 -139
- wrfrun/extension/goos_sst/__init__.py +2 -2
- wrfrun/extension/goos_sst/core.py +9 -14
- wrfrun/extension/goos_sst/res/__init__.py +0 -1
- wrfrun/extension/goos_sst/utils.py +50 -44
- wrfrun/extension/littler/core.py +105 -88
- wrfrun/extension/utils.py +4 -3
- wrfrun/log.py +117 -0
- wrfrun/model/__init__.py +11 -7
- wrfrun/model/constants.py +52 -0
- wrfrun/model/palm/__init__.py +30 -0
- wrfrun/model/palm/core.py +145 -0
- wrfrun/model/palm/namelist.py +33 -0
- wrfrun/model/plot.py +99 -119
- wrfrun/model/type.py +116 -0
- wrfrun/model/utils.py +9 -20
- wrfrun/model/wrf/__init__.py +4 -9
- wrfrun/model/wrf/core.py +246 -161
- wrfrun/model/wrf/exec_wrap.py +13 -12
- wrfrun/model/wrf/geodata.py +116 -100
- wrfrun/model/wrf/log.py +103 -0
- wrfrun/model/wrf/namelist.py +90 -73
- wrfrun/model/wrf/plot.py +102 -0
- wrfrun/model/wrf/scheme.py +108 -52
- wrfrun/model/wrf/utils.py +39 -25
- wrfrun/model/wrf/vtable.py +35 -3
- wrfrun/plot/__init__.py +20 -0
- wrfrun/plot/wps.py +96 -73
- wrfrun/res/__init__.py +103 -5
- wrfrun/res/config/config.template.toml +8 -0
- wrfrun/res/config/palm.template.toml +23 -0
- wrfrun/run.py +105 -77
- wrfrun/scheduler/__init__.py +1 -0
- wrfrun/scheduler/lsf.py +3 -2
- wrfrun/scheduler/pbs.py +3 -2
- wrfrun/scheduler/script.py +17 -5
- wrfrun/scheduler/slurm.py +3 -2
- wrfrun/scheduler/utils.py +14 -2
- wrfrun/utils.py +88 -199
- wrfrun/workspace/__init__.py +8 -5
- wrfrun/workspace/core.py +20 -12
- wrfrun/workspace/palm.py +137 -0
- wrfrun/workspace/wrf.py +16 -15
- wrfrun-0.3.1.dist-info/METADATA +239 -0
- wrfrun-0.3.1.dist-info/RECORD +78 -0
- wrfrun/core/config.py +0 -923
- wrfrun/model/base.py +0 -14
- wrfrun-0.2.0.dist-info/METADATA +0 -68
- wrfrun-0.2.0.dist-info/RECORD +0 -62
- {wrfrun-0.2.0.dist-info → wrfrun-0.3.1.dist-info}/WHEEL +0 -0
- {wrfrun-0.2.0.dist-info → wrfrun-0.3.1.dist-info}/entry_points.txt +0 -0
wrfrun/model/wrf/scheme.py
CHANGED
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
wrfrun.model.wrf.scheme
|
|
3
|
+
#######################
|
|
4
|
+
|
|
5
|
+
This file contains dataclasses to determine schemes for WRF.
|
|
6
|
+
|
|
7
|
+
.. autosummary::
|
|
8
|
+
:toctree: generated/
|
|
9
|
+
|
|
10
|
+
SchemeCumulus
|
|
11
|
+
SchemeLandSurfaceModel
|
|
12
|
+
SchemeLongWave
|
|
13
|
+
SchemePBL
|
|
14
|
+
SchemeShortWave
|
|
15
|
+
SchemeSurfaceLayer
|
|
16
|
+
SchemeMicrophysics
|
|
17
|
+
|
|
18
|
+
How to use
|
|
19
|
+
**********
|
|
20
|
+
|
|
21
|
+
All dataclasses have class method ``get_scheme_id``, which accepts the name of scheme and return the corresponding index.
|
|
22
|
+
You can also use attributes of dataclasses.
|
|
23
|
+
|
|
24
|
+
**For example**
|
|
25
|
+
|
|
26
|
+
.. code-block:: python
|
|
27
|
+
:caption: main.py
|
|
28
|
+
|
|
29
|
+
from wrfrun.model.wrf import SchemeLongWave
|
|
30
|
+
|
|
31
|
+
# 1. Use function get_scheme_id.
|
|
32
|
+
scheme_id = SchemeLongWave.get_scheme_id("rrtmg")
|
|
33
|
+
# 2. Access attributes.
|
|
34
|
+
scheme_id = SchemeLongWave.RRTMG
|
|
35
|
+
|
|
3
36
|
"""
|
|
37
|
+
|
|
4
38
|
from dataclasses import dataclass
|
|
5
39
|
|
|
6
|
-
from wrfrun.
|
|
40
|
+
from wrfrun.log import logger
|
|
7
41
|
|
|
8
42
|
|
|
9
43
|
@dataclass()
|
|
@@ -11,6 +45,7 @@ class SchemeLongWave:
|
|
|
11
45
|
"""
|
|
12
46
|
Long wave physics schemes.
|
|
13
47
|
"""
|
|
48
|
+
|
|
14
49
|
OFF = 0
|
|
15
50
|
RRTM = 1
|
|
16
51
|
CAM = 3
|
|
@@ -18,16 +53,19 @@ class SchemeLongWave:
|
|
|
18
53
|
NEW_GODDARD = 5
|
|
19
54
|
FLG = 7
|
|
20
55
|
RRTMG_K = 14
|
|
21
|
-
FAST_RRTMG = 24
|
|
56
|
+
FAST_RRTMG = 24 # for GPU and MIC
|
|
22
57
|
HELD_SUAREZ = 31
|
|
23
58
|
GFDL = 99
|
|
24
59
|
|
|
25
60
|
@classmethod
|
|
26
61
|
def get_scheme_id(cls, key: str = "rrtm"):
|
|
27
|
-
"""
|
|
62
|
+
"""
|
|
63
|
+
Get the corresponding integer label for long wave radiation scheme.
|
|
64
|
+
|
|
65
|
+
Reference link: `longwave-radiation-schemes <https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/physics.html#longwave-radiation-schemes>`_.
|
|
28
66
|
|
|
29
|
-
|
|
30
|
-
|
|
67
|
+
:param key: Name of long wave radiation scheme. Defaults to "rrtm".
|
|
68
|
+
:type key: str
|
|
31
69
|
"""
|
|
32
70
|
# Here is the map of scheme name and integer label in WRF
|
|
33
71
|
# Reference link: https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/physics.html#longwave-radiation-schemes
|
|
@@ -41,14 +79,12 @@ class SchemeLongWave:
|
|
|
41
79
|
"rrtmg-k": cls.RRTMG_K,
|
|
42
80
|
"fast-rrtmg": cls.FAST_RRTMG,
|
|
43
81
|
"held-suarez": cls.HELD_SUAREZ,
|
|
44
|
-
"gfdl": cls.GFDL
|
|
82
|
+
"gfdl": cls.GFDL,
|
|
45
83
|
}
|
|
46
84
|
|
|
47
85
|
# check if key is in map
|
|
48
86
|
if key not in integer_label_map:
|
|
49
|
-
logger.error(
|
|
50
|
-
f"Key error: {key}. Valid key: {list(integer_label_map.keys())}"
|
|
51
|
-
)
|
|
87
|
+
logger.error(f"Key error: {key}. Valid key: {list(integer_label_map.keys())}")
|
|
52
88
|
raise KeyError
|
|
53
89
|
|
|
54
90
|
return integer_label_map[key]
|
|
@@ -59,6 +95,7 @@ class SchemeShortWave:
|
|
|
59
95
|
"""
|
|
60
96
|
Short wave physics schemes.
|
|
61
97
|
"""
|
|
98
|
+
|
|
62
99
|
OFF = 0
|
|
63
100
|
DUDHIA = 1
|
|
64
101
|
GODDARD = 2
|
|
@@ -73,10 +110,13 @@ class SchemeShortWave:
|
|
|
73
110
|
|
|
74
111
|
@classmethod
|
|
75
112
|
def get_scheme_id(cls, key: str = "rrtmg"):
|
|
76
|
-
"""
|
|
113
|
+
"""
|
|
114
|
+
Get corresponding integer label for short wave radiation scheme.
|
|
77
115
|
|
|
78
|
-
|
|
79
|
-
|
|
116
|
+
Reference link: `shortwave-radiation-schemes <https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/physics.html#shortwave-radiation-schemes>`_.
|
|
117
|
+
|
|
118
|
+
:param key: Name of short wave radiation scheme. Defaults to "rrtmg".
|
|
119
|
+
:type key: str
|
|
80
120
|
"""
|
|
81
121
|
# Here is the map of scheme name and integer label in WRF
|
|
82
122
|
# Reference link: https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/physics.html#shortwave-radiation-schemes
|
|
@@ -91,14 +131,12 @@ class SchemeShortWave:
|
|
|
91
131
|
"rrtmg-k": cls.RRTMG_K,
|
|
92
132
|
"fast-rrtmg": cls.FAST_RRTMG,
|
|
93
133
|
"earth-hs-force": cls.EARTH_HELD_SUAREZ_FORCING,
|
|
94
|
-
"gfdl": cls.GODDARD
|
|
134
|
+
"gfdl": cls.GODDARD,
|
|
95
135
|
}
|
|
96
136
|
|
|
97
137
|
# check if key is in map
|
|
98
138
|
if key not in integer_label_map:
|
|
99
|
-
logger.error(
|
|
100
|
-
f"Key error: {key}. Valid key: {list(integer_label_map.keys())}"
|
|
101
|
-
)
|
|
139
|
+
logger.error(f"Key error: {key}. Valid key: {list(integer_label_map.keys())}")
|
|
102
140
|
raise KeyError
|
|
103
141
|
|
|
104
142
|
return integer_label_map[key]
|
|
@@ -109,6 +147,7 @@ class SchemeCumulus:
|
|
|
109
147
|
"""
|
|
110
148
|
Cumulus parameterization schemes.
|
|
111
149
|
"""
|
|
150
|
+
|
|
112
151
|
OFF = 0
|
|
113
152
|
KAIN_FRITSCH = 1
|
|
114
153
|
BMJ = 2
|
|
@@ -127,10 +166,13 @@ class SchemeCumulus:
|
|
|
127
166
|
|
|
128
167
|
@classmethod
|
|
129
168
|
def get_scheme_id(cls, key: str = "kf"):
|
|
130
|
-
"""
|
|
169
|
+
"""
|
|
170
|
+
Get corresponding integer label for cumulus parameterization scheme.
|
|
171
|
+
|
|
172
|
+
Reference link: `cumulus-parameterization <https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/physics.html#cumulus-parameterization>`_.
|
|
131
173
|
|
|
132
|
-
|
|
133
|
-
|
|
174
|
+
:param key: Name of cumulus parameterization scheme. Defaults to "kf".
|
|
175
|
+
:type key: str
|
|
134
176
|
"""
|
|
135
177
|
# Here is the map of scheme name and integer label in WRF
|
|
136
178
|
# Reference link: https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/physics.html#cumulus-parameterization
|
|
@@ -149,14 +191,12 @@ class SchemeCumulus:
|
|
|
149
191
|
"nt": cls.NEW_TIEDTKE,
|
|
150
192
|
"gd": cls.GRELL_DEVENYI,
|
|
151
193
|
"nsas": cls.NSAS,
|
|
152
|
-
"old-kf": cls.OLD_KF
|
|
194
|
+
"old-kf": cls.OLD_KF,
|
|
153
195
|
}
|
|
154
196
|
|
|
155
197
|
# check if key is in map
|
|
156
198
|
if key not in integer_label_map:
|
|
157
|
-
logger.error(
|
|
158
|
-
f"Key error: {key}. Valid key: {list(integer_label_map.keys())}"
|
|
159
|
-
)
|
|
199
|
+
logger.error(f"Key error: {key}. Valid key: {list(integer_label_map.keys())}")
|
|
160
200
|
raise KeyError
|
|
161
201
|
|
|
162
202
|
return integer_label_map[key]
|
|
@@ -167,6 +207,7 @@ class SchemePBL:
|
|
|
167
207
|
"""
|
|
168
208
|
PBL physics schemes.
|
|
169
209
|
"""
|
|
210
|
+
|
|
170
211
|
OFF = 0
|
|
171
212
|
YSU = 1
|
|
172
213
|
MYJ = 2
|
|
@@ -185,10 +226,13 @@ class SchemePBL:
|
|
|
185
226
|
|
|
186
227
|
@classmethod
|
|
187
228
|
def get_scheme_id(cls, key: str = "ysu"):
|
|
188
|
-
"""
|
|
229
|
+
"""
|
|
230
|
+
Get corresponding integer label for PBL scheme.
|
|
189
231
|
|
|
190
|
-
|
|
191
|
-
|
|
232
|
+
Reference link: `pbl-scheme-options <https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/physics.html#pbl-scheme-options>`_.
|
|
233
|
+
|
|
234
|
+
:param key: Name of PBL scheme. Defaults to "ysu".
|
|
235
|
+
:type key: str
|
|
192
236
|
"""
|
|
193
237
|
# Here is the map of scheme name and integer label in WRF
|
|
194
238
|
# Reference link: https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/physics.html#pbl-scheme-options
|
|
@@ -207,14 +251,12 @@ class SchemePBL:
|
|
|
207
251
|
"gbm": cls.GBM,
|
|
208
252
|
"eeps": cls.EEPS,
|
|
209
253
|
"keps": cls.KEPS,
|
|
210
|
-
"mrf": cls.MRF
|
|
254
|
+
"mrf": cls.MRF,
|
|
211
255
|
}
|
|
212
256
|
|
|
213
257
|
# check if key is in map
|
|
214
258
|
if key not in integer_label_map:
|
|
215
|
-
logger.error(
|
|
216
|
-
f"Key error: {key}. Valid key: {list(integer_label_map.keys())}"
|
|
217
|
-
)
|
|
259
|
+
logger.error(f"Key error: {key}. Valid key: {list(integer_label_map.keys())}")
|
|
218
260
|
raise KeyError
|
|
219
261
|
|
|
220
262
|
return integer_label_map[key]
|
|
@@ -225,6 +267,7 @@ class SchemeLandSurfaceModel:
|
|
|
225
267
|
"""
|
|
226
268
|
Land surface model physics schemes.
|
|
227
269
|
"""
|
|
270
|
+
|
|
228
271
|
OFF = 0
|
|
229
272
|
SLAB = 1
|
|
230
273
|
NOAH = 2
|
|
@@ -236,10 +279,13 @@ class SchemeLandSurfaceModel:
|
|
|
236
279
|
|
|
237
280
|
@classmethod
|
|
238
281
|
def get_scheme_id(cls, key: str = "noah"):
|
|
239
|
-
"""
|
|
282
|
+
"""
|
|
283
|
+
Get corresponding integer label for land surface scheme.
|
|
284
|
+
|
|
285
|
+
Reference link: `lsm-scheme-details-and-references <https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/physics.html#lsm-scheme-details-and-references>`_.
|
|
240
286
|
|
|
241
|
-
|
|
242
|
-
|
|
287
|
+
:param key: Name of land surface scheme. Defaults to "noah".
|
|
288
|
+
:type key: str
|
|
243
289
|
"""
|
|
244
290
|
# Here is the map of scheme name and integer label in WRF
|
|
245
291
|
# Reference link: https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/physics.html#lsm-scheme-details-and-references
|
|
@@ -251,14 +297,12 @@ class SchemeLandSurfaceModel:
|
|
|
251
297
|
"noah-mp": cls.NOAH_MP,
|
|
252
298
|
"clm4": cls.CLM4,
|
|
253
299
|
"px": cls.PLEIM_XIU,
|
|
254
|
-
"ssib": cls.SSIB
|
|
300
|
+
"ssib": cls.SSIB,
|
|
255
301
|
}
|
|
256
302
|
|
|
257
303
|
# check if key is in map
|
|
258
304
|
if key not in integer_label_map:
|
|
259
|
-
logger.error(
|
|
260
|
-
f"Key error: {key}. Valid key: {list(integer_label_map.keys())}"
|
|
261
|
-
)
|
|
305
|
+
logger.error(f"Key error: {key}. Valid key: {list(integer_label_map.keys())}")
|
|
262
306
|
raise KeyError
|
|
263
307
|
|
|
264
308
|
return integer_label_map[key]
|
|
@@ -269,6 +313,7 @@ class SchemeSurfaceLayer:
|
|
|
269
313
|
"""
|
|
270
314
|
Surface layer physics schemes.
|
|
271
315
|
"""
|
|
316
|
+
|
|
272
317
|
OFF = 0
|
|
273
318
|
MM5 = 1
|
|
274
319
|
MONIN_OBUKHOV = 2
|
|
@@ -280,10 +325,13 @@ class SchemeSurfaceLayer:
|
|
|
280
325
|
|
|
281
326
|
@classmethod
|
|
282
327
|
def get_scheme_id(cls, key: str = "mm5"):
|
|
283
|
-
"""
|
|
328
|
+
"""
|
|
329
|
+
Get corresponding integer label for surface layer scheme.
|
|
284
330
|
|
|
285
|
-
|
|
286
|
-
|
|
331
|
+
Reference link: `sf_sfclay_physics <https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/namelist_variables.html#:~:text=this%20Users%E2%80%99%20Guide.-,sf_sfclay_physics,-surface%20layer%20physics>`_.
|
|
332
|
+
|
|
333
|
+
:param key: Name of surface layer scheme. Defaults to "mo".
|
|
334
|
+
:type key: str
|
|
287
335
|
"""
|
|
288
336
|
# Here is the map of scheme name and integer label in WRF
|
|
289
337
|
# Reference link: https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/namelist_variables.html
|
|
@@ -295,14 +343,12 @@ class SchemeSurfaceLayer:
|
|
|
295
343
|
"mynn": cls.MYNN,
|
|
296
344
|
"px": cls.PLEIM_XIU,
|
|
297
345
|
"temf": cls.TEMF,
|
|
298
|
-
"old-mm5": cls.OLD_MM5
|
|
346
|
+
"old-mm5": cls.OLD_MM5,
|
|
299
347
|
}
|
|
300
348
|
|
|
301
349
|
# check if key is in map
|
|
302
350
|
if key not in integer_label_map:
|
|
303
|
-
logger.error(
|
|
304
|
-
f"Key error: {key}. Valid key: {list(integer_label_map.keys())}"
|
|
305
|
-
)
|
|
351
|
+
logger.error(f"Key error: {key}. Valid key: {list(integer_label_map.keys())}")
|
|
306
352
|
raise KeyError
|
|
307
353
|
|
|
308
354
|
return integer_label_map[key]
|
|
@@ -313,6 +359,7 @@ class SchemeMicrophysics:
|
|
|
313
359
|
"""
|
|
314
360
|
Microphysics schemes.
|
|
315
361
|
"""
|
|
362
|
+
|
|
316
363
|
OFF = 0
|
|
317
364
|
KESSLER = 1
|
|
318
365
|
PURDUE_LIN = 2
|
|
@@ -345,10 +392,13 @@ class SchemeMicrophysics:
|
|
|
345
392
|
|
|
346
393
|
@classmethod
|
|
347
394
|
def get_scheme_id(cls, key: str = "lin"):
|
|
348
|
-
"""
|
|
395
|
+
"""
|
|
396
|
+
Get corresponding integer label for microphysics scheme.
|
|
397
|
+
|
|
398
|
+
Reference link: `physics <https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/namelist_variables.html#physics>`_.
|
|
349
399
|
|
|
350
|
-
|
|
351
|
-
|
|
400
|
+
:param key: Name of microphysics scheme. Defaults to "PURDUE_LIN".
|
|
401
|
+
:type key: str
|
|
352
402
|
"""
|
|
353
403
|
# Here is the map of scheme name and integer label in WRF
|
|
354
404
|
# Reference link: https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/namelist_variables.html
|
|
@@ -384,12 +434,18 @@ class SchemeMicrophysics:
|
|
|
384
434
|
|
|
385
435
|
# check if key is in map
|
|
386
436
|
if key not in integer_label_map:
|
|
387
|
-
logger.error(
|
|
388
|
-
f"Key error: {key}. Valid key: {list(integer_label_map.keys())}"
|
|
389
|
-
)
|
|
437
|
+
logger.error(f"Key error: {key}. Valid key: {list(integer_label_map.keys())}")
|
|
390
438
|
raise KeyError
|
|
391
439
|
|
|
392
440
|
return integer_label_map[key]
|
|
393
441
|
|
|
394
442
|
|
|
395
|
-
__all__ = [
|
|
443
|
+
__all__ = [
|
|
444
|
+
"SchemeCumulus",
|
|
445
|
+
"SchemeLandSurfaceModel",
|
|
446
|
+
"SchemeLongWave",
|
|
447
|
+
"SchemePBL",
|
|
448
|
+
"SchemeShortWave",
|
|
449
|
+
"SchemeSurfaceLayer",
|
|
450
|
+
"SchemeMicrophysics",
|
|
451
|
+
]
|
wrfrun/model/wrf/utils.py
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
|
+
"""
|
|
2
|
+
wrfrun.model.wrf.utils
|
|
3
|
+
######################
|
|
4
|
+
|
|
5
|
+
Utility functions used by wrf model part.
|
|
6
|
+
|
|
7
|
+
.. autosummary::
|
|
8
|
+
:toctree: generated/
|
|
9
|
+
|
|
10
|
+
get_metgrid_levels
|
|
11
|
+
reconcile_namelist_metgrid
|
|
12
|
+
process_after_ndown
|
|
13
|
+
"""
|
|
14
|
+
|
|
1
15
|
from os import listdir
|
|
2
16
|
from os.path import exists
|
|
3
17
|
from typing import Dict
|
|
4
18
|
|
|
5
19
|
from xarray import open_dataset
|
|
6
20
|
|
|
7
|
-
from wrfrun import
|
|
8
|
-
from wrfrun.
|
|
21
|
+
from wrfrun.core import WRFRUN
|
|
22
|
+
from wrfrun.log import logger
|
|
9
23
|
|
|
10
24
|
|
|
11
25
|
def get_metgrid_levels(nc_file: str) -> Dict[str, int]:
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
Args:
|
|
15
|
-
nc_file (str): Output nc file path
|
|
26
|
+
"""
|
|
27
|
+
Read metgrid output file and get metgrid levels, land cat and metgrid soil levels.
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
|
|
29
|
+
:param nc_file: Output nc file path.
|
|
30
|
+
:type nc_file: str
|
|
31
|
+
:return: {num_metgrid_levels: number, num_land_cat: number, num_metgrid_soil_level: number}
|
|
32
|
+
:rtype: Dict[str, int]
|
|
19
33
|
"""
|
|
20
34
|
# check file
|
|
21
35
|
if not exists(nc_file):
|
|
@@ -30,11 +44,7 @@ def get_metgrid_levels(nc_file: str) -> Dict[str, int]:
|
|
|
30
44
|
num_land_cat = dataset.attrs["NUM_LAND_CAT"]
|
|
31
45
|
num_metgrid_soil_levels = dataset.attrs["NUM_METGRID_SOIL_LEVELS"]
|
|
32
46
|
|
|
33
|
-
return dict(
|
|
34
|
-
num_metgrid_levels=num_metgrid_levels,
|
|
35
|
-
num_land_cat=num_land_cat,
|
|
36
|
-
num_metgrid_soil_levels=num_metgrid_soil_levels
|
|
37
|
-
)
|
|
47
|
+
return dict(num_metgrid_levels=num_metgrid_levels, num_land_cat=num_land_cat, num_metgrid_soil_levels=num_metgrid_soil_levels)
|
|
38
48
|
|
|
39
49
|
|
|
40
50
|
def reconcile_namelist_metgrid(metgrid_path: str):
|
|
@@ -48,7 +58,7 @@ def reconcile_namelist_metgrid(metgrid_path: str):
|
|
|
48
58
|
:return:
|
|
49
59
|
:rtype:
|
|
50
60
|
"""
|
|
51
|
-
logger.info(
|
|
61
|
+
logger.info("Checking values in WRF namelist and metgrid output ...")
|
|
52
62
|
metgrid_output_name = [x for x in listdir(metgrid_path) if x.endswith(".nc")]
|
|
53
63
|
metgrid_output_name.sort()
|
|
54
64
|
metgrid_output_name = metgrid_output_name[0]
|
|
@@ -60,24 +70,21 @@ def reconcile_namelist_metgrid(metgrid_path: str):
|
|
|
60
70
|
"num_metgrid_levels": metgrid_levels["num_metgrid_levels"],
|
|
61
71
|
"num_metgrid_soil_levels": metgrid_levels["num_metgrid_soil_levels"],
|
|
62
72
|
},
|
|
63
|
-
"physics": {
|
|
64
|
-
"num_land_cat": metgrid_levels["num_land_cat"]
|
|
65
|
-
}
|
|
73
|
+
"physics": {"num_land_cat": metgrid_levels["num_land_cat"]},
|
|
66
74
|
}
|
|
67
75
|
|
|
68
|
-
|
|
76
|
+
WRFRUN.config.update_namelist(update_values, "wrf")
|
|
69
77
|
|
|
70
78
|
|
|
71
79
|
def process_after_ndown():
|
|
72
80
|
"""
|
|
73
81
|
After running ndown.exe, namelist settings are supposed to be changed,
|
|
74
82
|
so WRF can simulate a higher resolution domain according to `WRF User's Guide <https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/running_wrf.html#wrf-nesting>`_.
|
|
75
|
-
`wrfrun` provide this function to help you change these settings which have multiple values for each domain.
|
|
76
|
-
The first value will be removed to ensure the value of higher resolution domain is the first value.
|
|
77
83
|
|
|
78
|
-
|
|
84
|
+
``wrfrun`` provide this function to help you change these settings which have multiple values for each domain.
|
|
85
|
+
The first value will be removed to ensure the value of higher resolution domain is the first value.
|
|
79
86
|
"""
|
|
80
|
-
WRFRUNConfig =
|
|
87
|
+
WRFRUNConfig = WRFRUN.config
|
|
81
88
|
namelist_data = WRFRUNConfig.get_namelist("wrf")
|
|
82
89
|
|
|
83
90
|
for section in namelist_data:
|
|
@@ -85,11 +92,18 @@ def process_after_ndown():
|
|
|
85
92
|
continue
|
|
86
93
|
|
|
87
94
|
for key in namelist_data[section]:
|
|
88
|
-
if key in [
|
|
95
|
+
if key in [
|
|
96
|
+
"grid_id",
|
|
97
|
+
"parent_id",
|
|
98
|
+
"i_parent_start",
|
|
99
|
+
"j_parent_start",
|
|
100
|
+
"parent_grid_ratio",
|
|
101
|
+
"parent_time_step_ratio",
|
|
102
|
+
"eta_levels",
|
|
103
|
+
]:
|
|
89
104
|
continue
|
|
90
105
|
|
|
91
106
|
if isinstance(namelist_data[section][key], list):
|
|
92
|
-
|
|
93
107
|
if len(namelist_data[section][key]) > 1:
|
|
94
108
|
namelist_data[section][key] = namelist_data[section][key][1:]
|
|
95
109
|
|
|
@@ -100,7 +114,7 @@ def process_after_ndown():
|
|
|
100
114
|
|
|
101
115
|
WRFRUNConfig.update_namelist(namelist_data, "wrf")
|
|
102
116
|
|
|
103
|
-
logger.info(
|
|
117
|
+
logger.info("Update namelist after running ndown.exe")
|
|
104
118
|
|
|
105
119
|
|
|
106
120
|
__all__ = ["reconcile_namelist_metgrid", "get_metgrid_levels", "process_after_ndown"]
|
wrfrun/model/wrf/vtable.py
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
|
+
"""
|
|
2
|
+
wrfrun.model.wrf.vtable
|
|
3
|
+
#######################
|
|
4
|
+
|
|
5
|
+
Dataclasses to represents VTable files in WRF.
|
|
6
|
+
|
|
7
|
+
.. autosummary::
|
|
8
|
+
:toctree: generated/
|
|
9
|
+
|
|
10
|
+
VtableFiles
|
|
11
|
+
|
|
12
|
+
How to use
|
|
13
|
+
**********
|
|
14
|
+
|
|
15
|
+
Attributes of :class:`VtableFiles` is a ``wrfrun`` URI, parse it will get the real path of VTable files.
|
|
16
|
+
|
|
17
|
+
**For example**
|
|
18
|
+
|
|
19
|
+
.. code-block:: python
|
|
20
|
+
:caption: main.py
|
|
21
|
+
|
|
22
|
+
from wrfrun.core import WRFRUN
|
|
23
|
+
from wrfrun.model.wrf import VtableFiles
|
|
24
|
+
|
|
25
|
+
vtable_real_file_path = WRFRUN.config.parse_resource_uri(VtableFiles.ERA_PL)
|
|
26
|
+
"""
|
|
27
|
+
|
|
1
28
|
from dataclasses import dataclass
|
|
2
29
|
|
|
3
|
-
from wrfrun.core import
|
|
30
|
+
from wrfrun.core import WRFRUN, WRFRunConfig
|
|
4
31
|
from wrfrun.workspace.wrf import get_wrf_workspace_path
|
|
5
32
|
|
|
6
33
|
VTABLE_URI = ":WRFRUN_VTABLE:"
|
|
@@ -10,8 +37,13 @@ VTABLE_URI = ":WRFRUN_VTABLE:"
|
|
|
10
37
|
class VtableFiles:
|
|
11
38
|
"""
|
|
12
39
|
Represent WPS Vtable files (v4.5).
|
|
13
|
-
|
|
40
|
+
|
|
41
|
+
**NOTE**
|
|
42
|
+
|
|
43
|
+
This class doesn't have method to check if the VTable file exists.
|
|
44
|
+
User need to check the VTable file when use it.
|
|
14
45
|
"""
|
|
46
|
+
|
|
15
47
|
AFWAICE = f"{VTABLE_URI}/Vtable.AFWAICE"
|
|
16
48
|
AGRMETSNOW = f"{VTABLE_URI}/Vtable.AGRMETSNOW"
|
|
17
49
|
AGRMETSOIL = f"{VTABLE_URI}/Vtable.AGRMETSOIL"
|
|
@@ -63,7 +95,7 @@ def _register_vtable_uri(wrfrun_config: WRFRunConfig):
|
|
|
63
95
|
wrfrun_config.register_resource_uri(VTABLE_URI, f"{get_wrf_workspace_path('wps')}/ungrib/Variable_Tables")
|
|
64
96
|
|
|
65
97
|
|
|
66
|
-
|
|
98
|
+
WRFRUN.set_config_register_func(_register_vtable_uri)
|
|
67
99
|
|
|
68
100
|
|
|
69
101
|
__all__ = ["VtableFiles"]
|
wrfrun/plot/__init__.py
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
wrfrun.plot
|
|
3
|
+
###########
|
|
4
|
+
|
|
5
|
+
Modules to plot model outputs.
|
|
6
|
+
|
|
7
|
+
Submodules
|
|
8
|
+
**********
|
|
9
|
+
|
|
10
|
+
========================================= ==========================================
|
|
11
|
+
:doc:`wps </api/plot.wps>` Functions to plot WPS outputs.
|
|
12
|
+
========================================= ==========================================
|
|
13
|
+
|
|
14
|
+
.. toctree::
|
|
15
|
+
:maxdepth: 1
|
|
16
|
+
:hidden:
|
|
17
|
+
|
|
18
|
+
wps <plot.wps>
|
|
19
|
+
"""
|
|
20
|
+
|
|
1
21
|
from .wps import *
|