foxes 1.1.0.2__py3-none-any.whl → 1.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 (131) hide show
  1. docs/source/conf.py +3 -2
  2. examples/dyn_wakes/run.py +2 -2
  3. examples/timelines/run.py +1 -1
  4. foxes/__init__.py +13 -2
  5. foxes/algorithms/downwind/downwind.py +6 -1
  6. foxes/algorithms/downwind/models/init_farm_data.py +5 -2
  7. foxes/algorithms/downwind/models/point_wakes_calc.py +0 -1
  8. foxes/algorithms/iterative/iterative.py +1 -1
  9. foxes/algorithms/sequential/sequential.py +4 -3
  10. foxes/config/__init__.py +1 -0
  11. foxes/config/config.py +134 -0
  12. foxes/constants.py +15 -6
  13. foxes/core/algorithm.py +22 -10
  14. foxes/core/data.py +2 -1
  15. foxes/core/engine.py +40 -34
  16. foxes/core/farm_controller.py +4 -3
  17. foxes/core/farm_data_model.py +6 -2
  18. foxes/core/model.py +2 -1
  19. foxes/core/point_data_model.py +4 -2
  20. foxes/core/rotor_model.py +8 -4
  21. foxes/core/turbine_type.py +1 -1
  22. foxes/core/wake_frame.py +7 -5
  23. foxes/core/wake_model.py +6 -1
  24. foxes/data/__init__.py +1 -1
  25. foxes/data/static_data.py +0 -7
  26. foxes/engines/dask.py +4 -3
  27. foxes/engines/single.py +1 -1
  28. foxes/input/__init__.py +1 -1
  29. foxes/input/farm_layout/from_csv.py +3 -1
  30. foxes/input/farm_layout/from_file.py +10 -10
  31. foxes/input/farm_layout/from_json.py +4 -3
  32. foxes/input/farm_layout/grid.py +3 -3
  33. foxes/input/states/create/random_abl_states.py +5 -3
  34. foxes/input/states/field_data_nc.py +22 -14
  35. foxes/input/states/multi_height.py +26 -15
  36. foxes/input/states/one_point_flow.py +6 -5
  37. foxes/input/states/scan_ws.py +4 -1
  38. foxes/input/states/single.py +15 -6
  39. foxes/input/states/slice_data_nc.py +18 -12
  40. foxes/input/states/states_table.py +17 -10
  41. foxes/input/yaml/__init__.py +3 -0
  42. foxes/input/yaml/dict.py +210 -0
  43. foxes/input/yaml/windio/__init__.py +4 -0
  44. foxes/input/{windio → yaml/windio}/get_states.py +7 -7
  45. foxes/input/{windio → yaml/windio}/read_attributes.py +61 -40
  46. foxes/input/{windio → yaml/windio}/read_farm.py +34 -43
  47. foxes/input/{windio → yaml/windio}/read_fields.py +11 -10
  48. foxes/input/yaml/windio/read_outputs.py +147 -0
  49. foxes/input/yaml/windio/windio.py +269 -0
  50. foxes/input/yaml/yaml.py +103 -0
  51. foxes/models/partial_wakes/axiwake.py +7 -6
  52. foxes/models/partial_wakes/centre.py +3 -2
  53. foxes/models/partial_wakes/segregated.py +5 -2
  54. foxes/models/point_models/set_uniform_data.py +5 -3
  55. foxes/models/rotor_models/centre.py +2 -2
  56. foxes/models/rotor_models/grid.py +5 -5
  57. foxes/models/rotor_models/levels.py +6 -6
  58. foxes/models/turbine_models/kTI_model.py +3 -1
  59. foxes/models/turbine_models/lookup_table.py +7 -4
  60. foxes/models/turbine_models/power_mask.py +14 -8
  61. foxes/models/turbine_models/sector_management.py +4 -2
  62. foxes/models/turbine_models/set_farm_vars.py +53 -23
  63. foxes/models/turbine_models/table_factors.py +8 -7
  64. foxes/models/turbine_models/yaw2yawm.py +0 -1
  65. foxes/models/turbine_models/yawm2yaw.py +0 -1
  66. foxes/models/turbine_types/CpCt_file.py +6 -3
  67. foxes/models/turbine_types/CpCt_from_two.py +6 -3
  68. foxes/models/turbine_types/PCt_file.py +7 -6
  69. foxes/models/turbine_types/PCt_from_two.py +11 -2
  70. foxes/models/turbine_types/TBL_file.py +3 -4
  71. foxes/models/turbine_types/wsrho2PCt_from_two.py +19 -11
  72. foxes/models/turbine_types/wsti2PCt_from_two.py +19 -11
  73. foxes/models/vertical_profiles/abl_log_neutral_ws.py +1 -1
  74. foxes/models/vertical_profiles/abl_log_stable_ws.py +1 -1
  75. foxes/models/vertical_profiles/abl_log_unstable_ws.py +1 -1
  76. foxes/models/vertical_profiles/abl_log_ws.py +1 -1
  77. foxes/models/wake_frames/dynamic_wakes.py +17 -9
  78. foxes/models/wake_frames/farm_order.py +4 -3
  79. foxes/models/wake_frames/rotor_wd.py +3 -1
  80. foxes/models/wake_frames/seq_dynamic_wakes.py +14 -7
  81. foxes/models/wake_frames/streamlines.py +9 -6
  82. foxes/models/wake_frames/timelines.py +21 -14
  83. foxes/models/wake_frames/yawed_wakes.py +3 -1
  84. foxes/models/wake_models/induction/vortex_sheet.py +0 -1
  85. foxes/models/wake_models/ti/crespo_hernandez.py +2 -1
  86. foxes/models/wake_models/wind/bastankhah14.py +3 -2
  87. foxes/models/wake_models/wind/bastankhah16.py +2 -1
  88. foxes/models/wake_models/wind/turbopark.py +9 -7
  89. foxes/models/wake_superpositions/ws_product.py +0 -1
  90. foxes/output/calc_points.py +7 -4
  91. foxes/output/farm_layout.py +30 -18
  92. foxes/output/farm_results_eval.py +4 -3
  93. foxes/output/grids.py +8 -7
  94. foxes/output/output.py +7 -2
  95. foxes/output/results_writer.py +10 -11
  96. foxes/output/rose_plot.py +38 -20
  97. foxes/output/rotor_point_plots.py +7 -3
  98. foxes/output/slice_data.py +1 -1
  99. foxes/output/state_turbine_map.py +5 -1
  100. foxes/output/state_turbine_table.py +7 -3
  101. foxes/output/turbine_type_curves.py +7 -2
  102. foxes/utils/dict.py +107 -3
  103. foxes/utils/geopandas_utils.py +3 -2
  104. {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/METADATA +20 -21
  105. {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/RECORD +122 -122
  106. {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/WHEEL +1 -1
  107. foxes-1.2.dist-info/entry_points.txt +3 -0
  108. tests/0_consistency/iterative/test_iterative.py +65 -67
  109. tests/0_consistency/partial_wakes/test_partial_wakes.py +58 -61
  110. tests/1_verification/flappy_0_6/PCt_files/test_PCt_files.py +56 -53
  111. tests/1_verification/flappy_0_6/abl_states/test_abl_states.py +41 -41
  112. tests/1_verification/flappy_0_6/partial_top_hat/test_partial_top_hat.py +34 -34
  113. tests/1_verification/flappy_0_6/row_Jensen_linear_centre/test_row_Jensen_linear_centre.py +50 -50
  114. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/test_row_Jensen_linear_tophat.py +51 -52
  115. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/test_row_Jensen_linear_tophat_IECTI_2005.py +73 -74
  116. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/test_row_Jensen_linear_tophat_IECTI_2019.py +73 -74
  117. tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/test_row_Jensen_quadratic_centre.py +51 -49
  118. tests/1_verification/flappy_0_6_2/grid_rotors/test_grid_rotors.py +101 -103
  119. tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/test_row_Bastankhah_Crespo.py +61 -62
  120. tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/test_row_Bastankhah_linear_centre.py +51 -52
  121. examples/windio/run.py +0 -29
  122. foxes/data/states/windio_timeseries_5000.nc +0 -0
  123. foxes/data/windio/DTU_10MW_turbine.yaml +0 -10
  124. foxes/data/windio/__init__.py +0 -0
  125. foxes/data/windio/windio_5turbines_timeseries.yaml +0 -79
  126. foxes/input/windio/__init__.py +0 -11
  127. foxes/input/windio/read_outputs.py +0 -172
  128. foxes/input/windio/runner.py +0 -183
  129. foxes/input/windio/windio.py +0 -193
  130. {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/LICENSE +0 -0
  131. {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,9 @@
1
1
  import numpy as np
2
2
 
3
3
  from foxes.core import TurbineModel
4
- import foxes.variables as FV
5
- import foxes.constants as FC
4
+ from foxes.config import config
6
5
  from foxes.utils import cubic_roots
6
+ import foxes.variables as FV
7
7
 
8
8
 
9
9
  class PowerMask(TurbineModel):
@@ -33,7 +33,13 @@ class PowerMask(TurbineModel):
33
33
 
34
34
  """
35
35
 
36
- def __init__(self, var_ws_P=FV.REWS3, factor_P=1.0e3, P_lim=100, induction="Betz"):
36
+ def __init__(
37
+ self,
38
+ var_ws_P=FV.REWS3,
39
+ factor_P=1.0e3,
40
+ P_lim=100,
41
+ induction="Betz",
42
+ ):
37
43
  """
38
44
  Constructor.
39
45
 
@@ -110,13 +116,13 @@ class PowerMask(TurbineModel):
110
116
 
111
117
  self._P_rated = []
112
118
  for t in algo.farm_controller.turbine_types:
113
- Pnom = FC.DTYPE(t.P_nominal)
119
+ Pnom = config.dtype_double(t.P_nominal)
114
120
  if np.isnan(Pnom):
115
121
  raise ValueError(
116
122
  f"Model '{self.name}': P_nominal is NaN for turbine type '{t.name}'"
117
123
  )
118
124
  self._P_rated.append(Pnom)
119
- self._P_rated = np.array(self._P_rated, dtype=FC.DTYPE)
125
+ self._P_rated = np.array(self._P_rated, dtype=config.dtype_double)
120
126
 
121
127
  def calculate(self, algo, mdata, fdata, st_sel):
122
128
  """
@@ -183,9 +189,9 @@ class PowerMask(TurbineModel):
183
189
 
184
190
  # find roots:
185
191
  N = len(cp)
186
- a3 = np.full(N, 4.0, dtype=FC.DTYPE)
187
- a2 = np.full(N, -8.0, dtype=FC.DTYPE)
188
- a1 = np.full(N, 4.0, dtype=FC.DTYPE)
192
+ a3 = np.full(N, 4.0, dtype=config.dtype_double)
193
+ a2 = np.full(N, -8.0, dtype=config.dtype_double)
194
+ a1 = np.full(N, 4.0, dtype=config.dtype_double)
189
195
  a0 = -cp / e
190
196
  rts = cubic_roots(a0, a1, a2, a3)
191
197
  rts[np.isnan(rts)] = np.inf
@@ -3,6 +3,7 @@ import pandas as pd
3
3
 
4
4
  from foxes.core import TurbineModel
5
5
  from foxes.utils import PandasFileHelper
6
+ from foxes.config import get_path
6
7
  import foxes.variables as FV
7
8
  import foxes.constants as FC
8
9
 
@@ -90,9 +91,10 @@ class SectorManagement(TurbineModel):
90
91
  if isinstance(self.source, pd.DataFrame):
91
92
  data = self.source
92
93
  else:
94
+ fpath = get_path(self.source)
93
95
  if verbosity > 0:
94
- print(f"{self.name}: Reading file {self.source}")
95
- data = PandasFileHelper.read_file(self.source, **self._rpars)
96
+ print(f"{self.name}: Reading file {fpath}")
97
+ data = PandasFileHelper.read_file(fpath, **self._rpars)
96
98
 
97
99
  if self._trbs is None:
98
100
  if self._col_i is not None and self._col_t is None:
@@ -1,8 +1,9 @@
1
1
  import numpy as np
2
2
 
3
3
  from foxes.core import TurbineModel
4
- import foxes.constants as FC
4
+ from foxes.config import config
5
5
  import foxes.variables as FV
6
+ import foxes.constants as FC
6
7
 
7
8
 
8
9
  class SetFarmVars(TurbineModel):
@@ -13,12 +14,14 @@ class SetFarmVars(TurbineModel):
13
14
  ----------
14
15
  vars: list of str
15
16
  The variables to be set
17
+ once: bool
18
+ Flag for running only once
16
19
 
17
20
  :group: models.turbine_models
18
21
 
19
22
  """
20
23
 
21
- def __init__(self, pre_rotor=False):
24
+ def __init__(self, pre_rotor=False, once=False):
22
25
  """
23
26
  Constructor.
24
27
 
@@ -27,9 +30,12 @@ class SetFarmVars(TurbineModel):
27
30
  pre_rotor: bool
28
31
  Flag for running this model before
29
32
  running the rotor model.
33
+ once: bool
34
+ Flag for running only once
30
35
 
31
36
  """
32
37
  super().__init__(pre_rotor=pre_rotor)
38
+ self.once = once
33
39
  self.reset()
34
40
 
35
41
  def add_var(self, var, data):
@@ -51,7 +57,7 @@ class SetFarmVars(TurbineModel):
51
57
  if self.running:
52
58
  raise ValueError(f"Model '{self.name}': Cannot add_var while running")
53
59
  self.vars.append(var)
54
- self.__vdata.append(np.asarray(data, dtype=FC.DTYPE))
60
+ self.__vdata.append(np.asarray(data, dtype=config.dtype_double))
55
61
 
56
62
  def reset(self):
57
63
  """
@@ -62,6 +68,23 @@ class SetFarmVars(TurbineModel):
62
68
  self.vars = []
63
69
  self.__vdata = []
64
70
 
71
+ def initialize(self, algo, verbosity=0, force=False):
72
+ """
73
+ Initializes the model.
74
+
75
+ Parameters
76
+ ----------
77
+ algo: foxes.core.Algorithm
78
+ The calculation algorithm
79
+ verbosity: int
80
+ The verbosity level, 0 = silent
81
+ force: bool
82
+ Overwrite existing data
83
+
84
+ """
85
+ super().initialize(algo, verbosity, force)
86
+ self.__once_done = set()
87
+
65
88
  def output_farm_vars(self, algo):
66
89
  """
67
90
  The variables which are being modified by the model.
@@ -105,7 +128,9 @@ class SetFarmVars(TurbineModel):
105
128
  idata = super().load_data(algo, verbosity)
106
129
 
107
130
  for i, v in enumerate(self.vars):
108
- data = np.full((algo.n_states, algo.n_turbines), np.nan, dtype=FC.DTYPE)
131
+ data = np.full(
132
+ (algo.n_states, algo.n_turbines), np.nan, dtype=config.dtype_double
133
+ )
109
134
  vdata = self.__vdata[i]
110
135
 
111
136
  # handle special case of call during vectorized optimization:
@@ -117,7 +142,7 @@ class SetFarmVars(TurbineModel):
117
142
  n_pop = algo.states.n_pop
118
143
  n_ost = algo.states.states.size()
119
144
  n_trb = algo.n_turbines
120
- vdata = np.zeros((n_pop, n_ost, n_trb), dtype=FC.DTYPE)
145
+ vdata = np.zeros((n_pop, n_ost, n_trb), dtype=config.dtype_double)
121
146
  vdata[:] = self.__vdata[i][None, :]
122
147
  vdata = vdata.reshape(n_pop * n_ost, n_trb)
123
148
 
@@ -130,7 +155,7 @@ class SetFarmVars(TurbineModel):
130
155
  for ti in range(algo.n_turbines):
131
156
  t = algo.farm.turbines[ti]
132
157
  if len(t.xy.shape) == 1:
133
- xy = np.zeros((algo.n_states, 2), dtype=FC.DTYPE)
158
+ xy = np.zeros((algo.n_states, 2), dtype=config.dtype_double)
134
159
  xy[:] = t.xy[None, :]
135
160
  t.xy = xy
136
161
  t.xy[:, i] = np.where(
@@ -141,7 +166,7 @@ class SetFarmVars(TurbineModel):
141
166
  if v in [FV.D, FV.H]:
142
167
  for ti in range(algo.n_turbines):
143
168
  t = algo.farm.turbines[ti]
144
- x = np.zeros(algo.n_states, dtype=FC.DTYPE)
169
+ x = np.zeros(algo.n_states, dtype=config.dtype_double)
145
170
  if v == FV.D:
146
171
  x[:] = t.D
147
172
  t.D = x
@@ -243,21 +268,26 @@ class SetFarmVars(TurbineModel):
243
268
  Values: numpy.ndarray with shape (n_states, n_turbines)
244
269
 
245
270
  """
246
- if self.pre_rotor:
247
- order = np.s_[:]
248
- ssel = np.s_[:]
249
- else:
250
- order = fdata[FV.ORDER]
251
- ssel = fdata[FV.ORDER_SSEL]
252
-
253
- bsel = np.zeros((fdata.n_states, fdata.n_turbines), dtype=bool)
254
- bsel[st_sel] = True
255
-
256
- for v in self.vars:
257
- data = mdata[self.var(v)][ssel, order]
258
- hsel = ~np.isnan(data)
259
- tsel = bsel & hsel
260
-
261
- fdata[v][tsel] = data[tsel]
271
+ i0 = mdata.states_i0(counter=True)
272
+ if not self.once or i0 not in self.__once_done:
273
+
274
+ if self.pre_rotor:
275
+ order = np.s_[:]
276
+ ssel = np.s_[:]
277
+ else:
278
+ order = fdata[FV.ORDER]
279
+ ssel = fdata[FV.ORDER_SSEL]
280
+
281
+ bsel = np.zeros((fdata.n_states, fdata.n_turbines), dtype=bool)
282
+ bsel[st_sel] = True
283
+
284
+ for v in self.vars:
285
+ data = mdata[self.var(v)][ssel, order]
286
+ hsel = ~np.isnan(data)
287
+ tsel = bsel & hsel
288
+
289
+ fdata[v][tsel] = data[tsel]
290
+
291
+ self.__once_done.add(i0)
262
292
 
263
293
  return {v: fdata[v] for v in self.vars}
@@ -4,7 +4,7 @@ from scipy.interpolate import interpn
4
4
 
5
5
  from foxes.core import TurbineModel
6
6
  from foxes.utils import PandasFileHelper
7
- import foxes.constants as FC
7
+ from foxes.config import config, get_path
8
8
 
9
9
 
10
10
  class TableFactors(TurbineModel):
@@ -106,15 +106,16 @@ class TableFactors(TurbineModel):
106
106
  if isinstance(self.data_source, pd.DataFrame):
107
107
  self._data = self.data_source
108
108
  else:
109
+ fpath = get_path(self.data_source)
109
110
  if verbosity > 0:
110
- print(f"{self.name}: Reading file {self.data_source}")
111
+ print(f"{self.name}: Reading file {fpath}")
111
112
  rpars = dict(index_col=0)
112
113
  rpars.update(self._rpars)
113
- self._data = PandasFileHelper.read_file(self.data_source, **rpars)
114
+ self._data = PandasFileHelper.read_file(fpath, **rpars)
114
115
 
115
- self._rvals = self._data.index.to_numpy(FC.DTYPE)
116
- self._cvals = self._data.columns.to_numpy(FC.DTYPE)
117
- self._data = self._data.to_numpy(FC.DTYPE)
116
+ self._rvals = self._data.index.to_numpy(config.dtype_double)
117
+ self._cvals = self._data.columns.to_numpy(config.dtype_double)
118
+ self._data = self._data.to_numpy(config.dtype_double)
118
119
 
119
120
  def calculate(self, algo, mdata, fdata, st_sel):
120
121
  """
@@ -143,7 +144,7 @@ class TableFactors(TurbineModel):
143
144
 
144
145
  """
145
146
  n_sel = np.sum(st_sel)
146
- qts = np.zeros((n_sel, 2), dtype=FC.DTYPE)
147
+ qts = np.zeros((n_sel, 2), dtype=config.dtype_double)
147
148
  qts[:, 0] = fdata[self.row_var][st_sel]
148
149
  qts[:, 1] = fdata[self.col_var][st_sel]
149
150
 
@@ -1,6 +1,5 @@
1
1
  from foxes.core import TurbineModel
2
2
  import foxes.variables as FV
3
- import foxes.constants as FC
4
3
  from foxes.utils import delta_wd
5
4
 
6
5
 
@@ -2,7 +2,6 @@ import numpy as np
2
2
 
3
3
  from foxes.core import TurbineModel
4
4
  import foxes.variables as FV
5
- import foxes.constants as FC
6
5
 
7
6
 
8
7
  class YAWM2YAW(TurbineModel):
@@ -1,11 +1,13 @@
1
1
  import numpy as np
2
2
  import pandas as pd
3
3
 
4
- from .PCt_file import PCtFile
5
4
  from foxes.data import parse_Pct_file_name
6
5
  from foxes.utils import PandasFileHelper
6
+ from foxes.config import config, get_path
7
7
  import foxes.constants as FC
8
8
 
9
+ from .PCt_file import PCtFile
10
+
9
11
 
10
12
  class CpCtFile(PCtFile):
11
13
  """
@@ -47,7 +49,8 @@ class CpCtFile(PCtFile):
47
49
  if not isinstance(data_source, pd.DataFrame):
48
50
  pars = parse_Pct_file_name(data_source)
49
51
  pars.update(parameters)
50
- data = PandasFileHelper.read_file(data_source, **pd_file_read_pars)
52
+ fpath = get_path(data_source)
53
+ data = PandasFileHelper.read_file(fpath, **pd_file_read_pars)
51
54
  else:
52
55
  data = data_source
53
56
  pars = parameters
@@ -63,7 +66,7 @@ class CpCtFile(PCtFile):
63
66
  ws_max = np.max(ws)
64
67
  N = int((ws_max - ws_min) / ws_delta)
65
68
 
66
- data_P = pd.DataFrame(index=range(N), dtype=FC.DTYPE)
69
+ data_P = pd.DataFrame(index=range(N), dtype=config.dtype_double)
67
70
  data_P["ws"] = np.linspace(ws_min, ws_max, N, endpoint=True)
68
71
  data_P["cp"] = np.interp(data_P["ws"], ws, cp, left=0, right=0)
69
72
  data_P["P"] = (
@@ -4,6 +4,7 @@ import pandas as pd
4
4
  from .PCt_from_two import PCtFromTwo
5
5
  from foxes.data import parse_Pct_two_files
6
6
  from foxes.utils import PandasFileHelper
7
+ from foxes.config import config, get_path
7
8
  import foxes.constants as FC
8
9
 
9
10
 
@@ -55,8 +56,10 @@ class CpCtFromTwo(PCtFromTwo):
55
56
  data_source_ct, pd.DataFrame
56
57
  ):
57
58
  pars = parse_Pct_two_files(data_source_cp, data_source_ct)
58
- data_cp = PandasFileHelper.read_file(data_source_cp, **pd_file_read_pars_cp)
59
- data_ct = PandasFileHelper.read_file(data_source_ct, **pd_file_read_pars_ct)
59
+ path_cp = get_path(data_source_cp)
60
+ path_ct = get_path(data_source_ct)
61
+ data_cp = PandasFileHelper.read_file(path_cp, **pd_file_read_pars_cp)
62
+ data_ct = PandasFileHelper.read_file(path_ct, **pd_file_read_pars_ct)
60
63
  else:
61
64
  data_cp = data_source_cp
62
65
  data_ct = data_source_ct
@@ -73,7 +76,7 @@ class CpCtFromTwo(PCtFromTwo):
73
76
  ws_max = np.max(ws)
74
77
  N = int((ws_max - ws_min) / ws_delta)
75
78
 
76
- data_P = pd.DataFrame(index=range(N), dtype=FC.DTYPE)
79
+ data_P = pd.DataFrame(index=range(N), dtype=config.dtype_double)
77
80
  data_P["ws"] = np.linspace(ws_min, ws_max, N, endpoint=True)
78
81
  data_P["cp"] = np.interp(data_P["ws"], ws, cp, left=0, right=0)
79
82
  data_P["P"] = (
@@ -5,6 +5,7 @@ from pathlib import Path
5
5
  from foxes.core import TurbineType
6
6
  from foxes.utils import PandasFileHelper
7
7
  from foxes.data import PCTCURVE, parse_Pct_file_name
8
+ from foxes.config import get_path
8
9
  import foxes.variables as FV
9
10
  import foxes.constants as FC
10
11
 
@@ -173,15 +174,15 @@ class PCtFile(TurbineType):
173
174
  if isinstance(self.source, pd.DataFrame):
174
175
  data = self.source
175
176
  else:
176
- fpath = algo.dbook.get_file_path(PCTCURVE, self.source, check_raw=True)
177
- if verbosity > 0:
178
- if not Path(self.source).is_file():
177
+ fpath = get_path(self.source)
178
+ if not fpath.is_file():
179
+ if verbosity > 0:
179
180
  print(
180
181
  f"Turbine type '{self.name}': Reading static data from context '{PCTCURVE}'"
181
182
  )
182
- print(f"Path: {fpath}")
183
- else:
184
- print(f"Turbine type '{self.name}': Reading file", self.source)
183
+ fpath = algo.dbook.get_file_path(PCTCURVE, self.source, check_raw=False)
184
+ if verbosity > 0:
185
+ print(f"Turbine type '{self.name}': Reading file", fpath)
185
186
  data = PandasFileHelper.read_file(fpath, **self.rpars)
186
187
 
187
188
  data = data.set_index(self.col_ws).sort_index()
@@ -4,6 +4,7 @@ import pandas as pd
4
4
  from foxes.core import TurbineType
5
5
  from foxes.utils import PandasFileHelper
6
6
  from foxes.data import PCTCURVE, parse_Pct_two_files
7
+ from foxes.config import get_path
7
8
  import foxes.variables as FV
8
9
  import foxes.constants as FC
9
10
 
@@ -194,7 +195,11 @@ class PCtFromTwo(TurbineType):
194
195
  if isinstance(self.source_P, pd.DataFrame):
195
196
  self._data_P = self.source_P
196
197
  else:
197
- fpath = algo.dbook.get_file_path(PCTCURVE, self.source_P, check_raw=True)
198
+ fpath = get_path(self.source_P)
199
+ if not fpath.is_file():
200
+ fpath = algo.dbook.get_file_path(
201
+ PCTCURVE, self.source_P, check_raw=False
202
+ )
198
203
  self._data_P = PandasFileHelper.read_file(fpath, **self.rpars_P)
199
204
 
200
205
  self._data_P = self._data_P.set_index(self.col_ws_P_file).sort_index()
@@ -205,7 +210,11 @@ class PCtFromTwo(TurbineType):
205
210
  if isinstance(self.source_ct, pd.DataFrame):
206
211
  self._data_ct = self.source_ct
207
212
  else:
208
- fpath = algo.dbook.get_file_path(PCTCURVE, self.source_ct, check_raw=True)
213
+ fpath = get_path(self.source_ct)
214
+ if not fpath.is_file():
215
+ fpath = algo.dbook.get_file_path(
216
+ PCTCURVE, self.source_ct, check_raw=False
217
+ )
209
218
  self._data_ct = PandasFileHelper.read_file(fpath, **self.rpars_ct)
210
219
 
211
220
  self._data_ct = self._data_ct.set_index(self.col_ws_ct_file).sort_index()
@@ -1,10 +1,9 @@
1
1
  import numpy as np
2
2
  import pandas as pd
3
- from pathlib import Path
3
+
4
+ from foxes.config import get_path
4
5
 
5
6
  from .PCt_file import PCtFile
6
- from foxes.data import parse_Pct_file_name
7
- import foxes.constants as FC
8
7
 
9
8
 
10
9
  class TBLFile(PCtFile):
@@ -58,7 +57,7 @@ class TBLFile(PCtFile):
58
57
  Additional parameters for PCtFile class
59
58
 
60
59
  """
61
- fpath = Path(tbl_file)
60
+ fpath = get_path(tbl_file)
62
61
  assert fpath.suffix == ".tbl", f"Expecting *.tbl file, got '{tbl_file}'"
63
62
 
64
63
  meta = np.genfromtxt(fpath, skip_header=1, max_rows=1)
@@ -5,8 +5,8 @@ from scipy.interpolate import interpn
5
5
  from foxes.core import TurbineType
6
6
  from foxes.utils import PandasFileHelper
7
7
  from foxes.data import PCTCURVE, parse_Pct_two_files
8
+ from foxes.config import config, get_path
8
9
  import foxes.variables as FV
9
- import foxes.constants as FC
10
10
 
11
11
 
12
12
  class WsRho2PCtFromTwo(TurbineType):
@@ -183,31 +183,39 @@ class WsRho2PCtFromTwo(TurbineType):
183
183
  if isinstance(self.source_P, pd.DataFrame):
184
184
  data = self.source_P
185
185
  else:
186
- fpath = algo.dbook.get_file_path(PCTCURVE, self.source_P, check_raw=True)
186
+ fpath = get_path(self.source_P)
187
+ if not fpath.is_file():
188
+ fpath = algo.dbook.get_file_path(
189
+ PCTCURVE, self.source_P, check_raw=False
190
+ )
187
191
  pars = {"index_col": 0}
188
192
  pars.update(self.rpars_P)
189
193
  data = PandasFileHelper.read_file(fpath, **pars)
190
194
 
191
195
  data.sort_index(inplace=True)
192
- data.columns = data.columns.astype(FC.DTYPE)
193
- self._ws_P = data.index.to_numpy(FC.DTYPE)
196
+ data.columns = data.columns.astype(config.dtype_double)
197
+ self._ws_P = data.index.to_numpy(config.dtype_double)
194
198
  self._rho_P = np.sort(data.columns.to_numpy())
195
- self._P = data[self._rho_P].to_numpy(FC.DTYPE)
199
+ self._P = data[self._rho_P].to_numpy(config.dtype_double)
196
200
 
197
201
  # read ct curve:
198
202
  if isinstance(self.source_ct, pd.DataFrame):
199
203
  data = self.source_ct
200
204
  else:
201
- fpath = algo.dbook.get_file_path(PCTCURVE, self.source_ct, check_raw=True)
205
+ fpath = get_path(self.source_ct)
206
+ if not fpath.is_file():
207
+ fpath = algo.dbook.get_file_path(
208
+ PCTCURVE, self.source_ct, check_raw=False
209
+ )
202
210
  pars = {"index_col": 0}
203
211
  pars.update(self.rpars_ct)
204
212
  data = PandasFileHelper.read_file(fpath, **pars)
205
213
 
206
214
  data.sort_index(inplace=True)
207
- data.columns = data.columns.astype(FC.DTYPE)
208
- self._ws_ct = data.index.to_numpy(FC.DTYPE)
215
+ data.columns = data.columns.astype(config.dtype_double)
216
+ self._ws_ct = data.index.to_numpy(config.dtype_double)
209
217
  self._rho_ct = np.sort(data.columns.to_numpy())
210
- self._ct = data[self._rho_ct].to_numpy(FC.DTYPE)
218
+ self._ct = data[self._rho_ct].to_numpy(config.dtype_double)
211
219
 
212
220
  return super().load_data(algo, verbosity)
213
221
 
@@ -267,7 +275,7 @@ class WsRho2PCtFromTwo(TurbineType):
267
275
  if np.any(st_sel_P):
268
276
  # prepare interpolation:
269
277
  n_sel = np.sum(st_sel_P)
270
- qts = np.zeros((n_sel, 2), dtype=FC.DTYPE) # ws, rho
278
+ qts = np.zeros((n_sel, 2), dtype=config.dtype_double) # ws, rho
271
279
  qts[:, 0] = fdata[self.WSP][st_sel_P]
272
280
  qts[:, 1] = fdata[FV.RHO][st_sel_P]
273
281
 
@@ -307,7 +315,7 @@ class WsRho2PCtFromTwo(TurbineType):
307
315
  if np.any(st_sel_ct):
308
316
  # prepare interpolation:
309
317
  n_sel = np.sum(st_sel_ct)
310
- qts = np.zeros((n_sel, 2), dtype=FC.DTYPE) # ws, rho
318
+ qts = np.zeros((n_sel, 2), dtype=config.dtype_double) # ws, rho
311
319
  qts[:, 0] = fdata[self.WSP][st_sel_ct]
312
320
  qts[:, 1] = fdata[FV.RHO][st_sel_ct]
313
321
 
@@ -6,7 +6,7 @@ from foxes.core import TurbineType
6
6
  from foxes.utils import PandasFileHelper
7
7
  from foxes.data import PCTCURVE, parse_Pct_two_files
8
8
  import foxes.variables as FV
9
- import foxes.constants as FC
9
+ from foxes.config import config, get_path
10
10
 
11
11
 
12
12
  class WsTI2PCtFromTwo(TurbineType):
@@ -195,31 +195,39 @@ class WsTI2PCtFromTwo(TurbineType):
195
195
  if isinstance(self.source_P, pd.DataFrame):
196
196
  data = self.source_P
197
197
  else:
198
- fpath = algo.dbook.get_file_path(PCTCURVE, self.source_P, check_raw=True)
198
+ fpath = get_path(self.source_P)
199
+ if not fpath.is_file():
200
+ fpath = algo.dbook.get_file_path(
201
+ PCTCURVE, self.source_P, check_raw=False
202
+ )
199
203
  pars = {"index_col": 0}
200
204
  pars.update(self.rpars_P)
201
205
  data = PandasFileHelper.read_file(fpath, **pars)
202
206
 
203
207
  data.sort_index(inplace=True)
204
- data.columns = data.columns.astype(FC.DTYPE)
205
- self._ws_P = data.index.to_numpy(FC.DTYPE)
208
+ data.columns = data.columns.astype(config.dtype_double)
209
+ self._ws_P = data.index.to_numpy(config.dtype_double)
206
210
  self._ti_P = np.sort(data.columns.to_numpy())
207
- self._P = data[self._ti_P].to_numpy(FC.DTYPE)
211
+ self._P = data[self._ti_P].to_numpy(config.dtype_double)
208
212
 
209
213
  # read ct curve:
210
214
  if isinstance(self.source_ct, pd.DataFrame):
211
215
  data = self.source_ct
212
216
  else:
213
- fpath = algo.dbook.get_file_path(PCTCURVE, self.source_ct, check_raw=True)
217
+ fpath = get_path(self.source_ct)
218
+ if not fpath.is_file():
219
+ fpath = algo.dbook.get_file_path(
220
+ PCTCURVE, self.source_ct, check_raw=False
221
+ )
214
222
  pars = {"index_col": 0}
215
223
  pars.update(self.rpars_ct)
216
224
  data = PandasFileHelper.read_file(fpath, **pars)
217
225
 
218
226
  data.sort_index(inplace=True)
219
- data.columns = data.columns.astype(FC.DTYPE)
220
- self._ws_ct = data.index.to_numpy(FC.DTYPE)
227
+ data.columns = data.columns.astype(config.dtype_double)
228
+ self._ws_ct = data.index.to_numpy(config.dtype_double)
221
229
  self._ti_ct = np.sort(data.columns.to_numpy())
222
- self._ct = data[self._ti_ct].to_numpy(FC.DTYPE)
230
+ self._ct = data[self._ti_ct].to_numpy(config.dtype_double)
223
231
 
224
232
  return super().load_data(algo, verbosity)
225
233
 
@@ -279,7 +287,7 @@ class WsTI2PCtFromTwo(TurbineType):
279
287
  if np.any(st_sel_P):
280
288
  # prepare interpolation:
281
289
  n_sel = np.sum(st_sel_P)
282
- qts = np.zeros((n_sel, 2), dtype=FC.DTYPE) # ws, ti
290
+ qts = np.zeros((n_sel, 2), dtype=config.dtype_double) # ws, ti
283
291
  qts[:, 0] = fdata[self.WSP][st_sel_P]
284
292
  qts[:, 1] = fdata[FV.TI][st_sel_P]
285
293
 
@@ -328,7 +336,7 @@ class WsTI2PCtFromTwo(TurbineType):
328
336
  if np.any(st_sel_ct):
329
337
  # prepare interpolation:
330
338
  n_sel = np.sum(st_sel_ct)
331
- qts = np.zeros((n_sel, 2), dtype=FC.DTYPE) # ws, ti
339
+ qts = np.zeros((n_sel, 2), dtype=config.dtype_double) # ws, ti
332
340
  qts[:, 0] = fdata[self.WSP][st_sel_ct]
333
341
  qts[:, 1] = fdata[FV.TI][st_sel_ct]
334
342
 
@@ -1,7 +1,7 @@
1
1
  from foxes.core import VerticalProfile
2
2
  from foxes.utils.abl import neutral
3
- import foxes.constants as FC
4
3
  import foxes.variables as FV
4
+ import foxes.constants as FC
5
5
 
6
6
 
7
7
  class ABLLogNeutralWsProfile(VerticalProfile):
@@ -1,7 +1,7 @@
1
1
  from foxes.core import VerticalProfile
2
2
  from foxes.utils.abl import stable
3
- import foxes.constants as FC
4
3
  import foxes.variables as FV
4
+ import foxes.constants as FC
5
5
 
6
6
 
7
7
  class ABLLogStableWsProfile(VerticalProfile):
@@ -1,7 +1,7 @@
1
1
  from foxes.core import VerticalProfile
2
2
  from foxes.utils.abl import unstable
3
- import foxes.constants as FC
4
3
  import foxes.variables as FV
4
+ import foxes.constants as FC
5
5
 
6
6
 
7
7
  class ABLLogUnstableWsProfile(VerticalProfile):
@@ -2,8 +2,8 @@ import numpy as np
2
2
 
3
3
  from foxes.core import VerticalProfile
4
4
  from foxes.utils import abl
5
- import foxes.constants as FC
6
5
  import foxes.variables as FV
6
+ import foxes.constants as FC
7
7
 
8
8
 
9
9
  class ABLLogWsProfile(VerticalProfile):