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/plot/wps.py
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
wrfrun.plot.wps
|
|
3
|
+
###############
|
|
4
|
+
|
|
5
|
+
Functions to plot outputs of ``geogrid.exe``.
|
|
6
|
+
|
|
7
|
+
.. autosummary::
|
|
8
|
+
:toctree: generated/
|
|
9
|
+
|
|
10
|
+
get_cmap_ticks
|
|
11
|
+
draw_geogrid
|
|
12
|
+
"""
|
|
13
|
+
|
|
1
14
|
from typing import Tuple
|
|
2
15
|
|
|
3
16
|
from cartopy import crs
|
|
@@ -6,80 +19,83 @@ from matplotlib.collections import QuadMesh
|
|
|
6
19
|
from matplotlib.colors import ListedColormap
|
|
7
20
|
from matplotlib.figure import Figure
|
|
8
21
|
from netCDF4 import Dataset # type: ignore
|
|
9
|
-
from wrf import getvar, latlon_coords, get_cartopy, to_np
|
|
10
22
|
from xarray import DataArray
|
|
11
23
|
|
|
12
|
-
from wrfrun.
|
|
24
|
+
from wrfrun.log import logger
|
|
13
25
|
|
|
14
26
|
# Here defines the colormap for landuse and soiltype
|
|
15
|
-
LANDUSE_CMAP = ListedColormap(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
LANDUSE_CMAP = ListedColormap(
|
|
28
|
+
(
|
|
29
|
+
[0, 0.4, 0], # 1: Evergreen Needleleaf Forest
|
|
30
|
+
[0, 0.4, 0.2], # 2: Evergreen Broadleaf Forest
|
|
31
|
+
[0.2, 0.8, 0.2], # 3: Deciduous Needleleaf Forest
|
|
32
|
+
[0.2, 0.8, 0.4], # 4: Deciduous Broadleaf Forest
|
|
33
|
+
[0.2, 0.6, 0.2], # 5: Mixed Forests
|
|
34
|
+
[0.3, 0.7, 0], # 6: Closed Shrublands
|
|
35
|
+
[0.82, 0.41, 0.12], # 7: Open Shurblands
|
|
36
|
+
[0.74, 0.71, 0.41], # 8: Woody Savannas
|
|
37
|
+
[1, 0.84, 0.0], # 9: Savannas
|
|
38
|
+
[0, 1, 0], # 10: Grasslands
|
|
39
|
+
[0, 1, 1], # 11: Permanent Wetlands
|
|
40
|
+
[1, 1, 0], # 12: Croplands
|
|
41
|
+
[1, 0, 0], # 13: Urban and Built-up
|
|
42
|
+
[0.7, 0.9, 0.3], # 14: Cropland/Natual Vegation Mosaic
|
|
43
|
+
[1, 1, 1], # 15: Snow and Ice
|
|
44
|
+
[0.914, 0.914, 0.7], # 16: Barren or Sparsely Vegetated
|
|
45
|
+
[0.5, 0.7, 1], # 17: Water (like oceans)
|
|
46
|
+
[0.86, 0.08, 0.23], # 18: Wooded Tundra
|
|
47
|
+
[0.97, 0.5, 0.31], # 19: Mixed Tundra
|
|
48
|
+
[0.91, 0.59, 0.48], # 20: Barren Tundra
|
|
49
|
+
[0, 0, 0.88], # 21: Lake
|
|
50
|
+
)
|
|
51
|
+
)
|
|
38
52
|
|
|
39
53
|
LANDUSE_LABELS = [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
"Evergreen Needleleaf Forest",
|
|
55
|
+
"Evergreen Broadleaf Forest",
|
|
56
|
+
"Deciduous Needleleaf Forest",
|
|
57
|
+
"Deciduous Broadleaf Forest",
|
|
58
|
+
"Mixed Forests",
|
|
59
|
+
"Closed Shrublands",
|
|
60
|
+
"Open Shrublands",
|
|
61
|
+
"Woody Savannas",
|
|
62
|
+
"Savannas",
|
|
63
|
+
"Grasslands",
|
|
64
|
+
"Permanent Wetlands",
|
|
65
|
+
"Croplands",
|
|
66
|
+
"Urban and Built-Up",
|
|
67
|
+
"Cropland/Natural Vegetation Mosaic",
|
|
68
|
+
"Snow and Ice",
|
|
69
|
+
"Barren or Sparsely Vegetated",
|
|
70
|
+
"Water",
|
|
71
|
+
"Wooded Tundra",
|
|
72
|
+
"Mixed Tundra",
|
|
73
|
+
"Barren Tundra",
|
|
74
|
+
"Lake",
|
|
61
75
|
]
|
|
62
76
|
|
|
63
77
|
|
|
64
78
|
# Here defines the colormap and labels for soil types
|
|
65
|
-
SOILTYPE_CMAP = ListedColormap(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
SOILTYPE_CMAP = ListedColormap(
|
|
80
|
+
(
|
|
81
|
+
[0, 0.4, 0], # 1: Sand
|
|
82
|
+
[0, 0.4, 0.2], # 2: Loamy Sand
|
|
83
|
+
[0.2, 0.8, 0.2], # 3: Sandy Loam
|
|
84
|
+
[0.2, 0.8, 0.4], # 4: Silt Loam
|
|
85
|
+
[0.2, 0.6, 0.2], # 5: Silt
|
|
86
|
+
[0.3, 0.7, 0], # 6: Loam
|
|
87
|
+
[0.82, 0.41, 0.12], # 7: Sandy Clay Loam
|
|
88
|
+
[0.74, 0.71, 0.41], # 8: Silty Clay Loam
|
|
89
|
+
[1, 0.84, 0.0], # 9: Clay Loam
|
|
90
|
+
[0, 1, 0], # 10: Sandy Clay
|
|
91
|
+
[0, 1, 1], # 11: Silty Clay
|
|
92
|
+
[1, 1, 0], # 12: Clay
|
|
93
|
+
[1, 0, 0], # 13: Organic Material
|
|
94
|
+
[0.7, 0.9, 0.3], # 14: Water
|
|
95
|
+
[1, 1, 1], # 15: Bedrock
|
|
96
|
+
[0.914, 0.914, 0.7], # 16: Other
|
|
97
|
+
)
|
|
98
|
+
)
|
|
83
99
|
|
|
84
100
|
SOILTYPE_LABELS = [
|
|
85
101
|
"Sand",
|
|
@@ -97,7 +113,7 @@ SOILTYPE_LABELS = [
|
|
|
97
113
|
"Organic Material",
|
|
98
114
|
"Water",
|
|
99
115
|
"Bedrock",
|
|
100
|
-
"Other"
|
|
116
|
+
"Other",
|
|
101
117
|
]
|
|
102
118
|
|
|
103
119
|
|
|
@@ -159,15 +175,24 @@ def draw_geogrid(data_path: str, field: str, fig: Figure, nrow: int, ncol: int,
|
|
|
159
175
|
:return: (GeoAxes, QuadMesh)
|
|
160
176
|
:rtype: tuple
|
|
161
177
|
"""
|
|
178
|
+
# lazy import
|
|
179
|
+
try:
|
|
180
|
+
from wrf import get_cartopy, getvar, latlon_coords, to_np
|
|
181
|
+
|
|
182
|
+
except ImportError:
|
|
183
|
+
logger.error("Currently `wrf-python` isn't list as `wrfrun` dependency.")
|
|
184
|
+
logger.error("You need to install `wrf-python` package to use this feature.")
|
|
185
|
+
exit(1)
|
|
186
|
+
|
|
162
187
|
# take out data
|
|
163
|
-
data: DataArray = getvar(Dataset(data_path), field)
|
|
188
|
+
data: DataArray = getvar(Dataset(data_path), field) # type: ignore
|
|
164
189
|
|
|
165
190
|
# soiltype data is different from landuse data
|
|
166
191
|
if field in ["SOILCTOP", "SOILCBOT"]:
|
|
167
|
-
data = data.argmax(dim="soil_cat", keep_attrs=True)
|
|
192
|
+
data = data.argmax(dim="soil_cat", keep_attrs=True) # type: ignore
|
|
168
193
|
# get data attrs
|
|
169
194
|
data_attrs = data.attrs
|
|
170
|
-
data = data + 1
|
|
195
|
+
data = data + 1 # type: ignore
|
|
171
196
|
data.attrs = data_attrs
|
|
172
197
|
|
|
173
198
|
# get latitude and longitude
|
|
@@ -183,14 +208,12 @@ def draw_geogrid(data_path: str, field: str, fig: Figure, nrow: int, ncol: int,
|
|
|
183
208
|
cmap, labels, ticks = get_cmap_ticks(field)
|
|
184
209
|
|
|
185
210
|
# convert data to numpy
|
|
186
|
-
data, lats, lons = to_np(data), to_np(lats), to_np(lons)
|
|
211
|
+
data, lats, lons = to_np(data), to_np(lats), to_np(lons) # type: ignore
|
|
187
212
|
|
|
188
213
|
# plot
|
|
189
|
-
im = ax.pcolormesh(
|
|
190
|
-
lons, lats, data, vmin=1, vmax=len(labels) + 1, cmap=cmap, transform=crs.PlateCarree()
|
|
191
|
-
)
|
|
214
|
+
im = ax.pcolormesh(lons, lats, data, vmin=1, vmax=len(labels) + 1, cmap=cmap, transform=crs.PlateCarree())
|
|
192
215
|
|
|
193
|
-
return ax, im
|
|
216
|
+
return ax, im # type: ignore
|
|
194
217
|
|
|
195
218
|
|
|
196
219
|
__all__ = ["draw_geogrid", "get_cmap_ticks"]
|
wrfrun/res/__init__.py
CHANGED
|
@@ -1,7 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
"""
|
|
2
|
+
wrfrun.res
|
|
3
|
+
##########
|
|
4
|
+
|
|
5
|
+
This module contains resources used by other wrfrun modules.
|
|
6
|
+
|
|
7
|
+
A ``__init__.py`` file will be generated by ``generate_init.py`` when building the package.
|
|
8
|
+
|
|
9
|
+
The main resource directory and each subdirectory has a ``name_map.json`` file,
|
|
10
|
+
which maps real name of files or directories to a simpler name.
|
|
11
|
+
``generate_init.py`` reads these JSON and generates variable names based on the name inside it.
|
|
12
|
+
|
|
13
|
+
For example, assume we have a directory which structure is like:
|
|
14
|
+
|
|
15
|
+
.. code-block::
|
|
16
|
+
|
|
17
|
+
res
|
|
18
|
+
|
|
|
19
|
+
|---extension
|
|
20
|
+
| |
|
|
21
|
+
| |---plotgrids.ncl
|
|
22
|
+
| ----name_map.json
|
|
23
|
+
|
|
|
24
|
+
|---job_scheduler
|
|
25
|
+
| |
|
|
26
|
+
| |---pbs.template
|
|
27
|
+
| ----name_map.json
|
|
28
|
+
|
|
|
29
|
+
|---config.yaml.template
|
|
30
|
+
----name_map.json
|
|
31
|
+
|
|
32
|
+
And the content of each ``name_map.json`` is:
|
|
33
|
+
|
|
34
|
+
.. code-block:: json
|
|
35
|
+
:caption: name_map.json
|
|
36
|
+
|
|
37
|
+
{
|
|
38
|
+
"extension": {
|
|
39
|
+
"name": "EXT",
|
|
40
|
+
"type": "dir",
|
|
41
|
+
},
|
|
42
|
+
"job_scheduler": {
|
|
43
|
+
"name": "JOBSYS",
|
|
44
|
+
"type": "dir",
|
|
45
|
+
},
|
|
46
|
+
"config.yaml.template": {
|
|
47
|
+
"name": "CONFIG_TEMPLATE",
|
|
48
|
+
"type": "file",
|
|
49
|
+
}
|
|
50
|
+
}
|
|
2
51
|
|
|
3
|
-
|
|
52
|
+
.. code-block:: json
|
|
53
|
+
:caption: name_map.json
|
|
54
|
+
|
|
55
|
+
{
|
|
56
|
+
"plotgrids.ncl": {
|
|
57
|
+
"name": "PLOT_DOMAIN_NCL",
|
|
58
|
+
"type": "file",
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.. code-block:: json
|
|
63
|
+
:caption: name_map.json
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
"pbs.template": {
|
|
67
|
+
"name": "PBS_TEMPLATE",
|
|
68
|
+
"type": "file",
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
Then, the generated variable names in ``__init__.py`` are:
|
|
73
|
+
|
|
74
|
+
.. code-block:: python
|
|
75
|
+
:caption: __init__.py
|
|
76
|
+
|
|
77
|
+
EXT_PLOT_DOMAIN_NCL = "..."
|
|
78
|
+
JOBSYS_PBS_TEMPLATE = "..."
|
|
79
|
+
CONFIG_TEMPLATE = "..."
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
# This file is generated by scripts `wrfrun/res/generate_init.py`.
|
|
83
|
+
# Don't change this file directly.
|
|
84
|
+
|
|
85
|
+
from os.path import abspath, dirname
|
|
4
86
|
|
|
87
|
+
from wrfrun.core import WRFRUN, WRFRunConfig
|
|
5
88
|
|
|
6
89
|
RES_PATH = abspath(dirname(__file__))
|
|
7
90
|
|
|
@@ -10,7 +93,7 @@ def _register_res_uri(wrfrun_config: WRFRunConfig):
|
|
|
10
93
|
wrfrun_config.register_resource_uri(wrfrun_config.WRFRUN_RESOURCE_PATH, RES_PATH)
|
|
11
94
|
|
|
12
95
|
|
|
13
|
-
|
|
96
|
+
WRFRUN.set_config_register_func(_register_res_uri)
|
|
14
97
|
|
|
15
98
|
|
|
16
99
|
RUN_SH_TEMPLATE = ":WRFRUN_RESOURCE_PATH:/run.template.sh"
|
|
@@ -25,13 +108,28 @@ NAMELIST_WRF = ":WRFRUN_RESOURCE_PATH:/namelist/namelist.input.wrf.template"
|
|
|
25
108
|
NAMELIST_WPS = ":WRFRUN_RESOURCE_PATH:/namelist/namelist.wps.template"
|
|
26
109
|
CONFIG_MAIN_TOML_TEMPLATE = ":WRFRUN_RESOURCE_PATH:/config/config.template.toml"
|
|
27
110
|
CONFIG_WRF_TOML_TEMPLATE = ":WRFRUN_RESOURCE_PATH:/config/wrf.template.toml"
|
|
111
|
+
CONFIG_PALM_TOML_TEMPLATE = ":WRFRUN_RESOURCE_PATH:/config/palm.template.toml"
|
|
28
112
|
|
|
29
113
|
|
|
30
114
|
def _set_config_template_path(wrfrun_config: WRFRunConfig):
|
|
31
115
|
wrfrun_config.set_config_template_path(CONFIG_MAIN_TOML_TEMPLATE)
|
|
32
116
|
|
|
33
117
|
|
|
34
|
-
|
|
118
|
+
WRFRUN.set_config_register_func(_set_config_template_path)
|
|
35
119
|
|
|
36
120
|
|
|
37
|
-
__all__ = [
|
|
121
|
+
__all__ = [
|
|
122
|
+
"RUN_SH_TEMPLATE",
|
|
123
|
+
"EXT_NCL_PLOT_SCRIPT",
|
|
124
|
+
"SCHEDULER_LSF_TEMPLATE",
|
|
125
|
+
"SCHEDULER_PBS_TEMPLATE",
|
|
126
|
+
"SCHEDULER_SLURM_TEMPLATE",
|
|
127
|
+
"NAMELIST_WRFDA",
|
|
128
|
+
"NAMELIST_DFI",
|
|
129
|
+
"NAMELIST_REAL",
|
|
130
|
+
"NAMELIST_WRF",
|
|
131
|
+
"NAMELIST_WPS",
|
|
132
|
+
"CONFIG_MAIN_TOML_TEMPLATE",
|
|
133
|
+
"CONFIG_WRF_TOML_TEMPLATE",
|
|
134
|
+
"CONFIG_PALM_TOML_TEMPLATE",
|
|
135
|
+
]
|
|
@@ -55,3 +55,11 @@ use = false
|
|
|
55
55
|
# You can give both absolute and relative path.
|
|
56
56
|
# The relative path is resolved based on this configuration file.
|
|
57
57
|
include = "./configs/wrf.toml"
|
|
58
|
+
|
|
59
|
+
[model.palm]
|
|
60
|
+
# If you want to use PALM model, set use to true.
|
|
61
|
+
use = false
|
|
62
|
+
# Import configurations from another toml file.
|
|
63
|
+
# You can give both absolute and relative path.
|
|
64
|
+
# The relative path is resolved based on this configuration file.
|
|
65
|
+
include = "./configs/palm.toml"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Config for PALM model.
|
|
2
|
+
# PALM model path.
|
|
3
|
+
palm_path = "/path/to/your/PALM/folder"
|
|
4
|
+
|
|
5
|
+
# Place data here.
|
|
6
|
+
data_dir_path = "/path/to/your/data/folder"
|
|
7
|
+
|
|
8
|
+
# Set PALM config identifier here.
|
|
9
|
+
# If you want to use a config identifier you never used before,
|
|
10
|
+
# make sure palm can build successfully.
|
|
11
|
+
config_identifier = "wrfrun"
|
|
12
|
+
|
|
13
|
+
# PALM config file.
|
|
14
|
+
# If empty, use the default config from PALM.
|
|
15
|
+
# You can get a file from PALM_INSTALL_DIR/.palm.config.default
|
|
16
|
+
config_file_path = ""
|
|
17
|
+
|
|
18
|
+
# You can provide topography file here.
|
|
19
|
+
topography_file = '/path/to/your/topography/file'
|
|
20
|
+
|
|
21
|
+
# You need to give your namelist file,
|
|
22
|
+
# cause wrfrun hasn't supported more options in toml config file yet.
|
|
23
|
+
user_namelist = '/path/to/your/namelist/file'
|