foxes 0.5.1__py3-none-any.whl → 0.5.2__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.
- foxes/VERSION +1 -1
- foxes/algorithms/downwind/downwind.py +41 -46
- foxes/algorithms/downwind/models/point_wakes_calc.py +4 -9
- foxes/algorithms/downwind/models/set_amb_point_results.py +5 -22
- foxes/core/algorithm.py +1 -1
- foxes/core/data_calc_model.py +26 -2
- foxes/core/partial_wakes_model.py +1 -1
- foxes/core/rotor_model.py +36 -2
- foxes/core/turbine_model.py +36 -0
- foxes/core/turbine_type.py +35 -1
- foxes/core/wake_frame.py +39 -3
- foxes/core/wake_model.py +36 -0
- foxes/models/model_book.py +132 -85
- foxes/models/turbine_models/rotor_centre_calc.py +1 -2
- foxes/models/turbine_types/CpCt_file.py +13 -3
- foxes/models/turbine_types/CpCt_from_two.py +14 -4
- foxes/models/vertical_profiles/abl_log_neutral_ws.py +32 -5
- foxes/models/vertical_profiles/abl_log_stable_ws.py +32 -4
- foxes/models/vertical_profiles/abl_log_unstable_ws.py +32 -4
- foxes/models/vertical_profiles/abl_log_ws.py +50 -18
- foxes/models/wake_frames/yawed_wakes.py +15 -9
- foxes/models/wake_models/induction/__init__.py +1 -1
- foxes/models/wake_models/induction/rankine_half_body.py +33 -7
- foxes/models/wake_models/ti/crespo_hernandez.py +6 -1
- foxes/models/wake_models/ti/iec_ti.py +5 -3
- foxes/models/wake_models/wind/__init__.py +2 -2
- foxes/models/wake_models/wind/{bastankhah.py → bastankhah14.py} +11 -14
- foxes/models/wake_models/wind/{porte_agel.py → bastankhah16.py} +24 -16
- foxes/models/wake_models/wind/turbopark.py +11 -22
- foxes/models/wake_superpositions/__init__.py +9 -5
- foxes/models/wake_superpositions/ti_linear.py +134 -0
- foxes/models/wake_superpositions/ti_max.py +134 -0
- foxes/models/wake_superpositions/{ti_superp.py → ti_pow.py} +15 -57
- foxes/models/wake_superpositions/ti_quadratic.py +134 -0
- foxes/models/wake_superpositions/ws_linear.py +170 -0
- foxes/models/wake_superpositions/ws_max.py +173 -0
- foxes/models/wake_superpositions/ws_pow.py +175 -0
- foxes/models/wake_superpositions/{product.py → ws_product.py} +43 -22
- foxes/models/wake_superpositions/ws_quadratic.py +170 -0
- foxes/output/__init__.py +4 -0
- foxes/output/calc_points.py +143 -0
- foxes/output/flow_plots_2d/__init__.py +1 -0
- foxes/output/flow_plots_2d/common.py +104 -1
- foxes/output/flow_plots_2d/flow_plots.py +237 -569
- foxes/output/flow_plots_2d/get_fig.py +183 -0
- foxes/output/flow_plots_2d/seq_flow_ani_plugin.py +0 -1
- foxes/output/grids.py +705 -0
- foxes/output/output.py +58 -11
- foxes/output/results_writer.py +101 -17
- foxes/output/round.py +10 -0
- foxes/output/slice_data.py +900 -0
- foxes/utils/__init__.py +5 -3
- foxes/utils/exec_python.py +56 -0
- foxes/utils/geopandas_utils.py +294 -0
- foxes/utils/pandas_utils.py +175 -0
- foxes/utils/plotly_utils.py +19 -0
- foxes/utils/xarray_utils.py +38 -0
- {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/METADATA +1 -1
- {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/RECORD +63 -49
- foxes/models/wake_superpositions/linear.py +0 -242
- foxes/models/wake_superpositions/max.py +0 -258
- foxes/models/wake_superpositions/quadratic.py +0 -252
- {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/LICENSE +0 -0
- {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/WHEEL +0 -0
- {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/top_level.txt +0 -0
- {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/zip-safe +0 -0
|
@@ -1,82 +1,39 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
|
-
from foxes.output import
|
|
4
|
-
import foxes.constants as FC
|
|
3
|
+
from foxes.output import SliceData
|
|
5
4
|
import foxes.variables as FV
|
|
6
5
|
|
|
7
|
-
from .
|
|
8
|
-
get_grid_xy,
|
|
9
|
-
get_grid_xz,
|
|
10
|
-
get_grid_yz,
|
|
11
|
-
calc_point_results,
|
|
12
|
-
get_fig,
|
|
13
|
-
)
|
|
6
|
+
from .get_fig import get_fig
|
|
14
7
|
|
|
15
8
|
|
|
16
|
-
class FlowPlots2D(
|
|
9
|
+
class FlowPlots2D(SliceData):
|
|
17
10
|
"""
|
|
18
11
|
Class for horizontal or vertical 2D flow plots
|
|
19
12
|
|
|
20
|
-
Attributes
|
|
21
|
-
----------
|
|
22
|
-
algo: foxes.Algorithm
|
|
23
|
-
The algorithm for point calculation
|
|
24
|
-
farm_results: xarray.Dataset
|
|
25
|
-
The farm results
|
|
26
|
-
runner: foxes.utils.runners.Runner, optional
|
|
27
|
-
The runner
|
|
28
|
-
|
|
29
13
|
:group: output.flow_plots_2d
|
|
30
14
|
|
|
31
15
|
"""
|
|
32
16
|
|
|
33
|
-
def __init__(self, algo, farm_results, runner=None):
|
|
34
|
-
"""
|
|
35
|
-
Constructor.
|
|
36
|
-
|
|
37
|
-
Parameters
|
|
38
|
-
----------
|
|
39
|
-
algo: foxes.Algorithm
|
|
40
|
-
The algorithm for point calculation
|
|
41
|
-
farm_results: xarray.Dataset
|
|
42
|
-
The farm results
|
|
43
|
-
runner: foxes.utils.runners.Runner, optional
|
|
44
|
-
The runner
|
|
45
|
-
|
|
46
|
-
"""
|
|
47
|
-
self.algo = algo
|
|
48
|
-
self.fres = farm_results
|
|
49
|
-
self.runner = runner
|
|
50
|
-
|
|
51
17
|
def get_mean_fig_xy(
|
|
52
18
|
self,
|
|
53
19
|
var,
|
|
54
|
-
resolution,
|
|
55
|
-
xmin=None,
|
|
56
|
-
ymin=None,
|
|
57
|
-
xmax=None,
|
|
58
|
-
ymax=None,
|
|
59
20
|
xlabel="x [m]",
|
|
60
21
|
ylabel="y [m]",
|
|
61
|
-
z=None,
|
|
62
|
-
xspace=500.0,
|
|
63
|
-
yspace=500.0,
|
|
64
22
|
levels=None,
|
|
65
|
-
vmin=None,
|
|
66
|
-
vmax=None,
|
|
67
23
|
figsize=None,
|
|
68
|
-
normalize_xy=None,
|
|
69
|
-
normalize_var=None,
|
|
70
24
|
title=None,
|
|
71
25
|
vlabel=None,
|
|
72
26
|
fig=None,
|
|
73
27
|
ax=None,
|
|
74
28
|
add_bar=True,
|
|
75
29
|
cmap=None,
|
|
76
|
-
|
|
77
|
-
|
|
30
|
+
vmin=None,
|
|
31
|
+
vmax=None,
|
|
32
|
+
quiver_n=None,
|
|
33
|
+
quiver_pars={},
|
|
78
34
|
ret_state=False,
|
|
79
35
|
ret_im=False,
|
|
36
|
+
ret_data=False,
|
|
80
37
|
animated=False,
|
|
81
38
|
**kwargs,
|
|
82
39
|
):
|
|
@@ -87,38 +44,14 @@ class FlowPlots2D(Output):
|
|
|
87
44
|
----------
|
|
88
45
|
var: str
|
|
89
46
|
The variable name
|
|
90
|
-
resolution: float
|
|
91
|
-
The resolution in m
|
|
92
|
-
xmin: float, optional
|
|
93
|
-
The min x coordinate, or None for automatic
|
|
94
|
-
ymin: float, optional
|
|
95
|
-
The min y coordinate, or None for automatic
|
|
96
|
-
xmax: float, optional
|
|
97
|
-
The max x coordinate, or None for automatic
|
|
98
|
-
ymax: float, optional
|
|
99
|
-
The max y coordinate, or None for automatic
|
|
100
47
|
xlabel: str, optional
|
|
101
48
|
The x axis label
|
|
102
49
|
ylabel: str, optional
|
|
103
50
|
The y axis label
|
|
104
|
-
z: float, optional
|
|
105
|
-
The z coordinate of the plane
|
|
106
|
-
xspace: float, optional
|
|
107
|
-
The extra space in x direction, before and after wind farm
|
|
108
|
-
yspace: float, optional
|
|
109
|
-
The extra space in y direction, before and after wind farm
|
|
110
51
|
levels: int, optional
|
|
111
52
|
The number of levels for the contourf plot, or None for pure image
|
|
112
|
-
vmin: float, optional
|
|
113
|
-
Minimum variable value
|
|
114
|
-
vmax: float, optional
|
|
115
|
-
Maximum variable value
|
|
116
53
|
figsize: tuple, optional
|
|
117
54
|
The figsize for plt.Figure
|
|
118
|
-
normalize_xy: float, optional
|
|
119
|
-
Divide x and y by this value
|
|
120
|
-
normalize_var: float, optional
|
|
121
|
-
Divide the variable by this value
|
|
122
55
|
title: str, optional
|
|
123
56
|
The title
|
|
124
57
|
vlabel: str, optional
|
|
@@ -131,22 +64,27 @@ class FlowPlots2D(Output):
|
|
|
131
64
|
Add a color bar
|
|
132
65
|
cmap: str, optional
|
|
133
66
|
The colormap
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
The
|
|
67
|
+
vmin: float, optional
|
|
68
|
+
The minimal variable value
|
|
69
|
+
vmax: float, optional
|
|
70
|
+
The maximal variable value
|
|
71
|
+
quiver_n: int, optional
|
|
72
|
+
Place a vector at each `n`th point
|
|
73
|
+
quiver_pars: dict, optional
|
|
74
|
+
Parameters for plt.quiver
|
|
138
75
|
ret_state: bool
|
|
139
76
|
Flag for state index return
|
|
140
77
|
ret_im: bool
|
|
141
78
|
Flag for image return
|
|
79
|
+
ret_data: bool
|
|
80
|
+
Flag for returning image data
|
|
142
81
|
animated: bool
|
|
143
82
|
Switch for usage for an animation
|
|
144
83
|
kwargs: dict, optional
|
|
145
|
-
|
|
146
|
-
function.
|
|
84
|
+
Additional parameters for SliceData.get_mean_data_xy
|
|
147
85
|
|
|
148
|
-
|
|
149
|
-
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
150
88
|
fig: matplotlib.Figure
|
|
151
89
|
The figure object
|
|
152
90
|
si: int, optional
|
|
@@ -154,145 +92,109 @@ class FlowPlots2D(Output):
|
|
|
154
92
|
im: tuple, optional
|
|
155
93
|
The image objects, matplotlib.collections.QuadMesh
|
|
156
94
|
or matplotlib.QuadContourSet
|
|
95
|
+
data: numpy.ndarray, optional
|
|
96
|
+
The image data, shape: (n_x, n_y)
|
|
157
97
|
|
|
158
98
|
"""
|
|
99
|
+
variables = list(set([var]+[FV.WD, FV.WS]))
|
|
100
|
+
vi = variables.index(var)
|
|
101
|
+
wdi = variables.index(FV.WD)
|
|
102
|
+
wsi = variables.index(FV.WS)
|
|
159
103
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
# calculate point results:
|
|
166
|
-
data = calc_point_results(
|
|
167
|
-
algo=self.algo,
|
|
168
|
-
farm_results=self.fres,
|
|
169
|
-
g_pts=g_pts,
|
|
170
|
-
verbosity=verbosity,
|
|
171
|
-
**kwargs,
|
|
172
|
-
)[var].to_numpy()
|
|
173
|
-
|
|
174
|
-
# take mean over states:
|
|
175
|
-
weights = self.fres[FV.WEIGHT][:, weight_turbine].to_numpy()
|
|
176
|
-
data = np.einsum("s,sp->p", weights, data)[None]
|
|
177
|
-
|
|
178
|
-
# find data min max:
|
|
179
|
-
vmin = vmin if vmin is not None else np.nanmin(data)
|
|
180
|
-
vmax = vmax if vmax is not None else np.nanmax(data)
|
|
181
|
-
if normalize_var is not None:
|
|
182
|
-
vmin /= normalize_var
|
|
183
|
-
vmax /= normalize_var
|
|
184
|
-
|
|
185
|
-
# normalize x and y:
|
|
186
|
-
if normalize_xy is not None:
|
|
187
|
-
x_pos /= normalize_xy
|
|
188
|
-
y_pos /= normalize_xy
|
|
104
|
+
data, gdata = self.get_mean_data_xy(variables=variables,
|
|
105
|
+
vmin={var: vmin} if vmin is not None else {},
|
|
106
|
+
vmax={var: vmax} if vmax is not None else {},
|
|
107
|
+
data_format="numpy", ret_grid=True, **kwargs)
|
|
108
|
+
x_pos, y_pos, z_pos, __ = gdata
|
|
189
109
|
|
|
190
110
|
if title is None:
|
|
191
111
|
title = f"States mean, z = {int(np.round(z_pos))} m"
|
|
192
112
|
|
|
113
|
+
# define wind vector arrows:
|
|
114
|
+
qpars = dict(angles="xy", scale_units="xy", scale=0.05)
|
|
115
|
+
qpars.update(quiver_pars)
|
|
116
|
+
quiv = (
|
|
117
|
+
None
|
|
118
|
+
if quiver_n is None
|
|
119
|
+
else (
|
|
120
|
+
quiver_n,
|
|
121
|
+
qpars,
|
|
122
|
+
data[None, :, :, wdi],
|
|
123
|
+
data[None, :, :, wsi],
|
|
124
|
+
)
|
|
125
|
+
)
|
|
126
|
+
|
|
193
127
|
# create plot:
|
|
194
|
-
|
|
128
|
+
out = get_fig(
|
|
195
129
|
var=var,
|
|
196
130
|
fig=fig,
|
|
197
131
|
figsize=figsize,
|
|
198
132
|
ax=ax,
|
|
199
|
-
data=data,
|
|
133
|
+
data=data[None, :, :, vi],
|
|
200
134
|
si=0,
|
|
201
135
|
s=None,
|
|
202
|
-
normalize_var=normalize_var,
|
|
203
136
|
levels=levels,
|
|
204
137
|
x_pos=x_pos,
|
|
205
138
|
y_pos=y_pos,
|
|
206
|
-
vmin=vmin,
|
|
207
|
-
vmax=vmax,
|
|
208
139
|
cmap=cmap,
|
|
209
140
|
xlabel=xlabel,
|
|
210
141
|
ylabel=ylabel,
|
|
211
142
|
title=title,
|
|
212
143
|
add_bar=add_bar,
|
|
213
144
|
vlabel=vlabel,
|
|
145
|
+
quiv=quiv,
|
|
214
146
|
ret_state=ret_state,
|
|
215
147
|
ret_im=ret_im,
|
|
216
148
|
animated=animated,
|
|
217
149
|
)
|
|
218
150
|
|
|
151
|
+
if ret_data:
|
|
152
|
+
out = list(out) if isinstance(out, tuple) else [out]
|
|
153
|
+
return tuple(out + [data[:, :, 0]])
|
|
154
|
+
|
|
155
|
+
return out
|
|
156
|
+
|
|
219
157
|
def get_mean_fig_xz(
|
|
220
158
|
self,
|
|
221
159
|
var,
|
|
222
|
-
resolution,
|
|
223
160
|
x_direction=270,
|
|
224
|
-
xmin=None,
|
|
225
|
-
zmin=0.0,
|
|
226
|
-
xmax=None,
|
|
227
|
-
zmax=None,
|
|
228
161
|
xlabel="x [m]",
|
|
229
162
|
zlabel="z [m]",
|
|
230
|
-
y=None,
|
|
231
|
-
xspace=500.0,
|
|
232
|
-
zspace=500.0,
|
|
233
163
|
levels=None,
|
|
234
|
-
vmin=None,
|
|
235
|
-
vmax=None,
|
|
236
164
|
figsize=None,
|
|
237
|
-
normalize_x=None,
|
|
238
|
-
normalize_z=None,
|
|
239
|
-
normalize_var=None,
|
|
240
165
|
title=None,
|
|
241
166
|
vlabel=None,
|
|
242
167
|
fig=None,
|
|
243
168
|
ax=None,
|
|
244
169
|
add_bar=True,
|
|
245
170
|
cmap=None,
|
|
246
|
-
|
|
247
|
-
|
|
171
|
+
vmin=None,
|
|
172
|
+
vmax=None,
|
|
173
|
+
quiver_n=None,
|
|
174
|
+
quiver_pars={},
|
|
248
175
|
ret_state=False,
|
|
249
176
|
ret_im=False,
|
|
177
|
+
ret_data=False,
|
|
250
178
|
animated=False,
|
|
251
179
|
**kwargs,
|
|
252
180
|
):
|
|
253
181
|
"""
|
|
254
|
-
Generates 2D farm flow figure in a
|
|
182
|
+
Generates 2D farm flow figure in a horizontal xz-plane.
|
|
255
183
|
|
|
256
184
|
Parameters
|
|
257
185
|
----------
|
|
258
186
|
var: str
|
|
259
187
|
The variable name
|
|
260
|
-
resolution: float
|
|
261
|
-
The resolution in m
|
|
262
188
|
x_direction: float, optional
|
|
263
189
|
The direction of the x axis, 0 = north
|
|
264
|
-
xmin: float, optional
|
|
265
|
-
The min x coordinate, or None for automatic
|
|
266
|
-
zmin: float, optional
|
|
267
|
-
The min z coordinate
|
|
268
|
-
xmax: float, optional
|
|
269
|
-
The max x coordinate, or None for automatic
|
|
270
|
-
zmax: float, optional
|
|
271
|
-
The max z coordinate, or None for automatic
|
|
272
190
|
xlabel: str, optional
|
|
273
191
|
The x axis label
|
|
274
192
|
zlabel: str, optional
|
|
275
193
|
The z axis label
|
|
276
|
-
y: float, optional
|
|
277
|
-
The y coordinate of the plane
|
|
278
|
-
xspace: float, optional
|
|
279
|
-
The extra space in x direction, before and after wind farm
|
|
280
|
-
zspace: float, optional
|
|
281
|
-
The extra space in z direction, below and above wind farm
|
|
282
194
|
levels: int, optional
|
|
283
195
|
The number of levels for the contourf plot, or None for pure image
|
|
284
|
-
vmin: float, optional
|
|
285
|
-
Minimum variable value
|
|
286
|
-
vmax: float, optional
|
|
287
|
-
Maximum variable value
|
|
288
196
|
figsize: tuple, optional
|
|
289
197
|
The figsize for plt.Figure
|
|
290
|
-
normalize_x: float, optional
|
|
291
|
-
Divide x by this value
|
|
292
|
-
normalize_z: float, optional
|
|
293
|
-
Divide z by this value
|
|
294
|
-
normalize_var: float, optional
|
|
295
|
-
Divide the variable by this value
|
|
296
198
|
title: str, optional
|
|
297
199
|
The title
|
|
298
200
|
vlabel: str, optional
|
|
@@ -305,22 +207,27 @@ class FlowPlots2D(Output):
|
|
|
305
207
|
Add a color bar
|
|
306
208
|
cmap: str, optional
|
|
307
209
|
The colormap
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
The
|
|
210
|
+
vmin: float, optional
|
|
211
|
+
The minimal variable value
|
|
212
|
+
vmax: float, optional
|
|
213
|
+
The maximal variable value
|
|
214
|
+
quiver_n: int, optional
|
|
215
|
+
Place a vector at each `n`th point
|
|
216
|
+
quiver_pars: dict, optional
|
|
217
|
+
Parameters for plt.quiver
|
|
312
218
|
ret_state: bool
|
|
313
219
|
Flag for state index return
|
|
314
220
|
ret_im: bool
|
|
315
221
|
Flag for image return
|
|
222
|
+
ret_data: bool
|
|
223
|
+
Flag for returning image data
|
|
316
224
|
animated: bool
|
|
317
225
|
Switch for usage for an animation
|
|
318
226
|
kwargs: dict, optional
|
|
319
|
-
|
|
320
|
-
function.
|
|
227
|
+
Additional parameters for SliceData.get_mean_data_xz
|
|
321
228
|
|
|
322
|
-
|
|
323
|
-
|
|
229
|
+
Returns
|
|
230
|
+
-------
|
|
324
231
|
fig: matplotlib.Figure
|
|
325
232
|
The figure object
|
|
326
233
|
si: int, optional
|
|
@@ -328,68 +235,51 @@ class FlowPlots2D(Output):
|
|
|
328
235
|
im: tuple, optional
|
|
329
236
|
The image objects, matplotlib.collections.QuadMesh
|
|
330
237
|
or matplotlib.QuadContourSet
|
|
238
|
+
data: numpy.ndarray, optional
|
|
239
|
+
The image data, shape: (n_x, n_y)
|
|
331
240
|
|
|
332
241
|
"""
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
xspace,
|
|
345
|
-
zspace,
|
|
346
|
-
verbosity,
|
|
347
|
-
)
|
|
348
|
-
|
|
349
|
-
# calculate point results:
|
|
350
|
-
data = calc_point_results(
|
|
351
|
-
algo=self.algo,
|
|
352
|
-
farm_results=self.fres,
|
|
353
|
-
g_pts=g_pts,
|
|
354
|
-
verbosity=verbosity,
|
|
355
|
-
**kwargs,
|
|
356
|
-
)[var].to_numpy()
|
|
357
|
-
|
|
358
|
-
# take mean over states:
|
|
359
|
-
weights = self.fres[FV.WEIGHT][:, weight_turbine].to_numpy()
|
|
360
|
-
data = np.einsum("s,sp->p", weights, data)[None]
|
|
361
|
-
|
|
362
|
-
# find data min max:
|
|
363
|
-
vmin = vmin if vmin is not None else np.nanmin(data)
|
|
364
|
-
vmax = vmax if vmax is not None else np.nanmax(data)
|
|
365
|
-
if normalize_var is not None:
|
|
366
|
-
vmin /= normalize_var
|
|
367
|
-
vmax /= normalize_var
|
|
368
|
-
|
|
369
|
-
# normalize x and z:
|
|
370
|
-
if normalize_x is not None:
|
|
371
|
-
x_pos /= normalize_x
|
|
372
|
-
if normalize_z is not None:
|
|
373
|
-
z_pos /= normalize_z
|
|
242
|
+
variables = list(set([var]+[FV.WD, FV.WS]))
|
|
243
|
+
vi = variables.index(var)
|
|
244
|
+
wdi = variables.index(FV.WD)
|
|
245
|
+
wsi = variables.index(FV.WS)
|
|
246
|
+
|
|
247
|
+
data, gdata = self.get_mean_data_xz(variables=variables,
|
|
248
|
+
vmin={var: vmin} if vmin is not None else {},
|
|
249
|
+
vmax={var: vmax} if vmax is not None else {},
|
|
250
|
+
x_direction=x_direction, data_format="numpy",
|
|
251
|
+
ret_grid=True, **kwargs)
|
|
252
|
+
x_pos, y_pos, z_pos, __ = gdata
|
|
374
253
|
|
|
375
254
|
if title is None:
|
|
376
255
|
title = f"States mean, x direction {x_direction}°, y = {int(np.round(y_pos))} m"
|
|
377
256
|
|
|
257
|
+
# define wind vector arrows:
|
|
258
|
+
qpars = dict(angles="xy", scale_units="xy", scale=0.05)
|
|
259
|
+
qpars.update(quiver_pars)
|
|
260
|
+
quiv = (
|
|
261
|
+
None
|
|
262
|
+
if quiver_n is None
|
|
263
|
+
else (
|
|
264
|
+
quiver_n,
|
|
265
|
+
qpars,
|
|
266
|
+
data[None, :, :, wdi],
|
|
267
|
+
data[None, :, :, wsi],
|
|
268
|
+
)
|
|
269
|
+
)
|
|
270
|
+
|
|
378
271
|
# create plot:
|
|
379
|
-
|
|
272
|
+
out = get_fig(
|
|
380
273
|
var=var,
|
|
381
274
|
fig=fig,
|
|
382
275
|
figsize=figsize,
|
|
383
276
|
ax=ax,
|
|
384
|
-
data=data,
|
|
277
|
+
data=data[None, :, :, vi],
|
|
385
278
|
si=0,
|
|
386
279
|
s=None,
|
|
387
|
-
normalize_var=normalize_var,
|
|
388
280
|
levels=levels,
|
|
389
281
|
x_pos=x_pos,
|
|
390
282
|
y_pos=z_pos,
|
|
391
|
-
vmin=vmin,
|
|
392
|
-
vmax=vmax,
|
|
393
283
|
cmap=cmap,
|
|
394
284
|
xlabel=xlabel,
|
|
395
285
|
ylabel=zlabel,
|
|
@@ -398,86 +288,57 @@ class FlowPlots2D(Output):
|
|
|
398
288
|
vlabel=vlabel,
|
|
399
289
|
ret_state=ret_state,
|
|
400
290
|
ret_im=ret_im,
|
|
291
|
+
quiv=quiv,
|
|
401
292
|
animated=animated,
|
|
402
293
|
)
|
|
403
294
|
|
|
295
|
+
if ret_data:
|
|
296
|
+
out = list(out) if isinstance(out, tuple) else [out]
|
|
297
|
+
return tuple(out + [data[:, :, 0]])
|
|
298
|
+
|
|
299
|
+
return out
|
|
300
|
+
|
|
404
301
|
def get_mean_fig_yz(
|
|
405
302
|
self,
|
|
406
303
|
var,
|
|
407
|
-
resolution,
|
|
408
304
|
x_direction=270,
|
|
409
|
-
ymin=None,
|
|
410
|
-
zmin=0.0,
|
|
411
|
-
ymax=None,
|
|
412
|
-
zmax=None,
|
|
413
305
|
ylabel="x [m]",
|
|
414
306
|
zlabel="z [m]",
|
|
415
|
-
x=None,
|
|
416
|
-
yspace=500.0,
|
|
417
|
-
zspace=500.0,
|
|
418
307
|
levels=None,
|
|
419
|
-
vmin=None,
|
|
420
|
-
vmax=None,
|
|
421
308
|
figsize=None,
|
|
422
|
-
normalize_y=None,
|
|
423
|
-
normalize_z=None,
|
|
424
|
-
normalize_var=None,
|
|
425
309
|
title=None,
|
|
426
310
|
vlabel=None,
|
|
427
311
|
fig=None,
|
|
428
312
|
ax=None,
|
|
429
313
|
add_bar=True,
|
|
430
314
|
cmap=None,
|
|
431
|
-
|
|
432
|
-
|
|
315
|
+
vmin=None,
|
|
316
|
+
vmax=None,
|
|
317
|
+
quiver_n=None,
|
|
318
|
+
quiver_pars={},
|
|
433
319
|
ret_state=False,
|
|
434
320
|
ret_im=False,
|
|
321
|
+
ret_data=False,
|
|
435
322
|
animated=False,
|
|
436
323
|
**kwargs,
|
|
437
324
|
):
|
|
438
325
|
"""
|
|
439
|
-
Generates 2D farm flow figure in a
|
|
326
|
+
Generates 2D farm flow figure in a horizontal yz-plane.
|
|
440
327
|
|
|
441
328
|
Parameters
|
|
442
329
|
----------
|
|
443
330
|
var: str
|
|
444
331
|
The variable name
|
|
445
|
-
resolution: float
|
|
446
|
-
The resolution in m
|
|
447
332
|
x_direction: float, optional
|
|
448
333
|
The direction of the x axis, 0 = north
|
|
449
|
-
ymin: float, optional
|
|
450
|
-
The min y coordinate, or None for automatic
|
|
451
|
-
zmin: float, optional
|
|
452
|
-
The min z coordinate
|
|
453
|
-
ymax: float, optional
|
|
454
|
-
The max y coordinate, or None for automatic
|
|
455
|
-
zmax: float, optional
|
|
456
|
-
The max z coordinate, or None for automatic
|
|
457
334
|
ylabel: str, optional
|
|
458
335
|
The y axis label
|
|
459
336
|
zlabel: str, optional
|
|
460
337
|
The z axis label
|
|
461
|
-
x: float, optional
|
|
462
|
-
The x coordinate of the plane
|
|
463
|
-
yspace: float, optional
|
|
464
|
-
The extra space in y direction, before and after wind farm
|
|
465
|
-
zspace: float, optional
|
|
466
|
-
The extra space in z direction, below and above wind farm
|
|
467
338
|
levels: int, optional
|
|
468
339
|
The number of levels for the contourf plot, or None for pure image
|
|
469
|
-
vmin: float, optional
|
|
470
|
-
Minimum variable value
|
|
471
|
-
vmax: float, optional
|
|
472
|
-
Maximum variable value
|
|
473
340
|
figsize: tuple, optional
|
|
474
341
|
The figsize for plt.Figure
|
|
475
|
-
normalize_y: float, optional
|
|
476
|
-
Divide y by this value
|
|
477
|
-
normalize_z: float, optional
|
|
478
|
-
Divide z by this value
|
|
479
|
-
normalize_var: float, optional
|
|
480
|
-
Divide the variable by this value
|
|
481
342
|
title: str, optional
|
|
482
343
|
The title
|
|
483
344
|
vlabel: str, optional
|
|
@@ -490,22 +351,27 @@ class FlowPlots2D(Output):
|
|
|
490
351
|
Add a color bar
|
|
491
352
|
cmap: str, optional
|
|
492
353
|
The colormap
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
The
|
|
354
|
+
vmin: float, optional
|
|
355
|
+
The minimal variable value
|
|
356
|
+
vmax: float, optional
|
|
357
|
+
The maximal variable value
|
|
358
|
+
quiver_n: int, optional
|
|
359
|
+
Place a vector at each `n`th point
|
|
360
|
+
quiver_pars: dict, optional
|
|
361
|
+
Parameters for plt.quiver
|
|
497
362
|
ret_state: bool
|
|
498
363
|
Flag for state index return
|
|
499
364
|
ret_im: bool
|
|
500
365
|
Flag for image return
|
|
366
|
+
ret_data: bool
|
|
367
|
+
Flag for returning image data
|
|
501
368
|
animated: bool
|
|
502
369
|
Switch for usage for an animation
|
|
503
370
|
kwargs: dict, optional
|
|
504
|
-
|
|
505
|
-
function.
|
|
371
|
+
Additional parameters for SliceData.get_mean_data_yz
|
|
506
372
|
|
|
507
|
-
|
|
508
|
-
|
|
373
|
+
Returns
|
|
374
|
+
-------
|
|
509
375
|
fig: matplotlib.Figure
|
|
510
376
|
The figure object
|
|
511
377
|
si: int, optional
|
|
@@ -513,68 +379,51 @@ class FlowPlots2D(Output):
|
|
|
513
379
|
im: tuple, optional
|
|
514
380
|
The image objects, matplotlib.collections.QuadMesh
|
|
515
381
|
or matplotlib.QuadContourSet
|
|
382
|
+
data: numpy.ndarray, optional
|
|
383
|
+
The image data, shape: (n_x, n_y)
|
|
516
384
|
|
|
517
385
|
"""
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
yspace,
|
|
530
|
-
zspace,
|
|
531
|
-
verbosity,
|
|
532
|
-
)
|
|
533
|
-
|
|
534
|
-
# calculate point results:
|
|
535
|
-
data = calc_point_results(
|
|
536
|
-
algo=self.algo,
|
|
537
|
-
farm_results=self.fres,
|
|
538
|
-
g_pts=g_pts,
|
|
539
|
-
verbosity=verbosity,
|
|
540
|
-
**kwargs,
|
|
541
|
-
)[var].to_numpy()
|
|
542
|
-
|
|
543
|
-
# take mean over states:
|
|
544
|
-
weights = self.fres[FV.WEIGHT][:, weight_turbine].to_numpy()
|
|
545
|
-
data = np.einsum("s,sp->p", weights, data)[None]
|
|
546
|
-
|
|
547
|
-
# find data min max:
|
|
548
|
-
vmin = vmin if vmin is not None else np.nanmin(data)
|
|
549
|
-
vmax = vmax if vmax is not None else np.nanmax(data)
|
|
550
|
-
if normalize_var is not None:
|
|
551
|
-
vmin /= normalize_var
|
|
552
|
-
vmax /= normalize_var
|
|
553
|
-
|
|
554
|
-
# normalize x and z:
|
|
555
|
-
if normalize_y is not None:
|
|
556
|
-
y_pos /= normalize_y
|
|
557
|
-
if normalize_z is not None:
|
|
558
|
-
z_pos /= normalize_z
|
|
386
|
+
variables = list(set([var]+[FV.WD, FV.WS]))
|
|
387
|
+
vi = variables.index(var)
|
|
388
|
+
wdi = variables.index(FV.WD)
|
|
389
|
+
wsi = variables.index(FV.WS)
|
|
390
|
+
|
|
391
|
+
data, gdata = self.get_mean_data_yz(variables=variables,
|
|
392
|
+
vmin={var: vmin} if vmin is not None else {},
|
|
393
|
+
vmax={var: vmax} if vmax is not None else {},
|
|
394
|
+
x_direction=x_direction, data_format="numpy",
|
|
395
|
+
ret_grid=True, **kwargs)
|
|
396
|
+
x_pos, y_pos, z_pos, __ = gdata
|
|
559
397
|
|
|
560
398
|
if title is None:
|
|
561
399
|
title = f"States mean, x direction {x_direction}°, x = {int(np.round(x_pos))} m"
|
|
562
400
|
|
|
401
|
+
# define wind vector arrows:
|
|
402
|
+
qpars = dict(angles="xy", scale_units="xy", scale=0.05)
|
|
403
|
+
qpars.update(quiver_pars)
|
|
404
|
+
quiv = (
|
|
405
|
+
None
|
|
406
|
+
if quiver_n is None
|
|
407
|
+
else (
|
|
408
|
+
quiver_n,
|
|
409
|
+
qpars,
|
|
410
|
+
data[None, :, :, wdi],
|
|
411
|
+
data[None, :, :, wsi],
|
|
412
|
+
)
|
|
413
|
+
)
|
|
414
|
+
|
|
563
415
|
# create plot:
|
|
564
|
-
|
|
416
|
+
out = get_fig(
|
|
565
417
|
var=var,
|
|
566
418
|
fig=fig,
|
|
567
419
|
figsize=figsize,
|
|
568
420
|
ax=ax,
|
|
569
|
-
data=data,
|
|
421
|
+
data=data[None, :, :, vi],
|
|
570
422
|
si=0,
|
|
571
423
|
s=None,
|
|
572
|
-
normalize_var=normalize_var,
|
|
573
424
|
levels=levels,
|
|
574
425
|
x_pos=y_pos,
|
|
575
426
|
y_pos=z_pos,
|
|
576
|
-
vmin=vmin,
|
|
577
|
-
vmax=vmax,
|
|
578
427
|
cmap=cmap,
|
|
579
428
|
xlabel=ylabel,
|
|
580
429
|
ylabel=zlabel,
|
|
@@ -583,38 +432,34 @@ class FlowPlots2D(Output):
|
|
|
583
432
|
vlabel=vlabel,
|
|
584
433
|
ret_state=ret_state,
|
|
585
434
|
ret_im=ret_im,
|
|
435
|
+
quiv=quiv,
|
|
586
436
|
invert_axis="x",
|
|
587
437
|
animated=animated,
|
|
588
438
|
)
|
|
589
439
|
|
|
440
|
+
if ret_data:
|
|
441
|
+
out = list(out) if isinstance(out, tuple) else [out]
|
|
442
|
+
return tuple(out + [data[:, :, 0]])
|
|
443
|
+
|
|
444
|
+
return out
|
|
445
|
+
|
|
590
446
|
def gen_states_fig_xy(
|
|
591
447
|
self,
|
|
592
448
|
var,
|
|
593
|
-
resolution,
|
|
594
|
-
xmin=None,
|
|
595
|
-
ymin=None,
|
|
596
|
-
xmax=None,
|
|
597
|
-
ymax=None,
|
|
598
449
|
xlabel="x [m]",
|
|
599
450
|
ylabel="y [m]",
|
|
600
|
-
z=None,
|
|
601
|
-
xspace=500.0,
|
|
602
|
-
yspace=500.0,
|
|
603
451
|
levels=None,
|
|
604
|
-
vmin=None,
|
|
605
|
-
vmax=None,
|
|
606
452
|
figsize=None,
|
|
607
|
-
normalize_xy=None,
|
|
608
|
-
normalize_var=None,
|
|
609
453
|
title=None,
|
|
610
454
|
vlabel=None,
|
|
611
455
|
fig=None,
|
|
612
456
|
ax=None,
|
|
613
457
|
add_bar=True,
|
|
614
458
|
cmap=None,
|
|
459
|
+
vmin=None,
|
|
460
|
+
vmax=None,
|
|
615
461
|
quiver_n=None,
|
|
616
462
|
quiver_pars={},
|
|
617
|
-
verbosity=0,
|
|
618
463
|
ret_state=False,
|
|
619
464
|
ret_im=False,
|
|
620
465
|
animated=False,
|
|
@@ -627,38 +472,14 @@ class FlowPlots2D(Output):
|
|
|
627
472
|
----------
|
|
628
473
|
var: str
|
|
629
474
|
The variable name
|
|
630
|
-
resolution: float
|
|
631
|
-
The resolution in m
|
|
632
|
-
xmin: float, optional
|
|
633
|
-
The min x coordinate, or None for automatic
|
|
634
|
-
ymin: float, optional
|
|
635
|
-
The min y coordinate, or None for automatic
|
|
636
|
-
xmax: float, optional
|
|
637
|
-
The max x coordinate, or None for automatic
|
|
638
|
-
ymax: float, optional
|
|
639
|
-
The max y coordinate, or None for automatic
|
|
640
475
|
xlabel: str, optional
|
|
641
476
|
The x axis label
|
|
642
477
|
ylabel: str, optional
|
|
643
478
|
The y axis label
|
|
644
|
-
z: float, optional
|
|
645
|
-
The z coordinate of the plane
|
|
646
|
-
xspace: float, optional
|
|
647
|
-
The extra space in x direction, before and after wind farm
|
|
648
|
-
yspace: float, optional
|
|
649
|
-
The extra space in y direction, before and after wind farm
|
|
650
479
|
levels: int, optional
|
|
651
480
|
The number of levels for the contourf plot, or None for pure image
|
|
652
|
-
vmin: float, optional
|
|
653
|
-
Minimum variable value
|
|
654
|
-
vmax: float, optional
|
|
655
|
-
Maximum variable value
|
|
656
481
|
figsize: tuple, optional
|
|
657
482
|
The figsize for plt.Figure
|
|
658
|
-
normalize_xy: float, optional
|
|
659
|
-
Divide x and y by this value
|
|
660
|
-
normalize_var: float, optional
|
|
661
|
-
Divide the variable by this value
|
|
662
483
|
title: str, optional
|
|
663
484
|
The title
|
|
664
485
|
vlabel: str, optional
|
|
@@ -671,12 +492,14 @@ class FlowPlots2D(Output):
|
|
|
671
492
|
Add a color bar
|
|
672
493
|
cmap: str, optional
|
|
673
494
|
The colormap
|
|
495
|
+
vmin: float, optional
|
|
496
|
+
The minimal variable value
|
|
497
|
+
vmax: float, optional
|
|
498
|
+
The maximal variable value
|
|
674
499
|
quiver_n: int, optional
|
|
675
500
|
Place a vector at each `n`th point
|
|
676
501
|
quiver_pars: dict, optional
|
|
677
502
|
Parameters for plt.quiver
|
|
678
|
-
verbosity: int, optional
|
|
679
|
-
The verbosity level
|
|
680
503
|
ret_state: bool
|
|
681
504
|
Flag for state index return
|
|
682
505
|
ret_im: bool
|
|
@@ -684,8 +507,7 @@ class FlowPlots2D(Output):
|
|
|
684
507
|
animated: bool
|
|
685
508
|
Switch for usage for an animation
|
|
686
509
|
kwargs: dict, optional
|
|
687
|
-
|
|
688
|
-
function.
|
|
510
|
+
Additional parameters for SliceData.get_states_data_xy
|
|
689
511
|
|
|
690
512
|
Yields
|
|
691
513
|
------
|
|
@@ -698,21 +520,17 @@ class FlowPlots2D(Output):
|
|
|
698
520
|
or matplotlib.QuadContourSet
|
|
699
521
|
|
|
700
522
|
"""
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
verbosity=verbosity,
|
|
713
|
-
**kwargs,
|
|
714
|
-
)
|
|
715
|
-
data = point_results[var].to_numpy()
|
|
523
|
+
variables = list(set([var]+[FV.WD, FV.WS]))
|
|
524
|
+
vi = variables.index(var)
|
|
525
|
+
wdi = variables.index(FV.WD)
|
|
526
|
+
wsi = variables.index(FV.WS)
|
|
527
|
+
|
|
528
|
+
data, states, gdata = self.get_states_data_xy(variables=variables,
|
|
529
|
+
vmin={var: vmin} if vmin is not None else {},
|
|
530
|
+
vmax={var: vmax} if vmax is not None else {},
|
|
531
|
+
data_format="numpy", ret_states=True, ret_grid=True,
|
|
532
|
+
**kwargs)
|
|
533
|
+
x_pos, y_pos, z_pos, __ = gdata
|
|
716
534
|
|
|
717
535
|
# define wind vector arrows:
|
|
718
536
|
qpars = dict(angles="xy", scale_units="xy", scale=0.05)
|
|
@@ -723,26 +541,13 @@ class FlowPlots2D(Output):
|
|
|
723
541
|
else (
|
|
724
542
|
quiver_n,
|
|
725
543
|
qpars,
|
|
726
|
-
|
|
727
|
-
|
|
544
|
+
data[..., wdi],
|
|
545
|
+
data[..., wsi],
|
|
728
546
|
)
|
|
729
547
|
)
|
|
730
|
-
del point_results
|
|
731
|
-
|
|
732
|
-
# find data min max:
|
|
733
|
-
vmin = vmin if vmin is not None else np.nanmin(data)
|
|
734
|
-
vmax = vmax if vmax is not None else np.nanmax(data)
|
|
735
|
-
if normalize_var is not None:
|
|
736
|
-
vmin /= normalize_var
|
|
737
|
-
vmax /= normalize_var
|
|
738
|
-
|
|
739
|
-
# normalize x and y:
|
|
740
|
-
if normalize_xy is not None:
|
|
741
|
-
x_pos /= normalize_xy
|
|
742
|
-
y_pos /= normalize_xy
|
|
743
548
|
|
|
744
549
|
# loop over states:
|
|
745
|
-
for si, s in enumerate(
|
|
550
|
+
for si, s in enumerate(states):
|
|
746
551
|
if not animated and title is None:
|
|
747
552
|
ttl = f"State {s}"
|
|
748
553
|
ttl += f", z = {int(np.round(z_pos))} m"
|
|
@@ -754,59 +559,44 @@ class FlowPlots2D(Output):
|
|
|
754
559
|
fig=fig,
|
|
755
560
|
figsize=figsize,
|
|
756
561
|
ax=ax,
|
|
757
|
-
data=data,
|
|
562
|
+
data=data[..., vi],
|
|
758
563
|
si=si,
|
|
759
564
|
s=s,
|
|
760
|
-
normalize_var=normalize_var,
|
|
761
565
|
levels=levels,
|
|
762
566
|
x_pos=x_pos,
|
|
763
567
|
y_pos=y_pos,
|
|
764
|
-
vmin=vmin,
|
|
765
|
-
vmax=vmax,
|
|
766
568
|
cmap=cmap,
|
|
767
569
|
xlabel=xlabel,
|
|
768
570
|
ylabel=ylabel,
|
|
769
571
|
title=ttl,
|
|
770
572
|
add_bar=add_bar,
|
|
771
573
|
vlabel=vlabel,
|
|
574
|
+
quiv=quiv,
|
|
772
575
|
ret_state=ret_state,
|
|
773
576
|
ret_im=ret_im,
|
|
774
|
-
quiv=quiv,
|
|
775
577
|
animated=animated,
|
|
776
578
|
)
|
|
777
579
|
|
|
778
580
|
yield out
|
|
779
|
-
|
|
581
|
+
|
|
780
582
|
def gen_states_fig_xz(
|
|
781
583
|
self,
|
|
782
584
|
var,
|
|
783
|
-
resolution,
|
|
784
585
|
x_direction=270.0,
|
|
785
|
-
xmin=None,
|
|
786
|
-
zmin=0.0,
|
|
787
|
-
xmax=None,
|
|
788
|
-
zmax=None,
|
|
789
586
|
xlabel="x [m]",
|
|
790
587
|
zlabel="z [m]",
|
|
791
|
-
y=None,
|
|
792
|
-
xspace=500.0,
|
|
793
|
-
zspace=500.0,
|
|
794
588
|
levels=None,
|
|
795
|
-
vmin=None,
|
|
796
|
-
vmax=None,
|
|
797
589
|
figsize=None,
|
|
798
|
-
normalize_x=None,
|
|
799
|
-
normalize_z=None,
|
|
800
|
-
normalize_var=None,
|
|
801
590
|
title=None,
|
|
802
591
|
vlabel=None,
|
|
803
592
|
fig=None,
|
|
804
593
|
ax=None,
|
|
805
594
|
add_bar=True,
|
|
806
595
|
cmap=None,
|
|
596
|
+
vmin=None,
|
|
597
|
+
vmax=None,
|
|
807
598
|
quiver_n=None,
|
|
808
599
|
quiver_pars={},
|
|
809
|
-
verbosity=0,
|
|
810
600
|
ret_state=False,
|
|
811
601
|
ret_im=False,
|
|
812
602
|
animated=False,
|
|
@@ -819,42 +609,16 @@ class FlowPlots2D(Output):
|
|
|
819
609
|
----------
|
|
820
610
|
var: str
|
|
821
611
|
The variable name
|
|
822
|
-
resolution: float
|
|
823
|
-
The resolution in m
|
|
824
612
|
x_direction: float, optional
|
|
825
613
|
The direction of the x axis, 0 = north
|
|
826
|
-
xmin: float, optional
|
|
827
|
-
The min x coordinate, or None for automatic
|
|
828
|
-
zmin: float, optional
|
|
829
|
-
The min z coordinate
|
|
830
|
-
xmax: float, optional
|
|
831
|
-
The max x coordinate, or None for automatic
|
|
832
|
-
zmax: float, optional
|
|
833
|
-
The max z coordinate, or None for automatic
|
|
834
614
|
xlabel: str, optional
|
|
835
615
|
The x axis label
|
|
836
616
|
zlabel: str, optional
|
|
837
617
|
The z axis label
|
|
838
|
-
y: float, optional
|
|
839
|
-
The y coordinate of the plane
|
|
840
|
-
xspace: float, optional
|
|
841
|
-
The extra space in x direction, before and after wind farm
|
|
842
|
-
zspace: float, optional
|
|
843
|
-
The extra space in z direction, below and above wind farm
|
|
844
618
|
levels: int, optional
|
|
845
619
|
The number of levels for the contourf plot, or None for pure image
|
|
846
|
-
vmin: float, optional
|
|
847
|
-
Minimum variable value
|
|
848
|
-
vmax: float, optional
|
|
849
|
-
Maximum variable value
|
|
850
620
|
figsize: tuple, optional
|
|
851
621
|
The figsize for plt.Figure
|
|
852
|
-
normalize_x: float, optional
|
|
853
|
-
Divide x by this value
|
|
854
|
-
normalize_z: float, optional
|
|
855
|
-
Divide z by this value
|
|
856
|
-
normalize_var: float, optional
|
|
857
|
-
Divide the variable by this value
|
|
858
622
|
title: str, optional
|
|
859
623
|
The title
|
|
860
624
|
vlabel: str, optional
|
|
@@ -867,12 +631,14 @@ class FlowPlots2D(Output):
|
|
|
867
631
|
Add a color bar
|
|
868
632
|
cmap: str, optional
|
|
869
633
|
The colormap
|
|
634
|
+
vmin: float, optional
|
|
635
|
+
The minimal variable value
|
|
636
|
+
vmax: float, optional
|
|
637
|
+
The maximal variable value
|
|
870
638
|
quiver_n: int, optional
|
|
871
639
|
Place a vector at ech `n`th point
|
|
872
640
|
quiver_pars: dict, optional
|
|
873
641
|
Parameters for plt.quiver
|
|
874
|
-
verbosity: int, optional
|
|
875
|
-
The verbosity level
|
|
876
642
|
ret_state: bool
|
|
877
643
|
Flag for state index return
|
|
878
644
|
ret_im: bool
|
|
@@ -880,8 +646,7 @@ class FlowPlots2D(Output):
|
|
|
880
646
|
animated: bool
|
|
881
647
|
Switch for usage for an animation
|
|
882
648
|
kwargs: dict, optional
|
|
883
|
-
|
|
884
|
-
function.
|
|
649
|
+
Additional parameters for SliceData.get_states_data_xz
|
|
885
650
|
|
|
886
651
|
Yields
|
|
887
652
|
------
|
|
@@ -894,31 +659,17 @@ class FlowPlots2D(Output):
|
|
|
894
659
|
or matplotlib.QuadContourSet
|
|
895
660
|
|
|
896
661
|
"""
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
xspace,
|
|
909
|
-
zspace,
|
|
910
|
-
verbosity,
|
|
911
|
-
)
|
|
912
|
-
|
|
913
|
-
# calculate point results:
|
|
914
|
-
point_results = calc_point_results(
|
|
915
|
-
algo=self.algo,
|
|
916
|
-
farm_results=self.fres,
|
|
917
|
-
g_pts=g_pts,
|
|
918
|
-
verbosity=verbosity,
|
|
919
|
-
**kwargs,
|
|
920
|
-
)
|
|
921
|
-
data = point_results[var].to_numpy()
|
|
662
|
+
variables = list(set([var]+[FV.WD, FV.WS]))
|
|
663
|
+
vi = variables.index(var)
|
|
664
|
+
wdi = variables.index(FV.WD)
|
|
665
|
+
wsi = variables.index(FV.WS)
|
|
666
|
+
|
|
667
|
+
data, states, gdata = self.get_states_data_xz(variables=variables,
|
|
668
|
+
vmin={var: vmin} if vmin is not None else {},
|
|
669
|
+
vmax={var: vmax} if vmax is not None else {},
|
|
670
|
+
data_format="numpy", ret_states=True, ret_grid=True,
|
|
671
|
+
**kwargs)
|
|
672
|
+
x_pos, y_pos, z_pos, __ = gdata
|
|
922
673
|
|
|
923
674
|
# define wind vector arrows:
|
|
924
675
|
qpars = dict(angles="xy", scale_units="xy", scale=0.05)
|
|
@@ -929,27 +680,13 @@ class FlowPlots2D(Output):
|
|
|
929
680
|
else (
|
|
930
681
|
quiver_n,
|
|
931
682
|
qpars,
|
|
932
|
-
|
|
933
|
-
|
|
683
|
+
data[..., wdi],
|
|
684
|
+
data[..., wsi],
|
|
934
685
|
)
|
|
935
686
|
)
|
|
936
|
-
del point_results
|
|
937
|
-
|
|
938
|
-
# find data min max:
|
|
939
|
-
vmin = vmin if vmin is not None else np.nanmin(data)
|
|
940
|
-
vmax = vmax if vmax is not None else np.nanmax(data)
|
|
941
|
-
if normalize_var is not None:
|
|
942
|
-
vmin /= normalize_var
|
|
943
|
-
vmax /= normalize_var
|
|
944
|
-
|
|
945
|
-
# normalize x and z:
|
|
946
|
-
if normalize_x is not None:
|
|
947
|
-
x_pos /= normalize_x
|
|
948
|
-
if normalize_z is not None:
|
|
949
|
-
z_pos /= normalize_z
|
|
950
687
|
|
|
951
688
|
# loop over states:
|
|
952
|
-
for si, s in enumerate(
|
|
689
|
+
for si, s in enumerate(states):
|
|
953
690
|
if not animated and title is None:
|
|
954
691
|
ttl = f"State {s}"
|
|
955
692
|
ttl += f", x direction = {x_direction}°"
|
|
@@ -962,24 +699,21 @@ class FlowPlots2D(Output):
|
|
|
962
699
|
fig=fig,
|
|
963
700
|
figsize=figsize,
|
|
964
701
|
ax=ax,
|
|
965
|
-
data=data,
|
|
702
|
+
data=data[..., vi],
|
|
966
703
|
si=si,
|
|
967
704
|
s=s,
|
|
968
|
-
normalize_var=normalize_var,
|
|
969
705
|
levels=levels,
|
|
970
706
|
x_pos=x_pos,
|
|
971
707
|
y_pos=z_pos,
|
|
972
|
-
vmin=vmin,
|
|
973
|
-
vmax=vmax,
|
|
974
708
|
cmap=cmap,
|
|
975
709
|
xlabel=xlabel,
|
|
976
710
|
ylabel=zlabel,
|
|
977
711
|
title=ttl,
|
|
978
712
|
add_bar=add_bar,
|
|
979
713
|
vlabel=vlabel,
|
|
714
|
+
quiv=quiv,
|
|
980
715
|
ret_state=ret_state,
|
|
981
716
|
ret_im=ret_im,
|
|
982
|
-
quiv=quiv,
|
|
983
717
|
animated=animated,
|
|
984
718
|
)
|
|
985
719
|
|
|
@@ -988,81 +722,43 @@ class FlowPlots2D(Output):
|
|
|
988
722
|
def gen_states_fig_yz(
|
|
989
723
|
self,
|
|
990
724
|
var,
|
|
991
|
-
resolution,
|
|
992
725
|
x_direction=270.0,
|
|
993
|
-
ymin=None,
|
|
994
|
-
zmin=0.0,
|
|
995
|
-
ymax=None,
|
|
996
|
-
zmax=None,
|
|
997
726
|
ylabel="y [m]",
|
|
998
727
|
zlabel="z [m]",
|
|
999
|
-
x=None,
|
|
1000
|
-
yspace=500.0,
|
|
1001
|
-
zspace=500.0,
|
|
1002
728
|
levels=None,
|
|
1003
|
-
vmin=None,
|
|
1004
|
-
vmax=None,
|
|
1005
729
|
figsize=None,
|
|
1006
|
-
normalize_y=None,
|
|
1007
|
-
normalize_z=None,
|
|
1008
|
-
normalize_var=None,
|
|
1009
730
|
title=None,
|
|
1010
731
|
vlabel=None,
|
|
1011
732
|
fig=None,
|
|
1012
733
|
ax=None,
|
|
1013
734
|
add_bar=True,
|
|
1014
735
|
cmap=None,
|
|
736
|
+
vmin=None,
|
|
737
|
+
vmax=None,
|
|
1015
738
|
quiver_n=None,
|
|
1016
739
|
quiver_pars={},
|
|
1017
|
-
verbosity=1,
|
|
1018
740
|
ret_state=False,
|
|
1019
741
|
ret_im=False,
|
|
1020
742
|
animated=False,
|
|
1021
743
|
**kwargs,
|
|
1022
744
|
):
|
|
1023
745
|
"""
|
|
1024
|
-
Generates 2D farm flow figure in a plane.
|
|
746
|
+
Generates 2D farm flow figure in a vertical yz-plane.
|
|
1025
747
|
|
|
1026
748
|
Parameters
|
|
1027
749
|
----------
|
|
1028
750
|
var: str
|
|
1029
751
|
The variable name
|
|
1030
|
-
resolution: float
|
|
1031
|
-
The resolution in m
|
|
1032
752
|
x_direction: float, optional
|
|
1033
753
|
The direction of the x axis, 0 = north
|
|
1034
|
-
ymin: float, optional
|
|
1035
|
-
The min y coordinate, or None for automatic
|
|
1036
|
-
zmin: float, optional
|
|
1037
|
-
The min z coordinate
|
|
1038
|
-
ymax: float, optional
|
|
1039
|
-
The max y coordinate, or None for automatic
|
|
1040
|
-
zmax: float, optional
|
|
1041
|
-
The max z coordinate, or None for automatic
|
|
1042
754
|
ylabel: str, optional
|
|
1043
755
|
The y axis label
|
|
1044
756
|
zlabel: str, optional
|
|
1045
757
|
The z axis label
|
|
1046
|
-
x: float, optional
|
|
1047
|
-
The x coordinate of the plane
|
|
1048
|
-
yspace: float, optional
|
|
1049
|
-
The extra space in y direction, left and right of wind farm
|
|
1050
|
-
zspace: float, optional
|
|
1051
|
-
The extra space in z direction, below and above wind farm
|
|
1052
758
|
levels: int, optional
|
|
1053
759
|
The number of levels for the contourf plot, or None for pure image
|
|
1054
|
-
vmin: float, optional
|
|
1055
|
-
Minimum variable value
|
|
1056
|
-
vmax: float, optional
|
|
1057
|
-
Maximum variable value
|
|
1058
760
|
figsize: tuple, optional
|
|
1059
761
|
The figsize for plt.Figure
|
|
1060
|
-
normalize_y: float, optional
|
|
1061
|
-
Divide y by this value
|
|
1062
|
-
normalize_z: float, optional
|
|
1063
|
-
Divide z by this value
|
|
1064
|
-
normalize_var: float, optional
|
|
1065
|
-
Divide the variable by this value
|
|
1066
762
|
title: str, optional
|
|
1067
763
|
The title
|
|
1068
764
|
vlabel: str, optional
|
|
@@ -1075,12 +771,14 @@ class FlowPlots2D(Output):
|
|
|
1075
771
|
Add a color bar
|
|
1076
772
|
cmap: str, optional
|
|
1077
773
|
The colormap
|
|
774
|
+
vmin: float, optional
|
|
775
|
+
The minimal variable value
|
|
776
|
+
vmax: float, optional
|
|
777
|
+
The maximal variable value
|
|
1078
778
|
quiver_n: int, optional
|
|
1079
779
|
Place a vector at ech `n`th point
|
|
1080
780
|
quiver_pars: dict, optional
|
|
1081
781
|
Parameters for plt.quiver
|
|
1082
|
-
verbosity: int, optional
|
|
1083
|
-
The verbosity level
|
|
1084
782
|
ret_state: bool
|
|
1085
783
|
Flag for state index return
|
|
1086
784
|
ret_im: bool
|
|
@@ -1088,8 +786,7 @@ class FlowPlots2D(Output):
|
|
|
1088
786
|
animated: bool
|
|
1089
787
|
Switch for usage for an animation
|
|
1090
788
|
kwargs: dict, optional
|
|
1091
|
-
|
|
1092
|
-
function.
|
|
789
|
+
Additional parameters for SliceData.get_states_data_yz
|
|
1093
790
|
|
|
1094
791
|
Yields
|
|
1095
792
|
------
|
|
@@ -1102,31 +799,19 @@ class FlowPlots2D(Output):
|
|
|
1102
799
|
or matplotlib.QuadContourSet
|
|
1103
800
|
|
|
1104
801
|
"""
|
|
802
|
+
variables = list(set([var]+[FV.WD, FV.WS]))
|
|
803
|
+
vi = variables.index(var)
|
|
804
|
+
wdi = variables.index(FV.WD)
|
|
805
|
+
wsi = variables.index(FV.WS)
|
|
806
|
+
|
|
807
|
+
data, states, gdata = self.get_states_data_yz(variables=variables,
|
|
808
|
+
vmin={var: vmin} if vmin is not None else {},
|
|
809
|
+
vmax={var: vmax} if vmax is not None else {},
|
|
810
|
+
data_format="numpy", ret_states=True, ret_grid=True,
|
|
811
|
+
**kwargs)
|
|
812
|
+
x_pos, y_pos, z_pos, __ = gdata
|
|
1105
813
|
|
|
1106
|
-
#
|
|
1107
|
-
x_pos, y_pos, z_pos, g_pts = get_grid_yz(
|
|
1108
|
-
self.fres,
|
|
1109
|
-
resolution,
|
|
1110
|
-
x_direction,
|
|
1111
|
-
ymin,
|
|
1112
|
-
zmin,
|
|
1113
|
-
ymax,
|
|
1114
|
-
zmax,
|
|
1115
|
-
x,
|
|
1116
|
-
yspace,
|
|
1117
|
-
zspace,
|
|
1118
|
-
verbosity,
|
|
1119
|
-
)
|
|
1120
|
-
|
|
1121
|
-
# calculate point results:
|
|
1122
|
-
point_results = calc_point_results(
|
|
1123
|
-
algo=self.algo,
|
|
1124
|
-
farm_results=self.fres,
|
|
1125
|
-
g_pts=g_pts,
|
|
1126
|
-
verbosity=verbosity,
|
|
1127
|
-
**kwargs,
|
|
1128
|
-
)
|
|
1129
|
-
data = point_results[var].to_numpy()
|
|
814
|
+
# define wind vector arrows:
|
|
1130
815
|
qpars = dict(angles="xy", scale_units="xy", scale=0.05)
|
|
1131
816
|
qpars.update(quiver_pars)
|
|
1132
817
|
quiv = (
|
|
@@ -1135,27 +820,13 @@ class FlowPlots2D(Output):
|
|
|
1135
820
|
else (
|
|
1136
821
|
quiver_n,
|
|
1137
822
|
qpars,
|
|
1138
|
-
|
|
1139
|
-
|
|
823
|
+
data[..., wdi],
|
|
824
|
+
data[..., wsi],
|
|
1140
825
|
)
|
|
1141
826
|
)
|
|
1142
|
-
del point_results
|
|
1143
|
-
|
|
1144
|
-
# find data min max:
|
|
1145
|
-
vmin = vmin if vmin is not None else np.nanmin(data)
|
|
1146
|
-
vmax = vmax if vmax is not None else np.nanmax(data)
|
|
1147
|
-
if normalize_var is not None:
|
|
1148
|
-
vmin /= normalize_var
|
|
1149
|
-
vmax /= normalize_var
|
|
1150
|
-
|
|
1151
|
-
# normalize x and z:
|
|
1152
|
-
if normalize_y is not None:
|
|
1153
|
-
y_pos /= normalize_y
|
|
1154
|
-
if normalize_z is not None:
|
|
1155
|
-
z_pos /= normalize_z
|
|
1156
827
|
|
|
1157
828
|
# loop over states:
|
|
1158
|
-
for si, s in enumerate(
|
|
829
|
+
for si, s in enumerate(states):
|
|
1159
830
|
ttl = f"State {s}" if title is None else title
|
|
1160
831
|
ttl += f", x direction = {x_direction}°"
|
|
1161
832
|
ttl += f", x = {int(np.round(x_pos))} m"
|
|
@@ -1165,24 +836,21 @@ class FlowPlots2D(Output):
|
|
|
1165
836
|
fig=fig,
|
|
1166
837
|
figsize=figsize,
|
|
1167
838
|
ax=ax,
|
|
1168
|
-
data=data,
|
|
839
|
+
data=data[..., vi],
|
|
1169
840
|
si=si,
|
|
1170
841
|
s=s,
|
|
1171
|
-
normalize_var=normalize_var,
|
|
1172
842
|
levels=levels,
|
|
1173
843
|
x_pos=y_pos,
|
|
1174
844
|
y_pos=z_pos,
|
|
1175
|
-
vmin=vmin,
|
|
1176
|
-
vmax=vmax,
|
|
1177
845
|
cmap=cmap,
|
|
1178
846
|
xlabel=ylabel,
|
|
1179
847
|
ylabel=zlabel,
|
|
1180
848
|
title=ttl,
|
|
1181
849
|
add_bar=add_bar,
|
|
1182
850
|
vlabel=vlabel,
|
|
851
|
+
quiv=quiv,
|
|
1183
852
|
ret_state=ret_state,
|
|
1184
853
|
ret_im=ret_im,
|
|
1185
|
-
quiv=quiv,
|
|
1186
854
|
invert_axis="x",
|
|
1187
855
|
animated=animated,
|
|
1188
856
|
)
|