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.
- wrfrun/__init__.py +8 -3
- wrfrun/cli.py +74 -31
- 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 +136 -380
- wrfrun/core/core.py +196 -0
- wrfrun/core/error.py +35 -2
- wrfrun/core/replay.py +10 -96
- wrfrun/core/server.py +74 -32
- wrfrun/core/type.py +171 -0
- wrfrun/data.py +312 -149
- 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 +5 -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 -114
- wrfrun/model/type.py +116 -0
- wrfrun/model/utils.py +9 -19
- wrfrun/model/wrf/__init__.py +4 -9
- wrfrun/model/wrf/core.py +262 -165
- wrfrun/model/wrf/exec_wrap.py +13 -12
- wrfrun/model/wrf/geodata.py +116 -99
- wrfrun/model/wrf/log.py +103 -0
- wrfrun/model/wrf/namelist.py +92 -76
- wrfrun/model/wrf/plot.py +102 -0
- wrfrun/model/wrf/scheme.py +108 -52
- wrfrun/model/wrf/utils.py +39 -24
- wrfrun/model/wrf/vtable.py +42 -7
- wrfrun/plot/__init__.py +20 -0
- wrfrun/plot/wps.py +90 -73
- wrfrun/res/__init__.py +115 -5
- wrfrun/res/config/config.template.toml +15 -0
- wrfrun/res/config/palm.template.toml +23 -0
- wrfrun/run.py +121 -77
- wrfrun/scheduler/__init__.py +1 -0
- wrfrun/scheduler/lsf.py +4 -1
- wrfrun/scheduler/pbs.py +4 -1
- wrfrun/scheduler/script.py +19 -5
- wrfrun/scheduler/slurm.py +4 -1
- wrfrun/scheduler/utils.py +14 -2
- wrfrun/utils.py +88 -199
- wrfrun/workspace/__init__.py +8 -5
- wrfrun/workspace/core.py +21 -11
- wrfrun/workspace/palm.py +137 -0
- wrfrun/workspace/wrf.py +59 -14
- wrfrun-0.3.0.dist-info/METADATA +240 -0
- wrfrun-0.3.0.dist-info/RECORD +78 -0
- wrfrun/core/config.py +0 -767
- wrfrun/model/base.py +0 -14
- wrfrun-0.1.9.dist-info/METADATA +0 -68
- wrfrun-0.1.9.dist-info/RECORD +0 -62
- {wrfrun-0.1.9.dist-info → wrfrun-0.3.0.dist-info}/WHEEL +0 -0
- {wrfrun-0.1.9.dist-info → wrfrun-0.3.0.dist-info}/entry_points.txt +0 -0
wrfrun/model/plot.py
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
wrfrun.model.plot
|
|
3
|
+
#################
|
|
4
|
+
|
|
5
|
+
This module is used to plot domain area so users can check their domain settings before running simulation.
|
|
6
|
+
|
|
7
|
+
.. autosummary::
|
|
8
|
+
:toctree: generated/
|
|
9
|
+
|
|
10
|
+
_calculate_x_y_offset
|
|
11
|
+
create_projection
|
|
12
|
+
parse_domain_setting
|
|
13
|
+
plot_domain_area
|
|
14
|
+
generate_domain_area
|
|
15
|
+
"""
|
|
16
|
+
|
|
1
17
|
from os.path import abspath, exists
|
|
2
|
-
from typing import
|
|
18
|
+
from typing import Union
|
|
3
19
|
|
|
4
20
|
import cartopy.feature as cfeature
|
|
5
21
|
import f90nml
|
|
@@ -8,31 +24,14 @@ from cartopy import crs
|
|
|
8
24
|
from cartopy.mpl.geoaxes import GeoAxes
|
|
9
25
|
from cartopy.mpl.gridliner import LATITUDE_FORMATTER, LONGITUDE_FORMATTER
|
|
10
26
|
from haversine.haversine import Direction, Unit, inverse_haversine
|
|
27
|
+
from matplotlib.figure import Figure
|
|
11
28
|
|
|
12
|
-
from
|
|
13
|
-
from
|
|
29
|
+
from ..core import WRFRUN
|
|
30
|
+
from ..log import logger
|
|
31
|
+
from ..utils import check_path
|
|
32
|
+
from .type import DomainSetting
|
|
14
33
|
|
|
15
34
|
|
|
16
|
-
class DomainSetting(TypedDict):
|
|
17
|
-
"""
|
|
18
|
-
Domain settings which can be used to create a projection.
|
|
19
|
-
"""
|
|
20
|
-
dx: int
|
|
21
|
-
dy: int
|
|
22
|
-
e_sn: Union[list[int], tuple[int]]
|
|
23
|
-
e_we: Union[list[int], tuple[int]]
|
|
24
|
-
i_parent_start: Union[list[int], tuple[int]]
|
|
25
|
-
j_parent_start: Union[list[int], tuple[int]]
|
|
26
|
-
max_dom: int
|
|
27
|
-
parent_grid_ratio: Union[list[int], tuple[int]]
|
|
28
|
-
map_proj: Literal["lambert", "polar", "mercator", "lat-lon"]
|
|
29
|
-
ref_lat: Union[int, float]
|
|
30
|
-
ref_lon: Union[int, float]
|
|
31
|
-
truelat1: Union[int, float]
|
|
32
|
-
truelat2: Union[int, float]
|
|
33
|
-
stand_lon: Union[int, float]
|
|
34
|
-
|
|
35
|
-
|
|
36
35
|
def _calculate_x_y_offset(domain_settings: DomainSetting) -> tuple[float, float]:
|
|
37
36
|
"""
|
|
38
37
|
Calculate X and Y offset from planar origin in metres.
|
|
@@ -42,12 +41,14 @@ def _calculate_x_y_offset(domain_settings: DomainSetting) -> tuple[float, float]
|
|
|
42
41
|
:return: (X offset, Y offset)
|
|
43
42
|
:rtype: tuple
|
|
44
43
|
"""
|
|
45
|
-
false_easting = (domain_settings["
|
|
46
|
-
false_northing = (domain_settings["
|
|
44
|
+
false_easting = (domain_settings["points_x"][0] - 1) / 2 * domain_settings["resolution_x"]
|
|
45
|
+
false_northing = (domain_settings["points_y"][0] - 1) / 2 * domain_settings["resolution_y"]
|
|
47
46
|
return false_easting, false_northing
|
|
48
47
|
|
|
49
48
|
|
|
50
|
-
def create_projection(
|
|
49
|
+
def create_projection(
|
|
50
|
+
domain_settings: DomainSetting,
|
|
51
|
+
) -> Union[crs.LambertConformal, crs.NorthPolarStereo, crs.SouthPolarStereo, crs.Mercator, crs.PlateCarree]:
|
|
51
52
|
"""
|
|
52
53
|
Create a projection from domain settings which can be used to draw images.
|
|
53
54
|
|
|
@@ -59,26 +60,25 @@ def create_projection(domain_settings: DomainSetting) -> crs.Projection:
|
|
|
59
60
|
:return: Projection object and the used domain settings.
|
|
60
61
|
:rtype: (Projection, domain settings)
|
|
61
62
|
"""
|
|
62
|
-
|
|
63
|
+
# declare the proj to pass static type check
|
|
64
|
+
proj = None
|
|
63
65
|
|
|
66
|
+
match domain_settings["projection_type"]:
|
|
64
67
|
case "lat-lon":
|
|
65
|
-
proj = crs.PlateCarree(central_longitude=domain_settings["
|
|
68
|
+
proj = crs.PlateCarree(central_longitude=domain_settings["reference_lon"])
|
|
66
69
|
|
|
67
70
|
case "lambert":
|
|
68
71
|
false_easting, false_northing = _calculate_x_y_offset(domain_settings)
|
|
69
72
|
proj = crs.LambertConformal(
|
|
70
|
-
central_longitude=domain_settings["
|
|
71
|
-
central_latitude=domain_settings["
|
|
72
|
-
standard_parallels=(
|
|
73
|
-
domain_settings["truelat1"],
|
|
74
|
-
domain_settings["truelat2"]
|
|
75
|
-
),
|
|
73
|
+
central_longitude=domain_settings["reference_lon"],
|
|
74
|
+
central_latitude=domain_settings["reference_lat"],
|
|
75
|
+
standard_parallels=(domain_settings["true_lat1"], domain_settings["true_lat2"]),
|
|
76
76
|
false_easting=false_easting,
|
|
77
|
-
false_northing=false_northing
|
|
77
|
+
false_northing=false_northing,
|
|
78
78
|
)
|
|
79
79
|
|
|
80
80
|
case "polar":
|
|
81
|
-
ref_lat = domain_settings["
|
|
81
|
+
ref_lat = domain_settings["reference_lat"]
|
|
82
82
|
if ref_lat > 0:
|
|
83
83
|
proj = crs.NorthPolarStereo(central_longitude=domain_settings["stand_lon"])
|
|
84
84
|
|
|
@@ -97,17 +97,18 @@ def create_projection(domain_settings: DomainSetting) -> crs.Projection:
|
|
|
97
97
|
# ref_lat_distance = ref_lat_distance if central_latitude < 0 else -ref_lat_distance
|
|
98
98
|
# false_northing = ref_lat_distance + false_northing
|
|
99
99
|
proj = crs.Mercator(
|
|
100
|
-
central_longitude=domain_settings["
|
|
101
|
-
latitude_true_scale=domain_settings["
|
|
100
|
+
central_longitude=domain_settings["reference_lon"],
|
|
101
|
+
latitude_true_scale=domain_settings["true_lat1"],
|
|
102
102
|
# false_northing=false_northing,
|
|
103
103
|
# false_easting=false_easting
|
|
104
104
|
)
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
raise KeyError(f"Unknown projection name: {domain_settings['map_proj']}")
|
|
106
|
+
if proj is not None:
|
|
107
|
+
return proj
|
|
109
108
|
|
|
110
|
-
|
|
109
|
+
else:
|
|
110
|
+
logger.error(f"Unknown projection name: {domain_settings['projection_type']}")
|
|
111
|
+
raise KeyError(f"Unknown projection name: {domain_settings['projection_type']}")
|
|
111
112
|
|
|
112
113
|
|
|
113
114
|
def parse_domain_setting(namelist: Union[str, dict]) -> DomainSetting:
|
|
@@ -140,30 +141,26 @@ def parse_domain_setting(namelist: Union[str, dict]) -> DomainSetting:
|
|
|
140
141
|
namelist = f90nml.read(namelist).todict()
|
|
141
142
|
|
|
142
143
|
domain_setting: DomainSetting = {
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
"
|
|
144
|
+
"resolution_x": namelist["geogrid"]["dx"],
|
|
145
|
+
"resolution_y": namelist["geogrid"]["dy"],
|
|
146
|
+
"points_y": namelist["geogrid"]["e_sn"],
|
|
147
|
+
"points_x": namelist["geogrid"]["e_we"],
|
|
148
|
+
"x_parent_index": namelist["geogrid"]["i_parent_start"],
|
|
149
|
+
"y_parent_index": namelist["geogrid"]["j_parent_start"],
|
|
150
|
+
"domain_num": namelist["share"]["max_dom"],
|
|
151
|
+
"grid_spacing_ratio": namelist["geogrid"]["parent_grid_ratio"],
|
|
152
|
+
"reference_lat": namelist["geogrid"]["ref_lat"],
|
|
153
|
+
"reference_lon": namelist["geogrid"]["ref_lon"],
|
|
154
|
+
"true_lat1": namelist["geogrid"]["truelat1"],
|
|
155
|
+
"true_lat2": namelist["geogrid"]["truelat2"],
|
|
155
156
|
"stand_lon": namelist["geogrid"]["stand_lon"],
|
|
156
|
-
"
|
|
157
|
+
"projection_type": namelist["geogrid"]["map_proj"],
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
return domain_setting
|
|
160
161
|
|
|
161
162
|
|
|
162
|
-
def plot_domain_area(
|
|
163
|
-
fig: plt.Figure,
|
|
164
|
-
domain_settings: Optional[DomainSetting] = None,
|
|
165
|
-
model_name: Optional[str] = None
|
|
166
|
-
):
|
|
163
|
+
def plot_domain_area(fig: Figure, domain_settings: DomainSetting):
|
|
167
164
|
"""
|
|
168
165
|
Plot domain area based on domain settings.
|
|
169
166
|
|
|
@@ -175,74 +172,53 @@ def plot_domain_area(
|
|
|
175
172
|
:type fig: Figure
|
|
176
173
|
:param domain_settings: Dictionary contains domain settings. If None, read domain settings from ``WRFRUNConfig``.
|
|
177
174
|
:type domain_settings: DomainSetting | None
|
|
178
|
-
:param model_name: Model's name for reading domain settings.
|
|
179
|
-
:type model_name: str | None
|
|
180
175
|
"""
|
|
181
|
-
if domain_settings is None:
|
|
182
|
-
if model_name is None:
|
|
183
|
-
logger.error("You need to give 'model_name' if `domain_settings == None`")
|
|
184
|
-
raise ValueError("You need to give 'model_name' if `domain_settings == None`")
|
|
185
|
-
|
|
186
|
-
user_settings = WRFRUNConfig.get_model_config(model_name)["domain"]
|
|
187
|
-
domain_settings: DomainSetting = {
|
|
188
|
-
"dx": user_settings["dx"],
|
|
189
|
-
"dy": user_settings["dy"],
|
|
190
|
-
"e_sn": user_settings["e_sn"],
|
|
191
|
-
"e_we": user_settings["e_we"],
|
|
192
|
-
"i_parent_start": user_settings["i_parent_start"],
|
|
193
|
-
"j_parent_start": user_settings["j_parent_start"],
|
|
194
|
-
"max_dom": user_settings["domain_num"],
|
|
195
|
-
"parent_grid_ratio": user_settings["parent_grid_ratio"],
|
|
196
|
-
"ref_lat": user_settings["ref_lat"],
|
|
197
|
-
"ref_lon": user_settings["ref_lon"],
|
|
198
|
-
"truelat1": user_settings["truelat1"],
|
|
199
|
-
"truelat2": user_settings["truelat2"],
|
|
200
|
-
"stand_lon": user_settings["stand_lon"],
|
|
201
|
-
"map_proj": user_settings["map_proj"]
|
|
202
|
-
}
|
|
203
|
-
|
|
204
176
|
proj = create_projection(domain_settings)
|
|
205
177
|
|
|
206
178
|
fig.clear()
|
|
207
|
-
ax: GeoAxes = fig.add_subplot(1, 1, 1, projection=proj)
|
|
179
|
+
ax: GeoAxes = fig.add_subplot(1, 1, 1, projection=proj) # type: ignore
|
|
208
180
|
ax.coastlines(resolution="50m")
|
|
209
181
|
ax.add_feature(cfeature.OCEAN)
|
|
210
182
|
ax.add_feature(cfeature.LAND)
|
|
211
183
|
|
|
212
184
|
# set gridline attributes, close the default labels
|
|
213
185
|
grid_line = ax.gridlines(
|
|
214
|
-
draw_labels=True,
|
|
215
|
-
|
|
186
|
+
draw_labels=True,
|
|
187
|
+
dms=True,
|
|
188
|
+
linestyle=":",
|
|
189
|
+
linewidth=0.3,
|
|
190
|
+
x_inline=False,
|
|
191
|
+
y_inline=False,
|
|
192
|
+
color="k",
|
|
193
|
+
rotate_labels=None,
|
|
194
|
+
xformatter=LONGITUDE_FORMATTER,
|
|
195
|
+
yformatter=LATITUDE_FORMATTER,
|
|
216
196
|
)
|
|
217
197
|
|
|
218
198
|
# close coordinates labels on the top and right
|
|
219
199
|
grid_line.top_labels = False
|
|
220
200
|
grid_line.right_labels = False
|
|
221
201
|
|
|
222
|
-
# align coordinates labels
|
|
223
|
-
grid_line.rotate_labels = None
|
|
224
|
-
|
|
225
|
-
# set label formatter
|
|
226
|
-
grid_line.xformattter = LONGITUDE_FORMATTER
|
|
227
|
-
grid_line.yformatter = LATITUDE_FORMATTER
|
|
228
202
|
ax.set_title("Domain Configuration")
|
|
229
203
|
|
|
230
204
|
# set area range
|
|
231
|
-
|
|
205
|
+
if isinstance(proj, crs.Mercator):
|
|
206
|
+
# we may need to calculate the range of longitude and latitude
|
|
207
|
+
ref_lon = domain_settings["reference_lon"]
|
|
208
|
+
ref_lat = domain_settings["reference_lat"]
|
|
209
|
+
false_easting, false_northing = _calculate_x_y_offset(domain_settings)
|
|
210
|
+
_, start_lon = inverse_haversine((ref_lat, ref_lon), false_easting, direction=Direction.WEST, unit=Unit.METERS)
|
|
211
|
+
_, end_lon = inverse_haversine((ref_lat, ref_lon), false_easting, direction=Direction.EAST, unit=Unit.METERS)
|
|
212
|
+
start_lat, _ = inverse_haversine((ref_lat, ref_lon), false_northing, direction=Direction.SOUTH, unit=Unit.METERS)
|
|
213
|
+
end_lat, _ = inverse_haversine((ref_lat, ref_lon), false_northing, direction=Direction.NORTH, unit=Unit.METERS)
|
|
214
|
+
ax.set_extent([start_lon, end_lon, start_lat, end_lat])
|
|
232
215
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
ref_lat = domain_settings["ref_lat"]
|
|
237
|
-
false_easting, false_northing = _calculate_x_y_offset(domain_settings)
|
|
238
|
-
_, start_lon = inverse_haversine((ref_lat, ref_lon), false_easting, direction=Direction.WEST, unit=Unit.METERS)
|
|
239
|
-
_, end_lon = inverse_haversine((ref_lat, ref_lon), false_easting, direction=Direction.EAST, unit=Unit.METERS)
|
|
240
|
-
start_lat, _ = inverse_haversine((ref_lat, ref_lon), false_northing, direction=Direction.SOUTH, unit=Unit.METERS)
|
|
241
|
-
end_lat, _ = inverse_haversine((ref_lat, ref_lon), false_northing, direction=Direction.NORTH, unit=Unit.METERS)
|
|
242
|
-
ax.set_extent([start_lon, end_lon, start_lat, end_lat])
|
|
216
|
+
elif isinstance(proj, crs.LambertConformal):
|
|
217
|
+
false_easting, false_northing = _calculate_x_y_offset(domain_settings)
|
|
218
|
+
ax.set_extent([0, false_easting * 2, 0, false_northing * 2], crs=proj)
|
|
243
219
|
|
|
244
|
-
|
|
245
|
-
|
|
220
|
+
else:
|
|
221
|
+
logger.error(f"Unsupported project type: {type(proj)}")
|
|
246
222
|
|
|
247
223
|
|
|
248
224
|
def generate_domain_area():
|
|
@@ -250,23 +226,32 @@ def generate_domain_area():
|
|
|
250
226
|
Generate domain area for each model based on user's config.
|
|
251
227
|
Images are saved to the output directory with name: "${model_name}_domain.png".
|
|
252
228
|
|
|
253
|
-
:return:
|
|
254
|
-
:rtype:
|
|
229
|
+
:return: True if domain area is ploted, else False.
|
|
230
|
+
:rtype: bool
|
|
255
231
|
"""
|
|
232
|
+
WRFRUNConfig = WRFRUN.config
|
|
256
233
|
save_path = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_OUTPUT_PATH)
|
|
257
234
|
check_path(save_path)
|
|
258
235
|
save_path = abspath(save_path)
|
|
259
236
|
|
|
260
237
|
fig = plt.figure(figsize=(10.24, 10.24))
|
|
261
238
|
|
|
239
|
+
flag = False
|
|
240
|
+
|
|
262
241
|
model_configs = WRFRUNConfig["model"]
|
|
263
242
|
for model_name in model_configs:
|
|
264
|
-
|
|
243
|
+
if model_name in ["wrf"] and model_configs[model_name]["use"]:
|
|
244
|
+
namelist = model_configs[model_name]
|
|
245
|
+
plot_domain_area(fig, parse_domain_setting(namelist))
|
|
246
|
+
|
|
247
|
+
_save_path = f"{save_path}/{model_name}_domain.png"
|
|
248
|
+
fig.savefig(_save_path)
|
|
249
|
+
|
|
250
|
+
logger.info(f"Save domain image for '{model_name}' to '{_save_path}'")
|
|
265
251
|
|
|
266
|
-
|
|
267
|
-
fig.savefig(_save_path)
|
|
252
|
+
flag = True
|
|
268
253
|
|
|
269
|
-
|
|
254
|
+
return flag
|
|
270
255
|
|
|
271
256
|
|
|
272
|
-
__all__ = ["plot_domain_area", "
|
|
257
|
+
__all__ = ["plot_domain_area", "create_projection", "generate_domain_area"]
|
wrfrun/model/type.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""
|
|
2
|
+
wrfrun.model.type
|
|
3
|
+
#################
|
|
4
|
+
|
|
5
|
+
Definition of types used in ``wrfrun.model``.
|
|
6
|
+
|
|
7
|
+
.. autosummary::
|
|
8
|
+
:toctree: generated/
|
|
9
|
+
|
|
10
|
+
DomainSetting
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from typing import Literal, TypedDict, Union
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DomainSetting(TypedDict):
|
|
17
|
+
"""
|
|
18
|
+
Domain settings which can be used to create a projection.
|
|
19
|
+
|
|
20
|
+
.. py:attribute:: resolution_x
|
|
21
|
+
:type: int
|
|
22
|
+
|
|
23
|
+
Spacing of the domain 1 grid points along the longitude direction, unit: meter.
|
|
24
|
+
|
|
25
|
+
.. py:attribute:: resolution_y
|
|
26
|
+
:type: int
|
|
27
|
+
|
|
28
|
+
Spacing of the domain 1 grid points along the latitude direction, unit: meter.
|
|
29
|
+
|
|
30
|
+
.. py:attribute:: points_x
|
|
31
|
+
:type: Union[list[int], tuple[int]]
|
|
32
|
+
|
|
33
|
+
Number of the grid points along the longitude direction of each domain.
|
|
34
|
+
|
|
35
|
+
.. py:attribute:: points_y
|
|
36
|
+
:type: Union[list[int], tuple[int]]
|
|
37
|
+
|
|
38
|
+
Number of the grid points along the latitude direction of each domain.
|
|
39
|
+
|
|
40
|
+
.. py:attribute:: x_parent_index
|
|
41
|
+
:type: Union[list[int], tuple[int]]
|
|
42
|
+
|
|
43
|
+
Corresponding x index in the parent grid of the first point.
|
|
44
|
+
|
|
45
|
+
.. py:attribute:: y_parent_index
|
|
46
|
+
:type: Union[list[int], tuple[int]]
|
|
47
|
+
|
|
48
|
+
Corresponding y index in the parent grid of the first point.
|
|
49
|
+
|
|
50
|
+
.. py:attribute:: domain_num
|
|
51
|
+
:type: int
|
|
52
|
+
|
|
53
|
+
Domain number.
|
|
54
|
+
|
|
55
|
+
.. py:attribute:: grid_spacing_ratio
|
|
56
|
+
:type: Union[list[int], tuple[int]]
|
|
57
|
+
|
|
58
|
+
Ratio of the grid resolution of each domain compared to the domain 1.
|
|
59
|
+
|
|
60
|
+
.. py:attribute:: projection_type
|
|
61
|
+
:type: Literal["lambert", "polar", "mercator", "lat-lon"]
|
|
62
|
+
|
|
63
|
+
Projection type.
|
|
64
|
+
|
|
65
|
+
.. py:attribute:: reference_lat
|
|
66
|
+
:type: Union[int, float]
|
|
67
|
+
|
|
68
|
+
Reference latitude.
|
|
69
|
+
|
|
70
|
+
.. py:attribute:: reference_lon
|
|
71
|
+
:type: Union[int, float]
|
|
72
|
+
|
|
73
|
+
Reference longitude.
|
|
74
|
+
|
|
75
|
+
.. py:attribute:: true_lat1
|
|
76
|
+
:type: Union[int, float]
|
|
77
|
+
|
|
78
|
+
True latitude (1:1 scale).
|
|
79
|
+
|
|
80
|
+
.. py:attribute:: true_lat2
|
|
81
|
+
:type: Union[int, float]
|
|
82
|
+
|
|
83
|
+
True latitude (1:1 scale).
|
|
84
|
+
|
|
85
|
+
.. py:attribute:: stand_lon
|
|
86
|
+
:type: Union[int, float]
|
|
87
|
+
|
|
88
|
+
Standard longitude.
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
# generally refers to the spacing of the parent grid points along the latitude, unit: meter
|
|
92
|
+
resolution_x: int
|
|
93
|
+
# spacing of the parent grid points along the longitude, unit: meter
|
|
94
|
+
resolution_y: int
|
|
95
|
+
# generally refers to the number of the grid points along the latitude.
|
|
96
|
+
points_x: Union[list[int], tuple[int]]
|
|
97
|
+
# number of the grid points along the longitude.
|
|
98
|
+
points_y: Union[list[int], tuple[int]]
|
|
99
|
+
# corresponding index in the parent grid of the first point.
|
|
100
|
+
x_parent_index: Union[list[int], tuple[int]]
|
|
101
|
+
y_parent_index: Union[list[int], tuple[int]]
|
|
102
|
+
# domain number
|
|
103
|
+
domain_num: int
|
|
104
|
+
# ratio of the grid point spacing.
|
|
105
|
+
grid_spacing_ratio: Union[list[int], tuple[int]]
|
|
106
|
+
# projection type
|
|
107
|
+
projection_type: Literal["lambert", "polar", "mercator", "lat-lon"]
|
|
108
|
+
# reference point, true longitude and latitude
|
|
109
|
+
reference_lat: Union[int, float]
|
|
110
|
+
reference_lon: Union[int, float]
|
|
111
|
+
true_lat1: Union[int, float]
|
|
112
|
+
true_lat2: Union[int, float]
|
|
113
|
+
stand_lon: Union[int, float]
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
__all__ = ["DomainSetting"]
|
wrfrun/model/utils.py
CHANGED
|
@@ -10,12 +10,8 @@ Utility functions used by models.
|
|
|
10
10
|
clear_model_logs
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
|
|
16
|
-
from ..core import WRFRUNConfig
|
|
17
|
-
from ..utils import check_path, logger
|
|
18
|
-
from ..workspace.wrf import WORKSPACE_MODEL_WRF
|
|
13
|
+
from ..core import WRFRUN
|
|
14
|
+
from .wrf.log import clear_wrf_logs
|
|
19
15
|
|
|
20
16
|
|
|
21
17
|
def clear_model_logs():
|
|
@@ -23,21 +19,15 @@ def clear_model_logs():
|
|
|
23
19
|
This function can automatically collect unsaved log files,
|
|
24
20
|
and save them to the corresponding output directory of the ``Executable``.
|
|
25
21
|
"""
|
|
26
|
-
|
|
27
|
-
work_path = WRFRUNConfig.parse_resource_uri(WORKSPACE_MODEL_WRF)
|
|
28
|
-
|
|
29
|
-
log_files = [x for x in listdir(work_path) if x.startswith("rsl.") or x.endswith(".log")]
|
|
30
|
-
|
|
31
|
-
if len(log_files) > 0:
|
|
32
|
-
logger.warning(f"Found unprocessed log files of {work_status}")
|
|
33
|
-
|
|
34
|
-
log_save_path = f"{WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_OUTPUT_PATH)}/{work_status}/logs"
|
|
35
|
-
check_path(log_save_path)
|
|
22
|
+
WRFRUNConfig = WRFRUN.config
|
|
36
23
|
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
func_map = {
|
|
25
|
+
"wrf": clear_wrf_logs
|
|
26
|
+
}
|
|
39
27
|
|
|
40
|
-
|
|
28
|
+
for _model in func_map:
|
|
29
|
+
if _model in WRFRUNConfig["model"] and WRFRUNConfig["model"][_model]["use"]:
|
|
30
|
+
func_map[_model]()
|
|
41
31
|
|
|
42
32
|
|
|
43
33
|
__all__ = ["clear_model_logs"]
|
wrfrun/model/wrf/__init__.py
CHANGED
|
@@ -8,34 +8,29 @@ Submodules
|
|
|
8
8
|
**********
|
|
9
9
|
|
|
10
10
|
============================================ ==================================================================================
|
|
11
|
-
:doc:`_metgrid </api/model.wrf._metgrid>` Utility functions used by :class:`MetGrid <core.MetGrid>`.
|
|
12
|
-
:doc:`_ndown </api/model.wrf._ndown>` Utility functions used by :class:`NDown <core.NDown>`.
|
|
13
11
|
:doc:`core </api/model.wrf.core>` Core implementation of WRF model.
|
|
14
12
|
:doc:`exec_wrap </api/model.wrf.exec_wrap>` Function wrappers for ``Executable`` defined in :doc:`core </api/model.wrf.core>`.
|
|
15
13
|
:doc:`geodata </api/model.wrf.geodata>` Utility functions to read / write geographical static datas.
|
|
14
|
+
:doc:`log </api/model.wrf.log>` Functions to parse and clear WPS/WRF model logs.
|
|
16
15
|
:doc:`namelist </api/model.wrf.namelist>` Functions to process WPS / WRF namelist files.
|
|
17
16
|
:doc:`plot </api/model.wrf.plot>` Functions to create projection from namelist settings to plot simulation domain.
|
|
18
17
|
:doc:`scheme </api/model.wrf.scheme>` Scheme ``dataclass``.
|
|
18
|
+
:doc:`utils </api/model.wrf.utils>` Utility functions used by wrf model part.
|
|
19
19
|
:doc:`vtable </api/model.wrf.vtable>` Vtable files ``dataclass``.
|
|
20
20
|
============================================ ==================================================================================
|
|
21
21
|
|
|
22
|
-
.. autosummary::
|
|
23
|
-
:toctree: generated/
|
|
24
|
-
|
|
25
|
-
prepare_namelist
|
|
26
|
-
|
|
27
22
|
.. toctree::
|
|
28
23
|
:maxdepth: 1
|
|
29
24
|
:hidden:
|
|
30
25
|
|
|
31
|
-
_metgrid <model.wrf._metgrid>
|
|
32
|
-
_ndown <model.wrf._ndown>
|
|
33
26
|
core <model.wrf.core>
|
|
34
27
|
exec_wrap <model.wrf.exec_wrap>
|
|
35
28
|
geodata <model.wrf.geodata>
|
|
29
|
+
log <model.wrf.log>
|
|
36
30
|
namelist <model.wrf.namelist>
|
|
37
31
|
plot <model.wrf.plot>
|
|
38
32
|
scheme <model.wrf.scheme>
|
|
33
|
+
utils <model.wrf.utils>
|
|
39
34
|
vtable <model.wrf.vtable>
|
|
40
35
|
"""
|
|
41
36
|
|