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.

Files changed (66) hide show
  1. foxes/VERSION +1 -1
  2. foxes/algorithms/downwind/downwind.py +41 -46
  3. foxes/algorithms/downwind/models/point_wakes_calc.py +4 -9
  4. foxes/algorithms/downwind/models/set_amb_point_results.py +5 -22
  5. foxes/core/algorithm.py +1 -1
  6. foxes/core/data_calc_model.py +26 -2
  7. foxes/core/partial_wakes_model.py +1 -1
  8. foxes/core/rotor_model.py +36 -2
  9. foxes/core/turbine_model.py +36 -0
  10. foxes/core/turbine_type.py +35 -1
  11. foxes/core/wake_frame.py +39 -3
  12. foxes/core/wake_model.py +36 -0
  13. foxes/models/model_book.py +132 -85
  14. foxes/models/turbine_models/rotor_centre_calc.py +1 -2
  15. foxes/models/turbine_types/CpCt_file.py +13 -3
  16. foxes/models/turbine_types/CpCt_from_two.py +14 -4
  17. foxes/models/vertical_profiles/abl_log_neutral_ws.py +32 -5
  18. foxes/models/vertical_profiles/abl_log_stable_ws.py +32 -4
  19. foxes/models/vertical_profiles/abl_log_unstable_ws.py +32 -4
  20. foxes/models/vertical_profiles/abl_log_ws.py +50 -18
  21. foxes/models/wake_frames/yawed_wakes.py +15 -9
  22. foxes/models/wake_models/induction/__init__.py +1 -1
  23. foxes/models/wake_models/induction/rankine_half_body.py +33 -7
  24. foxes/models/wake_models/ti/crespo_hernandez.py +6 -1
  25. foxes/models/wake_models/ti/iec_ti.py +5 -3
  26. foxes/models/wake_models/wind/__init__.py +2 -2
  27. foxes/models/wake_models/wind/{bastankhah.py → bastankhah14.py} +11 -14
  28. foxes/models/wake_models/wind/{porte_agel.py → bastankhah16.py} +24 -16
  29. foxes/models/wake_models/wind/turbopark.py +11 -22
  30. foxes/models/wake_superpositions/__init__.py +9 -5
  31. foxes/models/wake_superpositions/ti_linear.py +134 -0
  32. foxes/models/wake_superpositions/ti_max.py +134 -0
  33. foxes/models/wake_superpositions/{ti_superp.py → ti_pow.py} +15 -57
  34. foxes/models/wake_superpositions/ti_quadratic.py +134 -0
  35. foxes/models/wake_superpositions/ws_linear.py +170 -0
  36. foxes/models/wake_superpositions/ws_max.py +173 -0
  37. foxes/models/wake_superpositions/ws_pow.py +175 -0
  38. foxes/models/wake_superpositions/{product.py → ws_product.py} +43 -22
  39. foxes/models/wake_superpositions/ws_quadratic.py +170 -0
  40. foxes/output/__init__.py +4 -0
  41. foxes/output/calc_points.py +143 -0
  42. foxes/output/flow_plots_2d/__init__.py +1 -0
  43. foxes/output/flow_plots_2d/common.py +104 -1
  44. foxes/output/flow_plots_2d/flow_plots.py +237 -569
  45. foxes/output/flow_plots_2d/get_fig.py +183 -0
  46. foxes/output/flow_plots_2d/seq_flow_ani_plugin.py +0 -1
  47. foxes/output/grids.py +705 -0
  48. foxes/output/output.py +58 -11
  49. foxes/output/results_writer.py +101 -17
  50. foxes/output/round.py +10 -0
  51. foxes/output/slice_data.py +900 -0
  52. foxes/utils/__init__.py +5 -3
  53. foxes/utils/exec_python.py +56 -0
  54. foxes/utils/geopandas_utils.py +294 -0
  55. foxes/utils/pandas_utils.py +175 -0
  56. foxes/utils/plotly_utils.py +19 -0
  57. foxes/utils/xarray_utils.py +38 -0
  58. {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/METADATA +1 -1
  59. {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/RECORD +63 -49
  60. foxes/models/wake_superpositions/linear.py +0 -242
  61. foxes/models/wake_superpositions/max.py +0 -258
  62. foxes/models/wake_superpositions/quadratic.py +0 -252
  63. {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/LICENSE +0 -0
  64. {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/WHEEL +0 -0
  65. {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/top_level.txt +0 -0
  66. {foxes-0.5.1.dist-info → foxes-0.5.2.dist-info}/zip-safe +0 -0
@@ -0,0 +1,183 @@
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ from mpl_toolkits.axes_grid1 import make_axes_locatable
4
+
5
+ from foxes.utils import wd2uv
6
+
7
+ def get_fig(
8
+ var,
9
+ fig,
10
+ figsize,
11
+ ax,
12
+ data,
13
+ si,
14
+ s,
15
+ levels,
16
+ x_pos,
17
+ y_pos,
18
+ cmap,
19
+ xlabel,
20
+ ylabel,
21
+ title,
22
+ add_bar,
23
+ vlabel,
24
+ ret_state,
25
+ ret_im,
26
+ quiv=None,
27
+ invert_axis=None,
28
+ animated=False,
29
+ ):
30
+ """
31
+ Helper function that creates the flow image plot.
32
+
33
+ Parameters
34
+ ----------
35
+ var: str
36
+ The variable name
37
+ fig: plt.Figure, optional
38
+ The figure object
39
+ figsize: tuple
40
+ The figsize for plt.Figure
41
+ ax: plt.Axes, optional
42
+ The figure axes
43
+ data: numpy.ndarray
44
+ The grid data to plot, shape: (n_states, n_x, x_y)
45
+ si: int, optional
46
+ The state counter
47
+ s: object
48
+ The state index
49
+ levels: int
50
+ The number of levels for the contourf plot,
51
+ or None for non-contour image
52
+ x_pos: numpy.ndarray
53
+ The grid x positions, shape: (n_x, 3)
54
+ y_pos: numpy.ndarray
55
+ The grid y positions, shape: (n_y, 3)
56
+ xlabel: str
57
+ The x axis label
58
+ ylabel: str
59
+ The y axis label
60
+ title: str, optional
61
+ The title
62
+ add_bar: bool
63
+ Add a color bar
64
+ vlabel: str, optional
65
+ The variable label
66
+ ret_state: bool
67
+ Flag for state index return
68
+ ret_im: bool
69
+ Flag for image return
70
+ quiv: tuple, optional
71
+ The quiver data: (n, pars, wd, ws)
72
+ invert_axis: str, optional
73
+ Which axis to invert, either x or y
74
+ animated: bool
75
+ Switch for usage for an animation
76
+
77
+ Yields
78
+ ------
79
+ fig: matplotlib.Figure
80
+ The figure object
81
+ si: int, optional
82
+ The state index
83
+ im: tuple, optional
84
+ The image objects, matplotlib.collections.QuadMesh
85
+ or matplotlib.QuadContourSet
86
+
87
+ """
88
+ # create plot:
89
+ if fig is None:
90
+ hfig = plt.figure(figsize=figsize)
91
+ else:
92
+ hfig = fig
93
+ if ax is None:
94
+ hax = hfig.add_subplot(111)
95
+ else:
96
+ hax = ax
97
+
98
+ # get results:
99
+ N_x = len(x_pos)
100
+ N_y = len(y_pos)
101
+ zz = data[si].reshape(N_x, N_y).T
102
+
103
+ # raw data image:
104
+ if levels is None:
105
+ im = hax.pcolormesh(
106
+ x_pos,
107
+ y_pos,
108
+ zz,
109
+ shading="auto",
110
+ cmap=cmap,
111
+ animated=animated,
112
+ )
113
+
114
+ # contour plot:
115
+ else:
116
+ im = hax.contourf(
117
+ x_pos,
118
+ y_pos,
119
+ zz,
120
+ levels=levels,
121
+ cmap=cmap,
122
+ # animated=animated,
123
+ )
124
+
125
+ qv = None
126
+ if quiv is not None and quiv[0] is not None:
127
+ n, pars, wd, ws = quiv
128
+ uv = wd2uv(wd[si], ws[si])
129
+ u = uv[:, :, 0].T[::n, ::n]
130
+ v = uv[:, :, 1].T[::n, ::n]
131
+ qv = hax.quiver(x_pos[::n], y_pos[::n], u, v, animated=animated, **pars)
132
+ del n, pars, u, v, uv
133
+
134
+ hax.autoscale_view()
135
+ hax.set_xlabel(xlabel)
136
+ hax.set_ylabel(ylabel)
137
+ hax.set_aspect("equal", adjustable="box")
138
+
139
+ ttl = None
140
+ if animated and title is None:
141
+ if hasattr(s, "dtype") and np.issubdtype(s.dtype, np.datetime64):
142
+ t = np.datetime_as_string(s, unit="m").replace("T", " ")
143
+ else:
144
+ t = s
145
+ ttl = hax.text(
146
+ 0.5,
147
+ 1.05,
148
+ f"State {t}",
149
+ backgroundcolor="w",
150
+ transform=hax.transAxes,
151
+ ha="center",
152
+ animated=True,
153
+ clip_on=False,
154
+ )
155
+ else:
156
+ hax.set_title(title if title is not None else f"State {s}")
157
+
158
+ if invert_axis == "x":
159
+ hax.invert_xaxis()
160
+ elif invert_axis == "y":
161
+ hax.invert_yaxis()
162
+
163
+ if add_bar:
164
+ divider = make_axes_locatable(hax)
165
+ cax = divider.append_axes("right", size="5%", pad=0.05)
166
+ vlab = vlabel if vlabel is not None else var
167
+ hfig.colorbar(im, cax=cax, orientation="vertical", label=vlab)
168
+ out = hfig
169
+ else:
170
+ out = fig
171
+
172
+ if ret_state or ret_im:
173
+ out = [out]
174
+ if ret_state:
175
+ out.append(si)
176
+ if ret_im:
177
+ out.append([i for i in [im, qv, ttl] if i is not None])
178
+ if ret_state or ret_im:
179
+ out = tuple(out)
180
+
181
+ return out
182
+
183
+
@@ -1,5 +1,4 @@
1
1
  from foxes.algorithms.sequential import SequentialPlugin
2
- import matplotlib.pyplot as plt
3
2
 
4
3
  from .flow_plots import FlowPlots2D
5
4