foxes 0.7.1__py3-none-any.whl → 0.7.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.

foxes/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
@@ -227,7 +227,9 @@ class Downwind(Algorithm):
227
227
  for i, m in enumerate(self.farm_controller.pre_rotor_models.models):
228
228
  print(f" {i}) {m.name}: {m} [pre-rotor]")
229
229
  for i, m in enumerate(self.farm_controller.post_rotor_models.models):
230
- print(f" {i+len(self.farm_controller.pre_rotor_models.models)}) {m.name}: {m}")
230
+ print(
231
+ f" {i+len(self.farm_controller.pre_rotor_models.models)}) {m.name}: {m}"
232
+ )
231
233
  print(deco)
232
234
  print()
233
235
 
foxes/models/__init__.py CHANGED
@@ -13,6 +13,6 @@ from . import wake_superpositions
13
13
  from . import farm_controllers
14
14
  from . import vertical_profiles
15
15
  from . import point_models
16
- from . import axial_induction_models
16
+ from . import axial_induction
17
17
 
18
18
  from .model_book import ModelBook
@@ -1,7 +1,7 @@
1
1
  from math import sqrt
2
2
  import foxes.models as fm
3
3
  import foxes.variables as FV
4
- from foxes.utils import Dict, FDict
4
+ from foxes.utils import FDict
5
5
 
6
6
  from foxes.core import (
7
7
  PointDataModel,
@@ -25,42 +25,42 @@ class ModelBook:
25
25
 
26
26
  Attributes
27
27
  ----------
28
- point_models: foxes.utils.Dict
28
+ point_models: foxes.utils.FDict
29
29
  The point models. Keys: model name str,
30
30
  values: foxes.core.PointDataModel
31
- rotor_models: foxes.utils.Dict
31
+ rotor_models: foxes.utils.FDict
32
32
  The rotor models. Keys: model name str,
33
33
  values: foxes.core.RotorModel
34
- turbine_types: foxes.utils.Dict
34
+ turbine_types: foxes.utils.FDict
35
35
  The turbine type models. Keys: model name str,
36
36
  values: foxes.core.TurbineType
37
- turbine_models: foxes.utils.Dict
37
+ turbine_models: foxes.utils.FDict
38
38
  The turbine models. Keys: model name str,
39
39
  values: foxes.core.TurbineModel
40
- farm_models: foxes.utils.Dict
40
+ farm_models: foxes.utils.FDict
41
41
  The farm models. Keys: model name str,
42
42
  values: foxes.core.FarmModel
43
- farm_controllers: foxes.utils.Dict
43
+ farm_controllers: foxes.utils.FDict
44
44
  The farm controllers. Keys: model name str,
45
45
  values: foxes.core.FarmController
46
- partial_wakes: foxes.utils.Dict
46
+ partial_wakes: foxes.utils.FDict
47
47
  The partial wakes. Keys: model name str,
48
48
  values: foxes.core.PartialWakeModel
49
- wake_frames: foxes.utils.Dict
49
+ wake_frames: foxes.utils.FDict
50
50
  The wake frames. Keys: model name str,
51
51
  values: foxes.core.WakeFrame
52
- wake_superpositions: foxes.utils.Dict
52
+ wake_superpositions: foxes.utils.FDict
53
53
  The wake superposition models. Keys: model name str,
54
54
  values: foxes.core.WakeSuperposition
55
- wake_models: foxes.utils.Dict
55
+ wake_models: foxes.utils.FDict
56
56
  The wake models. Keys: model name str,
57
57
  values: foxes.core.WakeModel
58
- induction_models: foxes.utils.Dict
58
+ induction_models: foxes.utils.FDict
59
59
  The induction models. Keys: model name str,
60
60
  values: foxes.core.AxialInductionModel
61
- sources: foxes.utils.Dict
61
+ sources: foxes.utils.FDict
62
62
  All sources dict
63
- base_classes: foxes.utils.Dict
63
+ base_classes: foxes.utils.FDict
64
64
  The base classes for all model types
65
65
 
66
66
  :group: models
@@ -77,7 +77,7 @@ class ModelBook:
77
77
  Path to power/ct curve file, for creation
78
78
  of default turbine type model
79
79
  """
80
- self.point_models = Dict(name="point_models")
80
+ self.point_models = FDict(name="point_models")
81
81
  self.point_models["tke2ti"] = fm.point_models.TKE2TI()
82
82
 
83
83
  self.rotor_models = FDict(name="rotor_models")
@@ -88,8 +88,11 @@ class ModelBook:
88
88
  n2 = float(n2)
89
89
  n = int(sqrt(n2))
90
90
  if n**2 != n2:
91
- raise Exception(f"GridRotor factory: Value {n2} is not the square of an integer")
91
+ raise Exception(
92
+ f"GridRotor factory: Value {n2} is not the square of an integer"
93
+ )
92
94
  return n
95
+
93
96
  self.rotor_models.add_factory(
94
97
  fm.rotor_models.GridRotor,
95
98
  "grid<n2>",
@@ -100,7 +103,7 @@ class ModelBook:
100
103
  )
101
104
  self.rotor_models.add_factory(
102
105
  fm.rotor_models.GridRotor,
103
- "raw_grid<n2>",
106
+ "grid<n2>_raw",
104
107
  kwargs=dict(calc_vars=rvars, reduce=False),
105
108
  var2arg={"n2": "n"},
106
109
  n2=_n2n,
@@ -115,13 +118,13 @@ class ModelBook:
115
118
  )
116
119
  self.rotor_models.add_factory(
117
120
  fm.rotor_models.LevelRotor,
118
- "raw_level<n>",
121
+ "level<n>_raw",
119
122
  kwargs=dict(calc_vars=rvars, reduce=False),
120
123
  n=lambda x: int(x),
121
124
  hints={"n": "(Number of vertical levels)"},
122
125
  )
123
126
 
124
- self.turbine_types = Dict(name="turbine_types")
127
+ self.turbine_types = FDict(name="turbine_types")
125
128
  self.turbine_types["null_type"] = fm.turbine_types.NullType()
126
129
  self.turbine_types["NREL5MW"] = fm.turbine_types.PCtFile(
127
130
  "NREL-5MW-D126-H90.csv", rho=1.225
@@ -165,8 +168,10 @@ class ModelBook:
165
168
  "kTI_<kTI>_<kb>",
166
169
  kTI=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
167
170
  kb=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
168
- hints={"kTI": "(Value, e.g. 004 for 0.04)",
169
- "kb": "(Value, e.g. 004 for 0.04)"},
171
+ hints={
172
+ "kTI": "(Value, e.g. 004 for 0.04)",
173
+ "kb": "(Value, e.g. 004 for 0.04)",
174
+ },
170
175
  )
171
176
  self.turbine_models.add_factory(
172
177
  fm.turbine_models.kTI,
@@ -174,8 +179,10 @@ class ModelBook:
174
179
  kwargs=dict(ti_var=FV.AMB_TI),
175
180
  kTI=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
176
181
  kb=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
177
- hints={"kTI": "(Value, e.g. 004 for 0.04)",
178
- "kb": "(Value, e.g. 004 for 0.04)"},
182
+ hints={
183
+ "kTI": "(Value, e.g. 004 for 0.04)",
184
+ "kb": "(Value, e.g. 004 for 0.04)",
185
+ },
179
186
  )
180
187
 
181
188
  self.turbine_models["hubh_data"] = fm.turbine_models.RotorCentreCalc(
@@ -187,7 +194,7 @@ class ModelBook:
187
194
  }
188
195
  )
189
196
 
190
- self.farm_models = Dict(
197
+ self.farm_models = FDict(
191
198
  name="farm_models",
192
199
  **{
193
200
  f"farm_{mname}": fm.farm_models.Turbine2FarmModel(m)
@@ -195,7 +202,7 @@ class ModelBook:
195
202
  },
196
203
  )
197
204
 
198
- self.farm_controllers = Dict(
205
+ self.farm_controllers = FDict(
199
206
  name="farm_controllers",
200
207
  basic_ctrl=fm.farm_controllers.BasicFarmController(),
201
208
  )
@@ -246,11 +253,13 @@ class ModelBook:
246
253
  )
247
254
 
248
255
  self.wake_frames["timelines"] = fm.wake_frames.Timelines()
256
+
249
257
  def _todt(x):
250
258
  if x[-1] == "s":
251
- return float(x[:-1])/60
259
+ return float(x[:-1]) / 60
252
260
  elif x[-3:] == "min":
253
261
  return float(x[:-3])
262
+
254
263
  self.wake_frames.add_factory(
255
264
  fm.wake_frames.Timelines,
256
265
  "timelines_<dt>",
@@ -266,7 +275,7 @@ class ModelBook:
266
275
  hints={"dt": "(Time step, e.g '10s', '1min' etc.)"},
267
276
  )
268
277
 
269
- self.wake_superpositions = Dict(
278
+ self.wake_superpositions = FDict(
270
279
  name="wake_superpositions",
271
280
  ws_linear=fm.wake_superpositions.WSLinear(scale_amb=False),
272
281
  ws_linear_lim=fm.wake_superpositions.WSLinear(
@@ -309,11 +318,9 @@ class ModelBook:
309
318
  ti_max=fm.wake_superpositions.TIMax(superp_to_amb="quadratic"),
310
319
  )
311
320
 
312
- self.axial_induction = Dict(name="induction_models")
313
- self.axial_induction["Betz"] = fm.axial_induction_models.BetzAxialInduction()
314
- self.axial_induction["Madsen"] = (
315
- fm.axial_induction_models.MadsenAxialInduction()
316
- )
321
+ self.axial_induction = FDict(name="induction_models")
322
+ self.axial_induction["Betz"] = fm.axial_induction.BetzAxialInduction()
323
+ self.axial_induction["Madsen"] = fm.axial_induction.MadsenAxialInduction()
317
324
 
318
325
  self.wake_models = FDict(name="wake_models")
319
326
 
@@ -328,8 +335,10 @@ class ModelBook:
328
335
  "Jensen_<superposition>_k<k>",
329
336
  superposition=lambda s: f"ws_{s}",
330
337
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
331
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
332
- "k": "(Value, e.g. 004 for 0.04)"},
338
+ hints={
339
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
340
+ "k": "(Value, e.g. 004 for 0.04)",
341
+ },
333
342
  )
334
343
 
335
344
  self.wake_models.add_factory(
@@ -345,8 +354,10 @@ class ModelBook:
345
354
  kwargs=dict(sbeta_factor=0.2),
346
355
  superposition=lambda s: f"ws_{s}",
347
356
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
348
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
349
- "k": "(Value, e.g. 004 for 0.04)"},
357
+ hints={
358
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
359
+ "k": "(Value, e.g. 004 for 0.04)",
360
+ },
350
361
  )
351
362
  self.wake_models.add_factory(
352
363
  fm.wake_models.wind.Bastankhah2014,
@@ -361,8 +372,10 @@ class ModelBook:
361
372
  kwargs=dict(sbeta_factor=0.2, induction="Betz"),
362
373
  superposition=lambda s: f"ws_{s}",
363
374
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
364
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
365
- "k": "(Value, e.g. 004 for 0.04)"},
375
+ hints={
376
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
377
+ "k": "(Value, e.g. 004 for 0.04)",
378
+ },
366
379
  )
367
380
  self.wake_models.add_factory(
368
381
  fm.wake_models.wind.Bastankhah2014,
@@ -377,8 +390,10 @@ class ModelBook:
377
390
  kwargs=dict(sbeta_factor=0.25),
378
391
  superposition=lambda s: f"ws_{s}",
379
392
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
380
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
381
- "k": "(Value, e.g. 004 for 0.04)"},
393
+ hints={
394
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
395
+ "k": "(Value, e.g. 004 for 0.04)",
396
+ },
382
397
  )
383
398
  self.wake_models.add_factory(
384
399
  fm.wake_models.wind.Bastankhah2014,
@@ -393,8 +408,10 @@ class ModelBook:
393
408
  kwargs=dict(sbeta_factor=0.25, induction="Betz"),
394
409
  superposition=lambda s: f"ws_{s}",
395
410
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
396
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
397
- "k": "(Value, e.g. 004 for 0.04)"},
411
+ hints={
412
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
413
+ "k": "(Value, e.g. 004 for 0.04)",
414
+ },
398
415
  )
399
416
 
400
417
  self.wake_models.add_factory(
@@ -408,8 +425,10 @@ class ModelBook:
408
425
  "Bastankhah2016_<superposition>_k<k>",
409
426
  superposition=lambda s: f"ws_{s}",
410
427
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
411
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
412
- "k": "(Value, e.g. 004 for 0.04)"},
428
+ hints={
429
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
430
+ "k": "(Value, e.g. 004 for 0.04)",
431
+ },
413
432
  )
414
433
  self.wake_models.add_factory(
415
434
  fm.wake_models.wind.Bastankhah2016,
@@ -424,8 +443,10 @@ class ModelBook:
424
443
  kwargs=dict(induction="Betz"),
425
444
  superposition=lambda s: f"ws_{s}",
426
445
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
427
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
428
- "k": "(Value, e.g. 004 for 0.04)"},
446
+ hints={
447
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
448
+ "k": "(Value, e.g. 004 for 0.04)",
449
+ },
429
450
  )
430
451
 
431
452
  self.wake_models.add_factory(
@@ -439,8 +460,10 @@ class ModelBook:
439
460
  "TurbOPark_<superposition>_k<k>",
440
461
  superposition=lambda s: f"ws_{s}",
441
462
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
442
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
443
- "k": "(Value, e.g. 004 for 0.04)"},
463
+ hints={
464
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
465
+ "k": "(Value, e.g. 004 for 0.04)",
466
+ },
444
467
  )
445
468
  self.wake_models.add_factory(
446
469
  fm.wake_models.wind.TurbOParkWake,
@@ -455,8 +478,10 @@ class ModelBook:
455
478
  kwargs=dict(induction="Betz"),
456
479
  superposition=lambda s: f"ws_{s}",
457
480
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
458
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
459
- "k": "(Value, e.g. 004 for 0.04)"},
481
+ hints={
482
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
483
+ "k": "(Value, e.g. 004 for 0.04)",
484
+ },
460
485
  )
461
486
 
462
487
  self.wake_models.add_factory(
@@ -464,8 +489,10 @@ class ModelBook:
464
489
  "TurbOParkIX_<superposition>_dx<dx>",
465
490
  superposition=lambda s: f"ws_{s}",
466
491
  dx=lambda x: float(x),
467
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
468
- "dx": "(Integration step in m)"},
492
+ hints={
493
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
494
+ "dx": "(Integration step in m)",
495
+ },
469
496
  )
470
497
 
471
498
  self.wake_models.add_factory(
@@ -474,9 +501,11 @@ class ModelBook:
474
501
  superposition=lambda s: f"ws_{s}",
475
502
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
476
503
  dx=lambda x: float(x),
477
- hints={"superposition": "(Superposition, e.g. linear for ws_linear)",
478
- "k": "(Value, e.g. 004 for 0.04)",
479
- "dx": "(Integration step in m)"},
504
+ hints={
505
+ "superposition": "(Superposition, e.g. linear for ws_linear)",
506
+ "k": "(Value, e.g. 004 for 0.04)",
507
+ "dx": "(Integration step in m)",
508
+ },
480
509
  )
481
510
 
482
511
  self.wake_models.add_factory(
@@ -493,8 +522,10 @@ class ModelBook:
493
522
  kwargs=dict(use_ambti=False),
494
523
  superposition=lambda s: f"ti_{s}",
495
524
  k=lambda x: float(f"0.{x[1:]}" if x[0] == "0" else float(x)),
496
- hints={"superposition": "(Superposition, e.g. linear for ti_linear)",
497
- "k": "(Value, e.g. 004 for 0.04)"},
525
+ hints={
526
+ "superposition": "(Superposition, e.g. linear for ti_linear)",
527
+ "k": "(Value, e.g. 004 for 0.04)",
528
+ },
498
529
  )
499
530
 
500
531
  self.wake_models.add_factory(
@@ -520,7 +551,7 @@ class ModelBook:
520
551
  fm.wake_models.induction.SelfSimilar2020()
521
552
  )
522
553
 
523
- self.sources = Dict(
554
+ self.sources = FDict(
524
555
  name="sources",
525
556
  point_models=self.point_models,
526
557
  rotor_models=self.rotor_models,
@@ -534,7 +565,7 @@ class ModelBook:
534
565
  wake_models=self.wake_models,
535
566
  axial_induction=self.axial_induction,
536
567
  )
537
- self.base_classes = Dict(
568
+ self.base_classes = FDict(
538
569
  name="base_classes",
539
570
  point_models=PointDataModel,
540
571
  rotor_models=RotorModel,
@@ -663,7 +694,7 @@ class ModelBook:
663
694
 
664
695
  """
665
696
  for ms in self.sources.values():
666
- if isinstance(ms, Dict):
697
+ if isinstance(ms, FDict):
667
698
  for m in ms.values():
668
699
  if m.initialized:
669
700
  m.finalize(algo, verbosity)
@@ -182,6 +182,7 @@ class WSMax(WakeSuperposition):
182
182
  w = np.minimum(w, self.lim_high - amb_results)
183
183
  return w
184
184
 
185
+
185
186
  class WSMaxLocal(WakeSuperposition):
186
187
  """
187
188
  Local max supersposition of wind deficit results
@@ -184,6 +184,7 @@ class WSPow(WakeSuperposition):
184
184
  w = np.minimum(w, self.lim_high - amb_results)
185
185
  return w
186
186
 
187
+
187
188
  class WSPowLocal(WakeSuperposition):
188
189
  """
189
190
  Local power supersposition of wind deficit results
@@ -179,6 +179,7 @@ class WSQuadratic(WakeSuperposition):
179
179
  w = np.minimum(w, self.lim_high - amb_results)
180
180
  return w
181
181
 
182
+
182
183
  class WSQuadraticLocal(WakeSuperposition):
183
184
  """
184
185
  Local quadratic supersposition of wind deficit results
foxes/utils/factory.py CHANGED
@@ -1,10 +1,13 @@
1
+ import numpy as np
2
+
1
3
  from .dict import Dict
2
4
 
5
+
3
6
  class Factory:
4
7
  """
5
- Constructs objects from a choice of allowed
8
+ Constructs objects from a choice of allowed
6
9
  constructor parameters
7
-
10
+
8
11
  Attributes
9
12
  ----------
10
13
  base: class
@@ -22,25 +25,26 @@ class Factory:
22
25
  Hints for print_toc, only for variables for which the
23
26
  options are functions or missing
24
27
  options: dict
25
- For each variable, e.g. A, B or C, the list or dict
28
+ For each variable, e.g. A, B or C, the list or dict
26
29
  or function that maps a str to the actual value
27
30
 
28
31
  :group: utils
29
-
32
+
30
33
  """
34
+
31
35
  def __init__(
32
- self,
33
- base,
34
- name_template,
35
- args=(),
36
- kwargs={},
37
- var2arg={},
38
- hints={},
39
- **options,
40
- ):
36
+ self,
37
+ base,
38
+ name_template,
39
+ args=(),
40
+ kwargs={},
41
+ var2arg={},
42
+ hints={},
43
+ **options,
44
+ ):
41
45
  """
42
46
  Constructor.
43
-
47
+
44
48
  Parameters
45
49
  ----------
46
50
  base: class
@@ -58,9 +62,9 @@ class Factory:
58
62
  Hints for print_toc, only for variables for which the
59
63
  options are functions or missing
60
64
  options: dict
61
- For each variable, e.g. A, B or C, the list or dict
65
+ For each variable, e.g. A, B or C, the list or dict
62
66
  or function that maps a str to the actual value
63
-
67
+
64
68
  """
65
69
  self.base = base
66
70
  self.name_template = name_template
@@ -71,7 +75,9 @@ class Factory:
71
75
 
72
76
  parts = name_template.split(">")
73
77
  if len(parts) < 2:
74
- raise ValueError(f"Factory '{name_template}': Expecting at least one variable in template, pattern '<..>'")
78
+ raise ValueError(
79
+ f"Factory '{name_template}': Expecting at least one variable in template, pattern '<..>'"
80
+ )
75
81
 
76
82
  self._vars = []
77
83
  self._pre = []
@@ -79,7 +85,13 @@ class Factory:
79
85
  if i < len(parts) - 1:
80
86
  parts2 = p.split("<")
81
87
  if len(parts2) != 2:
82
- raise ValueError(f"Factory '{name_template}': incomplete pattern brackets '<..>'")
88
+ raise ValueError(
89
+ f"Factory '{name_template}': incomplete pattern brackets '<..>' between variables, e.g. '_'"
90
+ )
91
+ if i > 0 and len(parts2[0]) == 0:
92
+ raise ValueError(
93
+ f"Factory '{name_template}': Missing seperator like '_' in template between variables '{self._vars[-1]}' and '{parts[1]}'"
94
+ )
83
95
  self._pre.append(parts2[0])
84
96
  self._vars.append(parts2[1])
85
97
  else:
@@ -89,34 +101,42 @@ class Factory:
89
101
  for vi, v in enumerate(self.variables):
90
102
  p = self._pre[vi]
91
103
  if vi < len(self.variables) - 1 and p == "":
92
- raise ValueError(f"Factory '{name_template}': Require indicator before variable '{v}' in template, e.g. '{v}<{v}>'")
93
-
104
+ raise ValueError(
105
+ f"Factory '{name_template}': Require indicator before variable '{v}' in template, e.g. '{v}<{v}>'"
106
+ )
107
+
94
108
  self.options = Dict(name=f"{self._pre[0]}_options")
95
- for v, o in options.items():
109
+ for v, o in options.items():
96
110
  if v not in self.variables:
97
- raise KeyError(f"Factory '{name_template}': Variable '{v}' found in options, but not in template")
111
+ raise KeyError(
112
+ f"Factory '{name_template}': Variable '{v}' found in options, but not in template"
113
+ )
98
114
  if isinstance(o, list) or isinstance(o, tuple):
99
115
  o = {str(k): k for k in o}
100
116
  if isinstance(o, dict):
101
117
  for k in o.keys():
102
118
  if not isinstance(k, str):
103
- raise TypeError(f"Factory '{name_template}': Found option for variable '{v}' that is not a str, {k}")
119
+ raise TypeError(
120
+ f"Factory '{name_template}': Found option for variable '{v}' that is not a str, {k}"
121
+ )
104
122
  self.options[v] = Dict(name=f"{self._pre[0]}_options_{v}", **o)
105
123
  elif hasattr(o, "__call__"):
106
124
  self.options[v] = o
107
125
  else:
108
- raise ValueError(f"Factory '{name_template}': Variable '{v}' has option of type '{type(v).__name__}'. Only list, tuple, dict or function are supported")
109
-
126
+ raise ValueError(
127
+ f"Factory '{name_template}': Variable '{v}' has option of type '{type(v).__name__}'. Only list, tuple, dict or function are supported"
128
+ )
129
+
110
130
  @property
111
131
  def name_prefix(self):
112
132
  """
113
133
  The beginning of the name template
114
-
134
+
115
135
  Returns
116
136
  -------
117
137
  nbase: str
118
138
  The beginning of the name template
119
-
139
+
120
140
  """
121
141
  return self._pre[0]
122
142
 
@@ -124,30 +144,30 @@ class Factory:
124
144
  def name_suffix(self):
125
145
  """
126
146
  The ending of the name template
127
-
147
+
128
148
  Returns
129
149
  -------
130
150
  nbase: str
131
151
  The ending of the name template
132
-
152
+
133
153
  """
134
154
  return self._pre[-1]
135
-
155
+
136
156
  @property
137
157
  def variables(self):
138
158
  """
139
159
  The list of variables
140
-
160
+
141
161
  Returns
142
162
  -------
143
163
  vrs: list of str
144
164
  The variables
145
-
165
+
146
166
  """
147
167
  return self._vars
148
-
168
+
149
169
  def __str__(self):
150
- """ String representation """
170
+ """String representation"""
151
171
  s = f"{self.name_template}: {self.base.__name__} with"
152
172
  for k, d in self.kwargs.items():
153
173
  s += f"\n {k}={d}"
@@ -157,11 +177,11 @@ class Factory:
157
177
  else:
158
178
  s += f"\n {v}={self.hints.get(v, '(value)')}"
159
179
  return s
160
-
180
+
161
181
  def check_match(self, name):
162
182
  """
163
183
  Tests if a name matches the template
164
-
184
+
165
185
  Parameters
166
186
  ----------
167
187
  name: str
@@ -171,7 +191,7 @@ class Factory:
171
191
  -------
172
192
  success: bool
173
193
  True if the template is matched
174
-
194
+
175
195
  """
176
196
  data_str = name
177
197
  for vi in range(len(self.variables)):
@@ -182,7 +202,7 @@ class Factory:
182
202
  return False
183
203
  data_str = data_str[j:]
184
204
 
185
- q = self._pre[vi+1]
205
+ q = self._pre[vi + 1]
186
206
  if q != "":
187
207
  i = data_str.find(q)
188
208
  j = i + len(q)
@@ -190,47 +210,42 @@ class Factory:
190
210
  return False
191
211
  else:
192
212
  data_str = ""
193
-
213
+
194
214
  return True
195
215
 
196
216
  def construct(self, name):
197
217
  """
198
218
  Create an object of the base class.
199
-
219
+
200
220
  Parameters
201
221
  ----------
202
222
  name: str
203
223
  The name, matching the template
204
-
224
+
205
225
  Returns
206
226
  -------
207
227
  obj: object
208
228
  The instance of the base class
209
-
229
+
210
230
  """
211
- data_str = name
231
+ j = 0
212
232
  wlist = []
213
- for vi, v in enumerate(self.variables):
214
- p = self._pre[vi]
215
- i = data_str.find(p)
216
- j = i + len(p)
217
- if i < 0 or len(data_str) <= j:
218
- raise ValueError(f"Factory '{self.name_template}': Name '{name}' not matching template")
219
- data_str = data_str[j:]
220
-
221
- q = self._pre[vi+1]
222
- if q != "":
223
- i = data_str.find(q)
224
- j = i + len(q)
225
- if i < 0 or len(data_str) <= j:
226
- raise ValueError(f"Factory '{self.name_template}': Name '{name}' not matching template")
227
- wlist.append(data_str[:i])
233
+ for pi, p in enumerate(self._pre):
234
+ if len(p) > 0:
235
+ i = name[j:].find(p)
236
+ if i < 0 or (pi == 0 and i > 0):
237
+ raise ValueError(
238
+ f"Factory '{self.name_template}': Name '{name}' not matching template"
239
+ )
240
+ w = name[j : j + i]
241
+ j += i + len(p)
228
242
  else:
229
- wlist.append(data_str)
230
- data_str = ""
243
+ w = name[j:]
244
+ if pi > 0:
245
+ wlist.append(w)
231
246
 
232
247
  kwargs = {}
233
- for vi, v in enumerate(self.variables):
248
+ for vi, v in enumerate(self.variables):
234
249
  w = self.var2arg.get(v, v)
235
250
  data = wlist[vi]
236
251
  if v in self.options:
@@ -246,24 +261,26 @@ class Factory:
246
261
 
247
262
  return self.base(*self.args, **kwargs)
248
263
 
264
+
249
265
  class FDict(Dict):
250
266
  """
251
267
  A dictionary with factory support
252
-
268
+
253
269
  Attributes
254
270
  ----------
255
271
  store_created: bool
256
272
  Flag for storing created objects
257
273
  factories: list of foxes.utils.Factory
258
274
  The factories
259
-
275
+
260
276
  :group: utils
261
-
277
+
262
278
  """
279
+
263
280
  def __init__(self, *args, store_created=True, **kwargs):
264
281
  """
265
282
  Constructor.
266
-
283
+
267
284
  Parameters
268
285
  ----------
269
286
  args: tuple, optional
@@ -272,7 +289,7 @@ class FDict(Dict):
272
289
  Flag for storing created objects
273
290
  kwargs: dict, optional
274
291
  Parameters for the base class
275
-
292
+
276
293
  """
277
294
  super().__init__(*args, **kwargs)
278
295
  self.store_created = store_created
@@ -281,21 +298,21 @@ class FDict(Dict):
281
298
  def add_factory(self, *args, **kwargs):
282
299
  """
283
300
  Constructor.
284
-
301
+
285
302
  Parameters
286
303
  ----------
287
304
  args: tuple, optional
288
305
  Parameters for the Factory constructor
289
306
  kwargs: dict, optional
290
307
  Parameters for the Factory constructor
291
-
308
+
292
309
  """
293
310
  f = Factory(*args, **kwargs)
294
311
  i = len(self.factories)
295
312
  for gi in range(len(self.factories) - 1, -1, -1):
296
313
  g = self.factories[gi]
297
314
  if (
298
- g.name_prefix == f.name_prefix
315
+ g.name_prefix == f.name_prefix
299
316
  and g.name_suffix == f.name_suffix
300
317
  and len(f.variables) > len(g.variables)
301
318
  ):
@@ -330,4 +347,3 @@ class FDict(Dict):
330
347
  k = ", ".join(sorted(list(self.keys())))
331
348
  e = f"{self.name}: Cannot find key '{key}', also no factory matches. Known keys: {k}. Known factories: {[f.name_template for f in self.factories]}"
332
349
  raise KeyError(e)
333
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foxes
3
- Version: 0.7.1
3
+ Version: 0.7.2
4
4
  Summary: Farm Optimization and eXtended yield Evaluation Software
5
5
  Author: Fraunhofer IWES
6
6
  Author-email: jonas.schmidt@iwes.fraunhofer.de
@@ -1,10 +1,10 @@
1
- foxes/VERSION,sha256=kCMRx7s4-hZY_0A972FY7nN4_p1uLihPocOHNcMb0ws,6
1
+ foxes/VERSION,sha256=0BdnGL0hTOhHTAbtYcOVyhE_38Ks3YbZqpkztA2bVh4,6
2
2
  foxes/__init__.py,sha256=4ptDOBaQC8fAd_ZH5XH7d5pIgx3JXEY9xLcK3Nrs2Ow,718
3
3
  foxes/constants.py,sha256=UfflqHQ67uSQYFFktZBSe6rrWntoL2ccpMHnKs7zTcA,2650
4
4
  foxes/variables.py,sha256=I-S25WejH33ffOcVnmN2TDL1pIxWqg0aM1lhIBwZ9NQ,4454
5
5
  foxes/algorithms/__init__.py,sha256=uaXU8OYMT3eclcE6a2b8NkozHVXoM1BF5RJA2XR4DUw,260
6
6
  foxes/algorithms/downwind/__init__.py,sha256=lyygq5GMc6NAPmH0b0mhGeccWyuC8JTOEMZl-UlmE5M,53
7
- foxes/algorithms/downwind/downwind.py,sha256=W2W1ftPTnfNroBSskbBbSYZSXM0_wSfTrye8wXmfu7k,21652
7
+ foxes/algorithms/downwind/downwind.py,sha256=7TuClA6ZbHNJg2L9oOrWWUQ_qhRsiRTwYuK1BkN8od0,21690
8
8
  foxes/algorithms/downwind/models/__init__.py,sha256=0ov8rjIQ02w3iB6yYCxaswPvHDlPM_8_di6xPh1TTkQ,300
9
9
  foxes/algorithms/downwind/models/farm_wakes_calc.py,sha256=nRE_lCwrlVYB9zXJ0XR557IncNb6M7tUbhN9kBPgw_c,5178
10
10
  foxes/algorithms/downwind/models/init_farm_data.py,sha256=sTUMYGLU9iHr56prdNRR4cs0yuCFp7gqiCDut685HKM,4022
@@ -83,11 +83,11 @@ foxes/input/states/create/random_abl_states.py,sha256=45h0a84FmeLZwxbtwtxs5kmoz8
83
83
  foxes/input/states/create/random_timeseries.py,sha256=gJpaQ4nEXxOjI4hp3xjNcVbCsmZUm-brXUxoqDb63WE,1266
84
84
  foxes/input/windio/__init__.py,sha256=Bj9qtJNapfvgFcjThCI_oDia2hvMKN_seNLgm5KhWhw,89
85
85
  foxes/input/windio/windio.py,sha256=GtUS3IpHdvb_f2WPcoutpbKNQMEZbE4Bc0U3EVfXBEQ,7948
86
- foxes/models/__init__.py,sha256=FNEKtkT75LfVkT7H9rXX2Jn_15xB1qKF-2p3_nwCzIU,413
87
- foxes/models/model_book.py,sha256=PXs0amTpouSpoMmGToGuaDaUMe4H2sI6XcZOdBXvz60,26376
88
- foxes/models/axial_induction_models/__init__.py,sha256=CdYOzu45DWu7xrzpRpFIQ6CGZIMABjjy_lqAszjj9lg,78
89
- foxes/models/axial_induction_models/betz.py,sha256=rAaq7pnu-FmfYh61BU5Af1h4_bG2AAimP4Qah1aZo88,894
90
- foxes/models/axial_induction_models/madsen.py,sha256=_-ycfh8SnIpCKWm1uwx5VH7f49FQvR0y1Nbb_U8xWyU,1403
86
+ foxes/models/__init__.py,sha256=oLuCuBgSGFPVviqtBhzEu-zo1lxLKeRE0ksqA3dkrz0,406
87
+ foxes/models/model_book.py,sha256=34HoVcIEUneqb4EZZYaC0mhtraulEO_Ga50omRJSAhY,26786
88
+ foxes/models/axial_induction/__init__.py,sha256=CdYOzu45DWu7xrzpRpFIQ6CGZIMABjjy_lqAszjj9lg,78
89
+ foxes/models/axial_induction/betz.py,sha256=rAaq7pnu-FmfYh61BU5Af1h4_bG2AAimP4Qah1aZo88,894
90
+ foxes/models/axial_induction/madsen.py,sha256=_-ycfh8SnIpCKWm1uwx5VH7f49FQvR0y1Nbb_U8xWyU,1403
91
91
  foxes/models/farm_controllers/__init__.py,sha256=oDdW_fA3GSkJBzn9Vsd3T9bBVhB9-j_IglFjYV4G2rU,72
92
92
  foxes/models/farm_controllers/basic.py,sha256=6pinNXiyfoG3apXhqQWcnxx4vN_7Q63YryXX5Z7kTE0,249
93
93
  foxes/models/farm_models/__init__.py,sha256=WoC1Cmeo5-LLdC5I_S9hwZhZOtBnWDL6azjaUTcoOuY,66
@@ -167,10 +167,10 @@ foxes/models/wake_superpositions/ti_max.py,sha256=fnfYmr_Wt9EPZftHoHnqRlTwFWAawr
167
167
  foxes/models/wake_superpositions/ti_pow.py,sha256=4ZS3d0ulRkIDaVeG2VvcdjpJch673INQRUGgj37cs_A,4160
168
168
  foxes/models/wake_superpositions/ti_quadratic.py,sha256=tkmaoIm7a-Q4c3qtMpBmX25jfcVdt0Qp7Xn0fQrxN4A,3926
169
169
  foxes/models/wake_superpositions/ws_linear.py,sha256=TiKaRAxNioY4oIloJODfT1zftnkXzhuqfqEkqG33owc,9155
170
- foxes/models/wake_superpositions/ws_max.py,sha256=lWQtvHwudPxyA1vUQodcqY37hlU4KiCWIC9XeupEHT8,9380
171
- foxes/models/wake_superpositions/ws_pow.py,sha256=HiuGiMffV7dT6qydK-O8VDuFsrx0bNEIancYy_zUO_o,9601
170
+ foxes/models/wake_superpositions/ws_max.py,sha256=MktXVo3PfMgh172DJP_KRftiqs8jXsuaQPLne1jHKyY,9381
171
+ foxes/models/wake_superpositions/ws_pow.py,sha256=aPtm5NwQx6byNfetSX57Z7tVkXtgXIRleSf4grKtZF0,9602
172
172
  foxes/models/wake_superpositions/ws_product.py,sha256=8dCDaKfuzHfTEBo0_N7BR-x_qG2tWXTabzPsgpIAtXk,4672
173
- foxes/models/wake_superpositions/ws_quadratic.py,sha256=6H0BXMXpraPX7iz_U6m8ZB9NSEcWgUJr7pR-x4ZzNo0,9196
173
+ foxes/models/wake_superpositions/ws_quadratic.py,sha256=jUo4wFkrUPbj-27m3ozCEzab7iamkNZtVlrCwY-Yh2w,9197
174
174
  foxes/opt/__init__.py,sha256=okwZagHJMkUkLvKCSQLbE0cjx_47RLl3bEz576j6CdI,172
175
175
  foxes/opt/constraints/__init__.py,sha256=UZzN_JlxGaASdGtvBn5d5xwdSDpwO6bklj3vw70IZvU,159
176
176
  foxes/opt/constraints/area_geometry.py,sha256=9TFsyuM8_pp3HEUV4N0w0KnhxOk0OLPMKd6ZvNQGC80,6156
@@ -221,7 +221,7 @@ foxes/utils/cubic_roots.py,sha256=u2Pf-yHZ6EASpFONMfkv0mvldmd1E1VRZxj69YabDoc,33
221
221
  foxes/utils/data_book.py,sha256=DgxusriNH-fhHNN_v6TY3QWcAnrAcw20Wgz7lDfbMeg,5302
222
222
  foxes/utils/dict.py,sha256=s922OY22wOKBMbzQ_g-T-MhEw1dga0d3CCwFwd0nI78,886
223
223
  foxes/utils/exec_python.py,sha256=BRylxWOyYHpjIZXCuoOp_A-P9VMoQZ13P2vpHs-lqj8,1714
224
- foxes/utils/factory.py,sha256=pq028O6hlDFxhvMf7QN8_EUc4GOoBocDPOjwRt7gG80,9994
224
+ foxes/utils/factory.py,sha256=_EO9H2xS-ceNJh9okS5FtQYKEGQUdcmhmCPZg6iLZ7w,10036
225
225
  foxes/utils/geopandas_helpers.py,sha256=inVQHMco6Op7YN3VFH1DGAJZWREuveJUS7gyoRudw2A,7895
226
226
  foxes/utils/geopandas_utils.py,sha256=inVQHMco6Op7YN3VFH1DGAJZWREuveJUS7gyoRudw2A,7895
227
227
  foxes/utils/load.py,sha256=7jrCX2GQ_GTgrSu3nz-jfxiyswa7Q3XXCYqobl6bkyk,1290
@@ -250,9 +250,9 @@ foxes/utils/geom2d/half_plane.py,sha256=kzZD6pkZxZ03MK9WAboWzXb5Ws5dWLQY9GIahD4D
250
250
  foxes/utils/geom2d/polygon.py,sha256=8ASfy7No_-Pt_xDSeNsDtLEkCjBWsNZK8nIxDQtqeOE,5534
251
251
  foxes/utils/runners/__init__.py,sha256=-WL4ZmdgNYldkqhCV6dR-aXCumBrH-Ea-V1shsRhsbs,55
252
252
  foxes/utils/runners/runners.py,sha256=Sc06qsCzPduMyxbywgf6G3uHRioDs1qWRSc6GZbLFAY,6932
253
- foxes-0.7.1.dist-info/LICENSE,sha256=bBCH6mYTPzSepk2s2UUZ3II_ZYXrn1bnSqB85-aZHxU,1071
254
- foxes-0.7.1.dist-info/METADATA,sha256=-i7RicI54Ewf9bAL0TQcPm19xduZAR3Qq2WKSEEzQvo,9520
255
- foxes-0.7.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
256
- foxes-0.7.1.dist-info/top_level.txt,sha256=B4spGR6JHsVHz7CEXsa68xsjYalAA70nBwHa1gfyRHc,6
257
- foxes-0.7.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
258
- foxes-0.7.1.dist-info/RECORD,,
253
+ foxes-0.7.2.dist-info/LICENSE,sha256=bBCH6mYTPzSepk2s2UUZ3II_ZYXrn1bnSqB85-aZHxU,1071
254
+ foxes-0.7.2.dist-info/METADATA,sha256=4M2qRnVI00yQWjqJ9Fc6srHQh1M-6pSypZlNaeDzVP0,9520
255
+ foxes-0.7.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
256
+ foxes-0.7.2.dist-info/top_level.txt,sha256=B4spGR6JHsVHz7CEXsa68xsjYalAA70nBwHa1gfyRHc,6
257
+ foxes-0.7.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
258
+ foxes-0.7.2.dist-info/RECORD,,
File without changes
File without changes