foxes 1.0__py3-none-any.whl → 1.1.1__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 +0 -1
- examples/states_lookup_table/run.py +1 -1
- examples/timeseries/run.py +11 -4
- foxes/algorithms/downwind/downwind.py +18 -13
- foxes/algorithms/downwind/models/farm_wakes_calc.py +1 -1
- foxes/algorithms/downwind/models/init_farm_data.py +1 -1
- foxes/algorithms/downwind/models/point_wakes_calc.py +1 -1
- foxes/algorithms/downwind/models/reorder_farm_output.py +1 -1
- foxes/algorithms/downwind/models/set_amb_farm_results.py +1 -1
- foxes/algorithms/downwind/models/set_amb_point_results.py +1 -1
- foxes/algorithms/iterative/iterative.py +1 -1
- foxes/algorithms/iterative/models/farm_wakes_calc.py +1 -1
- foxes/algorithms/iterative/models/urelax.py +3 -3
- foxes/algorithms/sequential/models/plugin.py +4 -4
- foxes/algorithms/sequential/models/seq_state.py +1 -1
- foxes/constants.py +5 -5
- foxes/core/algorithm.py +2 -2
- foxes/core/data_calc_model.py +2 -2
- foxes/core/engine.py +20 -10
- foxes/core/farm_controller.py +3 -3
- foxes/core/farm_data_model.py +1 -1
- foxes/core/ground_model.py +2 -2
- foxes/core/model.py +122 -108
- foxes/core/partial_wakes_model.py +1 -1
- foxes/core/point_data_model.py +2 -2
- foxes/core/states.py +1 -1
- foxes/core/turbine_type.py +2 -2
- foxes/core/wake_frame.py +8 -30
- foxes/core/wake_model.py +3 -2
- foxes/core/wake_superposition.py +1 -1
- foxes/data/windio/windio_5turbines_timeseries.yaml +9 -15
- foxes/engines/__init__.py +1 -0
- foxes/engines/dask.py +13 -6
- foxes/engines/multiprocess.py +5 -8
- foxes/engines/numpy.py +8 -26
- foxes/engines/pool.py +10 -24
- foxes/engines/ray.py +79 -0
- foxes/engines/single.py +3 -1
- foxes/input/farm_layout/from_json.py +1 -1
- foxes/input/states/__init__.py +1 -0
- foxes/input/states/field_data_nc.py +4 -4
- foxes/input/states/multi_height.py +4 -4
- foxes/input/states/scan_ws.py +1 -1
- foxes/input/states/single.py +1 -1
- foxes/input/states/slice_data_nc.py +681 -0
- foxes/input/states/states_table.py +3 -3
- foxes/input/windio/__init__.py +1 -1
- foxes/input/windio/read_attributes.py +8 -2
- foxes/input/windio/read_fields.py +3 -0
- foxes/input/windio/read_outputs.py +8 -2
- foxes/input/windio/windio.py +6 -2
- foxes/models/farm_models/turbine2farm.py +1 -1
- foxes/models/ground_models/wake_mirror.py +2 -2
- foxes/models/model_book.py +29 -2
- foxes/models/partial_wakes/axiwake.py +3 -3
- foxes/models/partial_wakes/top_hat.py +2 -2
- foxes/models/point_models/set_uniform_data.py +1 -1
- foxes/models/point_models/tke2ti.py +1 -1
- foxes/models/point_models/wake_deltas.py +1 -1
- foxes/models/rotor_models/grid.py +2 -2
- foxes/models/turbine_models/calculator.py +4 -4
- foxes/models/turbine_models/kTI_model.py +22 -6
- foxes/models/turbine_models/lookup_table.py +3 -2
- foxes/models/turbine_types/PCt_file.py +5 -5
- foxes/models/turbine_types/PCt_from_two.py +5 -5
- foxes/models/turbine_types/TBL_file.py +80 -0
- foxes/models/turbine_types/__init__.py +1 -0
- foxes/models/turbine_types/lookup.py +5 -5
- foxes/models/turbine_types/null_type.py +3 -3
- foxes/models/turbine_types/wsrho2PCt_from_two.py +7 -7
- foxes/models/turbine_types/wsti2PCt_from_two.py +9 -9
- foxes/models/vertical_profiles/__init__.py +1 -1
- foxes/models/wake_frames/dynamic_wakes.py +2 -2
- foxes/models/wake_frames/farm_order.py +2 -2
- foxes/models/wake_frames/rotor_wd.py +2 -2
- foxes/models/wake_frames/seq_dynamic_wakes.py +5 -11
- foxes/models/wake_frames/streamlines.py +2 -2
- foxes/models/wake_frames/timelines.py +2 -2
- foxes/models/wake_frames/yawed_wakes.py +3 -3
- foxes/models/wake_models/dist_sliced.py +1 -1
- foxes/models/wake_models/induction/rankine_half_body.py +1 -1
- foxes/models/wake_models/induction/rathmann.py +76 -22
- foxes/models/wake_models/induction/self_similar.py +76 -26
- foxes/models/wake_models/induction/vortex_sheet.py +84 -46
- foxes/models/wake_models/ti/crespo_hernandez.py +6 -4
- foxes/models/wake_models/ti/iec_ti.py +7 -5
- foxes/models/wake_models/wind/bastankhah14.py +6 -4
- foxes/models/wake_models/wind/bastankhah16.py +9 -9
- foxes/models/wake_models/wind/jensen.py +3 -2
- foxes/models/wake_models/wind/turbopark.py +14 -11
- foxes/models/wake_superpositions/ti_linear.py +1 -1
- foxes/models/wake_superpositions/ti_max.py +1 -1
- foxes/models/wake_superpositions/ti_pow.py +1 -1
- foxes/models/wake_superpositions/ti_quadratic.py +1 -1
- foxes/models/wake_superpositions/ws_linear.py +8 -7
- foxes/models/wake_superpositions/ws_max.py +8 -7
- foxes/models/wake_superpositions/ws_pow.py +8 -7
- foxes/models/wake_superpositions/ws_product.py +5 -5
- foxes/models/wake_superpositions/ws_quadratic.py +8 -7
- foxes/output/farm_layout.py +14 -10
- foxes/output/farm_results_eval.py +1 -1
- foxes/output/grids.py +1 -1
- foxes/output/results_writer.py +2 -2
- foxes/output/rose_plot.py +3 -3
- foxes/output/seq_plugins/seq_flow_ani_plugin.py +2 -2
- foxes/output/seq_plugins/seq_wake_debug_plugin.py +2 -2
- foxes/output/state_turbine_map.py +1 -1
- foxes/utils/abl/neutral.py +2 -2
- foxes/utils/abl/stable.py +2 -2
- foxes/utils/abl/unstable.py +2 -2
- foxes/utils/data_book.py +1 -1
- foxes/utils/dict.py +23 -0
- foxes/utils/exec_python.py +1 -1
- foxes/utils/factory.py +29 -1
- foxes/utils/geom2d/circle.py +1 -1
- foxes/utils/geom2d/polygon.py +1 -1
- foxes/utils/geopandas_utils.py +2 -2
- foxes/utils/load.py +2 -2
- foxes/utils/pandas_helpers.py +1 -1
- foxes/utils/xarray_utils.py +1 -1
- foxes/variables.py +3 -3
- {foxes-1.0.dist-info → foxes-1.1.1.dist-info}/METADATA +8 -6
- {foxes-1.0.dist-info → foxes-1.1.1.dist-info}/RECORD +127 -125
- {foxes-1.0.dist-info → foxes-1.1.1.dist-info}/WHEEL +1 -1
- foxes/utils/geopandas_helpers.py +0 -294
- /examples/{induction_RHB → induction}/run.py +0 -0
- {foxes-1.0.dist-info → foxes-1.1.1.dist-info}/LICENSE +0 -0
- {foxes-1.0.dist-info → foxes-1.1.1.dist-info}/top_level.txt +0 -0
foxes/utils/geopandas_helpers.py
DELETED
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
import argparse
|
|
3
|
-
|
|
4
|
-
import foxes.constants as FC
|
|
5
|
-
from .dict import Dict
|
|
6
|
-
from .geom2d import AreaUnion, ClosedPolygon
|
|
7
|
-
|
|
8
|
-
try:
|
|
9
|
-
import geopandas as gpd
|
|
10
|
-
|
|
11
|
-
IMPORT_GPD_OK = True
|
|
12
|
-
except ImportError:
|
|
13
|
-
gpd = None
|
|
14
|
-
IMPORT_GPD_OK = False
|
|
15
|
-
|
|
16
|
-
try:
|
|
17
|
-
import utm
|
|
18
|
-
|
|
19
|
-
IMPORT_UTM_OK = True
|
|
20
|
-
except ImportError:
|
|
21
|
-
utm = None
|
|
22
|
-
IMPORT_UTM_OK = False
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def check_import_gpd():
|
|
26
|
-
"""
|
|
27
|
-
Checks if library import worked,
|
|
28
|
-
raises error otherwise.
|
|
29
|
-
"""
|
|
30
|
-
if not IMPORT_GPD_OK:
|
|
31
|
-
print("\n\nFailed to import geopandas. Please install, either via pip:\n")
|
|
32
|
-
print(" pip install geopandas\n")
|
|
33
|
-
print("or via conda:\n")
|
|
34
|
-
print(" conda install -c conda-forge geopandas\n")
|
|
35
|
-
raise ImportError("Failed to import geopandas")
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def check_import_utm():
|
|
39
|
-
"""
|
|
40
|
-
Checks if library import worked,
|
|
41
|
-
raises error otherwise.
|
|
42
|
-
"""
|
|
43
|
-
if not IMPORT_UTM_OK:
|
|
44
|
-
print("\n\nFailed to import utm. Please install, either via pip:\n")
|
|
45
|
-
print(" pip install utm\n")
|
|
46
|
-
print("or via conda:\n")
|
|
47
|
-
print(" conda install -c conda-forge utm\n")
|
|
48
|
-
raise ImportError("Failed to import utm")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def read_shp(fname, **kwargs):
|
|
52
|
-
"""
|
|
53
|
-
Read a shape file
|
|
54
|
-
|
|
55
|
-
Parameters
|
|
56
|
-
----------
|
|
57
|
-
fname: str
|
|
58
|
-
Path to the .shp file
|
|
59
|
-
kwargs: dict, optional
|
|
60
|
-
Additional parameters for geopandas.read_file()
|
|
61
|
-
|
|
62
|
-
Returns
|
|
63
|
-
-------
|
|
64
|
-
data: geopandas.GeoDataFrame
|
|
65
|
-
The data frame in WSG84
|
|
66
|
-
|
|
67
|
-
:group: utils
|
|
68
|
-
|
|
69
|
-
"""
|
|
70
|
-
check_import_gpd()
|
|
71
|
-
gpdf = gpd.read_file(fname, **kwargs)
|
|
72
|
-
return gpdf.to_crs("EPSG:4326") # Convert to WGS84
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def shp2csv(ifile, ofile, in_kwargs={}, out_kwargs={}, verbosity=1):
|
|
76
|
-
"""
|
|
77
|
-
Read shape file, write csv file
|
|
78
|
-
|
|
79
|
-
Parameters
|
|
80
|
-
----------
|
|
81
|
-
iname: str
|
|
82
|
-
Path to the input .shp file
|
|
83
|
-
oname: str
|
|
84
|
-
Path to the output .csv file
|
|
85
|
-
in_kwargs: dict
|
|
86
|
-
Additional parameters for geopandas.read_file()
|
|
87
|
-
out_kwargs: dict
|
|
88
|
-
Additional parameters for geopandas to_csv()
|
|
89
|
-
verbosity: int
|
|
90
|
-
The verbosity level, 0 = silent
|
|
91
|
-
|
|
92
|
-
:group: utils
|
|
93
|
-
|
|
94
|
-
"""
|
|
95
|
-
if verbosity > 0:
|
|
96
|
-
print("Reading file", ifile)
|
|
97
|
-
|
|
98
|
-
gpdf = read_shp(ifile, **in_kwargs)
|
|
99
|
-
|
|
100
|
-
if verbosity > 0:
|
|
101
|
-
print("Writing file", ofile)
|
|
102
|
-
|
|
103
|
-
gpdf.to_csv(ofile, **out_kwargs)
|
|
104
|
-
|
|
105
|
-
return gpdf
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def _extract_poly_coords(geom):
|
|
109
|
-
"""
|
|
110
|
-
Helper function for shapefile reading
|
|
111
|
-
"""
|
|
112
|
-
if geom.geom_type == "Polygon":
|
|
113
|
-
exterior_coords = geom.exterior.coords[:]
|
|
114
|
-
interior_coords = []
|
|
115
|
-
for interior in geom.interiors:
|
|
116
|
-
interior_coords.append(interior.coords[:])
|
|
117
|
-
elif geom.geom_type == "MultiPolygon":
|
|
118
|
-
exterior_coords = []
|
|
119
|
-
interior_coords = []
|
|
120
|
-
for part in geom.geoms:
|
|
121
|
-
epe, epi = _extract_poly_coords(part) # Recursive call
|
|
122
|
-
exterior_coords.append(epe)
|
|
123
|
-
interior_coords.append(epi)
|
|
124
|
-
else:
|
|
125
|
-
raise ValueError("Unhandled geometry type: " + repr(geom.type))
|
|
126
|
-
return exterior_coords, interior_coords
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
def read_shp_polygons(
|
|
130
|
-
fname,
|
|
131
|
-
names=None,
|
|
132
|
-
name_col="Name",
|
|
133
|
-
geom_col="geometry",
|
|
134
|
-
to_utm=True,
|
|
135
|
-
ret_utm_zone=False,
|
|
136
|
-
**kwargs,
|
|
137
|
-
):
|
|
138
|
-
"""
|
|
139
|
-
Reads the polygon points from a shp file.
|
|
140
|
-
|
|
141
|
-
Parameters
|
|
142
|
-
----------
|
|
143
|
-
fname: str
|
|
144
|
-
Path to the .shp file
|
|
145
|
-
names: list: of str, optinal
|
|
146
|
-
The names of the polygons to be extracted. All by
|
|
147
|
-
default
|
|
148
|
-
name_col: int
|
|
149
|
-
Column that contains the area names
|
|
150
|
-
geom_col: str
|
|
151
|
-
The geometry column
|
|
152
|
-
to_utm: bool or str, optional
|
|
153
|
-
Convert to UTM coordinates. If str, then UTM zone
|
|
154
|
-
plus letter, e.g. "32U"
|
|
155
|
-
ret_utm_zone: bool
|
|
156
|
-
Return UTM zone plus letter as str
|
|
157
|
-
kwargs: dict, optional
|
|
158
|
-
Additional parameters for geopandas.read_shp()
|
|
159
|
-
|
|
160
|
-
Returns
|
|
161
|
-
-------
|
|
162
|
-
point_dict_exterior: dict
|
|
163
|
-
Dict with list of array of points. Key: area name,
|
|
164
|
-
Value: list:np.ndarray, shape of latter: (n_points, 2)
|
|
165
|
-
point_dict_interior: dict
|
|
166
|
-
Dict with list of array of points. Key: area name,
|
|
167
|
-
Value: list:np.ndarray, shape of latter: (n_points, 2)
|
|
168
|
-
utm_zone_str: str, optional
|
|
169
|
-
The utem zone plus letter as str, e.g. "32U"
|
|
170
|
-
|
|
171
|
-
:group: utils
|
|
172
|
-
|
|
173
|
-
"""
|
|
174
|
-
|
|
175
|
-
pdf = read_shp(fname, **kwargs)
|
|
176
|
-
pnames = list(pdf[name_col])
|
|
177
|
-
|
|
178
|
-
utmz = None
|
|
179
|
-
utml = None
|
|
180
|
-
apply_utm = False
|
|
181
|
-
if isinstance(to_utm, str) or to_utm == True:
|
|
182
|
-
apply_utm = True
|
|
183
|
-
check_import_utm()
|
|
184
|
-
utmz = int(to_utm[:-1]) if isinstance(to_utm, str) else None
|
|
185
|
-
utml = to_utm[-1] if isinstance(to_utm, str) else None
|
|
186
|
-
|
|
187
|
-
exterior = Dict()
|
|
188
|
-
interior = Dict()
|
|
189
|
-
names = pnames if names is None else names
|
|
190
|
-
for name in names:
|
|
191
|
-
if name == name: # exclude nan values
|
|
192
|
-
if not name in pnames:
|
|
193
|
-
raise KeyError(
|
|
194
|
-
f"Name '{name}' not found in file '{fname}'. Names: {pnames}"
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
a = pdf.loc[pnames.index(name), geom_col]
|
|
198
|
-
epe, epi = _extract_poly_coords(a)
|
|
199
|
-
|
|
200
|
-
def _to_utm(poly):
|
|
201
|
-
nonlocal utmz, utml
|
|
202
|
-
utm_poly = np.zeros_like(poly)
|
|
203
|
-
utm_poly[:, 0], utm_poly[:, 1], utmz, utml = utm.from_latlon(
|
|
204
|
-
poly[:, 1],
|
|
205
|
-
poly[:, 0],
|
|
206
|
-
force_zone_number=utmz,
|
|
207
|
-
force_zone_letter=utml,
|
|
208
|
-
)
|
|
209
|
-
return utm_poly
|
|
210
|
-
|
|
211
|
-
def _to_numpy(data):
|
|
212
|
-
if not len(data):
|
|
213
|
-
return []
|
|
214
|
-
if isinstance(data[0], tuple):
|
|
215
|
-
out = np.array(data, dtype=FC.DTYPE)
|
|
216
|
-
return _to_utm(out) if apply_utm else out
|
|
217
|
-
return [_to_numpy(d) for d in data]
|
|
218
|
-
|
|
219
|
-
exterior[name] = _to_numpy(epe)
|
|
220
|
-
interior[name] = _to_numpy(epi)
|
|
221
|
-
|
|
222
|
-
if ret_utm_zone:
|
|
223
|
-
return exterior, interior, f"{utmz}{utml}"
|
|
224
|
-
else:
|
|
225
|
-
return exterior, interior
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
def shp2geom2d(*args, ret_utm_zone=False, **kwargs):
|
|
229
|
-
"""
|
|
230
|
-
Read shapefile into geom2d geometry
|
|
231
|
-
|
|
232
|
-
Parameters
|
|
233
|
-
----------
|
|
234
|
-
args: tuple, optional
|
|
235
|
-
Arguments for read_shp_polygons()
|
|
236
|
-
ret_utm_zone: bool
|
|
237
|
-
Return UTM zone plus letter as str
|
|
238
|
-
kwargs: dict, optional
|
|
239
|
-
Keyword arguments for read_shp_polygons()
|
|
240
|
-
|
|
241
|
-
Returns
|
|
242
|
-
-------
|
|
243
|
-
geom: foxes.tools.geom2D.AreaGeometry
|
|
244
|
-
The geometry object
|
|
245
|
-
utm_zone_str: str, optional
|
|
246
|
-
The utem zone plus letter as str, e.g. "32U"
|
|
247
|
-
|
|
248
|
-
:group: utils
|
|
249
|
-
|
|
250
|
-
"""
|
|
251
|
-
|
|
252
|
-
exint = read_shp_polygons(*args, ret_utm_zone=ret_utm_zone, **kwargs)
|
|
253
|
-
|
|
254
|
-
def _create_geom(data):
|
|
255
|
-
if not len(data):
|
|
256
|
-
return None
|
|
257
|
-
if isinstance(data, dict):
|
|
258
|
-
gs = [_create_geom(g) for g in data.values()]
|
|
259
|
-
gs = [g for g in gs if g is not None]
|
|
260
|
-
return AreaUnion(gs) if len(gs) else None
|
|
261
|
-
if isinstance(data, np.ndarray) and len(data.shape) == 2:
|
|
262
|
-
return ClosedPolygon(data)
|
|
263
|
-
gs = [_create_geom(g) for g in data]
|
|
264
|
-
gs = [g for g in gs if g is not None]
|
|
265
|
-
return AreaUnion(gs) if len(gs) else None
|
|
266
|
-
|
|
267
|
-
gext = _create_geom(exint[0])
|
|
268
|
-
gint = _create_geom(exint[1])
|
|
269
|
-
geom = gext - gint if gint is not None else gext
|
|
270
|
-
|
|
271
|
-
if ret_utm_zone:
|
|
272
|
-
return geom, exint[2]
|
|
273
|
-
else:
|
|
274
|
-
return geom
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if __name__ == "__main__":
|
|
278
|
-
# define arguments and options:
|
|
279
|
-
parser = argparse.ArgumentParser()
|
|
280
|
-
parser.add_argument("shp_file", help="The input .shp file")
|
|
281
|
-
parser.add_argument("-n", "--names", help="Area names", default=None, nargs="+")
|
|
282
|
-
parser.add_argument(
|
|
283
|
-
"--no_utm", help="switch off conversion to UTM", action="store_true"
|
|
284
|
-
)
|
|
285
|
-
args = parser.parse_args()
|
|
286
|
-
|
|
287
|
-
g = shp2geom2d(args.shp_file, to_utm=not args.no_utm, names=args.names)
|
|
288
|
-
|
|
289
|
-
import matplotlib.pyplot as plt
|
|
290
|
-
|
|
291
|
-
fig, ax = plt.subplots()
|
|
292
|
-
g.add_to_figure(ax)
|
|
293
|
-
plt.show()
|
|
294
|
-
plt.close(fig)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|