foxes 0.8.2__py3-none-any.whl → 1.1.0.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 (215) hide show
  1. docs/source/conf.py +353 -0
  2. examples/abl_states/run.py +160 -0
  3. examples/compare_rotors_pwakes/run.py +217 -0
  4. examples/compare_wakes/run.py +241 -0
  5. examples/dyn_wakes/run.py +311 -0
  6. examples/field_data_nc/run.py +121 -0
  7. examples/induction/run.py +201 -0
  8. examples/multi_height/run.py +113 -0
  9. examples/power_mask/run.py +249 -0
  10. examples/random_timeseries/run.py +210 -0
  11. examples/scan_row/run.py +193 -0
  12. examples/sector_management/run.py +162 -0
  13. examples/sequential/run.py +209 -0
  14. examples/single_state/run.py +201 -0
  15. examples/states_lookup_table/run.py +137 -0
  16. examples/streamline_wakes/run.py +138 -0
  17. examples/tab_file/run.py +142 -0
  18. examples/timelines/run.py +267 -0
  19. examples/timeseries/run.py +190 -0
  20. examples/timeseries_slurm/run.py +185 -0
  21. examples/wind_rose/run.py +141 -0
  22. examples/windio/run.py +29 -0
  23. examples/yawed_wake/run.py +196 -0
  24. foxes/__init__.py +4 -8
  25. foxes/algorithms/__init__.py +1 -1
  26. foxes/algorithms/downwind/downwind.py +247 -111
  27. foxes/algorithms/downwind/models/farm_wakes_calc.py +12 -7
  28. foxes/algorithms/downwind/models/init_farm_data.py +2 -2
  29. foxes/algorithms/downwind/models/point_wakes_calc.py +6 -7
  30. foxes/algorithms/downwind/models/reorder_farm_output.py +1 -2
  31. foxes/algorithms/downwind/models/set_amb_farm_results.py +1 -1
  32. foxes/algorithms/downwind/models/set_amb_point_results.py +5 -3
  33. foxes/algorithms/iterative/iterative.py +74 -34
  34. foxes/algorithms/iterative/models/farm_wakes_calc.py +12 -7
  35. foxes/algorithms/iterative/models/urelax.py +3 -3
  36. foxes/algorithms/sequential/models/plugin.py +5 -5
  37. foxes/algorithms/sequential/models/seq_state.py +1 -1
  38. foxes/algorithms/sequential/sequential.py +126 -255
  39. foxes/constants.py +22 -7
  40. foxes/core/__init__.py +1 -0
  41. foxes/core/algorithm.py +632 -147
  42. foxes/core/data.py +252 -20
  43. foxes/core/data_calc_model.py +15 -291
  44. foxes/core/engine.py +640 -0
  45. foxes/core/farm_controller.py +38 -10
  46. foxes/core/farm_data_model.py +16 -1
  47. foxes/core/ground_model.py +2 -2
  48. foxes/core/model.py +249 -182
  49. foxes/core/partial_wakes_model.py +1 -1
  50. foxes/core/point_data_model.py +17 -2
  51. foxes/core/rotor_model.py +27 -21
  52. foxes/core/states.py +17 -1
  53. foxes/core/turbine_type.py +28 -0
  54. foxes/core/wake_frame.py +30 -34
  55. foxes/core/wake_model.py +5 -5
  56. foxes/core/wake_superposition.py +1 -1
  57. foxes/data/windio/windio_5turbines_timeseries.yaml +31 -15
  58. foxes/engines/__init__.py +17 -0
  59. foxes/engines/dask.py +982 -0
  60. foxes/engines/default.py +75 -0
  61. foxes/engines/futures.py +72 -0
  62. foxes/engines/mpi.py +38 -0
  63. foxes/engines/multiprocess.py +71 -0
  64. foxes/engines/numpy.py +167 -0
  65. foxes/engines/pool.py +249 -0
  66. foxes/engines/ray.py +79 -0
  67. foxes/engines/single.py +141 -0
  68. foxes/input/farm_layout/__init__.py +1 -0
  69. foxes/input/farm_layout/from_csv.py +4 -0
  70. foxes/input/farm_layout/from_json.py +2 -2
  71. foxes/input/farm_layout/grid.py +2 -2
  72. foxes/input/farm_layout/ring.py +65 -0
  73. foxes/input/farm_layout/row.py +2 -2
  74. foxes/input/states/__init__.py +7 -0
  75. foxes/input/states/create/random_abl_states.py +1 -1
  76. foxes/input/states/field_data_nc.py +158 -33
  77. foxes/input/states/multi_height.py +128 -14
  78. foxes/input/states/one_point_flow.py +577 -0
  79. foxes/input/states/scan_ws.py +74 -3
  80. foxes/input/states/single.py +1 -1
  81. foxes/input/states/slice_data_nc.py +681 -0
  82. foxes/input/states/states_table.py +204 -35
  83. foxes/input/windio/__init__.py +2 -2
  84. foxes/input/windio/get_states.py +44 -23
  85. foxes/input/windio/read_attributes.py +48 -17
  86. foxes/input/windio/read_farm.py +116 -102
  87. foxes/input/windio/read_fields.py +16 -6
  88. foxes/input/windio/read_outputs.py +71 -24
  89. foxes/input/windio/runner.py +31 -17
  90. foxes/input/windio/windio.py +41 -23
  91. foxes/models/farm_models/turbine2farm.py +1 -1
  92. foxes/models/ground_models/wake_mirror.py +10 -6
  93. foxes/models/model_book.py +58 -20
  94. foxes/models/partial_wakes/axiwake.py +3 -3
  95. foxes/models/partial_wakes/rotor_points.py +3 -3
  96. foxes/models/partial_wakes/top_hat.py +2 -2
  97. foxes/models/point_models/set_uniform_data.py +1 -1
  98. foxes/models/point_models/tke2ti.py +1 -1
  99. foxes/models/point_models/wake_deltas.py +1 -1
  100. foxes/models/rotor_models/centre.py +4 -0
  101. foxes/models/rotor_models/grid.py +24 -25
  102. foxes/models/rotor_models/levels.py +4 -5
  103. foxes/models/turbine_models/calculator.py +4 -6
  104. foxes/models/turbine_models/kTI_model.py +22 -6
  105. foxes/models/turbine_models/lookup_table.py +30 -4
  106. foxes/models/turbine_models/rotor_centre_calc.py +4 -3
  107. foxes/models/turbine_models/set_farm_vars.py +103 -34
  108. foxes/models/turbine_types/PCt_file.py +27 -3
  109. foxes/models/turbine_types/PCt_from_two.py +27 -3
  110. foxes/models/turbine_types/TBL_file.py +80 -0
  111. foxes/models/turbine_types/__init__.py +2 -0
  112. foxes/models/turbine_types/lookup.py +316 -0
  113. foxes/models/turbine_types/null_type.py +51 -1
  114. foxes/models/turbine_types/wsrho2PCt_from_two.py +29 -5
  115. foxes/models/turbine_types/wsti2PCt_from_two.py +31 -7
  116. foxes/models/vertical_profiles/__init__.py +1 -1
  117. foxes/models/vertical_profiles/data_profile.py +1 -1
  118. foxes/models/wake_frames/__init__.py +1 -0
  119. foxes/models/wake_frames/dynamic_wakes.py +424 -0
  120. foxes/models/wake_frames/farm_order.py +25 -5
  121. foxes/models/wake_frames/rotor_wd.py +6 -4
  122. foxes/models/wake_frames/seq_dynamic_wakes.py +61 -74
  123. foxes/models/wake_frames/streamlines.py +21 -22
  124. foxes/models/wake_frames/timelines.py +330 -129
  125. foxes/models/wake_frames/yawed_wakes.py +7 -4
  126. foxes/models/wake_models/dist_sliced.py +2 -4
  127. foxes/models/wake_models/induction/rankine_half_body.py +5 -5
  128. foxes/models/wake_models/induction/rathmann.py +78 -24
  129. foxes/models/wake_models/induction/self_similar.py +78 -28
  130. foxes/models/wake_models/induction/vortex_sheet.py +86 -48
  131. foxes/models/wake_models/ti/crespo_hernandez.py +6 -4
  132. foxes/models/wake_models/ti/iec_ti.py +40 -21
  133. foxes/models/wake_models/top_hat.py +1 -1
  134. foxes/models/wake_models/wind/bastankhah14.py +8 -6
  135. foxes/models/wake_models/wind/bastankhah16.py +17 -16
  136. foxes/models/wake_models/wind/jensen.py +4 -3
  137. foxes/models/wake_models/wind/turbopark.py +16 -13
  138. foxes/models/wake_superpositions/ti_linear.py +1 -1
  139. foxes/models/wake_superpositions/ti_max.py +1 -1
  140. foxes/models/wake_superpositions/ti_pow.py +1 -1
  141. foxes/models/wake_superpositions/ti_quadratic.py +1 -1
  142. foxes/models/wake_superpositions/ws_linear.py +8 -7
  143. foxes/models/wake_superpositions/ws_max.py +8 -7
  144. foxes/models/wake_superpositions/ws_pow.py +8 -7
  145. foxes/models/wake_superpositions/ws_product.py +5 -5
  146. foxes/models/wake_superpositions/ws_quadratic.py +8 -7
  147. foxes/output/__init__.py +4 -1
  148. foxes/output/farm_layout.py +16 -12
  149. foxes/output/farm_results_eval.py +1 -1
  150. foxes/output/flow_plots_2d/__init__.py +0 -1
  151. foxes/output/flow_plots_2d/flow_plots.py +70 -30
  152. foxes/output/grids.py +92 -22
  153. foxes/output/results_writer.py +2 -2
  154. foxes/output/rose_plot.py +3 -3
  155. foxes/output/seq_plugins/__init__.py +2 -0
  156. foxes/output/{flow_plots_2d → seq_plugins}/seq_flow_ani_plugin.py +64 -22
  157. foxes/output/seq_plugins/seq_wake_debug_plugin.py +145 -0
  158. foxes/output/slice_data.py +131 -111
  159. foxes/output/state_turbine_map.py +19 -14
  160. foxes/output/state_turbine_table.py +19 -19
  161. foxes/utils/__init__.py +1 -1
  162. foxes/utils/abl/neutral.py +2 -2
  163. foxes/utils/abl/stable.py +2 -2
  164. foxes/utils/abl/unstable.py +2 -2
  165. foxes/utils/data_book.py +1 -1
  166. foxes/utils/dev_utils.py +42 -0
  167. foxes/utils/dict.py +24 -1
  168. foxes/utils/exec_python.py +1 -1
  169. foxes/utils/factory.py +176 -53
  170. foxes/utils/geom2d/circle.py +1 -1
  171. foxes/utils/geom2d/polygon.py +1 -1
  172. foxes/utils/geopandas_utils.py +2 -2
  173. foxes/utils/load.py +2 -2
  174. foxes/utils/pandas_helpers.py +3 -2
  175. foxes/utils/wind_dir.py +0 -2
  176. foxes/utils/xarray_utils.py +24 -14
  177. foxes/variables.py +39 -2
  178. {foxes-0.8.2.dist-info → foxes-1.1.0.2.dist-info}/METADATA +75 -33
  179. foxes-1.1.0.2.dist-info/RECORD +309 -0
  180. {foxes-0.8.2.dist-info → foxes-1.1.0.2.dist-info}/WHEEL +1 -1
  181. foxes-1.1.0.2.dist-info/top_level.txt +4 -0
  182. tests/0_consistency/iterative/test_iterative.py +92 -0
  183. tests/0_consistency/partial_wakes/test_partial_wakes.py +90 -0
  184. tests/1_verification/flappy_0_6/PCt_files/flappy/run.py +85 -0
  185. tests/1_verification/flappy_0_6/PCt_files/test_PCt_files.py +103 -0
  186. tests/1_verification/flappy_0_6/abl_states/flappy/run.py +85 -0
  187. tests/1_verification/flappy_0_6/abl_states/test_abl_states.py +87 -0
  188. tests/1_verification/flappy_0_6/partial_top_hat/flappy/run.py +82 -0
  189. tests/1_verification/flappy_0_6/partial_top_hat/test_partial_top_hat.py +82 -0
  190. tests/1_verification/flappy_0_6/row_Jensen_linear_centre/flappy/run.py +92 -0
  191. tests/1_verification/flappy_0_6/row_Jensen_linear_centre/test_row_Jensen_linear_centre.py +93 -0
  192. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/flappy/run.py +92 -0
  193. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/test_row_Jensen_linear_tophat.py +96 -0
  194. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/flappy/run.py +94 -0
  195. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/test_row_Jensen_linear_tophat_IECTI_2005.py +122 -0
  196. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/flappy/run.py +94 -0
  197. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/test_row_Jensen_linear_tophat_IECTI_2019.py +122 -0
  198. tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/flappy/run.py +92 -0
  199. tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/test_row_Jensen_quadratic_centre.py +93 -0
  200. tests/1_verification/flappy_0_6_2/grid_rotors/flappy/run.py +85 -0
  201. tests/1_verification/flappy_0_6_2/grid_rotors/test_grid_rotors.py +130 -0
  202. tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/flappy/run.py +96 -0
  203. tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/test_row_Bastankhah_Crespo.py +116 -0
  204. tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/flappy/run.py +93 -0
  205. tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/test_row_Bastankhah_linear_centre.py +99 -0
  206. tests/3_examples/test_examples.py +34 -0
  207. foxes/VERSION +0 -1
  208. foxes/output/flow_plots_2d.py +0 -0
  209. foxes/utils/geopandas_helpers.py +0 -294
  210. foxes/utils/runners/__init__.py +0 -1
  211. foxes/utils/runners/runners.py +0 -280
  212. foxes-0.8.2.dist-info/RECORD +0 -247
  213. foxes-0.8.2.dist-info/top_level.txt +0 -1
  214. foxes-0.8.2.dist-info/zip-safe +0 -1
  215. {foxes-0.8.2.dist-info → foxes-1.1.0.2.dist-info}/LICENSE +0 -0
@@ -0,0 +1,145 @@
1
+ from foxes.algorithms.sequential import SequentialPlugin
2
+ from foxes.models.wake_frames.seq_dynamic_wakes import SeqDynamicWakes
3
+
4
+
5
+ class SeqWakeDebugPlugin(SequentialPlugin):
6
+ """
7
+ Plugin for creating wake debug plots in animations
8
+
9
+ Attributes
10
+ ----------
11
+ show_p: bool
12
+ Flag for showing wake points
13
+ show_v: bool
14
+ Flag for showing wake vectors
15
+ vpars: dict
16
+ Additional parameters for vector lines
17
+ ppars: dict
18
+ Additional parameters for point scatter
19
+
20
+ :group: output.seq_plugins
21
+
22
+ """
23
+
24
+ def __init__(self, show_p=True, show_v=True, vpars={}, **ppars):
25
+ """
26
+ Constructor.
27
+
28
+ Parameters
29
+ ----------
30
+ show_p: bool
31
+ Flag for showing wake points
32
+ show_v: bool
33
+ Flag for showing wake vectors
34
+ vpars: dict
35
+ Additional parameters for vector lines
36
+ ppars: dict, optional
37
+ Additional parameters for point scatter
38
+
39
+ """
40
+ super().__init__()
41
+ self.show_p = show_p
42
+ self.show_v = show_v
43
+
44
+ self.vpars = dict(color="blue")
45
+ self.vpars.update(vpars)
46
+
47
+ self.ppars = dict(color="blue")
48
+ self.ppars.update(ppars)
49
+
50
+ def initialize(self, algo):
51
+ """
52
+ Initialize data based on the intial iterator
53
+
54
+ Parameters
55
+ ----------
56
+ algo: foxes.algorithms.sequential.Sequential
57
+ The current sequential algorithm
58
+
59
+ """
60
+ super().initialize(algo)
61
+ self._data = []
62
+
63
+ def update(self, algo, fres, pres=None):
64
+ """
65
+ Updates data based on current iteration
66
+
67
+ Parameters
68
+ ----------
69
+ algo: foxes.algorithms.sequential.Sequential
70
+ The latest sequential algorithm
71
+ fres: xarray.Dataset
72
+ The latest farm results
73
+ pres: xarray.Dataset, optional
74
+ The latest point results
75
+
76
+ """
77
+ super().update(algo, fres, pres)
78
+
79
+ wframe = algo.wake_frame
80
+ if not isinstance(wframe, SeqDynamicWakes):
81
+ raise ValueError(
82
+ f"Wake frame not of type SeqDynamicWakes, got {type(algo.wake_frame).__name__}"
83
+ )
84
+
85
+ counter = algo.counter
86
+ N = counter + 1
87
+ dt = wframe._dt[counter] if counter < len(wframe._dt) else wframe._dt[-1]
88
+
89
+ self._data.append(
90
+ (
91
+ dt,
92
+ wframe._traces_p[:N].copy(),
93
+ wframe._traces_v[:N].copy(),
94
+ )
95
+ )
96
+
97
+ def gen_images(self, ax):
98
+ """
99
+
100
+ Parameters
101
+ ----------
102
+ ax: matplotlib.Axis
103
+ The plotting axis
104
+
105
+ Yields
106
+ ------
107
+ imgs: tuple
108
+ The (figure, artists) tuple
109
+
110
+ """
111
+ while len(self._data):
112
+
113
+ dt, pts, v = self._data.pop(0)
114
+
115
+ N = len(pts)
116
+ artists = []
117
+ if self.show_p:
118
+ artists += [
119
+ ax.scatter(
120
+ pts[:, downwind_index, 0],
121
+ pts[:, downwind_index, 1],
122
+ animated=True,
123
+ **self.ppars,
124
+ )
125
+ for downwind_index in range(self.algo.n_turbines)
126
+ ]
127
+
128
+ if self.show_v:
129
+ for downwind_index in range(self.algo.n_turbines):
130
+ for i in range(N):
131
+ p = pts[i, downwind_index]
132
+ dxy = v[i, downwind_index] * dt
133
+ artists.append(
134
+ ax.arrow(
135
+ p[0],
136
+ p[1],
137
+ dxy[0],
138
+ dxy[1],
139
+ length_includes_head=True,
140
+ animated=True,
141
+ **self.vpars,
142
+ )
143
+ )
144
+
145
+ yield ax.get_figure(), artists
@@ -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
- sel={FC.STATE: states_sel} if states_sel is not None else None,
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
- xmin,
300
- ymin,
301
- xmax,
302
- ymax,
303
- z,
304
- xspace,
305
- yspace,
306
- verbosity-self.verbosity_delta,
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
- x_direction,
441
- xmin,
442
- zmin,
443
- xmax,
444
- zmax,
445
- y,
446
- xspace,
447
- zspace,
448
- verbosity-self.verbosity_delta,
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
- x_direction,
584
- ymin,
585
- zmin,
586
- ymax,
587
- zmax,
588
- x,
589
- yspace,
590
- zspace,
591
- verbosity-self.verbosity_delta,
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
- xmin,
800
- ymin,
801
- xmax,
802
- ymax,
803
- z,
804
- xspace,
805
- yspace,
806
- verbosity-self.verbosity_delta,
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
- x_direction,
937
- xmin,
938
- zmin,
939
- xmax,
940
- zmax,
941
- y,
942
- xspace,
943
- zspace,
944
- verbosity-self.verbosity_delta,
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
- x_direction,
1076
- ymin,
1077
- zmin,
1078
- ymax,
1079
- zmax,
1080
- x,
1081
- yspace,
1082
- zspace,
1083
- verbosity-self.verbosity_delta,
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
 
@@ -7,7 +7,7 @@ from .output import Output
7
7
 
8
8
  class StateTurbineMap(Output):
9
9
  """
10
- Creates heat maps with turbines on the one
10
+ Creates heat maps with turbines on one axis
11
11
  and states on the other axis.
12
12
 
13
13
  Attributes
@@ -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(states, turbines)
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.T, **prgs)
85
+ c = ax.pcolormesh(x, y, z, **prgs)
83
86
 
84
- ax.set_xticks(turbines[:-1] + 0.5)
85
- ax.set_xticklabels(turbines[:-1])
86
- yt = ax.get_yticks()
87
- ytl = ax.get_yticklabels()
88
- ax.set_yticks(yt[:-1] + 0.5 * (yt[-1] - yt[-2]), ytl[:-1])
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
- xt = ax.get_xticks()
91
- xtl = [None for t in xt]
92
- xtl[::5] = ax.get_xticklabels()[::5]
93
- ax.set_xticks(xt, xtl)
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.set_xlabel("Turbine index")
99
- ax.set_ylabel("State")
103
+ ax.set_ylabel("Turbine index")
104
+ ax.set_xlabel("State")
100
105
 
101
106
  return ax