foxes 1.5__py3-none-any.whl → 1.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.

Files changed (38) hide show
  1. examples/abl_states/run.py +58 -56
  2. examples/dyn_wakes/run.py +110 -118
  3. examples/field_data_nc/run.py +22 -20
  4. examples/multi_height/run.py +8 -6
  5. examples/scan_row/run.py +89 -87
  6. examples/sector_management/run.py +40 -38
  7. examples/states_lookup_table/run.py +6 -4
  8. examples/streamline_wakes/run.py +8 -6
  9. examples/timelines/run.py +100 -98
  10. examples/timeseries/run.py +71 -76
  11. examples/wind_rose/run.py +27 -25
  12. examples/yawed_wake/run.py +82 -80
  13. foxes/core/algorithm.py +1 -0
  14. foxes/engines/pool.py +1 -0
  15. foxes/input/yaml/windio/read_attributes.py +8 -2
  16. foxes/input/yaml/windio/read_farm.py +20 -0
  17. foxes/input/yaml/windio/read_fields.py +3 -0
  18. foxes/input/yaml/windio/read_outputs.py +24 -12
  19. foxes/input/yaml/windio/read_site.py +33 -12
  20. foxes/input/yaml/windio/windio.py +1 -0
  21. foxes/models/farm_controllers/__init__.py +1 -0
  22. foxes/models/farm_controllers/op_flag.py +196 -0
  23. foxes/models/wake_models/induction/self_similar.py +22 -4
  24. foxes/models/wake_models/induction/self_similar2020.py +1 -1
  25. foxes/models/wake_models/ti/crespo_hernandez.py +1 -1
  26. foxes/models/wake_models/wind/bastankhah14.py +1 -1
  27. foxes/models/wake_models/wind/bastankhah16.py +1 -1
  28. foxes/models/wake_models/wind/turbopark.py +1 -1
  29. foxes/output/state_turbine_map.py +7 -4
  30. foxes/utils/xarray_utils.py +20 -12
  31. foxes/variables.py +8 -3
  32. {foxes-1.5.dist-info → foxes-1.5.2.dist-info}/METADATA +5 -6
  33. {foxes-1.5.dist-info → foxes-1.5.2.dist-info}/RECORD +38 -36
  34. tests/2_models/turbine_models/test_set_farm_vars.py +64 -0
  35. {foxes-1.5.dist-info → foxes-1.5.2.dist-info}/WHEEL +0 -0
  36. {foxes-1.5.dist-info → foxes-1.5.2.dist-info}/entry_points.txt +0 -0
  37. {foxes-1.5.dist-info → foxes-1.5.2.dist-info}/licenses/LICENSE +0 -0
  38. {foxes-1.5.dist-info → foxes-1.5.2.dist-info}/top_level.txt +0 -0
@@ -91,70 +91,72 @@ if __name__ == "__main__":
91
91
  wake_frame="rotor_wd",
92
92
  partial_wakes=args.pwakes,
93
93
  mbook=mbook,
94
- engine=args.engine,
94
+ )
95
+
96
+ with foxes.Engine.new(
97
+ engine_type=args.engine,
95
98
  n_procs=args.n_cpus,
96
99
  chunk_size_states=args.chunksize_states,
97
100
  chunk_size_points=args.chunksize_points,
98
- )
99
-
100
- time0 = time.time()
101
- farm_results = algo.calc_farm()
102
- time1 = time.time()
101
+ ):
102
+ time0 = time.time()
103
+ farm_results = algo.calc_farm()
104
+ time1 = time.time()
103
105
 
104
- print("\nCalc time =", time1 - time0, "\n")
106
+ print("\nCalc time =", time1 - time0, "\n")
105
107
 
106
- print(farm_results)
108
+ print(farm_results)
107
109
 
108
- fr = farm_results.to_dataframe()
109
- print(fr[[FV.WD, FV.H, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]])
110
+ fr = farm_results.to_dataframe()
111
+ print(fr[[FV.WD, FV.H, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]])
110
112
 
111
- o = foxes.output.FarmResultsEval(farm_results)
112
- o = foxes.output.FarmResultsEval(farm_results)
113
- o.add_capacity(algo)
114
- o.add_capacity(algo, ambient=True)
115
- o.add_efficiency()
113
+ o = foxes.output.FarmResultsEval(farm_results)
114
+ o = foxes.output.FarmResultsEval(farm_results)
115
+ o.add_capacity(algo)
116
+ o.add_capacity(algo, ambient=True)
117
+ o.add_efficiency()
116
118
 
117
- # state-turbine results
118
- farm_df = farm_results.to_dataframe()
119
- print("\nFarm results data:\n")
120
- print(
121
- farm_df[
122
- [
123
- FV.X,
124
- FV.WD,
125
- FV.AMB_REWS,
126
- FV.REWS,
127
- FV.AMB_TI,
128
- FV.TI,
129
- FV.AMB_P,
130
- FV.P,
131
- FV.EFF,
119
+ # state-turbine results
120
+ farm_df = farm_results.to_dataframe()
121
+ print("\nFarm results data:\n")
122
+ print(
123
+ farm_df[
124
+ [
125
+ FV.X,
126
+ FV.WD,
127
+ FV.AMB_REWS,
128
+ FV.REWS,
129
+ FV.AMB_TI,
130
+ FV.TI,
131
+ FV.AMB_P,
132
+ FV.P,
133
+ FV.EFF,
134
+ ]
132
135
  ]
133
- ]
134
- )
135
- print()
136
+ )
137
+ print()
136
138
 
137
- # results by turbine
138
- turbine_results = o.reduce_states(
139
- {
140
- FV.AMB_P: "weights",
141
- FV.P: "weights",
142
- FV.AMB_CAP: "weights",
143
- FV.CAP: "weights",
144
- }
145
- )
146
- turbine_results[FV.AMB_YLD] = o.calc_turbine_yield(
147
- algo=algo, annual=True, ambient=True
148
- )
149
- turbine_results[FV.YLD] = o.calc_turbine_yield(algo=algo, annual=True)
150
- turbine_results[FV.EFF] = turbine_results[FV.P] / turbine_results[FV.AMB_P]
151
- print("\nResults by turbine:\n")
152
- print(turbine_results)
139
+ # results by turbine
140
+ turbine_results = o.reduce_states(
141
+ {
142
+ FV.AMB_P: "weights",
143
+ FV.P: "weights",
144
+ FV.AMB_CAP: "weights",
145
+ FV.CAP: "weights",
146
+ }
147
+ )
148
+ turbine_results[FV.AMB_YLD] = o.calc_turbine_yield(
149
+ algo=algo, annual=True, ambient=True
150
+ )
151
+ turbine_results[FV.YLD] = o.calc_turbine_yield(algo=algo, annual=True)
152
+ turbine_results[FV.EFF] = turbine_results[FV.P] / turbine_results[FV.AMB_P]
153
+ print("\nResults by turbine:\n")
154
+ print(turbine_results)
153
155
 
154
- # power results
155
- P0 = o.calc_mean_farm_power(ambient=True)
156
- P = o.calc_mean_farm_power()
157
- print(f"\nFarm power : {P / 1000:.1f} MW")
158
- print(f"Farm ambient power: {P0 / 1000:.1f} MW")
159
- print(f"Farm efficiency : {o.calc_farm_efficiency():.2f}")
160
- print(f"Annual farm yield : {turbine_results[FV.YLD].sum():.2f} GWh.")
156
+ # power results
157
+ P0 = o.calc_mean_farm_power(ambient=True)
158
+ P = o.calc_mean_farm_power()
159
+ print(f"\nFarm power : {P / 1000:.1f} MW")
160
+ print(f"Farm ambient power: {P0 / 1000:.1f} MW")
161
+ print(f"Farm efficiency : {o.calc_farm_efficiency():.2f}")
162
+ print(f"Annual farm yield : {turbine_results[FV.YLD].sum():.2f} GWh.")
examples/dyn_wakes/run.py CHANGED
@@ -182,14 +182,6 @@ if __name__ == "__main__":
182
182
  plt.show()
183
183
  plt.close(ax.get_figure())
184
184
 
185
- engine = foxes.Engine.new(
186
- engine_type=args.engine,
187
- n_procs=args.n_cpus,
188
- chunk_size_states=args.chunksize_states,
189
- chunk_size_points=args.chunksize_points,
190
- )
191
- engine.initialize()
192
-
193
185
  algo = foxes.algorithms.Iterative(
194
186
  farm,
195
187
  states=states,
@@ -204,131 +196,131 @@ if __name__ == "__main__":
204
196
  verbosity=1,
205
197
  )
206
198
 
207
- time0 = time.time()
208
- farm_results = algo.calc_farm()
209
- time1 = time.time()
199
+ with foxes.Engine.new(
200
+ engine_type=args.engine,
201
+ n_procs=args.n_cpus,
202
+ chunk_size_states=args.chunksize_states,
203
+ chunk_size_points=args.chunksize_points,
204
+ ):
205
+ time0 = time.time()
206
+ farm_results = algo.calc_farm()
207
+ time1 = time.time()
210
208
 
211
- print("\nCalc time =", time1 - time0, "\n")
209
+ print("\nCalc time =", time1 - time0, "\n")
212
210
 
213
- o = foxes.output.FarmResultsEval(farm_results)
214
- o.add_capacity(algo)
215
- o.add_capacity(algo, ambient=True)
216
- o.add_efficiency()
211
+ o = foxes.output.FarmResultsEval(farm_results)
212
+ o.add_capacity(algo)
213
+ o.add_capacity(algo, ambient=True)
214
+ o.add_efficiency()
217
215
 
218
- print("\nFarm results:\n")
219
- print(farm_results)
216
+ print("\nFarm results:\n")
217
+ print(farm_results)
220
218
 
221
- # state-turbine results
222
- farm_df = farm_results.to_dataframe()
223
- print("\nFarm results data:\n")
224
- print(
225
- farm_df[
226
- [
227
- FV.X,
228
- FV.Y,
229
- FV.WD,
230
- FV.AMB_REWS,
231
- FV.REWS,
232
- FV.AMB_TI,
233
- FV.TI,
234
- FV.AMB_P,
235
- FV.P,
236
- FV.EFF,
219
+ # state-turbine results
220
+ farm_df = farm_results.to_dataframe()
221
+ print("\nFarm results data:\n")
222
+ print(
223
+ farm_df[
224
+ [
225
+ FV.X,
226
+ FV.Y,
227
+ FV.WD,
228
+ FV.AMB_REWS,
229
+ FV.REWS,
230
+ FV.AMB_TI,
231
+ FV.TI,
232
+ FV.AMB_P,
233
+ FV.P,
234
+ FV.EFF,
235
+ ]
237
236
  ]
238
- ]
239
- )
240
- print()
241
- print(farm_df[[FV.AMB_REWS, FV.REWS, FV.CT, FV.EFF]].describe())
242
-
243
- # power results
244
- P0 = o.calc_mean_farm_power(ambient=True)
245
- P = o.calc_mean_farm_power()
246
- print(f"\nFarm power : {P / 1000:.1f} MW")
247
- print(f"Farm ambient power: {P0 / 1000:.1f} MW")
248
- print(f"Farm efficiency : {o.calc_farm_efficiency() * 100:.2f} %")
249
-
250
- engine.finalize()
251
-
252
- if not args.nofig:
253
- sts = np.arange(farm_results.sizes["state"])
254
- plt.plot(sts, farm_results.REWS[:, 1], label="Turbine 1")
255
- plt.plot(sts, farm_results.REWS[:, 4], label="Turbine 4")
256
- plt.plot(sts, farm_results.REWS[:, 7], label="Turbine 7")
257
- plt.legend()
258
- plt.xlabel("State")
259
- plt.ylabel("REWS [m/s]")
260
- plt.show()
261
- plt.close()
262
-
263
- if not args.nofig and args.animation:
264
- print("\nCalculating animation")
265
-
266
- fig, axs = plt.subplots(
267
- 2, 1, figsize=(5.2, 7), gridspec_kw={"height_ratios": [3, 1]}
268
237
  )
238
+ print()
239
+ print(farm_df[[FV.AMB_REWS, FV.REWS, FV.CT, FV.EFF]].describe())
269
240
 
270
- engine.initialize()
241
+ # power results
242
+ P0 = o.calc_mean_farm_power(ambient=True)
243
+ P = o.calc_mean_farm_power()
244
+ print(f"\nFarm power : {P / 1000:.1f} MW")
245
+ print(f"Farm ambient power: {P0 / 1000:.1f} MW")
246
+ print(f"Farm efficiency : {o.calc_farm_efficiency() * 100:.2f} %")
271
247
 
272
- of = foxes.output.FlowPlots2D(algo, farm_results)
273
- ofg = of.gen_states_fig_xy(
274
- FV.WS,
275
- resolution=30,
276
- quiver_pars=dict(angles="xy", scale_units="xy", scale=0.013),
277
- quiver_n=35,
278
- xmax=5000,
279
- ymax=5000,
280
- vmin=0,
281
- fig=fig,
282
- ax=axs[0],
283
- ret_im=True,
284
- title=None,
285
- animated=True,
286
- precalc=True,
287
- rotor_color="red",
288
- )
289
- next(ofg)
248
+ if not args.nofig:
249
+ sts = np.arange(farm_results.sizes["state"])
250
+ plt.plot(sts, farm_results.REWS[:, 1], label="Turbine 1")
251
+ plt.plot(sts, farm_results.REWS[:, 4], label="Turbine 4")
252
+ plt.plot(sts, farm_results.REWS[:, 7], label="Turbine 7")
253
+ plt.legend()
254
+ plt.xlabel("State")
255
+ plt.ylabel("REWS [m/s]")
256
+ plt.show()
257
+ plt.close()
290
258
 
291
- engine.finalize()
259
+ if not args.nofig and args.animation:
260
+ print("\nCalculating animation")
292
261
 
293
- anim = foxes.output.Animator(fig)
294
- anim.add_generator(ofg)
295
- anim.add_generator(
296
- o.gen_stdata(
297
- turbines=[1, 4, 7],
298
- variable=FV.REWS,
262
+ fig, axs = plt.subplots(
263
+ 2, 1, figsize=(5.2, 7), gridspec_kw={"height_ratios": [3, 1]}
264
+ )
265
+
266
+ of = foxes.output.FlowPlots2D(algo, farm_results)
267
+ ofg = of.gen_states_fig_xy(
268
+ FV.WS,
269
+ resolution=30,
270
+ quiver_pars=dict(angles="xy", scale_units="xy", scale=0.013),
271
+ quiver_n=35,
272
+ xmax=5000,
273
+ ymax=5000,
274
+ vmin=0,
299
275
  fig=fig,
300
- ax=axs[1],
276
+ ax=axs[0],
301
277
  ret_im=True,
302
- legloc="upper right",
278
+ title=None,
303
279
  animated=True,
280
+ precalc=True,
281
+ rotor_color="red",
282
+ )
283
+ next(ofg)
284
+
285
+ anim = foxes.output.Animator(fig)
286
+ anim.add_generator(ofg)
287
+ anim.add_generator(
288
+ o.gen_stdata(
289
+ turbines=[1, 4, 7],
290
+ variable=FV.REWS,
291
+ fig=fig,
292
+ ax=axs[1],
293
+ ret_im=True,
294
+ legloc="upper right",
295
+ animated=True,
296
+ )
304
297
  )
305
- )
306
298
 
307
- ani = anim.animate()
299
+ ani = anim.animate()
308
300
 
309
- lo = foxes.output.FarmLayoutOutput(farm)
310
- lo.get_figure(
311
- fig=fig,
312
- ax=axs[0],
313
- title="",
314
- annotate=1,
315
- anno_delx=-120,
316
- anno_dely=-60,
317
- alpha=0,
318
- )
301
+ lo = foxes.output.FarmLayoutOutput(farm)
302
+ lo.get_figure(
303
+ fig=fig,
304
+ ax=axs[0],
305
+ title="",
306
+ annotate=1,
307
+ anno_delx=-120,
308
+ anno_dely=-60,
309
+ alpha=0,
310
+ )
319
311
 
320
- axs[0].scatter(
321
- [args.ref_xy[0]],
322
- [args.ref_xy[1]],
323
- marker="x",
324
- color="red",
325
- s=80,
326
- animated=True,
327
- )
312
+ axs[0].scatter(
313
+ [args.ref_xy[0]],
314
+ [args.ref_xy[1]],
315
+ marker="x",
316
+ color="red",
317
+ s=80,
318
+ animated=True,
319
+ )
328
320
 
329
- fpath = Path(args.ani_file)
330
- print("Writing file", fpath)
331
- if fpath.suffix == ".gif":
332
- ani.save(filename=fpath, writer="pillow", fps=args.fps)
333
- else:
334
- ani.save(filename=fpath, writer="ffmpeg", fps=args.fps)
321
+ fpath = Path(args.ani_file)
322
+ print("Writing file", fpath)
323
+ if fpath.suffix == ".gif":
324
+ ani.save(filename=fpath, writer="pillow", fps=args.fps)
325
+ else:
326
+ ani.save(filename=fpath, writer="ffmpeg", fps=args.fps)
@@ -98,31 +98,33 @@ if __name__ == "__main__":
98
98
  wake_frame=args.wake_frame,
99
99
  partial_wakes=args.pwakes,
100
100
  mbook=mbook,
101
- engine=args.engine,
102
- n_procs=args.n_cpus,
103
- chunk_size_states=args.chunksize_states,
104
- chunk_size_points=args.chunksize_points,
105
101
  verbosity=1,
106
102
  )
107
103
 
108
- time0 = time.time()
109
- farm_results = algo.calc_farm()
110
- time1 = time.time()
104
+ with foxes.Engine.new(
105
+ engine_type=args.engine,
106
+ n_procs=args.n_cpus,
107
+ chunk_size_states=args.chunksize_states,
108
+ chunk_size_points=args.chunksize_points,
109
+ ):
110
+ time0 = time.time()
111
+ farm_results = algo.calc_farm()
112
+ time1 = time.time()
111
113
 
112
- print("\nCalc time =", time1 - time0, "\n")
114
+ print("\nCalc time =", time1 - time0, "\n")
113
115
 
114
- print(farm_results)
116
+ print(farm_results)
115
117
 
116
- fr = farm_results.to_dataframe()
117
- print(fr[[FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]])
118
+ fr = farm_results.to_dataframe()
119
+ print(fr[[FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]])
118
120
 
119
- o = foxes.output.SlicesData(algo, farm_results)
120
- ds = o.get_states_data_xy(
121
- z_list=[90, 100], variables=[FV.WS], resolution=50, verbosity=1
122
- )
123
- print(ds)
121
+ o = foxes.output.SlicesData(algo, farm_results)
122
+ ds = o.get_states_data_xy(
123
+ z_list=[90, 100], variables=[FV.WS], resolution=50, verbosity=1
124
+ )
125
+ print(ds)
124
126
 
125
- if not args.nofig:
126
- o = foxes.output.FlowPlots2D(algo, farm_results)
127
- o.get_mean_fig_xy(FV.WS, resolution=10)
128
- plt.show()
127
+ if not args.nofig:
128
+ o = foxes.output.FlowPlots2D(algo, farm_results)
129
+ o.get_mean_fig_xy(FV.WS, resolution=10)
130
+ plt.show()
@@ -91,14 +91,16 @@ if __name__ == "__main__":
91
91
  wake_frame="rotor_wd",
92
92
  partial_wakes=args.pwakes,
93
93
  mbook=mbook,
94
- engine=args.engine,
95
- n_procs=args.n_cpus,
96
- chunk_size_states=args.chunksize_states,
97
94
  )
98
95
 
99
- time0 = time.time()
100
- farm_results = algo.calc_farm()
101
- time1 = time.time()
96
+ with foxes.Engine.new(
97
+ engine_type=args.engine,
98
+ n_procs=args.n_cpus,
99
+ chunk_size_states=args.chunksize_states,
100
+ ):
101
+ time0 = time.time()
102
+ farm_results = algo.calc_farm()
103
+ time1 = time.time()
102
104
 
103
105
  print("\nCalc time =", time1 - time0, "\n")
104
106
 
examples/scan_row/run.py CHANGED
@@ -102,97 +102,99 @@ if __name__ == "__main__":
102
102
  wake_frame="rotor_wd",
103
103
  partial_wakes=args.pwakes,
104
104
  mbook=mbook,
105
- engine=args.engine,
105
+ )
106
+
107
+ with foxes.Engine.new(
108
+ engine_type=args.engine,
106
109
  n_procs=args.n_cpus,
107
110
  chunk_size_states=args.chunksize_states,
108
111
  chunk_size_points=args.chunksize_points,
109
- )
110
-
111
- time0 = time.time()
112
- farm_results = algo.calc_farm()
113
- time1 = time.time()
114
-
115
- print("\nCalc time =", time1 - time0, "\n")
116
-
117
- print("\nFarm results:\n", farm_results)
118
-
119
- o = foxes.output.FarmResultsEval(farm_results)
120
- o.add_capacity(algo)
121
- o.add_capacity(algo, ambient=True)
122
- o.add_efficiency()
123
-
124
- # state-turbine results
125
- farm_df = farm_results.to_dataframe()
126
- print("\nFarm results data:\n")
127
- print(
128
- farm_df[
129
- [
130
- FV.X,
131
- FV.WD,
132
- FV.AMB_REWS,
133
- FV.REWS,
134
- FV.AMB_TI,
135
- FV.TI,
136
- FV.AMB_P,
137
- FV.P,
138
- FV.EFF,
139
- ]
140
- ]
141
- )
142
- print()
143
-
144
- # results by turbine
145
- turbine_results = o.reduce_states(
146
- {
147
- FV.AMB_P: "weights",
148
- FV.P: "weights",
149
- FV.AMB_CAP: "weights",
150
- FV.CAP: "weights",
151
- }
152
- )
153
- turbine_results[FV.AMB_YLD] = o.calc_turbine_yield(
154
- algo=algo, annual=True, ambient=True
155
- )
156
- turbine_results[FV.YLD] = o.calc_turbine_yield(algo=algo, annual=True)
157
- turbine_results[FV.EFF] = turbine_results[FV.P] / turbine_results[FV.AMB_P]
158
- print("\nResults by turbine:\n")
159
- print(turbine_results)
160
-
161
- # power results
162
- P0 = o.calc_mean_farm_power(ambient=True)
163
- P = o.calc_mean_farm_power()
164
- print(f"\nFarm power : {P / 1000:.1f} MW")
165
- print(f"Farm ambient power: {P0 / 1000:.1f} MW")
166
- print(f"Farm efficiency : {o.calc_farm_efficiency() * 100:.2f} %")
167
- print(f"Annual farm yield : {turbine_results[FV.YLD].sum():.2f} GWh.")
168
- print()
169
-
170
- if not args.nofig and args.calc_cline:
171
- points = np.zeros((n_s, n_p, 3))
172
- points[:, :, 0] = np.linspace(p0[0], p0[0] + n_t * stp[0] + 10 * D, n_p)[
173
- None, :
174
- ]
175
- points[:, :, 1] = p0[1]
176
- points[:, :, 2] = H
177
- print("\nPOINTS:\n", points[0])
178
-
112
+ ):
179
113
  time0 = time.time()
180
- point_results = algo.calc_points(farm_results, points)
114
+ farm_results = algo.calc_farm()
181
115
  time1 = time.time()
116
+
182
117
  print("\nCalc time =", time1 - time0, "\n")
183
118
 
184
- print(point_results)
185
-
186
- fig, ax = plt.subplots()
187
- for s in range(points.shape[0]):
188
- ax.plot(points[s, :, 0], point_results[FV.WS][s, :])
189
- ax.set_xlabel("x [m]")
190
- ax.set_ylabel("Wind speed [m/s]")
191
- ax.set_title("Centreline wind speed")
192
- plt.show()
193
- plt.close(fig)
194
-
195
- if not args.nofig and args.calc_mean:
196
- o = foxes.output.FlowPlots2D(algo, farm_results)
197
- fig = o.get_mean_fig_xy(FV.WS, resolution=10)
198
- plt.show()
119
+ print("\nFarm results:\n", farm_results)
120
+
121
+ o = foxes.output.FarmResultsEval(farm_results)
122
+ o.add_capacity(algo)
123
+ o.add_capacity(algo, ambient=True)
124
+ o.add_efficiency()
125
+
126
+ # state-turbine results
127
+ farm_df = farm_results.to_dataframe()
128
+ print("\nFarm results data:\n")
129
+ print(
130
+ farm_df[
131
+ [
132
+ FV.X,
133
+ FV.WD,
134
+ FV.AMB_REWS,
135
+ FV.REWS,
136
+ FV.AMB_TI,
137
+ FV.TI,
138
+ FV.AMB_P,
139
+ FV.P,
140
+ FV.EFF,
141
+ ]
142
+ ]
143
+ )
144
+ print()
145
+
146
+ # results by turbine
147
+ turbine_results = o.reduce_states(
148
+ {
149
+ FV.AMB_P: "weights",
150
+ FV.P: "weights",
151
+ FV.AMB_CAP: "weights",
152
+ FV.CAP: "weights",
153
+ }
154
+ )
155
+ turbine_results[FV.AMB_YLD] = o.calc_turbine_yield(
156
+ algo=algo, annual=True, ambient=True
157
+ )
158
+ turbine_results[FV.YLD] = o.calc_turbine_yield(algo=algo, annual=True)
159
+ turbine_results[FV.EFF] = turbine_results[FV.P] / turbine_results[FV.AMB_P]
160
+ print("\nResults by turbine:\n")
161
+ print(turbine_results)
162
+
163
+ # power results
164
+ P0 = o.calc_mean_farm_power(ambient=True)
165
+ P = o.calc_mean_farm_power()
166
+ print(f"\nFarm power : {P / 1000:.1f} MW")
167
+ print(f"Farm ambient power: {P0 / 1000:.1f} MW")
168
+ print(f"Farm efficiency : {o.calc_farm_efficiency() * 100:.2f} %")
169
+ print(f"Annual farm yield : {turbine_results[FV.YLD].sum():.2f} GWh.")
170
+ print()
171
+
172
+ if not args.nofig and args.calc_cline:
173
+ points = np.zeros((n_s, n_p, 3))
174
+ points[:, :, 0] = np.linspace(p0[0], p0[0] + n_t * stp[0] + 10 * D, n_p)[
175
+ None, :
176
+ ]
177
+ points[:, :, 1] = p0[1]
178
+ points[:, :, 2] = H
179
+ print("\nPOINTS:\n", points[0])
180
+
181
+ time0 = time.time()
182
+ point_results = algo.calc_points(farm_results, points)
183
+ time1 = time.time()
184
+ print("\nCalc time =", time1 - time0, "\n")
185
+
186
+ print(point_results)
187
+
188
+ fig, ax = plt.subplots()
189
+ for s in range(points.shape[0]):
190
+ ax.plot(points[s, :, 0], point_results[FV.WS][s, :])
191
+ ax.set_xlabel("x [m]")
192
+ ax.set_ylabel("Wind speed [m/s]")
193
+ ax.set_title("Centreline wind speed")
194
+ plt.show()
195
+ plt.close(fig)
196
+
197
+ if not args.nofig and args.calc_mean:
198
+ o = foxes.output.FlowPlots2D(algo, farm_results)
199
+ fig = o.get_mean_fig_xy(FV.WS, resolution=10)
200
+ plt.show()