foxes 0.8.2__py3-none-any.whl → 1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of foxes might be problematic. Click here for more details.
- docs/source/conf.py +353 -0
- examples/abl_states/run.py +160 -0
- examples/compare_rotors_pwakes/run.py +217 -0
- examples/compare_wakes/run.py +241 -0
- examples/dyn_wakes/run.py +311 -0
- examples/field_data_nc/run.py +121 -0
- examples/induction_RHB/run.py +201 -0
- examples/multi_height/run.py +113 -0
- examples/power_mask/run.py +249 -0
- examples/random_timeseries/run.py +210 -0
- examples/scan_row/run.py +193 -0
- examples/sector_management/run.py +162 -0
- examples/sequential/run.py +209 -0
- examples/single_state/run.py +201 -0
- examples/states_lookup_table/run.py +137 -0
- examples/streamline_wakes/run.py +138 -0
- examples/tab_file/run.py +142 -0
- examples/timelines/run.py +267 -0
- examples/timeseries/run.py +183 -0
- examples/timeseries_slurm/run.py +185 -0
- examples/wind_rose/run.py +141 -0
- examples/windio/run.py +29 -0
- examples/yawed_wake/run.py +196 -0
- foxes/__init__.py +4 -8
- foxes/algorithms/__init__.py +1 -1
- foxes/algorithms/downwind/downwind.py +232 -101
- foxes/algorithms/downwind/models/farm_wakes_calc.py +11 -6
- foxes/algorithms/downwind/models/init_farm_data.py +1 -1
- foxes/algorithms/downwind/models/point_wakes_calc.py +5 -6
- foxes/algorithms/downwind/models/reorder_farm_output.py +0 -1
- foxes/algorithms/downwind/models/set_amb_point_results.py +4 -2
- foxes/algorithms/iterative/iterative.py +73 -33
- foxes/algorithms/iterative/models/farm_wakes_calc.py +11 -6
- foxes/algorithms/sequential/models/plugin.py +1 -1
- foxes/algorithms/sequential/sequential.py +126 -255
- foxes/constants.py +17 -2
- foxes/core/__init__.py +1 -0
- foxes/core/algorithm.py +631 -146
- foxes/core/data.py +252 -20
- foxes/core/data_calc_model.py +13 -289
- foxes/core/engine.py +630 -0
- foxes/core/farm_controller.py +37 -9
- foxes/core/farm_data_model.py +15 -0
- foxes/core/model.py +133 -80
- foxes/core/point_data_model.py +15 -0
- foxes/core/rotor_model.py +27 -21
- foxes/core/states.py +16 -0
- foxes/core/turbine_type.py +28 -0
- foxes/core/wake_frame.py +22 -4
- foxes/core/wake_model.py +2 -3
- foxes/data/windio/windio_5turbines_timeseries.yaml +23 -1
- foxes/engines/__init__.py +16 -0
- foxes/engines/dask.py +975 -0
- foxes/engines/default.py +75 -0
- foxes/engines/futures.py +72 -0
- foxes/engines/mpi.py +38 -0
- foxes/engines/multiprocess.py +74 -0
- foxes/engines/numpy.py +185 -0
- foxes/engines/pool.py +263 -0
- foxes/engines/single.py +139 -0
- foxes/input/farm_layout/__init__.py +1 -0
- foxes/input/farm_layout/from_csv.py +4 -0
- foxes/input/farm_layout/from_json.py +1 -1
- foxes/input/farm_layout/grid.py +2 -2
- foxes/input/farm_layout/ring.py +65 -0
- foxes/input/farm_layout/row.py +2 -2
- foxes/input/states/__init__.py +6 -0
- foxes/input/states/create/random_abl_states.py +1 -1
- foxes/input/states/field_data_nc.py +157 -32
- foxes/input/states/multi_height.py +127 -13
- foxes/input/states/one_point_flow.py +577 -0
- foxes/input/states/scan_ws.py +73 -2
- foxes/input/states/states_table.py +204 -35
- foxes/input/windio/__init__.py +1 -1
- foxes/input/windio/get_states.py +44 -23
- foxes/input/windio/read_attributes.py +41 -16
- foxes/input/windio/read_farm.py +116 -102
- foxes/input/windio/read_fields.py +13 -6
- foxes/input/windio/read_outputs.py +63 -22
- foxes/input/windio/runner.py +31 -17
- foxes/input/windio/windio.py +36 -22
- foxes/models/ground_models/wake_mirror.py +8 -4
- foxes/models/model_book.py +29 -18
- foxes/models/partial_wakes/rotor_points.py +3 -3
- foxes/models/rotor_models/centre.py +4 -0
- foxes/models/rotor_models/grid.py +22 -23
- foxes/models/rotor_models/levels.py +4 -5
- foxes/models/turbine_models/calculator.py +0 -2
- foxes/models/turbine_models/lookup_table.py +27 -2
- foxes/models/turbine_models/rotor_centre_calc.py +4 -3
- foxes/models/turbine_models/set_farm_vars.py +103 -34
- foxes/models/turbine_types/PCt_file.py +24 -0
- foxes/models/turbine_types/PCt_from_two.py +24 -0
- foxes/models/turbine_types/__init__.py +1 -0
- foxes/models/turbine_types/lookup.py +316 -0
- foxes/models/turbine_types/null_type.py +50 -0
- foxes/models/turbine_types/wsrho2PCt_from_two.py +24 -0
- foxes/models/turbine_types/wsti2PCt_from_two.py +24 -0
- foxes/models/vertical_profiles/data_profile.py +1 -1
- foxes/models/wake_frames/__init__.py +1 -0
- foxes/models/wake_frames/dynamic_wakes.py +424 -0
- foxes/models/wake_frames/farm_order.py +23 -3
- foxes/models/wake_frames/rotor_wd.py +4 -2
- foxes/models/wake_frames/seq_dynamic_wakes.py +56 -63
- foxes/models/wake_frames/streamlines.py +19 -20
- foxes/models/wake_frames/timelines.py +328 -127
- foxes/models/wake_frames/yawed_wakes.py +4 -1
- foxes/models/wake_models/dist_sliced.py +1 -3
- foxes/models/wake_models/induction/rankine_half_body.py +4 -4
- foxes/models/wake_models/induction/rathmann.py +2 -2
- foxes/models/wake_models/induction/self_similar.py +2 -2
- foxes/models/wake_models/induction/vortex_sheet.py +2 -2
- foxes/models/wake_models/ti/iec_ti.py +34 -17
- foxes/models/wake_models/top_hat.py +1 -1
- foxes/models/wake_models/wind/bastankhah14.py +2 -2
- foxes/models/wake_models/wind/bastankhah16.py +8 -7
- foxes/models/wake_models/wind/jensen.py +1 -1
- foxes/models/wake_models/wind/turbopark.py +2 -2
- foxes/output/__init__.py +4 -1
- foxes/output/farm_layout.py +2 -2
- foxes/output/flow_plots_2d/__init__.py +0 -1
- foxes/output/flow_plots_2d/flow_plots.py +70 -30
- foxes/output/grids.py +91 -21
- foxes/output/seq_plugins/__init__.py +2 -0
- foxes/output/{flow_plots_2d → seq_plugins}/seq_flow_ani_plugin.py +62 -20
- foxes/output/seq_plugins/seq_wake_debug_plugin.py +145 -0
- foxes/output/slice_data.py +131 -111
- foxes/output/state_turbine_map.py +18 -13
- foxes/output/state_turbine_table.py +19 -19
- foxes/utils/__init__.py +1 -1
- foxes/utils/dev_utils.py +42 -0
- foxes/utils/dict.py +1 -1
- foxes/utils/factory.py +147 -52
- foxes/utils/pandas_helpers.py +4 -3
- foxes/utils/wind_dir.py +0 -2
- foxes/utils/xarray_utils.py +23 -13
- foxes/variables.py +37 -0
- {foxes-0.8.2.dist-info → foxes-1.0.dist-info}/METADATA +71 -33
- foxes-1.0.dist-info/RECORD +307 -0
- {foxes-0.8.2.dist-info → foxes-1.0.dist-info}/WHEEL +1 -1
- foxes-1.0.dist-info/top_level.txt +4 -0
- tests/0_consistency/iterative/test_iterative.py +92 -0
- tests/0_consistency/partial_wakes/test_partial_wakes.py +90 -0
- tests/1_verification/flappy_0_6/PCt_files/flappy/run.py +85 -0
- tests/1_verification/flappy_0_6/PCt_files/test_PCt_files.py +103 -0
- tests/1_verification/flappy_0_6/abl_states/flappy/run.py +85 -0
- tests/1_verification/flappy_0_6/abl_states/test_abl_states.py +87 -0
- tests/1_verification/flappy_0_6/partial_top_hat/flappy/run.py +82 -0
- tests/1_verification/flappy_0_6/partial_top_hat/test_partial_top_hat.py +82 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_centre/flappy/run.py +92 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_centre/test_row_Jensen_linear_centre.py +93 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/flappy/run.py +92 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/test_row_Jensen_linear_tophat.py +96 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/flappy/run.py +94 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/test_row_Jensen_linear_tophat_IECTI_2005.py +122 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/flappy/run.py +94 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/test_row_Jensen_linear_tophat_IECTI_2019.py +122 -0
- tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/flappy/run.py +92 -0
- tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/test_row_Jensen_quadratic_centre.py +93 -0
- tests/1_verification/flappy_0_6_2/grid_rotors/flappy/run.py +85 -0
- tests/1_verification/flappy_0_6_2/grid_rotors/test_grid_rotors.py +130 -0
- tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/flappy/run.py +96 -0
- tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/test_row_Bastankhah_Crespo.py +116 -0
- tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/flappy/run.py +93 -0
- tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/test_row_Bastankhah_linear_centre.py +99 -0
- tests/3_examples/test_examples.py +34 -0
- foxes/VERSION +0 -1
- foxes/output/flow_plots_2d.py +0 -0
- foxes/utils/runners/__init__.py +0 -1
- foxes/utils/runners/runners.py +0 -280
- foxes-0.8.2.dist-info/RECORD +0 -247
- foxes-0.8.2.dist-info/top_level.txt +0 -1
- foxes-0.8.2.dist-info/zip-safe +0 -1
- {foxes-0.8.2.dist-info → foxes-1.0.dist-info}/LICENSE +0 -0
foxes/output/slice_data.py
CHANGED
|
@@ -18,23 +18,20 @@ class SliceData(Output):
|
|
|
18
18
|
The algorithm for point calculation
|
|
19
19
|
farm_results: xarray.Dataset
|
|
20
20
|
The farm results
|
|
21
|
-
runner: foxes.utils.runners.Runner, optional
|
|
22
|
-
The runner
|
|
23
21
|
verbosity_delta: int
|
|
24
22
|
Verbosity threshold for printing calculation info
|
|
25
|
-
|
|
23
|
+
|
|
26
24
|
:group: output
|
|
27
25
|
|
|
28
26
|
"""
|
|
29
27
|
|
|
30
28
|
def __init__(
|
|
31
|
-
self,
|
|
32
|
-
algo,
|
|
33
|
-
farm_results,
|
|
34
|
-
runner=None,
|
|
29
|
+
self,
|
|
30
|
+
algo,
|
|
31
|
+
farm_results,
|
|
35
32
|
verbosity_delta=1,
|
|
36
33
|
**kwargs,
|
|
37
|
-
|
|
34
|
+
):
|
|
38
35
|
"""
|
|
39
36
|
Constructor.
|
|
40
37
|
|
|
@@ -44,8 +41,6 @@ class SliceData(Output):
|
|
|
44
41
|
The algorithm for point calculation
|
|
45
42
|
farm_results: xarray.Dataset
|
|
46
43
|
The farm results
|
|
47
|
-
runner: foxes.utils.runners.Runner, optional
|
|
48
|
-
The runner
|
|
49
44
|
verbosity_delta: int
|
|
50
45
|
Verbosity threshold for printing calculation info
|
|
51
46
|
kwargs: dict, optional
|
|
@@ -55,7 +50,6 @@ class SliceData(Output):
|
|
|
55
50
|
super().__init__(**kwargs)
|
|
56
51
|
self.algo = algo
|
|
57
52
|
self.fres = farm_results
|
|
58
|
-
self.runner = runner
|
|
59
53
|
self.verbosity_delta = verbosity_delta
|
|
60
54
|
|
|
61
55
|
def _data_mod(
|
|
@@ -129,8 +123,6 @@ class SliceData(Output):
|
|
|
129
123
|
label_map,
|
|
130
124
|
vmin,
|
|
131
125
|
vmax,
|
|
132
|
-
states_sel,
|
|
133
|
-
states_isel,
|
|
134
126
|
weight_turbine,
|
|
135
127
|
to_file,
|
|
136
128
|
write_pars,
|
|
@@ -144,9 +136,7 @@ class SliceData(Output):
|
|
|
144
136
|
algo=self.algo,
|
|
145
137
|
farm_results=self.fres,
|
|
146
138
|
g_pts=g_pts,
|
|
147
|
-
|
|
148
|
-
isel={FC.STATE: states_isel} if states_isel is not None else None,
|
|
149
|
-
verbosity=verbosity-self.verbosity_delta,
|
|
139
|
+
verbosity=verbosity - self.verbosity_delta,
|
|
150
140
|
**kwargs,
|
|
151
141
|
)
|
|
152
142
|
states = point_results[FC.STATE].to_numpy()
|
|
@@ -197,7 +187,8 @@ class SliceData(Output):
|
|
|
197
187
|
|
|
198
188
|
def get_mean_data_xy(
|
|
199
189
|
self,
|
|
200
|
-
resolution,
|
|
190
|
+
resolution=None,
|
|
191
|
+
n_img_points=None,
|
|
201
192
|
variables=None,
|
|
202
193
|
data_format="xarray",
|
|
203
194
|
xmin=None,
|
|
@@ -229,8 +220,10 @@ class SliceData(Output):
|
|
|
229
220
|
|
|
230
221
|
Parameters
|
|
231
222
|
----------
|
|
232
|
-
resolution: float
|
|
223
|
+
resolution: float, optional
|
|
233
224
|
The resolution in m
|
|
225
|
+
n_img_points: tuple of int, optional
|
|
226
|
+
The number of image points (n, m) in the two directions
|
|
234
227
|
variables: list of str, optional
|
|
235
228
|
The variables, or None for all
|
|
236
229
|
data_format: str
|
|
@@ -294,16 +287,19 @@ class SliceData(Output):
|
|
|
294
287
|
|
|
295
288
|
"""
|
|
296
289
|
gdata = grids.get_grid_xy(
|
|
297
|
-
self.fres,
|
|
298
|
-
resolution,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
290
|
+
farm_results=self.fres,
|
|
291
|
+
resolution=resolution,
|
|
292
|
+
n_img_points=n_img_points,
|
|
293
|
+
xmin=xmin,
|
|
294
|
+
ymin=ymin,
|
|
295
|
+
xmax=xmax,
|
|
296
|
+
ymax=ymax,
|
|
297
|
+
z=z,
|
|
298
|
+
xspace=xspace,
|
|
299
|
+
yspace=yspace,
|
|
300
|
+
states_sel=states_sel,
|
|
301
|
+
states_isel=states_isel,
|
|
302
|
+
verbosity=verbosity - self.verbosity_delta,
|
|
307
303
|
)
|
|
308
304
|
|
|
309
305
|
data = self._calc_mean_data(
|
|
@@ -318,13 +314,13 @@ class SliceData(Output):
|
|
|
318
314
|
label_map,
|
|
319
315
|
vmin,
|
|
320
316
|
vmax,
|
|
321
|
-
states_sel,
|
|
322
|
-
states_isel,
|
|
323
317
|
weight_turbine,
|
|
324
318
|
to_file,
|
|
325
319
|
write_pars,
|
|
326
320
|
ret_states,
|
|
327
321
|
verbosity,
|
|
322
|
+
states_sel=states_sel,
|
|
323
|
+
states_isel=states_isel,
|
|
328
324
|
**kwargs,
|
|
329
325
|
)
|
|
330
326
|
|
|
@@ -335,7 +331,8 @@ class SliceData(Output):
|
|
|
335
331
|
|
|
336
332
|
def get_mean_data_xz(
|
|
337
333
|
self,
|
|
338
|
-
resolution,
|
|
334
|
+
resolution=None,
|
|
335
|
+
n_img_points=None,
|
|
339
336
|
variables=None,
|
|
340
337
|
data_format="xarray",
|
|
341
338
|
x_direction=270,
|
|
@@ -368,8 +365,10 @@ class SliceData(Output):
|
|
|
368
365
|
|
|
369
366
|
Parameters
|
|
370
367
|
----------
|
|
371
|
-
resolution: float
|
|
368
|
+
resolution: float, optional
|
|
372
369
|
The resolution in m
|
|
370
|
+
n_img_points: tuple of int, optional
|
|
371
|
+
The number of image points (n, m) in the two directions
|
|
373
372
|
variables: list of str, optional
|
|
374
373
|
The variables, or None for all
|
|
375
374
|
data_format: str
|
|
@@ -435,17 +434,20 @@ class SliceData(Output):
|
|
|
435
434
|
|
|
436
435
|
"""
|
|
437
436
|
gdata = grids.get_grid_xz(
|
|
438
|
-
self.fres,
|
|
439
|
-
resolution,
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
437
|
+
farm_results=self.fres,
|
|
438
|
+
resolution=resolution,
|
|
439
|
+
n_img_points=n_img_points,
|
|
440
|
+
x_direction=x_direction,
|
|
441
|
+
xmin=xmin,
|
|
442
|
+
zmin=zmin,
|
|
443
|
+
xmax=xmax,
|
|
444
|
+
zmax=zmax,
|
|
445
|
+
y=y,
|
|
446
|
+
xspace=xspace,
|
|
447
|
+
zspace=zspace,
|
|
448
|
+
states_sel=states_sel,
|
|
449
|
+
states_isel=states_isel,
|
|
450
|
+
verbosity=verbosity - self.verbosity_delta,
|
|
449
451
|
)
|
|
450
452
|
gdatb = (gdata[0], gdata[2], gdata[1], gdata[3])
|
|
451
453
|
|
|
@@ -461,13 +463,13 @@ class SliceData(Output):
|
|
|
461
463
|
label_map,
|
|
462
464
|
vmin,
|
|
463
465
|
vmax,
|
|
464
|
-
states_sel,
|
|
465
|
-
states_isel,
|
|
466
466
|
weight_turbine,
|
|
467
467
|
to_file,
|
|
468
468
|
write_pars,
|
|
469
469
|
ret_states,
|
|
470
470
|
verbosity,
|
|
471
|
+
states_sel=states_sel,
|
|
472
|
+
states_isel=states_isel,
|
|
471
473
|
**kwargs,
|
|
472
474
|
)
|
|
473
475
|
|
|
@@ -478,7 +480,8 @@ class SliceData(Output):
|
|
|
478
480
|
|
|
479
481
|
def get_mean_data_yz(
|
|
480
482
|
self,
|
|
481
|
-
resolution,
|
|
483
|
+
resolution=None,
|
|
484
|
+
n_img_points=None,
|
|
482
485
|
variables=None,
|
|
483
486
|
data_format="xarray",
|
|
484
487
|
x_direction=270,
|
|
@@ -511,8 +514,10 @@ class SliceData(Output):
|
|
|
511
514
|
|
|
512
515
|
Parameters
|
|
513
516
|
----------
|
|
514
|
-
resolution: float
|
|
517
|
+
resolution: float, optional
|
|
515
518
|
The resolution in m
|
|
519
|
+
n_img_points: tuple of int, optional
|
|
520
|
+
The number of image points (n, m) in the two directions
|
|
516
521
|
variables: list of str, optional
|
|
517
522
|
The variables, or None for all
|
|
518
523
|
data_format: str
|
|
@@ -578,17 +583,20 @@ class SliceData(Output):
|
|
|
578
583
|
|
|
579
584
|
"""
|
|
580
585
|
gdata = grids.get_grid_yz(
|
|
581
|
-
self.fres,
|
|
582
|
-
resolution,
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
586
|
+
farm_results=self.fres,
|
|
587
|
+
resolution=resolution,
|
|
588
|
+
n_img_points=n_img_points,
|
|
589
|
+
x_direction=x_direction,
|
|
590
|
+
ymin=ymin,
|
|
591
|
+
zmin=zmin,
|
|
592
|
+
ymax=ymax,
|
|
593
|
+
zmax=zmax,
|
|
594
|
+
x=x,
|
|
595
|
+
yspace=yspace,
|
|
596
|
+
zspace=zspace,
|
|
597
|
+
states_sel=states_sel,
|
|
598
|
+
states_isel=states_isel,
|
|
599
|
+
verbosity=verbosity - self.verbosity_delta,
|
|
592
600
|
)
|
|
593
601
|
gdatb = (gdata[1], gdata[2], gdata[0], gdata[3])
|
|
594
602
|
|
|
@@ -604,13 +612,13 @@ class SliceData(Output):
|
|
|
604
612
|
label_map,
|
|
605
613
|
vmin,
|
|
606
614
|
vmax,
|
|
607
|
-
states_sel,
|
|
608
|
-
states_isel,
|
|
609
615
|
weight_turbine,
|
|
610
616
|
to_file,
|
|
611
617
|
write_pars,
|
|
612
618
|
ret_states,
|
|
613
619
|
verbosity,
|
|
620
|
+
states_sel=states_sel,
|
|
621
|
+
states_isel=states_isel,
|
|
614
622
|
**kwargs,
|
|
615
623
|
)
|
|
616
624
|
|
|
@@ -635,8 +643,6 @@ class SliceData(Output):
|
|
|
635
643
|
label_map,
|
|
636
644
|
vmin,
|
|
637
645
|
vmax,
|
|
638
|
-
states_sel,
|
|
639
|
-
states_isel,
|
|
640
646
|
to_file,
|
|
641
647
|
write_pars,
|
|
642
648
|
ret_states,
|
|
@@ -645,15 +651,11 @@ class SliceData(Output):
|
|
|
645
651
|
):
|
|
646
652
|
"""Helper function for states data calculation"""
|
|
647
653
|
# calculate point results:
|
|
648
|
-
if states_sel is not None:
|
|
649
|
-
kwargs["sel"] = {FC.STATE: states_sel}
|
|
650
|
-
if states_isel is not None:
|
|
651
|
-
kwargs["isel"] = {FC.STATE: states_isel}
|
|
652
654
|
point_results = grids.calc_point_results(
|
|
653
655
|
algo=self.algo,
|
|
654
656
|
farm_results=self.fres,
|
|
655
657
|
g_pts=g_pts,
|
|
656
|
-
verbosity=verbosity-self.verbosity_delta,
|
|
658
|
+
verbosity=verbosity - self.verbosity_delta,
|
|
657
659
|
**kwargs,
|
|
658
660
|
)
|
|
659
661
|
states = point_results[FC.STATE].to_numpy()
|
|
@@ -700,7 +702,8 @@ class SliceData(Output):
|
|
|
700
702
|
|
|
701
703
|
def get_states_data_xy(
|
|
702
704
|
self,
|
|
703
|
-
resolution,
|
|
705
|
+
resolution=None,
|
|
706
|
+
n_img_points=None,
|
|
704
707
|
variables=None,
|
|
705
708
|
data_format="xarray",
|
|
706
709
|
xmin=None,
|
|
@@ -731,8 +734,10 @@ class SliceData(Output):
|
|
|
731
734
|
|
|
732
735
|
Parameters
|
|
733
736
|
----------
|
|
734
|
-
resolution: float
|
|
737
|
+
resolution: float, optional
|
|
735
738
|
The resolution in m
|
|
739
|
+
n_img_points: tuple of int, optional
|
|
740
|
+
The number of image points (n, m) in the two directions
|
|
736
741
|
variables: list of str, optional
|
|
737
742
|
The variables, or None for all
|
|
738
743
|
data_format: str
|
|
@@ -794,16 +799,19 @@ class SliceData(Output):
|
|
|
794
799
|
|
|
795
800
|
"""
|
|
796
801
|
gdata = grids.get_grid_xy(
|
|
797
|
-
self.fres,
|
|
798
|
-
resolution,
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
802
|
+
farm_results=self.fres,
|
|
803
|
+
resolution=resolution,
|
|
804
|
+
n_img_points=n_img_points,
|
|
805
|
+
xmin=xmin,
|
|
806
|
+
ymin=ymin,
|
|
807
|
+
xmax=xmax,
|
|
808
|
+
ymax=ymax,
|
|
809
|
+
z=z,
|
|
810
|
+
xspace=xspace,
|
|
811
|
+
yspace=yspace,
|
|
812
|
+
states_sel=states_sel,
|
|
813
|
+
states_isel=states_isel,
|
|
814
|
+
verbosity=verbosity - self.verbosity_delta,
|
|
807
815
|
)
|
|
808
816
|
|
|
809
817
|
data = self._calc_states_data(
|
|
@@ -818,12 +826,12 @@ class SliceData(Output):
|
|
|
818
826
|
label_map,
|
|
819
827
|
vmin,
|
|
820
828
|
vmax,
|
|
821
|
-
states_sel,
|
|
822
|
-
states_isel,
|
|
823
829
|
to_file,
|
|
824
830
|
write_pars,
|
|
825
831
|
ret_states,
|
|
826
832
|
verbosity,
|
|
833
|
+
states_sel=states_sel,
|
|
834
|
+
states_isel=states_isel,
|
|
827
835
|
**kwargs,
|
|
828
836
|
)
|
|
829
837
|
|
|
@@ -834,7 +842,8 @@ class SliceData(Output):
|
|
|
834
842
|
|
|
835
843
|
def get_states_data_xz(
|
|
836
844
|
self,
|
|
837
|
-
resolution,
|
|
845
|
+
resolution=None,
|
|
846
|
+
n_img_points=None,
|
|
838
847
|
variables=None,
|
|
839
848
|
data_format="xarray",
|
|
840
849
|
x_direction=270,
|
|
@@ -866,8 +875,10 @@ class SliceData(Output):
|
|
|
866
875
|
|
|
867
876
|
Parameters
|
|
868
877
|
----------
|
|
869
|
-
resolution: float
|
|
878
|
+
resolution: float, optional
|
|
870
879
|
The resolution in m
|
|
880
|
+
n_img_points: tuple of int, optional
|
|
881
|
+
The number of image points (n, m) in the two directions
|
|
871
882
|
variables: list of str, optional
|
|
872
883
|
The variables, or None for all
|
|
873
884
|
data_format: str
|
|
@@ -931,17 +942,20 @@ class SliceData(Output):
|
|
|
931
942
|
|
|
932
943
|
"""
|
|
933
944
|
gdata = grids.get_grid_xz(
|
|
934
|
-
self.fres,
|
|
935
|
-
resolution,
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
+
farm_results=self.fres,
|
|
946
|
+
resolution=resolution,
|
|
947
|
+
n_img_points=n_img_points,
|
|
948
|
+
x_direction=x_direction,
|
|
949
|
+
xmin=xmin,
|
|
950
|
+
zmin=zmin,
|
|
951
|
+
xmax=xmax,
|
|
952
|
+
zmax=zmax,
|
|
953
|
+
y=y,
|
|
954
|
+
xspace=xspace,
|
|
955
|
+
zspace=zspace,
|
|
956
|
+
states_sel=states_sel,
|
|
957
|
+
states_isel=states_isel,
|
|
958
|
+
verbosity=verbosity - self.verbosity_delta,
|
|
945
959
|
)
|
|
946
960
|
gdatb = (gdata[0], gdata[2], gdata[1], gdata[3])
|
|
947
961
|
|
|
@@ -957,12 +971,12 @@ class SliceData(Output):
|
|
|
957
971
|
label_map,
|
|
958
972
|
vmin,
|
|
959
973
|
vmax,
|
|
960
|
-
states_sel,
|
|
961
|
-
states_isel,
|
|
962
974
|
to_file,
|
|
963
975
|
write_pars,
|
|
964
976
|
ret_states,
|
|
965
977
|
verbosity,
|
|
978
|
+
states_sel=states_sel,
|
|
979
|
+
states_isel=states_isel,
|
|
966
980
|
**kwargs,
|
|
967
981
|
)
|
|
968
982
|
|
|
@@ -973,7 +987,8 @@ class SliceData(Output):
|
|
|
973
987
|
|
|
974
988
|
def get_states_data_yz(
|
|
975
989
|
self,
|
|
976
|
-
resolution,
|
|
990
|
+
resolution=None,
|
|
991
|
+
n_img_points=None,
|
|
977
992
|
variables=None,
|
|
978
993
|
data_format="xarray",
|
|
979
994
|
x_direction=270,
|
|
@@ -1005,8 +1020,10 @@ class SliceData(Output):
|
|
|
1005
1020
|
|
|
1006
1021
|
Parameters
|
|
1007
1022
|
----------
|
|
1008
|
-
resolution: float
|
|
1023
|
+
resolution: float, optional
|
|
1009
1024
|
The resolution in m
|
|
1025
|
+
n_img_points: tuple of int, optional
|
|
1026
|
+
The number of image points (n, m) in the two directions
|
|
1010
1027
|
variables: list of str, optional
|
|
1011
1028
|
The variables, or None for all
|
|
1012
1029
|
data_format: str
|
|
@@ -1070,17 +1087,20 @@ class SliceData(Output):
|
|
|
1070
1087
|
|
|
1071
1088
|
"""
|
|
1072
1089
|
gdata = grids.get_grid_yz(
|
|
1073
|
-
self.fres,
|
|
1074
|
-
resolution,
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1090
|
+
farm_results=self.fres,
|
|
1091
|
+
resolution=resolution,
|
|
1092
|
+
n_img_points=n_img_points,
|
|
1093
|
+
x_direction=x_direction,
|
|
1094
|
+
ymin=ymin,
|
|
1095
|
+
zmin=zmin,
|
|
1096
|
+
ymax=ymax,
|
|
1097
|
+
zmax=zmax,
|
|
1098
|
+
x=x,
|
|
1099
|
+
yspace=yspace,
|
|
1100
|
+
zspace=zspace,
|
|
1101
|
+
states_sel=states_sel,
|
|
1102
|
+
states_isel=states_isel,
|
|
1103
|
+
verbosity=verbosity - self.verbosity_delta,
|
|
1084
1104
|
)
|
|
1085
1105
|
gdatb = (gdata[1], gdata[2], gdata[0], gdata[3])
|
|
1086
1106
|
|
|
@@ -1096,12 +1116,12 @@ class SliceData(Output):
|
|
|
1096
1116
|
label_map,
|
|
1097
1117
|
vmin,
|
|
1098
1118
|
vmax,
|
|
1099
|
-
states_sel,
|
|
1100
|
-
states_isel,
|
|
1101
1119
|
to_file,
|
|
1102
1120
|
write_pars,
|
|
1103
1121
|
ret_states,
|
|
1104
1122
|
verbosity,
|
|
1123
|
+
states_sel=states_sel,
|
|
1124
|
+
states_isel=states_isel,
|
|
1105
1125
|
**kwargs,
|
|
1106
1126
|
)
|
|
1107
1127
|
|
|
@@ -37,6 +37,7 @@ class StateTurbineMap(Output):
|
|
|
37
37
|
title=None,
|
|
38
38
|
ax=None,
|
|
39
39
|
figsize=None,
|
|
40
|
+
rotate_xlabels=None,
|
|
40
41
|
**kwargs,
|
|
41
42
|
):
|
|
42
43
|
"""
|
|
@@ -53,6 +54,8 @@ class StateTurbineMap(Output):
|
|
|
53
54
|
figsize: tuple
|
|
54
55
|
The figsize argument for plt.subplots()
|
|
55
56
|
in case ax is not provided
|
|
57
|
+
rotate_xlabels: float, optional
|
|
58
|
+
Rotate the x-labels by this number of degrees
|
|
56
59
|
kwargs: dict, optional
|
|
57
60
|
Additional parameters for plt.pcolormesh()
|
|
58
61
|
|
|
@@ -73,29 +76,31 @@ class StateTurbineMap(Output):
|
|
|
73
76
|
states = np.append(states, states[-1] + ds)
|
|
74
77
|
turbines = np.arange(len(turbines) + 1)
|
|
75
78
|
|
|
76
|
-
y, x = np.meshgrid(
|
|
79
|
+
y, x = np.meshgrid(turbines, states)
|
|
77
80
|
z = self.results[variable].to_numpy()
|
|
78
81
|
|
|
79
82
|
prgs = {"shading": "flat"}
|
|
80
83
|
prgs.update(kwargs)
|
|
81
84
|
|
|
82
|
-
c = ax.pcolormesh(x, y, z
|
|
85
|
+
c = ax.pcolormesh(x, y, z, **prgs)
|
|
83
86
|
|
|
84
|
-
ax.
|
|
85
|
-
ax.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
ax.
|
|
87
|
+
ax.set_yticks(turbines[:-1] + 0.5)
|
|
88
|
+
ax.set_yticklabels(turbines[:-1])
|
|
89
|
+
xt = ax.get_xticks()
|
|
90
|
+
xtl = ax.get_xticklabels()
|
|
91
|
+
ax.set_xticks(
|
|
92
|
+
xt[:-1] + 0.5 * (xt[-1] - xt[-2]), xtl[:-1], rotation=rotate_xlabels
|
|
93
|
+
)
|
|
89
94
|
if len(turbines) > 10:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
ax.
|
|
95
|
+
yt = ax.get_yticks()
|
|
96
|
+
ytl = [None for t in yt]
|
|
97
|
+
ytl[::5] = ax.get_yticklabels()[::5]
|
|
98
|
+
ax.set_yticks(yt, ytl)
|
|
94
99
|
fig.colorbar(c, ax=ax)
|
|
95
100
|
|
|
96
101
|
t = title if title is not None else variable
|
|
97
102
|
ax.set_title(t)
|
|
98
|
-
ax.
|
|
99
|
-
ax.
|
|
103
|
+
ax.set_ylabel("Turbine index")
|
|
104
|
+
ax.set_xlabel("State")
|
|
100
105
|
|
|
101
106
|
return ax
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
from xarray import Dataset
|
|
2
2
|
|
|
3
3
|
from foxes.utils import write_nc
|
|
4
|
-
import foxes.constants as FC
|
|
4
|
+
import foxes.constants as FC
|
|
5
5
|
|
|
6
6
|
from .output import Output
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
class StateTurbineTable(Output):
|
|
9
10
|
"""
|
|
10
11
|
Creates tables of state-turbine type data
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
Attributes
|
|
13
14
|
----------
|
|
14
15
|
farm_results: xarray.Dataset
|
|
15
16
|
The farm results
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
:group: output
|
|
18
|
-
|
|
19
|
+
|
|
19
20
|
"""
|
|
21
|
+
|
|
20
22
|
def __init__(self, farm_results):
|
|
21
23
|
"""
|
|
22
24
|
Constructor.
|
|
@@ -28,17 +30,17 @@ class StateTurbineTable(Output):
|
|
|
28
30
|
|
|
29
31
|
"""
|
|
30
32
|
self.farm_results = farm_results
|
|
31
|
-
|
|
33
|
+
|
|
32
34
|
def get_dataset(
|
|
33
|
-
self,
|
|
34
|
-
variables,
|
|
35
|
-
name_map={},
|
|
36
|
-
to_file=None,
|
|
35
|
+
self,
|
|
36
|
+
variables,
|
|
37
|
+
name_map={},
|
|
38
|
+
to_file=None,
|
|
37
39
|
**kwargs,
|
|
38
|
-
|
|
40
|
+
):
|
|
39
41
|
"""
|
|
40
42
|
Creates a dataset object
|
|
41
|
-
|
|
43
|
+
|
|
42
44
|
Parameters
|
|
43
45
|
----------
|
|
44
46
|
variables: list of str
|
|
@@ -49,12 +51,12 @@ class StateTurbineTable(Output):
|
|
|
49
51
|
The output file path, if writing is desired
|
|
50
52
|
kwargs: dict, optional
|
|
51
53
|
Additional parameters for write_nc
|
|
52
|
-
|
|
54
|
+
|
|
53
55
|
Returns
|
|
54
56
|
-------
|
|
55
57
|
table: xarray.Dataset
|
|
56
58
|
The state-turbine data table
|
|
57
|
-
|
|
59
|
+
|
|
58
60
|
"""
|
|
59
61
|
state = name_map.get(FC.STATE, FC.STATE)
|
|
60
62
|
turbine = name_map.get(FC.TURBINE, FC.TURBINE)
|
|
@@ -65,14 +67,12 @@ class StateTurbineTable(Output):
|
|
|
65
67
|
turbine: self.farm_results[FC.TURBINE].to_numpy(),
|
|
66
68
|
},
|
|
67
69
|
data_vars={
|
|
68
|
-
name_map.get(v, v): (
|
|
69
|
-
(state, turbine), self.farm_results[v].to_numpy())
|
|
70
|
+
name_map.get(v, v): ((state, turbine), self.farm_results[v].to_numpy())
|
|
70
71
|
for v in variables
|
|
71
|
-
}
|
|
72
|
+
},
|
|
72
73
|
)
|
|
73
|
-
|
|
74
|
+
|
|
74
75
|
if to_file is not None:
|
|
75
76
|
write_nc(ds=ds, fpath=to_file, **kwargs)
|
|
76
|
-
|
|
77
|
+
|
|
77
78
|
return ds
|
|
78
|
-
|
foxes/utils/__init__.py
CHANGED
|
@@ -17,8 +17,8 @@ from .regularize import sqrt_reg
|
|
|
17
17
|
from .windrose_plot import TabWindroseAxes
|
|
18
18
|
from .tab_files import read_tab_file
|
|
19
19
|
from .random_xy import random_xy_square
|
|
20
|
+
from .dev_utils import print_mem
|
|
20
21
|
|
|
21
22
|
from . import two_circles
|
|
22
23
|
from . import abl
|
|
23
|
-
from . import runners
|
|
24
24
|
from . import geom2d
|
foxes/utils/dev_utils.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from .load import import_module
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def print_mem(obj, min_csize=0, max_csize=None, pre_str="OBJECT SIZE"):
|
|
5
|
+
"""
|
|
6
|
+
Prints the memory consumption of a model and its components
|
|
7
|
+
|
|
8
|
+
Parmeters
|
|
9
|
+
---------
|
|
10
|
+
obj: object
|
|
11
|
+
The object to be analyzed
|
|
12
|
+
min_csize: int
|
|
13
|
+
The minimal size of a component for being shown
|
|
14
|
+
max_csize: int, optional
|
|
15
|
+
The maximal allowed size of a component
|
|
16
|
+
pre_str: str
|
|
17
|
+
String to be printed before
|
|
18
|
+
|
|
19
|
+
:group: utils
|
|
20
|
+
|
|
21
|
+
"""
|
|
22
|
+
objsize = import_module("objsize")
|
|
23
|
+
n = obj.name if hasattr(obj, "name") else ""
|
|
24
|
+
print(pre_str, type(obj).__name__, n, objsize.get_deep_size(obj))
|
|
25
|
+
for k in dir(obj):
|
|
26
|
+
o = None
|
|
27
|
+
try:
|
|
28
|
+
if (
|
|
29
|
+
hasattr(obj, k)
|
|
30
|
+
and not callable(getattr(obj, k))
|
|
31
|
+
and (len(k) < 3 or k[:2] != "__")
|
|
32
|
+
):
|
|
33
|
+
o = getattr(obj, k)
|
|
34
|
+
except ValueError:
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
if o is not None:
|
|
38
|
+
s = objsize.get_deep_size(getattr(obj, k))
|
|
39
|
+
if s >= min_csize:
|
|
40
|
+
print(" ", k, s)
|
|
41
|
+
if max_csize is not None and s > max_csize:
|
|
42
|
+
raise ValueError(f"Component {k} exceeds maximal size {max_csize}")
|