foxes 1.4__py3-none-any.whl → 1.5.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 +1 -1
- examples/abl_states/run.py +58 -56
- examples/dyn_wakes/run.py +110 -118
- examples/field_data_nc/run.py +23 -21
- examples/multi_height/run.py +8 -6
- examples/scan_row/run.py +89 -87
- examples/sector_management/run.py +40 -38
- examples/states_lookup_table/run.py +6 -4
- examples/streamline_wakes/run.py +10 -8
- examples/timelines/run.py +100 -98
- examples/timeseries/run.py +71 -76
- examples/wind_rose/run.py +27 -25
- examples/yawed_wake/run.py +85 -81
- foxes/algorithms/downwind/downwind.py +5 -5
- foxes/algorithms/downwind/models/init_farm_data.py +58 -28
- foxes/algorithms/downwind/models/set_amb_farm_results.py +1 -1
- foxes/core/algorithm.py +6 -5
- foxes/core/data.py +75 -4
- foxes/core/data_calc_model.py +4 -2
- foxes/core/engine.py +33 -40
- foxes/core/farm_data_model.py +16 -13
- foxes/core/model.py +19 -1
- foxes/core/point_data_model.py +19 -14
- foxes/core/rotor_model.py +1 -0
- foxes/core/wake_deflection.py +3 -3
- foxes/data/states/point_cloud_100.nc +0 -0
- foxes/data/states/weibull_cloud_4.nc +0 -0
- foxes/data/states/weibull_grid.nc +0 -0
- foxes/engines/dask.py +3 -6
- foxes/engines/default.py +2 -2
- foxes/engines/numpy.py +11 -10
- foxes/engines/pool.py +21 -11
- foxes/engines/single.py +8 -6
- foxes/input/farm_layout/__init__.py +1 -0
- foxes/input/farm_layout/from_arrays.py +68 -0
- foxes/input/states/__init__.py +7 -1
- foxes/input/states/dataset_states.py +710 -0
- foxes/input/states/field_data.py +531 -0
- foxes/input/states/multi_height.py +2 -0
- foxes/input/states/one_point_flow.py +1 -0
- foxes/input/states/point_cloud_data.py +618 -0
- foxes/input/states/scan.py +2 -0
- foxes/input/states/single.py +2 -0
- foxes/input/states/states_table.py +13 -23
- foxes/input/states/weibull_sectors.py +182 -77
- foxes/input/states/wrg_states.py +1 -1
- foxes/input/yaml/dict.py +25 -24
- foxes/input/yaml/windio/read_attributes.py +40 -27
- foxes/input/yaml/windio/read_farm.py +12 -10
- foxes/input/yaml/windio/read_outputs.py +25 -15
- foxes/input/yaml/windio/read_site.py +121 -12
- foxes/input/yaml/windio/windio.py +22 -10
- foxes/input/yaml/yaml.py +1 -0
- foxes/models/model_book.py +16 -15
- foxes/models/rotor_models/__init__.py +1 -0
- foxes/models/rotor_models/centre.py +1 -1
- foxes/models/rotor_models/direct_infusion.py +241 -0
- foxes/models/turbine_models/calculator.py +16 -3
- foxes/models/turbine_models/kTI_model.py +1 -0
- foxes/models/turbine_models/lookup_table.py +2 -0
- foxes/models/turbine_models/power_mask.py +1 -0
- foxes/models/turbine_models/rotor_centre_calc.py +2 -0
- foxes/models/turbine_models/sector_management.py +1 -0
- foxes/models/turbine_models/set_farm_vars.py +3 -8
- foxes/models/turbine_models/table_factors.py +2 -0
- foxes/models/turbine_models/thrust2ct.py +1 -0
- foxes/models/turbine_models/yaw2yawm.py +2 -0
- foxes/models/turbine_models/yawm2yaw.py +2 -0
- foxes/models/turbine_types/PCt_file.py +2 -4
- foxes/models/turbine_types/PCt_from_two.py +1 -0
- foxes/models/turbine_types/__init__.py +1 -0
- foxes/models/turbine_types/calculator_type.py +123 -0
- foxes/models/turbine_types/null_type.py +1 -0
- foxes/models/turbine_types/wsrho2PCt_from_two.py +2 -0
- foxes/models/turbine_types/wsti2PCt_from_two.py +3 -1
- foxes/output/farm_layout.py +2 -0
- foxes/output/farm_results_eval.py +4 -1
- foxes/output/flow_plots_2d/flow_plots.py +18 -0
- foxes/output/flow_plots_2d/get_fig.py +1 -0
- foxes/output/output.py +6 -1
- foxes/output/results_writer.py +1 -1
- foxes/output/rose_plot.py +10 -0
- foxes/output/rotor_point_plots.py +3 -0
- foxes/output/state_turbine_map.py +3 -0
- foxes/output/turbine_type_curves.py +3 -0
- foxes/utils/dict.py +46 -34
- foxes/utils/factory.py +2 -2
- foxes/utils/xarray_utils.py +20 -12
- {foxes-1.4.dist-info → foxes-1.5.1.dist-info}/METADATA +32 -52
- {foxes-1.4.dist-info → foxes-1.5.1.dist-info}/RECORD +94 -86
- foxes/input/states/field_data_nc.py +0 -833
- {foxes-1.4.dist-info → foxes-1.5.1.dist-info}/WHEEL +0 -0
- {foxes-1.4.dist-info → foxes-1.5.1.dist-info}/entry_points.txt +0 -0
- {foxes-1.4.dist-info → foxes-1.5.1.dist-info}/licenses/LICENSE +0 -0
- {foxes-1.4.dist-info → foxes-1.5.1.dist-info}/top_level.txt +0 -0
foxes/core/farm_data_model.py
CHANGED
|
@@ -66,28 +66,29 @@ class FarmDataModel(DataCalcModel):
|
|
|
66
66
|
"""
|
|
67
67
|
return (FC.STATE, FC.TURBINE)
|
|
68
68
|
|
|
69
|
-
def
|
|
69
|
+
def ensure_output_vars(self, algo, fdata):
|
|
70
70
|
"""
|
|
71
|
-
|
|
71
|
+
Ensures that the output variables are present in the farm data.
|
|
72
72
|
|
|
73
73
|
Parameters
|
|
74
74
|
----------
|
|
75
75
|
algo: foxes.core.Algorithm
|
|
76
76
|
The calculation algorithm
|
|
77
|
-
|
|
78
|
-
The model data
|
|
79
|
-
fdata: foxes.core.Data
|
|
77
|
+
fdata: foxes.core.FData
|
|
80
78
|
The farm data
|
|
81
79
|
|
|
82
80
|
"""
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
for var in self.output_farm_vars(algo):
|
|
82
|
+
if var not in fdata:
|
|
83
|
+
fdata.add(
|
|
84
|
+
var,
|
|
85
|
+
np.full(
|
|
86
|
+
(fdata.n_states, fdata.n_turbines),
|
|
87
|
+
np.nan,
|
|
88
|
+
dtype=config.dtype_double,
|
|
89
|
+
),
|
|
90
|
+
(FC.STATE, FC.TURBINE),
|
|
89
91
|
)
|
|
90
|
-
fdata.dims[v] = (FC.STATE, FC.TURBINE)
|
|
91
92
|
|
|
92
93
|
@abstractmethod
|
|
93
94
|
def calculate(self, algo, mdata, fdata):
|
|
@@ -264,7 +265,7 @@ class FarmDataModelList(FarmDataModel):
|
|
|
264
265
|
The model data
|
|
265
266
|
fdata: foxes.core.FData
|
|
266
267
|
The farm data
|
|
267
|
-
parameters: list of dict
|
|
268
|
+
parameters: list of dict
|
|
268
269
|
A list of parameter dicts, one for each model
|
|
269
270
|
|
|
270
271
|
Returns
|
|
@@ -274,6 +275,8 @@ class FarmDataModelList(FarmDataModel):
|
|
|
274
275
|
Values: numpy.ndarray with shape (n_states, n_turbines)
|
|
275
276
|
|
|
276
277
|
"""
|
|
278
|
+
self.ensure_output_vars(algo, fdata)
|
|
279
|
+
|
|
277
280
|
if parameters is None:
|
|
278
281
|
parameters = [{}] * len(self.models)
|
|
279
282
|
elif not isinstance(parameters, list):
|
foxes/core/model.py
CHANGED
|
@@ -64,12 +64,30 @@ class Model(ABC):
|
|
|
64
64
|
|
|
65
65
|
Returns
|
|
66
66
|
-------
|
|
67
|
-
str
|
|
67
|
+
vnm: str
|
|
68
68
|
Model specific variable name
|
|
69
69
|
|
|
70
70
|
"""
|
|
71
71
|
return f"{self.name}_{v}"
|
|
72
72
|
|
|
73
|
+
def unvar(self, vnm):
|
|
74
|
+
"""
|
|
75
|
+
Translates model specific variable name to origninal variable name.
|
|
76
|
+
|
|
77
|
+
Parameters
|
|
78
|
+
----------
|
|
79
|
+
vnm: str
|
|
80
|
+
The vamodel specific variable name
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
v: str
|
|
85
|
+
Original variable name
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
lng = len(f"{self.name}_")
|
|
89
|
+
return vnm[lng:] if vnm.startswith(f"{self.name}_") else None
|
|
90
|
+
|
|
73
91
|
@property
|
|
74
92
|
def initialized(self):
|
|
75
93
|
"""
|
foxes/core/point_data_model.py
CHANGED
|
@@ -42,30 +42,33 @@ class PointDataModel(DataCalcModel):
|
|
|
42
42
|
"""
|
|
43
43
|
return (FC.STATE, FC.TARGET, FC.TPOINT)
|
|
44
44
|
|
|
45
|
-
def
|
|
45
|
+
def ensure_output_vars(self, algo, tdata):
|
|
46
46
|
"""
|
|
47
|
-
|
|
47
|
+
Ensures that the output variables are present in the target data.
|
|
48
48
|
|
|
49
49
|
Parameters
|
|
50
50
|
----------
|
|
51
51
|
algo: foxes.core.Algorithm
|
|
52
52
|
The calculation algorithm
|
|
53
|
-
|
|
54
|
-
The model data
|
|
55
|
-
fdata: foxes.core.Data
|
|
56
|
-
The farm data
|
|
57
|
-
tdata: foxes.core.Data
|
|
53
|
+
tdata: foxes.core.TData
|
|
58
54
|
The target point data
|
|
59
55
|
|
|
60
56
|
"""
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
vrs = set(self.output_point_vars(algo))
|
|
58
|
+
if hasattr(self, "fixed_vars"):
|
|
59
|
+
vrs.update(self.fixed_vars.keys())
|
|
60
|
+
|
|
61
|
+
for var in vrs:
|
|
62
|
+
if var not in tdata:
|
|
63
|
+
tdata.add(
|
|
64
|
+
var,
|
|
65
|
+
np.full(
|
|
66
|
+
(tdata.n_states, tdata.n_targets, tdata.n_tpoints),
|
|
67
|
+
np.nan,
|
|
68
|
+
dtype=config.dtype_double,
|
|
69
|
+
),
|
|
70
|
+
(FC.STATE, FC.TARGET, FC.TPOINT),
|
|
67
71
|
)
|
|
68
|
-
tdata.dims[v] = (FC.STATE, FC.TARGET, FC.TPOINT)
|
|
69
72
|
|
|
70
73
|
@abstractmethod
|
|
71
74
|
def calculate(self, algo, mdata, fdata, tdata):
|
|
@@ -247,6 +250,8 @@ class PointDataModelList(PointDataModel):
|
|
|
247
250
|
(n_states, n_targets, n_tpoints)
|
|
248
251
|
|
|
249
252
|
"""
|
|
253
|
+
self.ensure_output_vars(algo, tdata)
|
|
254
|
+
|
|
250
255
|
if parameters is None:
|
|
251
256
|
parameters = [{}] * len(self.models)
|
|
252
257
|
elif not isinstance(parameters, list):
|
foxes/core/rotor_model.py
CHANGED
foxes/core/wake_deflection.py
CHANGED
|
@@ -113,13 +113,13 @@ class WakeDeflection(Model):
|
|
|
113
113
|
)
|
|
114
114
|
|
|
115
115
|
@classmethod
|
|
116
|
-
def new(cls,
|
|
116
|
+
def new(cls, wdefl_type, *args, **kwargs):
|
|
117
117
|
"""
|
|
118
118
|
Run-time wake deflection model factory.
|
|
119
119
|
|
|
120
120
|
Parameters
|
|
121
121
|
----------
|
|
122
|
-
|
|
122
|
+
wdefl_type: str
|
|
123
123
|
The selected derived class name
|
|
124
124
|
args: tuple, optional
|
|
125
125
|
Additional parameters for constructor
|
|
@@ -127,4 +127,4 @@ class WakeDeflection(Model):
|
|
|
127
127
|
Additional parameters for constructor
|
|
128
128
|
|
|
129
129
|
"""
|
|
130
|
-
return new_instance(cls,
|
|
130
|
+
return new_instance(cls, wdefl_type, *args, **kwargs)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
foxes/engines/dask.py
CHANGED
|
@@ -199,7 +199,6 @@ def _run_as_ufunc(
|
|
|
199
199
|
out_coords,
|
|
200
200
|
calc_pars,
|
|
201
201
|
init_vars,
|
|
202
|
-
ensure_variables,
|
|
203
202
|
calculate,
|
|
204
203
|
):
|
|
205
204
|
"""
|
|
@@ -314,7 +313,6 @@ def _run_as_ufunc(
|
|
|
314
313
|
data[1].dims[FV.WEIGHT] = data[0].dims[FV.WEIGHT]
|
|
315
314
|
|
|
316
315
|
# run model calculation:
|
|
317
|
-
ensure_variables(algo, *data)
|
|
318
316
|
results = calculate(algo, *data, **calc_pars)
|
|
319
317
|
|
|
320
318
|
# replace missing results by first input data with matching shape:
|
|
@@ -385,7 +383,7 @@ class XArrayEngine(DaskBaseEngine):
|
|
|
385
383
|
self,
|
|
386
384
|
algo,
|
|
387
385
|
model,
|
|
388
|
-
model_data
|
|
386
|
+
model_data,
|
|
389
387
|
farm_data=None,
|
|
390
388
|
point_data=None,
|
|
391
389
|
out_vars=[],
|
|
@@ -408,9 +406,9 @@ class XArrayEngine(DaskBaseEngine):
|
|
|
408
406
|
should be run
|
|
409
407
|
model_data: xarray.Dataset
|
|
410
408
|
The initial model data
|
|
411
|
-
farm_data: xarray.Dataset
|
|
409
|
+
farm_data: xarray.Dataset, optional
|
|
412
410
|
The initial farm data
|
|
413
|
-
point_data: xarray.Dataset
|
|
411
|
+
point_data: xarray.Dataset, optional
|
|
414
412
|
The initial point data
|
|
415
413
|
out_vars: list of str, optional
|
|
416
414
|
Names of the output variables
|
|
@@ -537,7 +535,6 @@ class XArrayEngine(DaskBaseEngine):
|
|
|
537
535
|
out_coords=out_coords,
|
|
538
536
|
calc_pars=calc_pars,
|
|
539
537
|
init_vars=ivars,
|
|
540
|
-
ensure_variables=model.ensure_variables,
|
|
541
538
|
calculate=model.calculate,
|
|
542
539
|
)
|
|
543
540
|
|
foxes/engines/default.py
CHANGED
|
@@ -60,7 +60,7 @@ class DefaultEngine(Engine):
|
|
|
60
60
|
self,
|
|
61
61
|
algo,
|
|
62
62
|
model,
|
|
63
|
-
model_data
|
|
63
|
+
model_data,
|
|
64
64
|
farm_data=None,
|
|
65
65
|
point_data=None,
|
|
66
66
|
**kwargs,
|
|
@@ -75,7 +75,7 @@ class DefaultEngine(Engine):
|
|
|
75
75
|
model: foxes.core.DataCalcModel
|
|
76
76
|
The model that whose calculate function
|
|
77
77
|
should be run
|
|
78
|
-
model_data: xarray.Dataset
|
|
78
|
+
model_data: xarray.Dataset
|
|
79
79
|
The initial model data
|
|
80
80
|
farm_data: xarray.Dataset, optional
|
|
81
81
|
The initial farm data
|
foxes/engines/numpy.py
CHANGED
|
@@ -49,7 +49,7 @@ class NumpyEngine(Engine):
|
|
|
49
49
|
self,
|
|
50
50
|
algo,
|
|
51
51
|
model,
|
|
52
|
-
model_data
|
|
52
|
+
model_data,
|
|
53
53
|
farm_data=None,
|
|
54
54
|
point_data=None,
|
|
55
55
|
out_vars=[],
|
|
@@ -71,9 +71,9 @@ class NumpyEngine(Engine):
|
|
|
71
71
|
should be run
|
|
72
72
|
model_data: xarray.Dataset
|
|
73
73
|
The initial model data
|
|
74
|
-
farm_data: xarray.Dataset
|
|
74
|
+
farm_data: xarray.Dataset, optional
|
|
75
75
|
The initial farm data
|
|
76
|
-
point_data: xarray.Dataset
|
|
76
|
+
point_data: xarray.Dataset, optional
|
|
77
77
|
The initial point data
|
|
78
78
|
out_vars: list of str, optional
|
|
79
79
|
Names of the output variables
|
|
@@ -108,9 +108,6 @@ class NumpyEngine(Engine):
|
|
|
108
108
|
coords = {}
|
|
109
109
|
if FC.STATE in out_coords and FC.STATE in model_data.coords:
|
|
110
110
|
coords[FC.STATE] = model_data[FC.STATE].to_numpy()
|
|
111
|
-
if farm_data is None:
|
|
112
|
-
farm_data = Dataset()
|
|
113
|
-
goal_data = farm_data if point_data is None else point_data
|
|
114
111
|
|
|
115
112
|
# DEBUG objec mem sizes:
|
|
116
113
|
# from foxes.utils import print_mem
|
|
@@ -161,10 +158,10 @@ class NumpyEngine(Engine):
|
|
|
161
158
|
results[key] = _run(
|
|
162
159
|
algo,
|
|
163
160
|
model,
|
|
164
|
-
data,
|
|
165
|
-
iterative,
|
|
166
|
-
chunk_store,
|
|
167
|
-
(i0_states, i0_targets),
|
|
161
|
+
*data,
|
|
162
|
+
iterative=iterative,
|
|
163
|
+
chunk_store=chunk_store,
|
|
164
|
+
i0_t0=(i0_states, i0_targets),
|
|
168
165
|
**calc_pars,
|
|
169
166
|
)
|
|
170
167
|
chunk_store.update(results[key][1])
|
|
@@ -177,7 +174,11 @@ class NumpyEngine(Engine):
|
|
|
177
174
|
|
|
178
175
|
i0_states = i1_states
|
|
179
176
|
|
|
177
|
+
if farm_data is None:
|
|
178
|
+
farm_data = Dataset()
|
|
179
|
+
goal_data = farm_data if point_data is None else point_data
|
|
180
180
|
del calc_pars, farm_data, point_data
|
|
181
|
+
|
|
181
182
|
if pbar is not None:
|
|
182
183
|
pbar.close()
|
|
183
184
|
|
foxes/engines/pool.py
CHANGED
|
@@ -7,7 +7,15 @@ from foxes.core import Engine
|
|
|
7
7
|
import foxes.constants as FC
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def _run(
|
|
10
|
+
def _run(
|
|
11
|
+
algo,
|
|
12
|
+
model,
|
|
13
|
+
*data,
|
|
14
|
+
iterative,
|
|
15
|
+
chunk_store,
|
|
16
|
+
i0_t0,
|
|
17
|
+
**cpars,
|
|
18
|
+
):
|
|
11
19
|
"""Helper function for running in a single process"""
|
|
12
20
|
algo.reset_chunk_store(chunk_store)
|
|
13
21
|
results = model.calculate(algo, *data, **cpars)
|
|
@@ -134,7 +142,7 @@ class PoolEngine(Engine):
|
|
|
134
142
|
self,
|
|
135
143
|
algo,
|
|
136
144
|
model,
|
|
137
|
-
model_data
|
|
145
|
+
model_data,
|
|
138
146
|
farm_data=None,
|
|
139
147
|
point_data=None,
|
|
140
148
|
out_vars=[],
|
|
@@ -156,9 +164,9 @@ class PoolEngine(Engine):
|
|
|
156
164
|
should be run
|
|
157
165
|
model_data: xarray.Dataset
|
|
158
166
|
The initial model data
|
|
159
|
-
farm_data: xarray.Dataset
|
|
167
|
+
farm_data: xarray.Dataset, optional
|
|
160
168
|
The initial farm data
|
|
161
|
-
point_data: xarray.Dataset
|
|
169
|
+
point_data: xarray.Dataset, optional
|
|
162
170
|
The initial point data
|
|
163
171
|
out_vars: list of str, optional
|
|
164
172
|
Names of the output variables
|
|
@@ -179,6 +187,7 @@ class PoolEngine(Engine):
|
|
|
179
187
|
The model results
|
|
180
188
|
|
|
181
189
|
"""
|
|
190
|
+
|
|
182
191
|
# subset selection:
|
|
183
192
|
model_data, farm_data, point_data = self.select_subsets(
|
|
184
193
|
model_data, farm_data, point_data, sel=sel, isel=isel
|
|
@@ -193,9 +202,6 @@ class PoolEngine(Engine):
|
|
|
193
202
|
coords = {}
|
|
194
203
|
if FC.STATE in out_coords and FC.STATE in model_data.coords:
|
|
195
204
|
coords[FC.STATE] = model_data[FC.STATE].to_numpy()
|
|
196
|
-
if farm_data is None:
|
|
197
|
-
farm_data = xr.Dataset()
|
|
198
|
-
goal_data = farm_data if point_data is None else point_data
|
|
199
205
|
|
|
200
206
|
# DEBUG objec mem sizes:
|
|
201
207
|
# from foxes.utils import print_mem
|
|
@@ -245,10 +251,10 @@ class PoolEngine(Engine):
|
|
|
245
251
|
_run,
|
|
246
252
|
algo,
|
|
247
253
|
model,
|
|
248
|
-
data,
|
|
249
|
-
iterative,
|
|
250
|
-
chunk_store,
|
|
251
|
-
(i0_states, i0_targets),
|
|
254
|
+
*data,
|
|
255
|
+
iterative=iterative,
|
|
256
|
+
chunk_store=chunk_store,
|
|
257
|
+
i0_t0=(i0_states, i0_targets),
|
|
252
258
|
**calc_pars,
|
|
253
259
|
)
|
|
254
260
|
del data
|
|
@@ -260,6 +266,10 @@ class PoolEngine(Engine):
|
|
|
260
266
|
|
|
261
267
|
i0_states = i1_states
|
|
262
268
|
|
|
269
|
+
if farm_data is None:
|
|
270
|
+
farm_data = xr.Dataset()
|
|
271
|
+
goal_data = farm_data if point_data is None else point_data
|
|
272
|
+
|
|
263
273
|
del calc_pars, farm_data, point_data
|
|
264
274
|
if pbar is not None:
|
|
265
275
|
pbar.close()
|
foxes/engines/single.py
CHANGED
|
@@ -73,7 +73,7 @@ class SingleChunkEngine(Engine):
|
|
|
73
73
|
self,
|
|
74
74
|
algo,
|
|
75
75
|
model,
|
|
76
|
-
model_data
|
|
76
|
+
model_data,
|
|
77
77
|
farm_data=None,
|
|
78
78
|
point_data=None,
|
|
79
79
|
out_vars=[],
|
|
@@ -95,9 +95,9 @@ class SingleChunkEngine(Engine):
|
|
|
95
95
|
should be run
|
|
96
96
|
model_data: xarray.Dataset
|
|
97
97
|
The initial model data
|
|
98
|
-
farm_data: xarray.Dataset
|
|
98
|
+
farm_data: xarray.Dataset, optional
|
|
99
99
|
The initial farm data
|
|
100
|
-
point_data: xarray.Dataset
|
|
100
|
+
point_data: xarray.Dataset, optional
|
|
101
101
|
The initial point data
|
|
102
102
|
out_vars: list of str, optional
|
|
103
103
|
Names of the output variables
|
|
@@ -133,9 +133,6 @@ class SingleChunkEngine(Engine):
|
|
|
133
133
|
coords = {}
|
|
134
134
|
if FC.STATE in out_coords and FC.STATE in model_data.coords:
|
|
135
135
|
coords[FC.STATE] = model_data[FC.STATE].to_numpy()
|
|
136
|
-
if farm_data is None:
|
|
137
|
-
farm_data = Dataset()
|
|
138
|
-
goal_data = farm_data if point_data is None else point_data
|
|
139
136
|
algo.reset_chunk_store(chunk_store)
|
|
140
137
|
|
|
141
138
|
# calculate:
|
|
@@ -157,6 +154,11 @@ class SingleChunkEngine(Engine):
|
|
|
157
154
|
|
|
158
155
|
results = {}
|
|
159
156
|
results[(0, 0)] = (model.calculate(algo, *data, **calc_pars), algo.chunk_store)
|
|
157
|
+
del data
|
|
158
|
+
|
|
159
|
+
if farm_data is None:
|
|
160
|
+
farm_data = Dataset()
|
|
161
|
+
goal_data = farm_data if point_data is None else point_data
|
|
160
162
|
|
|
161
163
|
return self.combine_results(
|
|
162
164
|
algo=algo,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from foxes.core import Turbine
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def add_from_arrays(
|
|
5
|
+
farm,
|
|
6
|
+
x,
|
|
7
|
+
y,
|
|
8
|
+
heights=None,
|
|
9
|
+
diameters=None,
|
|
10
|
+
ids=None,
|
|
11
|
+
names=None,
|
|
12
|
+
turbine_base_name="T",
|
|
13
|
+
turbine_base_name_count_shift=False,
|
|
14
|
+
verbosity=1,
|
|
15
|
+
**turbine_parameters,
|
|
16
|
+
):
|
|
17
|
+
"""
|
|
18
|
+
Add turbines to wind farm from direct one dimensional data arrays.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
farm: foxes.WindFarm
|
|
23
|
+
The wind farm
|
|
24
|
+
x: list or numpy.ndarray
|
|
25
|
+
The x-coordinates of the turbines
|
|
26
|
+
y: list or numpy.ndarray
|
|
27
|
+
The y-coordinates of the turbines
|
|
28
|
+
heights: list or numpy.ndarray, optional
|
|
29
|
+
The hub heights of the turbines, or None
|
|
30
|
+
diameters: list or numpy.ndarray, optional
|
|
31
|
+
The rotor diameters of the turbines, or None
|
|
32
|
+
ids: list or numpy.ndarray, optional
|
|
33
|
+
The ids of the turbines, or None
|
|
34
|
+
names: list or numpy.ndarray, optional
|
|
35
|
+
The names of the turbines, or None
|
|
36
|
+
turbine_base_name: str, optional
|
|
37
|
+
The turbine base name, only used
|
|
38
|
+
if col_name is None
|
|
39
|
+
turbine_base_name_count_shift: bool, optional
|
|
40
|
+
Start turbine names by 1 instead of 0
|
|
41
|
+
verbosity: int
|
|
42
|
+
The verbosity level, 0 = silent
|
|
43
|
+
turbine_parameters: dict, optional
|
|
44
|
+
Additional parameters are forwarded to the WindFarm.add_turbine().
|
|
45
|
+
|
|
46
|
+
:group: input.farm_layout
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
tmodels = turbine_parameters.pop("turbine_models", [])
|
|
50
|
+
H = turbine_parameters.pop("H", None)
|
|
51
|
+
D = turbine_parameters.pop("D", None)
|
|
52
|
+
|
|
53
|
+
for i in range(len(x)):
|
|
54
|
+
s = 1 if turbine_base_name_count_shift else 0
|
|
55
|
+
tname = f"{turbine_base_name}{i + s}" if names is None else names[i]
|
|
56
|
+
|
|
57
|
+
farm.add_turbine(
|
|
58
|
+
Turbine(
|
|
59
|
+
name=tname,
|
|
60
|
+
index=ids[i] if ids is not None else i,
|
|
61
|
+
xy=[x[i], y[i]],
|
|
62
|
+
H=heights[i] if heights is not None else H,
|
|
63
|
+
D=diameters[i] if diameters is not None else D,
|
|
64
|
+
turbine_models=tmodels,
|
|
65
|
+
**turbine_parameters,
|
|
66
|
+
),
|
|
67
|
+
verbosity=verbosity,
|
|
68
|
+
)
|
foxes/input/states/__init__.py
CHANGED
|
@@ -4,14 +4,20 @@ Atmospheric input states.
|
|
|
4
4
|
|
|
5
5
|
from .single import SingleStateStates as SingleStateStates
|
|
6
6
|
from .scan import ScanStates as ScanStates
|
|
7
|
-
from .field_data_nc import FieldDataNC as FieldDataNC
|
|
8
7
|
from .wrg_states import WRGStates as WRGStates
|
|
9
8
|
from .weibull_sectors import WeibullSectors as WeibullSectors
|
|
9
|
+
from .dataset_states import DatasetStates as DatasetStates
|
|
10
10
|
|
|
11
11
|
from .states_table import StatesTable as StatesTable
|
|
12
12
|
from .states_table import Timeseries as Timeseries
|
|
13
13
|
from .states_table import TabStates as TabStates
|
|
14
14
|
|
|
15
|
+
from .field_data import FieldData as FieldData
|
|
16
|
+
from .field_data import WeibullField as WeibullField
|
|
17
|
+
|
|
18
|
+
from .point_cloud_data import WeibullPointCloud as WeibullPointCloud
|
|
19
|
+
from .point_cloud_data import PointCloudData as PointCloudData
|
|
20
|
+
|
|
15
21
|
from .multi_height import MultiHeightStates as MultiHeightStates
|
|
16
22
|
from .multi_height import MultiHeightTimeseries as MultiHeightTimeseries
|
|
17
23
|
from .multi_height import MultiHeightNCStates as MultiHeightNCStates
|