wrfrun 0.1.8__py3-none-any.whl → 0.2.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.
- wrfrun/cli.py +131 -0
- wrfrun/core/base.py +52 -19
- wrfrun/core/config.py +257 -170
- wrfrun/core/error.py +8 -1
- wrfrun/core/replay.py +1 -1
- wrfrun/core/server.py +91 -71
- wrfrun/data.py +14 -16
- wrfrun/extension/goos_sst/__init__.py +5 -5
- wrfrun/extension/goos_sst/core.py +4 -1
- wrfrun/extension/goos_sst/res/Vtable.ERA_GOOS_SST +1 -1
- wrfrun/extension/goos_sst/res/__init__.py +17 -0
- wrfrun/extension/goos_sst/utils.py +21 -5
- wrfrun/extension/littler/__init__.py +57 -1
- wrfrun/extension/littler/{utils.py → core.py} +329 -43
- wrfrun/extension/utils.py +24 -22
- wrfrun/model/__init__.py +24 -1
- wrfrun/model/plot.py +259 -36
- wrfrun/model/utils.py +19 -9
- wrfrun/model/wrf/__init__.py +41 -0
- wrfrun/model/wrf/core.py +229 -101
- wrfrun/model/wrf/exec_wrap.py +49 -35
- wrfrun/model/wrf/geodata.py +2 -1
- wrfrun/model/wrf/namelist.py +78 -4
- wrfrun/model/wrf/{_metgrid.py → utils.py} +38 -3
- wrfrun/model/wrf/vtable.py +9 -5
- wrfrun/res/__init__.py +22 -7
- wrfrun/res/config/config.template.toml +57 -0
- wrfrun/res/{config.toml.template → config/wrf.template.toml} +7 -46
- wrfrun/res/run.template.sh +10 -0
- wrfrun/res/scheduler/lsf.template +5 -0
- wrfrun/res/{job_scheduler → scheduler}/pbs.template +1 -1
- wrfrun/res/{job_scheduler → scheduler}/slurm.template +2 -1
- wrfrun/run.py +39 -27
- wrfrun/scheduler/__init__.py +35 -0
- wrfrun/scheduler/env.py +44 -0
- wrfrun/scheduler/lsf.py +49 -0
- wrfrun/scheduler/pbs.py +50 -0
- wrfrun/scheduler/script.py +72 -0
- wrfrun/scheduler/slurm.py +50 -0
- wrfrun/scheduler/utils.py +14 -0
- wrfrun/utils.py +8 -3
- wrfrun/workspace/__init__.py +38 -0
- wrfrun/workspace/core.py +94 -0
- wrfrun/workspace/wrf.py +165 -0
- {wrfrun-0.1.8.dist-info → wrfrun-0.2.0.dist-info}/METADATA +3 -2
- wrfrun-0.2.0.dist-info/RECORD +62 -0
- wrfrun-0.2.0.dist-info/entry_points.txt +3 -0
- wrfrun/model/wrf/_ndown.py +0 -39
- wrfrun/pbs.py +0 -86
- wrfrun/res/run.sh.template +0 -16
- wrfrun/workspace.py +0 -88
- wrfrun-0.1.8.dist-info/RECORD +0 -51
- {wrfrun-0.1.8.dist-info → wrfrun-0.2.0.dist-info}/WHEEL +0 -0
wrfrun/model/wrf/exec_wrap.py
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
"""
|
|
2
|
+
wrfrun.model.wrf.exec_wrap
|
|
3
|
+
##########################
|
|
4
|
+
|
|
5
|
+
Function wrapper of WPS / WRF :doc:`Executables </api/model.wrf.core>`.
|
|
6
|
+
|
|
7
|
+
.. autosummary::
|
|
8
|
+
:toctree: generated/
|
|
9
|
+
|
|
10
|
+
geogrid
|
|
11
|
+
ungrib
|
|
12
|
+
metgrid
|
|
13
|
+
real
|
|
14
|
+
wrf
|
|
15
|
+
dfi
|
|
16
|
+
ndown
|
|
17
|
+
"""
|
|
18
|
+
|
|
2
19
|
from typing import Optional, Union
|
|
3
20
|
|
|
4
21
|
from wrfrun import WRFRUNConfig
|
|
5
|
-
from .core import DFI, GeoGrid, MetGrid, Real, UnGrib, WRF
|
|
22
|
+
from .core import DFI, GeoGrid, MetGrid, NDown, Real, UnGrib, WRF
|
|
6
23
|
|
|
7
24
|
|
|
8
25
|
def geogrid(geogrid_tbl_file: Union[str, None] = None):
|
|
9
26
|
"""
|
|
10
|
-
|
|
27
|
+
Function interface for :class:`GeoGrid <wrfrun.model.wrf.core.GeoGrid>`.
|
|
11
28
|
|
|
12
29
|
:param geogrid_tbl_file: Custom GEOGRID.TBL file path. Defaults to None.
|
|
13
30
|
"""
|
|
@@ -16,67 +33,66 @@ def geogrid(geogrid_tbl_file: Union[str, None] = None):
|
|
|
16
33
|
|
|
17
34
|
def ungrib(vtable_file: Union[str, None] = None, input_data_path: Optional[str] = None, prefix="FILE"):
|
|
18
35
|
"""
|
|
19
|
-
|
|
36
|
+
Function interface for :class:`UnGrib <wrfrun.model.wrf.core.UnGrib>`.
|
|
20
37
|
|
|
21
|
-
:param vtable_file:
|
|
38
|
+
:param vtable_file: Path of the Vtable file.
|
|
39
|
+
Defaults to :attr:`VtableFiles.ERA_PL <vtable.VtableFiles.ERA_PL>`.
|
|
22
40
|
:type vtable_file: str
|
|
23
|
-
:param input_data_path: Directory path of
|
|
41
|
+
:param input_data_path: Directory path of input GRIB files.
|
|
42
|
+
Defaults to ``input_data_path`` set in user's config file.
|
|
24
43
|
:type input_data_path: str
|
|
25
|
-
:param prefix: Prefix of
|
|
44
|
+
:param prefix: Prefix of outputs.
|
|
26
45
|
:type prefix: str
|
|
27
46
|
"""
|
|
28
|
-
|
|
29
|
-
WRFRUNConfig.set_ungrib_out_prefix(prefix)
|
|
30
|
-
|
|
31
|
-
UnGrib(vtable_file, input_data_path)()
|
|
47
|
+
UnGrib(vtable_file, input_data_path).set_ungrib_output_prefix(prefix)()
|
|
32
48
|
|
|
33
49
|
|
|
34
50
|
def metgrid(geogrid_data_path: Optional[str] = None, ungrib_data_path: Optional[str] = None, fg_names: Union[str, list[str]] = "FILE"):
|
|
35
51
|
"""
|
|
36
|
-
|
|
52
|
+
Function interface for :class:`MetGrid <wrfrun.model.wrf.core.MetGrid>`.
|
|
37
53
|
|
|
38
|
-
:param geogrid_data_path: Directory path of
|
|
54
|
+
:param geogrid_data_path: Directory path of :class:`GeoGrid <wrfrun.model.wrf.core.GeoGrid>` outputs.
|
|
55
|
+
If is ``None``, try to use the output path specified by config file.
|
|
39
56
|
:type geogrid_data_path: str
|
|
40
|
-
:param ungrib_data_path: Directory path of
|
|
57
|
+
:param ungrib_data_path: Directory path of :class:`UnGrib <wrfrun.model.wrf.core.UnGrib>` outputs.
|
|
58
|
+
If is ``None``, try to use the output path specified by config file.
|
|
41
59
|
:type ungrib_data_path: str
|
|
42
|
-
:param fg_names:
|
|
60
|
+
:param fg_names: ``fg_name`` of metgrid, a single prefix string or a string list.
|
|
43
61
|
:type fg_names: str | list
|
|
44
62
|
"""
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
fg_names
|
|
48
|
-
WRFRUNConfig.set_metgrid_fg_names(fg_names)
|
|
49
|
-
|
|
50
|
-
MetGrid(geogrid_data_path, ungrib_data_path, WRFRUNConfig.get_core_num())()
|
|
63
|
+
MetGrid(
|
|
64
|
+
geogrid_data_path, ungrib_data_path, WRFRUNConfig.get_core_num()
|
|
65
|
+
).set_metgrid_fg_names(fg_names)()
|
|
51
66
|
|
|
52
67
|
|
|
53
68
|
def real(metgrid_data_path: Union[str, None] = None):
|
|
54
69
|
"""
|
|
55
|
-
|
|
70
|
+
Function interface for :class:`Real <wrfrun.model.wrf.core.Real>`.
|
|
56
71
|
|
|
57
|
-
:param metgrid_data_path:
|
|
72
|
+
:param metgrid_data_path: Directory path of :class:`MetGrid <wrfrun.model.wrf.core.MetGrid>` outputs.
|
|
73
|
+
If is ``None``, try to use the workspace path or output path in the config file.
|
|
58
74
|
"""
|
|
59
75
|
Real(metgrid_data_path, WRFRUNConfig.get_core_num())()
|
|
60
76
|
|
|
61
77
|
|
|
62
78
|
def wrf(input_file_dir_path: Union[str, None] = None, restart_file_dir_path: Optional[str] = None, save_restarts=False):
|
|
63
79
|
"""
|
|
64
|
-
|
|
80
|
+
Function interface for :class:`WRF <wrfrun.model.wrf.core.WRF>`.
|
|
65
81
|
|
|
66
|
-
:param input_file_dir_path:
|
|
67
|
-
:param restart_file_dir_path:
|
|
68
|
-
:param save_restarts:
|
|
82
|
+
:param input_file_dir_path: Directory path of input data.
|
|
83
|
+
:param restart_file_dir_path: Directory path of restart files.
|
|
84
|
+
:param save_restarts: If saving restart files. Defaults to False.
|
|
69
85
|
"""
|
|
70
86
|
WRF(input_file_dir_path, restart_file_dir_path, save_restarts, WRFRUNConfig.get_core_num())()
|
|
71
87
|
|
|
72
88
|
|
|
73
89
|
def dfi(input_file_dir_path: Optional[str] = None, update_real_output=True):
|
|
74
90
|
"""
|
|
75
|
-
|
|
91
|
+
Function interface for :class:`DFI <wrfrun.model.wrf.core.DFI>`.
|
|
76
92
|
|
|
77
|
-
:param input_file_dir_path:
|
|
93
|
+
:param input_file_dir_path: Directory path of input data.
|
|
78
94
|
:type input_file_dir_path: str
|
|
79
|
-
:param update_real_output: If update
|
|
95
|
+
:param update_real_output: If update corresponding files in :class:`Real <wrfrun.model.wrf.core.Real>` outputs.
|
|
80
96
|
:type update_real_output: bool
|
|
81
97
|
"""
|
|
82
98
|
DFI(input_file_dir_path, update_real_output, WRFRUNConfig.get_core_num())()
|
|
@@ -84,16 +100,14 @@ def dfi(input_file_dir_path: Optional[str] = None, update_real_output=True):
|
|
|
84
100
|
|
|
85
101
|
def ndown(wrfout_file_path: str, real_output_dir_path: Optional[str] = None, update_namelist=True):
|
|
86
102
|
"""
|
|
87
|
-
|
|
103
|
+
Function interface for :class:`NDown <wrfrun.model.wrf.core.NDown>`.
|
|
88
104
|
|
|
89
105
|
:param wrfout_file_path: wrfout file path.
|
|
90
106
|
:type wrfout_file_path: str
|
|
91
|
-
:param real_output_dir_path:
|
|
107
|
+
:param real_output_dir_path: Directory path of :class:`Real <wrfrun.model.wrf.core.Real>` outputs.
|
|
92
108
|
:type real_output_dir_path: str
|
|
93
|
-
:param update_namelist: If update
|
|
109
|
+
:param update_namelist: If update namelist settings for the final integral.
|
|
94
110
|
:type update_namelist: bool
|
|
95
|
-
:return:
|
|
96
|
-
:rtype:
|
|
97
111
|
"""
|
|
98
112
|
NDown(wrfout_file_path, real_output_dir_path, update_namelist, WRFRUNConfig.get_core_num())()
|
|
99
113
|
|
wrfrun/model/wrf/geodata.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import OrderedDict, Union
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
from xarray import DataArray
|
|
7
7
|
|
|
8
|
-
from wrfrun.core import
|
|
8
|
+
from wrfrun.core import get_wrfrun_config
|
|
9
9
|
from wrfrun.utils import logger
|
|
10
10
|
|
|
11
11
|
# for example: 00001-00200.00201-00400
|
|
@@ -75,6 +75,7 @@ def parse_geographical_data_index(index_path: str) -> OrderedDict:
|
|
|
75
75
|
# since the index file is very similar to fortran namelist file,
|
|
76
76
|
# we can manually add "&index" and "/" and parse it as a namelist
|
|
77
77
|
# temp file store path
|
|
78
|
+
WRFRUNConfig = get_wrfrun_config()
|
|
78
79
|
temp_file = f"{WRFRUNConfig.WRFRUN_TEMP_PATH}/geogrid_data.index"
|
|
79
80
|
temp_file = WRFRUNConfig.parse_resource_uri(temp_file)
|
|
80
81
|
|
wrfrun/model/wrf/namelist.py
CHANGED
|
@@ -1,12 +1,83 @@
|
|
|
1
1
|
from datetime import datetime, timedelta
|
|
2
|
-
from os.path import exists
|
|
2
|
+
from os.path import basename, dirname, exists
|
|
3
3
|
from typing import Union
|
|
4
4
|
|
|
5
5
|
from wrfrun.core import WRFRUNConfig
|
|
6
6
|
from wrfrun.res import NAMELIST_DFI, NAMELIST_WPS, NAMELIST_WRF, NAMELIST_WRFDA
|
|
7
7
|
from wrfrun.utils import logger
|
|
8
|
+
from wrfrun.workspace.wrf import get_wrf_workspace_path
|
|
8
9
|
from .scheme import *
|
|
9
10
|
|
|
11
|
+
UNGRIB_OUTPUT_DIR = "./outputs"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def get_ungrib_out_dir_path() -> str:
|
|
15
|
+
"""
|
|
16
|
+
Get the output directory of ungrib output (WRF intermediate file).
|
|
17
|
+
|
|
18
|
+
:return: URI path.
|
|
19
|
+
:rtype: str
|
|
20
|
+
"""
|
|
21
|
+
wif_prefix = WRFRUNConfig.get_namelist("wps")["ungrib"]["prefix"]
|
|
22
|
+
wif_path = f"{get_wrf_workspace_path('wps')}/{dirname(wif_prefix)}"
|
|
23
|
+
|
|
24
|
+
return wif_path
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def get_ungrib_out_prefix() -> str:
|
|
28
|
+
"""
|
|
29
|
+
Get the prefix string of ungrib output (WRF intermediate file).
|
|
30
|
+
|
|
31
|
+
:return: Prefix string of ungrib output (WRF intermediate file).
|
|
32
|
+
:rtype: str
|
|
33
|
+
"""
|
|
34
|
+
wif_prefix = WRFRUNConfig.get_namelist("wps")["ungrib"]["prefix"]
|
|
35
|
+
wif_prefix = basename(wif_prefix)
|
|
36
|
+
return wif_prefix
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def set_ungrib_out_prefix(prefix: str):
|
|
40
|
+
"""
|
|
41
|
+
Set the prefix string of ungrib output (WRF intermediate file).
|
|
42
|
+
|
|
43
|
+
:param prefix: Prefix string of ungrib output (WRF intermediate file).
|
|
44
|
+
:type prefix: str
|
|
45
|
+
"""
|
|
46
|
+
WRFRUNConfig.update_namelist(
|
|
47
|
+
{
|
|
48
|
+
"ungrib": {"prefix": f"{UNGRIB_OUTPUT_DIR}/{prefix}"}
|
|
49
|
+
}, "wps"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def get_metgrid_fg_names() -> list[str]:
|
|
54
|
+
"""
|
|
55
|
+
Get prefix strings from "fg_name" in namelist "metgrid" section.
|
|
56
|
+
|
|
57
|
+
:return: Prefix strings list.
|
|
58
|
+
:rtype: list
|
|
59
|
+
"""
|
|
60
|
+
fg_names = WRFRUNConfig.get_namelist("wps")["metgrid"]["fg_name"]
|
|
61
|
+
fg_names = [basename(x) for x in fg_names]
|
|
62
|
+
return fg_names
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def set_metgrid_fg_names(prefix: Union[str, list[str]]):
|
|
66
|
+
"""
|
|
67
|
+
Set prefix strings of "fg_name" in namelist "metgrid" section.
|
|
68
|
+
|
|
69
|
+
:param prefix: Prefix strings list.
|
|
70
|
+
:type prefix: str | list
|
|
71
|
+
"""
|
|
72
|
+
if isinstance(prefix, str):
|
|
73
|
+
prefix = [prefix, ]
|
|
74
|
+
fg_names = [f"{UNGRIB_OUTPUT_DIR}/{x}" for x in prefix]
|
|
75
|
+
WRFRUNConfig.update_namelist(
|
|
76
|
+
{
|
|
77
|
+
"metgrid": {"fg_name": fg_names}
|
|
78
|
+
}, "wps"
|
|
79
|
+
)
|
|
80
|
+
|
|
10
81
|
|
|
11
82
|
def _check_start_end_date(max_dom: int, start_date: Union[datetime, list[datetime]], end_date: Union[datetime, list[datetime]]) -> tuple[list[datetime], list[datetime]]:
|
|
12
83
|
"""
|
|
@@ -84,7 +155,9 @@ def prepare_wps_namelist():
|
|
|
84
155
|
"truelat2": wrf_config["domain"]["truelat2"],
|
|
85
156
|
"stand_lon": wrf_config["domain"]["stand_lon"],
|
|
86
157
|
"geog_data_path": wrf_config["geog_data_path"]
|
|
87
|
-
}
|
|
158
|
+
},
|
|
159
|
+
"ungrib": {"prefix": f"{UNGRIB_OUTPUT_DIR}/FILE"},
|
|
160
|
+
"metgrid": {"fg_name": f"{UNGRIB_OUTPUT_DIR}/FILE"}
|
|
88
161
|
}
|
|
89
162
|
|
|
90
163
|
# # update namelist
|
|
@@ -107,7 +180,7 @@ def prepare_wrf_namelist():
|
|
|
107
180
|
wrf_config = WRFRUNConfig.get_model_config("wrf")
|
|
108
181
|
|
|
109
182
|
# get debug level
|
|
110
|
-
debug_level =
|
|
183
|
+
debug_level = wrf_config["debug_level"]
|
|
111
184
|
|
|
112
185
|
# get domain number, start_date and end_date
|
|
113
186
|
max_dom = wrf_config["domain"]["domain_num"]
|
|
@@ -370,4 +443,5 @@ def prepare_wrfda_namelist():
|
|
|
370
443
|
WRFRUNConfig.update_namelist(user_namelist_data, "wrfda")
|
|
371
444
|
|
|
372
445
|
|
|
373
|
-
__all__ = ["prepare_wrf_namelist", "prepare_wps_namelist", "prepare_wrfda_namelist", "prepare_dfi_namelist"
|
|
446
|
+
__all__ = ["prepare_wrf_namelist", "prepare_wps_namelist", "prepare_wrfda_namelist", "prepare_dfi_namelist", "get_ungrib_out_prefix", "get_ungrib_out_dir_path",
|
|
447
|
+
"set_ungrib_out_prefix", "get_metgrid_fg_names", "set_metgrid_fg_names"]
|
|
@@ -4,7 +4,7 @@ from typing import Dict
|
|
|
4
4
|
|
|
5
5
|
from xarray import open_dataset
|
|
6
6
|
|
|
7
|
-
from wrfrun
|
|
7
|
+
from wrfrun import get_wrfrun_config
|
|
8
8
|
from wrfrun.utils import logger
|
|
9
9
|
|
|
10
10
|
|
|
@@ -65,7 +65,42 @@ def reconcile_namelist_metgrid(metgrid_path: str):
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
get_wrfrun_config().update_namelist(update_values, "wrf")
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
def process_after_ndown():
|
|
72
|
+
"""
|
|
73
|
+
After running ndown.exe, namelist settings are supposed to be changed,
|
|
74
|
+
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
|
+
|
|
78
|
+
:return:
|
|
79
|
+
"""
|
|
80
|
+
WRFRUNConfig = get_wrfrun_config()
|
|
81
|
+
namelist_data = WRFRUNConfig.get_namelist("wrf")
|
|
82
|
+
|
|
83
|
+
for section in namelist_data:
|
|
84
|
+
if section in ["bdy_control", "namelist_quilt"]:
|
|
85
|
+
continue
|
|
86
|
+
|
|
87
|
+
for key in namelist_data[section]:
|
|
88
|
+
if key in ["grid_id", "parent_id", "i_parent_start", "j_parent_start", "parent_grid_ratio", "parent_time_step_ratio", "eta_levels"]:
|
|
89
|
+
continue
|
|
90
|
+
|
|
91
|
+
if isinstance(namelist_data[section][key], list):
|
|
92
|
+
|
|
93
|
+
if len(namelist_data[section][key]) > 1:
|
|
94
|
+
namelist_data[section][key] = namelist_data[section][key][1:]
|
|
95
|
+
|
|
96
|
+
namelist_data["domains"]["max_dom"] = 1
|
|
97
|
+
|
|
98
|
+
time_ratio = namelist_data["domains"]["parent_time_step_ratio"][1]
|
|
99
|
+
namelist_data["domains"]["time_step"] = namelist_data["domains"]["time_step"] // time_ratio
|
|
100
|
+
|
|
101
|
+
WRFRUNConfig.update_namelist(namelist_data, "wrf")
|
|
102
|
+
|
|
103
|
+
logger.info(f"Update namelist after running ndown.exe")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
__all__ = ["reconcile_namelist_metgrid", "get_metgrid_levels", "process_after_ndown"]
|
wrfrun/model/wrf/vtable.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
|
|
3
|
-
from wrfrun.core import
|
|
4
|
-
|
|
3
|
+
from wrfrun.core import WRFRunConfig, set_register_func
|
|
4
|
+
from wrfrun.workspace.wrf import get_wrf_workspace_path
|
|
5
5
|
|
|
6
6
|
VTABLE_URI = ":WRFRUN_VTABLE:"
|
|
7
7
|
|
|
@@ -57,9 +57,13 @@ class VtableFiles:
|
|
|
57
57
|
UKMO_NO_HEIGHTS = f"{VTABLE_URI}/Vtable.UKMO_no_heights"
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
def _register_vtable_uri(wrfrun_config: WRFRunConfig):
|
|
61
|
+
# register uri
|
|
62
|
+
if not wrfrun_config.check_resource_uri(VTABLE_URI):
|
|
63
|
+
wrfrun_config.register_resource_uri(VTABLE_URI, f"{get_wrf_workspace_path('wps')}/ungrib/Variable_Tables")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
set_register_func(_register_vtable_uri)
|
|
63
67
|
|
|
64
68
|
|
|
65
69
|
__all__ = ["VtableFiles"]
|
wrfrun/res/__init__.py
CHANGED
|
@@ -1,22 +1,37 @@
|
|
|
1
1
|
from os.path import abspath, dirname
|
|
2
2
|
|
|
3
|
-
from wrfrun.core import
|
|
3
|
+
from wrfrun.core import set_register_func, WRFRunConfig
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
RES_PATH = abspath(dirname(__file__))
|
|
7
|
-
WRFRUNConfig.register_resource_uri(WRFRUNConfig.WRFRUN_RESOURCE_PATH, RES_PATH)
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
def _register_res_uri(wrfrun_config: WRFRunConfig):
|
|
10
|
+
wrfrun_config.register_resource_uri(wrfrun_config.WRFRUN_RESOURCE_PATH, RES_PATH)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
set_register_func(_register_res_uri)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
RUN_SH_TEMPLATE = ":WRFRUN_RESOURCE_PATH:/run.template.sh"
|
|
10
17
|
EXT_NCL_PLOT_SCRIPT = ":WRFRUN_RESOURCE_PATH:/extension/plotgrids.ncl"
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
SCHEDULER_LSF_TEMPLATE = ":WRFRUN_RESOURCE_PATH:/scheduler/lsf.template"
|
|
19
|
+
SCHEDULER_PBS_TEMPLATE = ":WRFRUN_RESOURCE_PATH:/scheduler/pbs.template"
|
|
20
|
+
SCHEDULER_SLURM_TEMPLATE = ":WRFRUN_RESOURCE_PATH:/scheduler/slurm.template"
|
|
13
21
|
NAMELIST_WRFDA = ":WRFRUN_RESOURCE_PATH:/namelist/namelist.input.da_wrfvar.template"
|
|
14
22
|
NAMELIST_DFI = ":WRFRUN_RESOURCE_PATH:/namelist/namelist.input.dfi.template"
|
|
15
23
|
NAMELIST_REAL = ":WRFRUN_RESOURCE_PATH:/namelist/namelist.input.real.template"
|
|
16
24
|
NAMELIST_WRF = ":WRFRUN_RESOURCE_PATH:/namelist/namelist.input.wrf.template"
|
|
17
25
|
NAMELIST_WPS = ":WRFRUN_RESOURCE_PATH:/namelist/namelist.wps.template"
|
|
26
|
+
CONFIG_MAIN_TOML_TEMPLATE = ":WRFRUN_RESOURCE_PATH:/config/config.template.toml"
|
|
27
|
+
CONFIG_WRF_TOML_TEMPLATE = ":WRFRUN_RESOURCE_PATH:/config/wrf.template.toml"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _set_config_template_path(wrfrun_config: WRFRunConfig):
|
|
31
|
+
wrfrun_config.set_config_template_path(CONFIG_MAIN_TOML_TEMPLATE)
|
|
32
|
+
|
|
18
33
|
|
|
19
|
-
|
|
34
|
+
set_register_func(_set_config_template_path)
|
|
20
35
|
|
|
21
36
|
|
|
22
|
-
__all__ = ["
|
|
37
|
+
__all__ = ["RUN_SH_TEMPLATE", "EXT_NCL_PLOT_SCRIPT", "SCHEDULER_LSF_TEMPLATE", "SCHEDULER_PBS_TEMPLATE", "SCHEDULER_SLURM_TEMPLATE", "NAMELIST_WRFDA", "NAMELIST_DFI", "NAMELIST_REAL", "NAMELIST_WRF", "NAMELIST_WPS", "CONFIG_MAIN_TOML_TEMPLATE", "CONFIG_WRF_TOML_TEMPLATE"]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Config template of wrfrun.
|
|
2
|
+
|
|
3
|
+
# Work directory.
|
|
4
|
+
# By setting work directory, you can let wrfrun work and save runtime files in a single directory.
|
|
5
|
+
# You can also set work_dir="" to let wrfrun work in the standard path.
|
|
6
|
+
work_dir = "./.wrfrun"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# Path of the directory which contains input data.
|
|
10
|
+
input_data_path = ""
|
|
11
|
+
|
|
12
|
+
# Path of the directory to store all outputs.
|
|
13
|
+
output_path = "./outputs"
|
|
14
|
+
log_path = "./logs"
|
|
15
|
+
|
|
16
|
+
# wrfrun can launch a socket server during NWP execution to report simulation progress.
|
|
17
|
+
# To enable the server, you need to configure the IP address and port on which it will listen to.
|
|
18
|
+
server_host = "localhost"
|
|
19
|
+
server_port = 54321
|
|
20
|
+
|
|
21
|
+
# How many cores you will use.
|
|
22
|
+
# Note that if you use a job scheduler (like PBS), this value means the number of cores each node you use.
|
|
23
|
+
core_num = 36
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
[job_scheduler]
|
|
27
|
+
# Job scheduler settings.
|
|
28
|
+
# Which job scheduler you want to use
|
|
29
|
+
# wrfrun supports following job schedulers:
|
|
30
|
+
# 1. PBS: "pbs"
|
|
31
|
+
# 2. LSF: "lfs"
|
|
32
|
+
# 3. Slurm: "slurm
|
|
33
|
+
job_scheduler = "pbs"
|
|
34
|
+
|
|
35
|
+
# Which queue should the task be submited to
|
|
36
|
+
queue_name = ""
|
|
37
|
+
|
|
38
|
+
# How many nodes you will use.
|
|
39
|
+
node_num = 1
|
|
40
|
+
|
|
41
|
+
# Custom environment settings
|
|
42
|
+
env_settings = {}
|
|
43
|
+
|
|
44
|
+
# Path of the python interpreter that will be used to run wrfrun.
|
|
45
|
+
# You can also give its name only.
|
|
46
|
+
python_interpreter = "/usr/bin/python3" # or just "python3"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
[model]
|
|
50
|
+
|
|
51
|
+
[model.wrf]
|
|
52
|
+
# If you want to use WRF model, set use to true.
|
|
53
|
+
use = false
|
|
54
|
+
# Import configurations from another toml file.
|
|
55
|
+
# You can give both absolute and relative path.
|
|
56
|
+
# The relative path is resolved based on this configuration file.
|
|
57
|
+
include = "./configs/wrf.toml"
|
|
@@ -1,46 +1,5 @@
|
|
|
1
|
-
# Config
|
|
2
|
-
#
|
|
3
|
-
input_data_path = ""
|
|
4
|
-
|
|
5
|
-
# Path of the directory to store all outputs.
|
|
6
|
-
output_path = "./outputs"
|
|
7
|
-
log_path = "./logs"
|
|
8
|
-
|
|
9
|
-
# wrfrun can launch a socket server during NWP execution to report simulation progress.
|
|
10
|
-
# To enable the server, you need to configure the IP address and port on which it will listen to.
|
|
11
|
-
server_host = "localhost"
|
|
12
|
-
server_port = 54321
|
|
13
|
-
|
|
14
|
-
# How many cores you will use.
|
|
15
|
-
# Note that if you use a job scheduler (like PBS), this value means the number of cores each node you use.
|
|
16
|
-
core_num = 36
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
[job_scheduler]
|
|
20
|
-
# Job scheduler settings.
|
|
21
|
-
# How many nodes you will use.
|
|
22
|
-
node_num = 1
|
|
23
|
-
|
|
24
|
-
# Custom environment settings
|
|
25
|
-
env_settings = {}
|
|
26
|
-
|
|
27
|
-
# Path of the python interpreter that will be used to run wrfrun.
|
|
28
|
-
# You can also give its name only.
|
|
29
|
-
python_interpreter = "/usr/bin/python3" # or just "python3"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
[model]
|
|
33
|
-
# Model debug level
|
|
34
|
-
debug_level = 100
|
|
35
|
-
|
|
36
|
-
# ################################################### Only settings above is necessary ###########################################
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
# ####################################### You can give more settings about the NWP you will use ##################################
|
|
40
|
-
|
|
41
|
-
[model.wrf]
|
|
42
|
-
# Config for WRF
|
|
43
|
-
# WRF model path
|
|
1
|
+
# Config for WRF model.
|
|
2
|
+
# WRF model path.
|
|
44
3
|
wps_path = '/path/to/your/WPS/folder'
|
|
45
4
|
wrf_path = '/path/to/your/WRF/folder'
|
|
46
5
|
# WRFDA is optional.
|
|
@@ -59,8 +18,10 @@ user_wrfda_namelist = ''
|
|
|
59
18
|
# If you make a restart run?
|
|
60
19
|
restart_mode = false
|
|
61
20
|
|
|
21
|
+
# debug level for WRF model
|
|
22
|
+
debug_level = 100
|
|
62
23
|
|
|
63
|
-
[
|
|
24
|
+
[time]
|
|
64
25
|
# Advance time config for WRF
|
|
65
26
|
# Set the start and end date. It will be used for all domains.
|
|
66
27
|
# You can also provide all the dates as a list, with each date for the corresponding domain.
|
|
@@ -87,7 +48,7 @@ parent_time_step_ratio = [1, 3, 4]
|
|
|
87
48
|
restart_interval = -1
|
|
88
49
|
|
|
89
50
|
|
|
90
|
-
[
|
|
51
|
+
[domain]
|
|
91
52
|
# Advance domain config for WRF.
|
|
92
53
|
# Set domain number.
|
|
93
54
|
domain_num = 3
|
|
@@ -119,7 +80,7 @@ ref_lon = 120.5
|
|
|
119
80
|
stand_lon = 120.5
|
|
120
81
|
|
|
121
82
|
|
|
122
|
-
[
|
|
83
|
+
[scheme]
|
|
123
84
|
# Advance physics scheme config for WRF.
|
|
124
85
|
# To loop up the nickname for all physics schemes, please see: https://wrfrun.syize.cn.
|
|
125
86
|
# Option contains many other settings related to the scheme.
|
|
@@ -3,4 +3,5 @@
|
|
|
3
3
|
#SBATCH -n{CORE_NUM} %core num
|
|
4
4
|
#SBATCH --time=9999:00:00 %maximum run time
|
|
5
5
|
#SBATCH --output={STDOUT_LOG_PATH} %stdout output log path
|
|
6
|
-
#SBATCH --error={STDERR_LOG_PATH} %error output log path
|
|
6
|
+
#SBATCH --error={STDERR_LOG_PATH} %error output log path
|
|
7
|
+
#SBATCH -p {QUEUE_NAME}
|