wrfrun 0.1.9__py3-none-any.whl → 0.3.0__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.
Files changed (66) hide show
  1. wrfrun/__init__.py +8 -3
  2. wrfrun/cli.py +74 -31
  3. wrfrun/core/__init__.py +27 -10
  4. wrfrun/core/_config.py +308 -0
  5. wrfrun/core/_constant.py +236 -0
  6. wrfrun/core/_exec_db.py +105 -0
  7. wrfrun/core/_namelist.py +287 -0
  8. wrfrun/core/_record.py +178 -0
  9. wrfrun/core/_resource.py +172 -0
  10. wrfrun/core/base.py +136 -380
  11. wrfrun/core/core.py +196 -0
  12. wrfrun/core/error.py +35 -2
  13. wrfrun/core/replay.py +10 -96
  14. wrfrun/core/server.py +74 -32
  15. wrfrun/core/type.py +171 -0
  16. wrfrun/data.py +312 -149
  17. wrfrun/extension/goos_sst/__init__.py +2 -2
  18. wrfrun/extension/goos_sst/core.py +9 -14
  19. wrfrun/extension/goos_sst/res/__init__.py +0 -1
  20. wrfrun/extension/goos_sst/utils.py +50 -44
  21. wrfrun/extension/littler/core.py +105 -88
  22. wrfrun/extension/utils.py +5 -3
  23. wrfrun/log.py +117 -0
  24. wrfrun/model/__init__.py +11 -7
  25. wrfrun/model/constants.py +52 -0
  26. wrfrun/model/palm/__init__.py +30 -0
  27. wrfrun/model/palm/core.py +145 -0
  28. wrfrun/model/palm/namelist.py +33 -0
  29. wrfrun/model/plot.py +99 -114
  30. wrfrun/model/type.py +116 -0
  31. wrfrun/model/utils.py +9 -19
  32. wrfrun/model/wrf/__init__.py +4 -9
  33. wrfrun/model/wrf/core.py +262 -165
  34. wrfrun/model/wrf/exec_wrap.py +13 -12
  35. wrfrun/model/wrf/geodata.py +116 -99
  36. wrfrun/model/wrf/log.py +103 -0
  37. wrfrun/model/wrf/namelist.py +92 -76
  38. wrfrun/model/wrf/plot.py +102 -0
  39. wrfrun/model/wrf/scheme.py +108 -52
  40. wrfrun/model/wrf/utils.py +39 -24
  41. wrfrun/model/wrf/vtable.py +42 -7
  42. wrfrun/plot/__init__.py +20 -0
  43. wrfrun/plot/wps.py +90 -73
  44. wrfrun/res/__init__.py +115 -5
  45. wrfrun/res/config/config.template.toml +15 -0
  46. wrfrun/res/config/palm.template.toml +23 -0
  47. wrfrun/run.py +121 -77
  48. wrfrun/scheduler/__init__.py +1 -0
  49. wrfrun/scheduler/lsf.py +4 -1
  50. wrfrun/scheduler/pbs.py +4 -1
  51. wrfrun/scheduler/script.py +19 -5
  52. wrfrun/scheduler/slurm.py +4 -1
  53. wrfrun/scheduler/utils.py +14 -2
  54. wrfrun/utils.py +88 -199
  55. wrfrun/workspace/__init__.py +8 -5
  56. wrfrun/workspace/core.py +21 -11
  57. wrfrun/workspace/palm.py +137 -0
  58. wrfrun/workspace/wrf.py +59 -14
  59. wrfrun-0.3.0.dist-info/METADATA +240 -0
  60. wrfrun-0.3.0.dist-info/RECORD +78 -0
  61. wrfrun/core/config.py +0 -767
  62. wrfrun/model/base.py +0 -14
  63. wrfrun-0.1.9.dist-info/METADATA +0 -68
  64. wrfrun-0.1.9.dist-info/RECORD +0 -62
  65. {wrfrun-0.1.9.dist-info → wrfrun-0.3.0.dist-info}/WHEEL +0 -0
  66. {wrfrun-0.1.9.dist-info → wrfrun-0.3.0.dist-info}/entry_points.txt +0 -0
@@ -1,9 +1,43 @@
1
1
  """
2
- This file contains function to determine schemes for WRF
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.utils import logger
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 # for GPU and MIC
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
- """Get the corresponding integer label for long wave radiation scheme
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
- Args:
30
- key (str, optional): Name of long wave radiation scheme. Defaults to "rrtm".
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
- """Get corresponding integer label for short wave radiation scheme
113
+ """
114
+ Get corresponding integer label for short wave radiation scheme.
77
115
 
78
- Args:
79
- key (str, optional): Name of short wave radiation scheme. Defaults to "rrtmg".
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
- """Get corresponding integer label for cumulus parameterization scheme
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
- Args:
133
- key (str, optional): Name of cumulus parameterization scheme. Defaults to "kf".
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
- """Get corresponding integer label for PBL scheme
229
+ """
230
+ Get corresponding integer label for PBL scheme.
189
231
 
190
- Args:
191
- key (str, optional): Name of PBL scheme. Defaults to "ysu".
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
- """Get corresponding integer label for land surface scheme
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
- Args:
242
- key (str, optional): Name of land surface scheme. Defaults to "noah".
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
- """Get corresponding integer label for surface layer scheme
328
+ """
329
+ Get corresponding integer label for surface layer scheme.
284
330
 
285
- Args:
286
- key (str, optional): Name of surface layer scheme. Defaults to "mo".
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
- """Get corresponding integer label for microphysics scheme
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
- Args:
351
- key (str, optional): Name of microphysics scheme. Defaults to "PURDUE_LIN".
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__ = ["SchemeCumulus", "SchemeLandSurfaceModel", "SchemeLongWave", "SchemePBL", "SchemeShortWave", "SchemeSurfaceLayer", "SchemeMicrophysics"]
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 WRFRUNConfig
8
- from wrfrun.utils import logger
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
- """Read metgrid output file and get metgrid levels, land cat and metgrid soil levels
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
- Returns:
18
- Dict[str, int]: {num_metgrid_levels: number, num_land_cat: number, num_metgrid_soil_level: number}
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(f"Checking values in WRF namelist and metgrid output ...")
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,23 +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
- WRFRUNConfig.update_namelist(update_values, "wrf")
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
- :return:
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
  """
87
+ WRFRUNConfig = WRFRUN.config
80
88
  namelist_data = WRFRUNConfig.get_namelist("wrf")
81
89
 
82
90
  for section in namelist_data:
@@ -84,11 +92,18 @@ def process_after_ndown():
84
92
  continue
85
93
 
86
94
  for key in namelist_data[section]:
87
- if key in ["grid_id", "parent_id", "i_parent_start", "j_parent_start", "parent_grid_ratio", "parent_time_step_ratio", "eta_levels"]:
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
+ ]:
88
104
  continue
89
105
 
90
106
  if isinstance(namelist_data[section][key], list):
91
-
92
107
  if len(namelist_data[section][key]) > 1:
93
108
  namelist_data[section][key] = namelist_data[section][key][1:]
94
109
 
@@ -99,7 +114,7 @@ def process_after_ndown():
99
114
 
100
115
  WRFRUNConfig.update_namelist(namelist_data, "wrf")
101
116
 
102
- logger.info(f"Update namelist after running ndown.exe")
117
+ logger.info("Update namelist after running ndown.exe")
103
118
 
104
119
 
105
120
  __all__ = ["reconcile_namelist_metgrid", "get_metgrid_levels", "process_after_ndown"]
@@ -1,8 +1,34 @@
1
- from dataclasses import dataclass
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
2
21
 
3
- from wrfrun.core import WRFRUNConfig
4
- from wrfrun.workspace.wrf import WORKSPACE_MODEL_WPS
22
+ from wrfrun.core import WRFRUN
23
+ from wrfrun.model.wrf import VtableFiles
5
24
 
25
+ vtable_real_file_path = WRFRUN.config.parse_resource_uri(VtableFiles.ERA_PL)
26
+ """
27
+
28
+ from dataclasses import dataclass
29
+
30
+ from wrfrun.core import WRFRUN, WRFRunConfig
31
+ from wrfrun.workspace.wrf import get_wrf_workspace_path
6
32
 
7
33
  VTABLE_URI = ":WRFRUN_VTABLE:"
8
34
 
@@ -11,8 +37,13 @@ VTABLE_URI = ":WRFRUN_VTABLE:"
11
37
  class VtableFiles:
12
38
  """
13
39
  Represent WPS Vtable files (v4.5).
14
- With the ":/" we can tell from user custom Vtable files.
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.
15
45
  """
46
+
16
47
  AFWAICE = f"{VTABLE_URI}/Vtable.AFWAICE"
17
48
  AGRMETSNOW = f"{VTABLE_URI}/Vtable.AGRMETSNOW"
18
49
  AGRMETSOIL = f"{VTABLE_URI}/Vtable.AGRMETSOIL"
@@ -58,9 +89,13 @@ class VtableFiles:
58
89
  UKMO_NO_HEIGHTS = f"{VTABLE_URI}/Vtable.UKMO_no_heights"
59
90
 
60
91
 
61
- # register uri
62
- if not WRFRUNConfig.check_resource_uri(VTABLE_URI):
63
- WRFRUNConfig.register_resource_uri(VTABLE_URI, f"{WORKSPACE_MODEL_WPS}/ungrib/Variable_Tables")
92
+ def _register_vtable_uri(wrfrun_config: WRFRunConfig):
93
+ # register uri
94
+ if not wrfrun_config.check_resource_uri(VTABLE_URI):
95
+ wrfrun_config.register_resource_uri(VTABLE_URI, f"{get_wrf_workspace_path('wps')}/ungrib/Variable_Tables")
96
+
97
+
98
+ WRFRUN.set_config_register_func(_register_vtable_uri)
64
99
 
65
100
 
66
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 *