foxes 1.2.2__py3-none-any.whl → 1.2.4__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.
Potentially problematic release.
This version of foxes might be problematic. Click here for more details.
- examples/field_data_nc/run.py +11 -4
- examples/streamline_wakes/run.py +6 -3
- foxes/algorithms/downwind/downwind.py +1 -0
- foxes/config/__init__.py +1 -1
- foxes/config/config.py +87 -14
- foxes/constants.py +12 -1
- foxes/core/algorithm.py +13 -8
- foxes/core/engine.py +30 -0
- foxes/core/farm_controller.py +41 -24
- foxes/core/states.py +1 -1
- foxes/core/wind_farm.py +109 -0
- foxes/engines/dask.py +88 -4
- foxes/engines/default.py +45 -2
- foxes/engines/mpi.py +5 -16
- foxes/engines/multiprocess.py +1 -10
- foxes/engines/numpy.py +30 -0
- foxes/engines/pool.py +48 -0
- foxes/engines/ray.py +1 -1
- foxes/engines/single.py +30 -0
- foxes/input/farm_layout/from_csv.py +2 -2
- foxes/input/farm_layout/from_file.py +2 -2
- foxes/input/farm_layout/from_json.py +2 -2
- foxes/input/states/__init__.py +0 -1
- foxes/input/states/create/random_abl_states.py +2 -2
- foxes/input/states/field_data_nc.py +286 -141
- foxes/input/states/multi_height.py +3 -3
- foxes/input/states/states_table.py +3 -3
- foxes/input/yaml/dict.py +83 -46
- foxes/input/yaml/windio/__init__.py +2 -1
- foxes/input/yaml/windio/read_attributes.py +17 -34
- foxes/input/yaml/windio/read_farm.py +57 -3
- foxes/input/yaml/windio/read_outputs.py +116 -56
- foxes/input/yaml/windio/{get_states.py → read_site.py} +69 -0
- foxes/input/yaml/windio/windio.py +42 -119
- foxes/input/yaml/yaml.py +3 -3
- foxes/models/model_book.py +1 -0
- foxes/models/point_models/__init__.py +1 -0
- foxes/models/point_models/ustar2ti.py +84 -0
- foxes/models/turbine_models/lookup_table.py +2 -2
- foxes/models/turbine_models/sector_management.py +2 -2
- foxes/models/turbine_models/table_factors.py +2 -2
- foxes/models/turbine_types/CpCt_file.py +2 -2
- foxes/models/turbine_types/CpCt_from_two.py +3 -3
- foxes/models/turbine_types/PCt_file.py +2 -2
- foxes/models/turbine_types/PCt_from_two.py +3 -3
- foxes/models/turbine_types/TBL_file.py +2 -2
- foxes/models/turbine_types/wsrho2PCt_from_two.py +3 -3
- foxes/models/turbine_types/wsti2PCt_from_two.py +3 -3
- foxes/output/__init__.py +1 -0
- foxes/output/output.py +5 -3
- foxes/output/slice_data.py +1 -1
- foxes/output/slices_data.py +323 -0
- foxes/output/state_turbine_table.py +11 -0
- foxes/utils/__init__.py +1 -0
- foxes/utils/load.py +12 -4
- foxes/utils/wrg_utils.py +79 -0
- foxes/utils/xarray_utils.py +14 -3
- foxes/variables.py +5 -0
- {foxes-1.2.2.dist-info → foxes-1.2.4.dist-info}/METADATA +6 -2
- {foxes-1.2.2.dist-info → foxes-1.2.4.dist-info}/RECORD +64 -62
- foxes/input/states/slice_data_nc.py +0 -687
- {foxes-1.2.2.dist-info → foxes-1.2.4.dist-info}/LICENSE +0 -0
- {foxes-1.2.2.dist-info → foxes-1.2.4.dist-info}/WHEEL +0 -0
- {foxes-1.2.2.dist-info → foxes-1.2.4.dist-info}/entry_points.txt +0 -0
- {foxes-1.2.2.dist-info → foxes-1.2.4.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import numpy as np
|
|
2
2
|
|
|
3
3
|
from foxes.utils import Dict
|
|
4
4
|
import foxes.variables as FV
|
|
@@ -7,15 +7,15 @@ import foxes.constants as FC
|
|
|
7
7
|
from .read_fields import foxes2wio
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def _read_turbine_outputs(wio_outs,
|
|
10
|
+
def _read_turbine_outputs(wio_outs, olist, algo, states_isel, verbosity):
|
|
11
11
|
"""Reads the turbine outputs request"""
|
|
12
|
-
if "turbine_outputs" in wio_outs and wio_outs["turbine_outputs"].
|
|
12
|
+
if "turbine_outputs" in wio_outs and wio_outs["turbine_outputs"].get_item(
|
|
13
13
|
"report", True
|
|
14
14
|
):
|
|
15
15
|
turbine_outputs = Dict(
|
|
16
16
|
wio_outs["turbine_outputs"], name=wio_outs.name + ".turbine_outputs"
|
|
17
17
|
)
|
|
18
|
-
turbine_nc_filename = turbine_outputs.
|
|
18
|
+
turbine_nc_filename = turbine_outputs.pop_item(
|
|
19
19
|
"turbine_nc_filename", "turbine_outputs.nc"
|
|
20
20
|
)
|
|
21
21
|
output_variables = turbine_outputs["output_variables"]
|
|
@@ -36,36 +36,44 @@ def _read_turbine_outputs(wio_outs, odict, verbosity):
|
|
|
36
36
|
}
|
|
37
37
|
)
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
isel = None
|
|
40
|
+
if states_isel is not None and len(states_isel):
|
|
41
|
+
isel = {"time": states_isel}
|
|
42
|
+
|
|
43
|
+
olist.append(
|
|
44
|
+
Dict(
|
|
45
|
+
output_type="StateTurbineTable",
|
|
46
|
+
functions=[
|
|
47
|
+
dict(
|
|
48
|
+
function="get_dataset",
|
|
49
|
+
variables=[vmap[v] for v in output_variables],
|
|
50
|
+
name_map=ivmap,
|
|
51
|
+
to_file=turbine_nc_filename,
|
|
52
|
+
round={
|
|
53
|
+
vw: FV.get_default_digits(vf) for vw, vf in vmap.items()
|
|
54
|
+
},
|
|
55
|
+
isel=isel,
|
|
56
|
+
verbosity=verbosity,
|
|
57
|
+
)
|
|
58
|
+
],
|
|
59
|
+
name=f"outputs.output{len(olist)}.StateTurbineTable",
|
|
60
|
+
)
|
|
51
61
|
)
|
|
52
62
|
|
|
53
63
|
|
|
54
|
-
def _read_flow_field(wio_outs,
|
|
64
|
+
def _read_flow_field(wio_outs, olist, algo, states_isel, verbosity):
|
|
55
65
|
"""Reads the flow field request"""
|
|
56
|
-
if "flow_field" in wio_outs and wio_outs["flow_field"].
|
|
66
|
+
if "flow_field" in wio_outs and wio_outs["flow_field"].get_item("report", True):
|
|
57
67
|
flow_field = Dict(wio_outs["flow_field"], name=wio_outs.name + ".flow_field")
|
|
58
|
-
flow_nc_filename = flow_field.
|
|
59
|
-
output_variables = flow_field.
|
|
60
|
-
|
|
68
|
+
flow_nc_filename = flow_field.pop_item("flow_nc_filename", "flow_field.nc")
|
|
69
|
+
output_variables = flow_field.pop_item("output_variables")
|
|
70
|
+
|
|
71
|
+
z_planes = Dict(
|
|
72
|
+
flow_field.pop_item("z_planes"), name=flow_field.name + ".z_planes"
|
|
73
|
+
)
|
|
61
74
|
z_sampling = z_planes["z_sampling"]
|
|
62
75
|
xy_sampling = z_planes["xy_sampling"]
|
|
63
|
-
|
|
64
|
-
flow_field.pop("cases_run", {}), name=flow_field.name + ".cases_run"
|
|
65
|
-
)
|
|
66
|
-
states_isel = cases_run.get("subset", None)
|
|
67
|
-
if "all_occurences" in cases_run and cases_run.pop("all_occurences"):
|
|
68
|
-
states_isel = None
|
|
76
|
+
|
|
69
77
|
if verbosity > 2:
|
|
70
78
|
print(" Reading flow_field")
|
|
71
79
|
print(" File name :", flow_nc_filename)
|
|
@@ -79,39 +87,76 @@ def _read_flow_field(wio_outs, odict, verbosity):
|
|
|
79
87
|
wind_direction=FV.WD,
|
|
80
88
|
)
|
|
81
89
|
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
z_list = []
|
|
91
|
+
if z_sampling == "plane_list":
|
|
92
|
+
z_list = z_planes.pop_item("z_list")
|
|
93
|
+
elif z_sampling == "hub_heights":
|
|
94
|
+
z_list = np.unique(algo.farm.get_hub_heights(algo))
|
|
95
|
+
elif z_sampling == "grid":
|
|
96
|
+
zb = z_planes.pop_item("z_bounds")
|
|
97
|
+
assert len(zb) == 2, f"Expecting two entries for z_bounds, got {zb}"
|
|
98
|
+
zn = z_planes.pop_item("z_number")
|
|
99
|
+
z_list = np.linspace(zb[0], zb[1], zn)
|
|
84
100
|
elif isinstance(z_sampling, (int, float)):
|
|
85
|
-
|
|
101
|
+
z_list = np.atleast_1d(z_sampling)
|
|
86
102
|
else:
|
|
87
103
|
raise NotImplementedError(
|
|
88
|
-
f"z_sampling '{z_sampling}'
|
|
104
|
+
f"z_sampling '{z_sampling}' is not supported. Choices: plane_list, hub_heights, grid."
|
|
89
105
|
)
|
|
90
|
-
|
|
91
|
-
if
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
z_list = np.asarray(z_list)
|
|
107
|
+
if verbosity > 2:
|
|
108
|
+
print(" z_list :", z_list)
|
|
109
|
+
|
|
110
|
+
if xy_sampling == "grid":
|
|
111
|
+
xb = z_planes.pop_item("x_bounds")
|
|
112
|
+
assert len(xb) == 2, f"Expecting two entries for x_bounds, got {xb}"
|
|
113
|
+
yb = z_planes.pop_item("y_bounds")
|
|
114
|
+
assert len(yb) == 2, f"Expecting two entries for y_bounds, got {yb}"
|
|
115
|
+
dx = z_planes.pop_item("dx")
|
|
116
|
+
dy = z_planes.pop_item("dy")
|
|
117
|
+
nx = max(int((xb[1] - xb[0]) / dx), 1) + 1
|
|
118
|
+
if (xb[1] - xb[0]) / (nx - 1) > dx:
|
|
119
|
+
nx += 1
|
|
120
|
+
ny = max(int((yb[1] - yb[0]) / dy), 1) + 1
|
|
121
|
+
if (yb[1] - yb[0]) / (ny - 1) > dy:
|
|
122
|
+
ny += 1
|
|
123
|
+
z_list = np.asarray(z_list)
|
|
124
|
+
if verbosity > 2:
|
|
125
|
+
print(" x_bounds :", xb)
|
|
126
|
+
print(" y_bounds :", yb)
|
|
127
|
+
print(" nx, ny :", (nx, ny))
|
|
128
|
+
print(" true dx :", (xb[1] - xb[0]) / (nx - 1))
|
|
129
|
+
print(" true dy :", (yb[1] - yb[0]) / (ny - 1))
|
|
130
|
+
olist.append(
|
|
131
|
+
Dict(
|
|
132
|
+
output_type="SlicesData",
|
|
133
|
+
verbosity_delta=3,
|
|
134
|
+
functions=[
|
|
135
|
+
dict(
|
|
136
|
+
function="get_states_data_xy",
|
|
137
|
+
z_list=z_list,
|
|
138
|
+
states_isel=states_isel,
|
|
139
|
+
xmin=xb[0],
|
|
140
|
+
xmax=xb[1],
|
|
141
|
+
ymin=yb[0],
|
|
142
|
+
ymax=yb[1],
|
|
143
|
+
n_img_points=(nx, ny),
|
|
144
|
+
variables=[vmap[v] for v in output_variables],
|
|
145
|
+
to_file=flow_nc_filename,
|
|
146
|
+
label_map=foxes2wio,
|
|
147
|
+
verbosity=verbosity,
|
|
148
|
+
)
|
|
149
|
+
],
|
|
150
|
+
name=f"outputs.output{len(olist)}.SliceData",
|
|
151
|
+
)
|
|
107
152
|
)
|
|
108
153
|
else:
|
|
109
154
|
raise NotImplementedError(
|
|
110
|
-
f"xy_sampling '{xy_sampling}' is not supported
|
|
155
|
+
f"xy_sampling '{xy_sampling}' is not supported. Choices: 'grid'."
|
|
111
156
|
)
|
|
112
157
|
|
|
113
158
|
|
|
114
|
-
def read_outputs(wio_outs,
|
|
159
|
+
def read_outputs(wio_outs, idict, algo, verbosity=1):
|
|
115
160
|
"""
|
|
116
161
|
Reads the windio outputs
|
|
117
162
|
|
|
@@ -119,8 +164,10 @@ def read_outputs(wio_outs, odict, verbosity=1):
|
|
|
119
164
|
----------
|
|
120
165
|
wio_outs: foxes.utils.Dict
|
|
121
166
|
The windio output data dict
|
|
122
|
-
|
|
123
|
-
The foxes
|
|
167
|
+
idict: foxes.utils.Dict
|
|
168
|
+
The foxes input data dictionary
|
|
169
|
+
algo: foxes.core.Algorithm
|
|
170
|
+
The algorithm
|
|
124
171
|
verbosity: int
|
|
125
172
|
The verbosity level, 0=silent
|
|
126
173
|
|
|
@@ -132,16 +179,29 @@ def read_outputs(wio_outs, odict, verbosity=1):
|
|
|
132
179
|
:group: input.yaml.windio
|
|
133
180
|
|
|
134
181
|
"""
|
|
135
|
-
odir = wio_outs.
|
|
182
|
+
odir = wio_outs.pop_item("output_folder", ".")
|
|
183
|
+
olist = []
|
|
136
184
|
if verbosity > 2:
|
|
137
|
-
print(" Reading
|
|
185
|
+
print(" Reading model_outputs_specification")
|
|
138
186
|
print(" Output dir:", odir)
|
|
139
187
|
print(" Contents :", [k for k in wio_outs.keys()])
|
|
140
188
|
|
|
189
|
+
# read subset:
|
|
190
|
+
cases_run = Dict(
|
|
191
|
+
wio_outs.pop_item("cases_run", {}), name=wio_outs.name + ".cases_run"
|
|
192
|
+
)
|
|
193
|
+
if cases_run.pop_item("all_occurences"):
|
|
194
|
+
states_isel = None
|
|
195
|
+
else:
|
|
196
|
+
states_isel = cases_run.pop_item("subset")
|
|
197
|
+
|
|
141
198
|
# read turbine_outputs:
|
|
142
|
-
_read_turbine_outputs(wio_outs,
|
|
199
|
+
_read_turbine_outputs(wio_outs, olist, algo, states_isel, verbosity)
|
|
143
200
|
|
|
144
201
|
# read flow field:
|
|
145
|
-
_read_flow_field(wio_outs,
|
|
202
|
+
_read_flow_field(wio_outs, olist, algo, states_isel, verbosity)
|
|
203
|
+
|
|
204
|
+
if len(olist):
|
|
205
|
+
idict["outputs"] = olist
|
|
146
206
|
|
|
147
207
|
return odir
|
|
@@ -4,9 +4,12 @@ from xarray import Dataset
|
|
|
4
4
|
from numbers import Number
|
|
5
5
|
|
|
6
6
|
from foxes.core import States
|
|
7
|
+
from foxes.utils import Dict
|
|
7
8
|
import foxes.variables as FV
|
|
8
9
|
import foxes.constants as FC
|
|
9
10
|
|
|
11
|
+
from .read_fields import read_wind_resource_field
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
def _get_profiles(coords, fields, dims, ovars, fixval, verbosity):
|
|
12
15
|
"""Read ABL profiles information
|
|
@@ -203,3 +206,69 @@ def get_states(coords, fields, dims, verbosity=1):
|
|
|
203
206
|
raise ValueError(
|
|
204
207
|
f"Failed to create states for coords {list(coords.keys())} and fields {list(fields.keys())} with dims {dims}"
|
|
205
208
|
)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def read_site(wio_dict, verbosity=1):
|
|
212
|
+
"""
|
|
213
|
+
Reads the site information
|
|
214
|
+
|
|
215
|
+
Parameters
|
|
216
|
+
----------
|
|
217
|
+
wio_dict: foxes.utils.Dict
|
|
218
|
+
The windio data
|
|
219
|
+
verbosity: int
|
|
220
|
+
The verbosity level, 0=silent
|
|
221
|
+
|
|
222
|
+
Returns
|
|
223
|
+
-------
|
|
224
|
+
states: foxes.core.States
|
|
225
|
+
The states object
|
|
226
|
+
|
|
227
|
+
:group: input.yaml.windio
|
|
228
|
+
|
|
229
|
+
"""
|
|
230
|
+
|
|
231
|
+
def _print(*args, level=1, **kwargs):
|
|
232
|
+
if verbosity >= level:
|
|
233
|
+
print(*args, **kwargs)
|
|
234
|
+
|
|
235
|
+
wio_site = Dict(wio_dict["site"], name=wio_dict.name + ".site")
|
|
236
|
+
_print("Reading site")
|
|
237
|
+
_print(" Name:", wio_site.pop_item("name", None))
|
|
238
|
+
_print(" Contents:", [k for k in wio_site.keys()])
|
|
239
|
+
_print(" Ignoring boundaries", level=2)
|
|
240
|
+
|
|
241
|
+
# read energy_resource:
|
|
242
|
+
energy_resource = Dict(
|
|
243
|
+
wio_site["energy_resource"], name=wio_site.name + ".energy_resource"
|
|
244
|
+
)
|
|
245
|
+
_print(" Reading energy_resource", level=2)
|
|
246
|
+
_print(" Name:", energy_resource.pop_item("name", None), level=2)
|
|
247
|
+
_print(" Contents:", [k for k in energy_resource.keys()], level=2)
|
|
248
|
+
|
|
249
|
+
# read wind_resource:
|
|
250
|
+
wind_resource = Dict(
|
|
251
|
+
energy_resource["wind_resource"], name=energy_resource.name + ".wind_resource"
|
|
252
|
+
)
|
|
253
|
+
_print(" Reading wind_resource", level=3)
|
|
254
|
+
_print(" Name:", wind_resource.pop_item("name", None), level=3)
|
|
255
|
+
_print(" Contents:", [k for k in wind_resource.keys()], level=3)
|
|
256
|
+
|
|
257
|
+
# read fields
|
|
258
|
+
coords = Dict(name="coords")
|
|
259
|
+
fields = Dict(name="fields")
|
|
260
|
+
dims = Dict(name="dims")
|
|
261
|
+
for n, d in wind_resource.items():
|
|
262
|
+
read_wind_resource_field(n, d, coords, fields, dims, verbosity)
|
|
263
|
+
if verbosity > 2:
|
|
264
|
+
print(" Coords:")
|
|
265
|
+
for c, d in coords.items():
|
|
266
|
+
print(f" {c}: Shape {d.shape}")
|
|
267
|
+
print(" Fields:")
|
|
268
|
+
for f, d in dims.items():
|
|
269
|
+
if len(d):
|
|
270
|
+
print(f" {f}: Dims {d}, shape {fields[f].shape}")
|
|
271
|
+
else:
|
|
272
|
+
print(f" {f} = {fields[f]}")
|
|
273
|
+
|
|
274
|
+
return get_states(coords, fields, dims, verbosity)
|
|
@@ -1,103 +1,17 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
|
|
4
|
-
from foxes.core import
|
|
4
|
+
from foxes.core import Algorithm
|
|
5
5
|
from foxes.models import ModelBook
|
|
6
6
|
from foxes.utils import import_module, Dict
|
|
7
7
|
|
|
8
|
-
from .
|
|
9
|
-
from .
|
|
10
|
-
from .read_farm import read_layout, read_turbine_types
|
|
8
|
+
from .read_site import read_site
|
|
9
|
+
from .read_farm import read_farm
|
|
11
10
|
from .read_attributes import read_attributes
|
|
11
|
+
from .read_outputs import read_outputs
|
|
12
12
|
from ..dict import run_dict
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def _read_site(wio_dict, verbosity):
|
|
16
|
-
"""Reads the site information"""
|
|
17
|
-
|
|
18
|
-
def _print(*args, level=1, **kwargs):
|
|
19
|
-
if verbosity >= level:
|
|
20
|
-
print(*args, **kwargs)
|
|
21
|
-
|
|
22
|
-
wio_site = Dict(wio_dict["site"], name=wio_dict.name + ".site")
|
|
23
|
-
_print("Reading site")
|
|
24
|
-
_print(" Name:", wio_site.pop("name", None))
|
|
25
|
-
_print(" Contents:", [k for k in wio_site.keys()])
|
|
26
|
-
_print(" Ignoring boundaries", level=2)
|
|
27
|
-
|
|
28
|
-
# read energy_resource:
|
|
29
|
-
energy_resource = Dict(
|
|
30
|
-
wio_site["energy_resource"], name=wio_site.name + ".energy_resource"
|
|
31
|
-
)
|
|
32
|
-
_print(" Reading energy_resource", level=2)
|
|
33
|
-
_print(" Name:", energy_resource.pop("name", None), level=2)
|
|
34
|
-
_print(" Contents:", [k for k in energy_resource.keys()], level=2)
|
|
35
|
-
|
|
36
|
-
# read wind_resource:
|
|
37
|
-
wind_resource = Dict(
|
|
38
|
-
energy_resource["wind_resource"], name=energy_resource.name + ".wind_resource"
|
|
39
|
-
)
|
|
40
|
-
_print(" Reading wind_resource", level=3)
|
|
41
|
-
_print(" Name:", wind_resource.pop("name", None), level=3)
|
|
42
|
-
_print(" Contents:", [k for k in wind_resource.keys()], level=3)
|
|
43
|
-
|
|
44
|
-
# read fields
|
|
45
|
-
coords = Dict(name="coords")
|
|
46
|
-
fields = Dict(name="fields")
|
|
47
|
-
dims = Dict(name="dims")
|
|
48
|
-
for n, d in wind_resource.items():
|
|
49
|
-
read_wind_resource_field(n, d, coords, fields, dims, verbosity)
|
|
50
|
-
if verbosity > 2:
|
|
51
|
-
print(" Coords:")
|
|
52
|
-
for c, d in coords.items():
|
|
53
|
-
print(f" {c}: Shape {d.shape}")
|
|
54
|
-
print(" Fields:")
|
|
55
|
-
for f, d in dims.items():
|
|
56
|
-
if len(d):
|
|
57
|
-
print(f" {f}: Dims {d}, shape {fields[f].shape}")
|
|
58
|
-
else:
|
|
59
|
-
print(f" {f} = {fields[f]}")
|
|
60
|
-
|
|
61
|
-
return get_states(coords, fields, dims, verbosity)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def _read_farm(wio_dict, mbook, verbosity):
|
|
65
|
-
"""Reads the wind farm information"""
|
|
66
|
-
wio_farm = Dict(wio_dict["wind_farm"], name=wio_dict.name + ".wind_farm")
|
|
67
|
-
if verbosity > 1:
|
|
68
|
-
print("Reading wind farm")
|
|
69
|
-
print(" Name:", wio_farm.pop("name", None))
|
|
70
|
-
print(" Contents:", [k for k in wio_farm.keys()])
|
|
71
|
-
|
|
72
|
-
# find REWS exponents:
|
|
73
|
-
try:
|
|
74
|
-
rotor_averaging = wio_dict["attributes"]["analysis"]["rotor_averaging"]
|
|
75
|
-
ws_exp_P = rotor_averaging["wind_speed_exponent_for_power"]
|
|
76
|
-
ws_exp_ct = rotor_averaging["wind_speed_exponent_for_ct"]
|
|
77
|
-
except KeyError:
|
|
78
|
-
ws_exp_P = 1
|
|
79
|
-
ws_exp_ct = 1
|
|
80
|
-
|
|
81
|
-
# read turbine type:
|
|
82
|
-
ttypes = read_turbine_types(wio_farm, mbook, ws_exp_P, ws_exp_ct, verbosity)
|
|
83
|
-
|
|
84
|
-
# read layouts and create wind farm:
|
|
85
|
-
farm = WindFarm()
|
|
86
|
-
wfarm = wio_farm["layouts"]
|
|
87
|
-
if isinstance(wfarm, dict):
|
|
88
|
-
layouts = Dict(wfarm, name=wio_farm.name + ".layouts")
|
|
89
|
-
else:
|
|
90
|
-
layouts = {str(i): l for i, l in enumerate(wfarm)}
|
|
91
|
-
layouts = Dict(layouts, name=wio_farm.name + ".layouts")
|
|
92
|
-
if verbosity > 2:
|
|
93
|
-
print(" Reading layouts")
|
|
94
|
-
print(" Contents:", [k for k in layouts.keys()])
|
|
95
|
-
for lname, ldict in layouts.items():
|
|
96
|
-
read_layout(lname, ldict, farm, ttypes, verbosity)
|
|
97
|
-
|
|
98
|
-
return farm
|
|
99
|
-
|
|
100
|
-
|
|
101
15
|
def read_windio(wio_dict, verbosity=1):
|
|
102
16
|
"""
|
|
103
17
|
Translate windio data to foxes input data
|
|
@@ -111,14 +25,12 @@ def read_windio(wio_dict, verbosity=1):
|
|
|
111
25
|
|
|
112
26
|
Returns
|
|
113
27
|
-------
|
|
114
|
-
idict: foxes.utils.Dict
|
|
28
|
+
idict: foxes.utils.Dict or dict
|
|
115
29
|
The foxes input data dictionary
|
|
116
|
-
|
|
117
|
-
The
|
|
118
|
-
|
|
119
|
-
The
|
|
120
|
-
mbook: foxes.models.ModelBook
|
|
121
|
-
The model book
|
|
30
|
+
algo: foxes.core.Algorithm
|
|
31
|
+
The algorithm
|
|
32
|
+
odir: pathlib.Path
|
|
33
|
+
The output directory
|
|
122
34
|
|
|
123
35
|
:group: input.yaml.windio
|
|
124
36
|
|
|
@@ -128,8 +40,11 @@ def read_windio(wio_dict, verbosity=1):
|
|
|
128
40
|
if verbosity >= level:
|
|
129
41
|
print(*args, **kwargs)
|
|
130
42
|
|
|
43
|
+
if not isinstance(wio_dict, Dict):
|
|
44
|
+
wio_dict = Dict(wio_dict, name="windio")
|
|
45
|
+
|
|
131
46
|
_print(f"Reading windio data")
|
|
132
|
-
_print(" Name:", wio_dict.
|
|
47
|
+
_print(" Name:", wio_dict.pop_item("name", None))
|
|
133
48
|
_print(" Contents:", [k for k in wio_dict.keys()])
|
|
134
49
|
|
|
135
50
|
idict = Dict(
|
|
@@ -141,17 +56,28 @@ def read_windio(wio_dict, verbosity=1):
|
|
|
141
56
|
verbosity=verbosity - 3,
|
|
142
57
|
),
|
|
143
58
|
calc_farm=Dict(run=True, name="wio2fxs.calc_farm"),
|
|
144
|
-
outputs=Dict(name="wio2fxs.outputs"),
|
|
145
59
|
name="wio2fxs",
|
|
146
60
|
)
|
|
147
61
|
|
|
148
62
|
mbook = ModelBook()
|
|
149
|
-
states =
|
|
150
|
-
farm =
|
|
63
|
+
states = read_site(wio_dict, verbosity)
|
|
64
|
+
farm = read_farm(wio_dict, mbook, verbosity)
|
|
65
|
+
|
|
66
|
+
wio_attrs = Dict(wio_dict["attributes"], name=wio_dict.name + ".attributes")
|
|
67
|
+
read_attributes(wio_attrs, idict, mbook, verbosity=verbosity)
|
|
151
68
|
|
|
152
|
-
|
|
69
|
+
algo = Algorithm.new(
|
|
70
|
+
farm=farm, states=states, mbook=mbook, **idict.pop_item("algorithm")
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
odir = None
|
|
74
|
+
if "model_outputs_specification" in wio_attrs:
|
|
75
|
+
outputs = Dict(
|
|
76
|
+
wio_attrs["model_outputs_specification"], name=wio_attrs.name + ".outputs"
|
|
77
|
+
)
|
|
78
|
+
odir = read_outputs(outputs, idict, algo, verbosity=verbosity)
|
|
153
79
|
|
|
154
|
-
return idict,
|
|
80
|
+
return idict, algo, odir
|
|
155
81
|
|
|
156
82
|
|
|
157
83
|
def foxes_windio():
|
|
@@ -171,7 +97,7 @@ def foxes_windio():
|
|
|
171
97
|
"yml_file",
|
|
172
98
|
help="The windio yaml file",
|
|
173
99
|
)
|
|
174
|
-
parser.add_argument("-o", "--
|
|
100
|
+
parser.add_argument("-o", "--output_dir", help="The output directory", default=None)
|
|
175
101
|
parser.add_argument("-r", "--rotor", help="The rotor model", default="centre")
|
|
176
102
|
parser.add_argument(
|
|
177
103
|
"-p", "--pwakes", help="The partial wakes models", default="centre", nargs="+"
|
|
@@ -213,15 +139,13 @@ def foxes_windio():
|
|
|
213
139
|
"--verbosity",
|
|
214
140
|
help="The verbosity level, 0 = silent",
|
|
215
141
|
type=int,
|
|
216
|
-
default=
|
|
142
|
+
default=1,
|
|
217
143
|
)
|
|
218
144
|
args = parser.parse_args()
|
|
219
145
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if v >= level:
|
|
224
|
-
print(*args, **kwargs)
|
|
146
|
+
def _print(*ags, level=1, **kwargs):
|
|
147
|
+
if args.verbosity >= level:
|
|
148
|
+
print(*ags, **kwargs)
|
|
225
149
|
|
|
226
150
|
if (
|
|
227
151
|
args.engine is not None
|
|
@@ -234,7 +158,7 @@ def foxes_windio():
|
|
|
234
158
|
n_procs=args.n_procs,
|
|
235
159
|
chunk_size_states=args.chunksize_states,
|
|
236
160
|
chunk_size_points=args.chunksize_points,
|
|
237
|
-
verbosity=
|
|
161
|
+
verbosity=args.verbosity,
|
|
238
162
|
)
|
|
239
163
|
else:
|
|
240
164
|
epars = None
|
|
@@ -243,27 +167,26 @@ def foxes_windio():
|
|
|
243
167
|
_print(f"Reading windio file {wio_file}")
|
|
244
168
|
yml_utils = import_module(
|
|
245
169
|
"windIO.utils.yml_utils",
|
|
246
|
-
|
|
170
|
+
pip_hint="pip install git+https://github.com/EUFLOW/windIO@master#egg=windIO",
|
|
171
|
+
conda_hint="",
|
|
247
172
|
)
|
|
248
173
|
|
|
249
174
|
wio = Dict(yml_utils.load_yaml(wio_file), name="windio")
|
|
250
|
-
idict,
|
|
175
|
+
idict, algo, odir = read_windio(wio, verbosity=args.verbosity)
|
|
251
176
|
|
|
252
|
-
if args.
|
|
177
|
+
if args.output_dir is not None:
|
|
253
178
|
odir = args.odir
|
|
254
179
|
|
|
255
180
|
run_dict(
|
|
256
181
|
idict,
|
|
257
|
-
|
|
258
|
-
states=states,
|
|
259
|
-
mbook=mbook,
|
|
182
|
+
algo=algo,
|
|
260
183
|
rotor_model=args.rotor,
|
|
261
184
|
partial_wakes=args.pwakes,
|
|
262
185
|
wake_models=args.wakes,
|
|
263
186
|
wake_frame=args.frame,
|
|
264
187
|
engine_pars=epars,
|
|
265
188
|
iterative=args.iterative,
|
|
266
|
-
|
|
267
|
-
|
|
189
|
+
input_dir=wio_file.parent,
|
|
190
|
+
output_dir=odir,
|
|
268
191
|
verbosity=args.verbosity,
|
|
269
192
|
)
|
foxes/input/yaml/yaml.py
CHANGED
|
@@ -23,7 +23,7 @@ def foxes_yaml():
|
|
|
23
23
|
"yml_file",
|
|
24
24
|
help="The input yaml file",
|
|
25
25
|
)
|
|
26
|
-
parser.add_argument("-o", "--
|
|
26
|
+
parser.add_argument("-o", "--output_dir", help="The output directory", default=None)
|
|
27
27
|
parser.add_argument("-r", "--rotor", help="The rotor model", default=None)
|
|
28
28
|
parser.add_argument(
|
|
29
29
|
"-p", "--pwakes", help="The partial wakes models", default=None, nargs="+"
|
|
@@ -97,7 +97,7 @@ def foxes_yaml():
|
|
|
97
97
|
wake_frame=args.frame,
|
|
98
98
|
engine_pars=epars,
|
|
99
99
|
iterative=args.iterative,
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
input_dir=fpath.parent,
|
|
101
|
+
output_dir=args.output_dir,
|
|
102
102
|
verbosity=args.verbosity,
|
|
103
103
|
)
|
foxes/models/model_book.py
CHANGED
|
@@ -83,6 +83,7 @@ class ModelBook:
|
|
|
83
83
|
"""
|
|
84
84
|
self.point_models = FDict(name="point_models")
|
|
85
85
|
self.point_models["tke2ti"] = fm.point_models.TKE2TI()
|
|
86
|
+
self.point_models["ustar2ti"] = fm.point_models.Ustar2TI()
|
|
86
87
|
|
|
87
88
|
self.rotor_models = FDict(name="rotor_models")
|
|
88
89
|
self.rotor_models["centre"] = fm.rotor_models.CentreRotor()
|