foxes 1.1.1__py3-none-any.whl → 1.2.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.

Files changed (155) hide show
  1. docs/source/conf.py +3 -1
  2. examples/abl_states/run.py +5 -5
  3. examples/dyn_wakes/run.py +2 -2
  4. examples/induction/run.py +5 -5
  5. examples/random_timeseries/run.py +13 -13
  6. examples/scan_row/run.py +12 -7
  7. examples/sector_management/run.py +11 -7
  8. examples/single_state/run.py +5 -5
  9. examples/tab_file/run.py +1 -1
  10. examples/timelines/run.py +1 -1
  11. examples/timeseries/run.py +5 -5
  12. examples/timeseries_slurm/run.py +5 -5
  13. examples/wind_rose/run.py +1 -1
  14. examples/yawed_wake/run.py +5 -5
  15. foxes/__init__.py +13 -2
  16. foxes/algorithms/downwind/downwind.py +21 -6
  17. foxes/algorithms/downwind/models/init_farm_data.py +5 -2
  18. foxes/algorithms/downwind/models/point_wakes_calc.py +0 -1
  19. foxes/algorithms/iterative/iterative.py +1 -1
  20. foxes/algorithms/sequential/sequential.py +5 -4
  21. foxes/config/__init__.py +1 -0
  22. foxes/config/config.py +134 -0
  23. foxes/constants.py +15 -6
  24. foxes/core/algorithm.py +46 -30
  25. foxes/core/axial_induction_model.py +18 -0
  26. foxes/core/data.py +2 -1
  27. foxes/core/engine.py +43 -49
  28. foxes/core/farm_controller.py +22 -3
  29. foxes/core/farm_data_model.py +6 -2
  30. foxes/core/ground_model.py +19 -0
  31. foxes/core/model.py +2 -1
  32. foxes/core/partial_wakes_model.py +9 -21
  33. foxes/core/point_data_model.py +22 -2
  34. foxes/core/rotor_model.py +9 -21
  35. foxes/core/states.py +2 -17
  36. foxes/core/turbine_model.py +2 -18
  37. foxes/core/turbine_type.py +2 -18
  38. foxes/core/vertical_profile.py +8 -20
  39. foxes/core/wake_frame.py +9 -25
  40. foxes/core/wake_model.py +24 -20
  41. foxes/core/wake_superposition.py +19 -0
  42. foxes/data/__init__.py +1 -1
  43. foxes/data/static_data.py +0 -7
  44. foxes/engines/dask.py +4 -3
  45. foxes/engines/single.py +1 -1
  46. foxes/input/__init__.py +1 -1
  47. foxes/input/farm_layout/from_csv.py +3 -1
  48. foxes/input/farm_layout/from_file.py +10 -10
  49. foxes/input/farm_layout/from_json.py +4 -3
  50. foxes/input/farm_layout/grid.py +3 -3
  51. foxes/input/states/__init__.py +1 -1
  52. foxes/input/states/create/random_abl_states.py +5 -3
  53. foxes/input/states/field_data_nc.py +36 -15
  54. foxes/input/states/multi_height.py +26 -15
  55. foxes/input/states/one_point_flow.py +6 -5
  56. foxes/input/states/{scan_ws.py → scan.py} +42 -52
  57. foxes/input/states/single.py +15 -6
  58. foxes/input/states/slice_data_nc.py +18 -12
  59. foxes/input/states/states_table.py +17 -10
  60. foxes/input/yaml/__init__.py +3 -0
  61. foxes/input/yaml/dict.py +381 -0
  62. foxes/input/yaml/windio/__init__.py +4 -0
  63. foxes/input/{windio → yaml/windio}/get_states.py +7 -7
  64. foxes/input/{windio → yaml/windio}/read_attributes.py +61 -40
  65. foxes/input/{windio → yaml/windio}/read_farm.py +34 -43
  66. foxes/input/{windio → yaml/windio}/read_fields.py +11 -10
  67. foxes/input/yaml/windio/read_outputs.py +147 -0
  68. foxes/input/yaml/windio/windio.py +269 -0
  69. foxes/input/yaml/yaml.py +103 -0
  70. foxes/models/partial_wakes/axiwake.py +7 -6
  71. foxes/models/partial_wakes/centre.py +3 -2
  72. foxes/models/partial_wakes/segregated.py +5 -2
  73. foxes/models/point_models/set_uniform_data.py +5 -3
  74. foxes/models/rotor_models/centre.py +2 -2
  75. foxes/models/rotor_models/grid.py +5 -5
  76. foxes/models/rotor_models/levels.py +6 -6
  77. foxes/models/turbine_models/kTI_model.py +3 -1
  78. foxes/models/turbine_models/lookup_table.py +7 -4
  79. foxes/models/turbine_models/power_mask.py +14 -8
  80. foxes/models/turbine_models/sector_management.py +4 -2
  81. foxes/models/turbine_models/set_farm_vars.py +53 -23
  82. foxes/models/turbine_models/table_factors.py +8 -7
  83. foxes/models/turbine_models/yaw2yawm.py +0 -1
  84. foxes/models/turbine_models/yawm2yaw.py +0 -1
  85. foxes/models/turbine_types/CpCt_file.py +6 -3
  86. foxes/models/turbine_types/CpCt_from_two.py +6 -3
  87. foxes/models/turbine_types/PCt_file.py +7 -6
  88. foxes/models/turbine_types/PCt_from_two.py +11 -2
  89. foxes/models/turbine_types/TBL_file.py +3 -4
  90. foxes/models/turbine_types/wsrho2PCt_from_two.py +19 -11
  91. foxes/models/turbine_types/wsti2PCt_from_two.py +19 -11
  92. foxes/models/vertical_profiles/abl_log_neutral_ws.py +1 -1
  93. foxes/models/vertical_profiles/abl_log_stable_ws.py +1 -1
  94. foxes/models/vertical_profiles/abl_log_unstable_ws.py +1 -1
  95. foxes/models/vertical_profiles/abl_log_ws.py +1 -1
  96. foxes/models/wake_frames/dynamic_wakes.py +17 -9
  97. foxes/models/wake_frames/farm_order.py +4 -3
  98. foxes/models/wake_frames/rotor_wd.py +3 -1
  99. foxes/models/wake_frames/seq_dynamic_wakes.py +14 -7
  100. foxes/models/wake_frames/streamlines.py +9 -6
  101. foxes/models/wake_frames/timelines.py +21 -14
  102. foxes/models/wake_frames/yawed_wakes.py +3 -1
  103. foxes/models/wake_models/induction/vortex_sheet.py +0 -1
  104. foxes/models/wake_models/ti/crespo_hernandez.py +2 -1
  105. foxes/models/wake_models/wind/bastankhah14.py +3 -2
  106. foxes/models/wake_models/wind/bastankhah16.py +2 -1
  107. foxes/models/wake_models/wind/turbopark.py +9 -7
  108. foxes/models/wake_superpositions/ws_product.py +0 -1
  109. foxes/output/__init__.py +2 -1
  110. foxes/output/calc_points.py +7 -4
  111. foxes/output/farm_layout.py +30 -18
  112. foxes/output/farm_results_eval.py +61 -38
  113. foxes/output/grids.py +8 -7
  114. foxes/output/output.py +9 -20
  115. foxes/output/plt.py +19 -0
  116. foxes/output/results_writer.py +10 -11
  117. foxes/output/rose_plot.py +448 -224
  118. foxes/output/rotor_point_plots.py +7 -3
  119. foxes/output/slice_data.py +1 -1
  120. foxes/output/state_turbine_map.py +5 -1
  121. foxes/output/state_turbine_table.py +7 -3
  122. foxes/output/turbine_type_curves.py +7 -2
  123. foxes/utils/__init__.py +1 -2
  124. foxes/utils/dict.py +107 -3
  125. foxes/utils/geopandas_utils.py +3 -2
  126. foxes/utils/subclasses.py +69 -0
  127. {foxes-1.1.1.dist-info → foxes-1.2.1.dist-info}/METADATA +18 -18
  128. {foxes-1.1.1.dist-info → foxes-1.2.1.dist-info}/RECORD +145 -145
  129. {foxes-1.1.1.dist-info → foxes-1.2.1.dist-info}/WHEEL +1 -1
  130. foxes-1.2.1.dist-info/entry_points.txt +3 -0
  131. tests/0_consistency/iterative/test_iterative.py +65 -67
  132. tests/0_consistency/partial_wakes/test_partial_wakes.py +58 -61
  133. tests/1_verification/flappy_0_6/PCt_files/test_PCt_files.py +56 -53
  134. tests/1_verification/flappy_0_6/abl_states/test_abl_states.py +41 -41
  135. tests/1_verification/flappy_0_6/partial_top_hat/test_partial_top_hat.py +34 -34
  136. tests/1_verification/flappy_0_6/row_Jensen_linear_centre/test_row_Jensen_linear_centre.py +57 -52
  137. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/test_row_Jensen_linear_tophat.py +58 -54
  138. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/test_row_Jensen_linear_tophat_IECTI_2005.py +80 -76
  139. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/test_row_Jensen_linear_tophat_IECTI_2019.py +80 -76
  140. tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/test_row_Jensen_quadratic_centre.py +58 -51
  141. tests/1_verification/flappy_0_6_2/grid_rotors/test_grid_rotors.py +101 -103
  142. tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/test_row_Bastankhah_Crespo.py +67 -64
  143. tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/test_row_Bastankhah_linear_centre.py +58 -54
  144. examples/windio/run.py +0 -29
  145. foxes/data/states/windio_timeseries_5000.nc +0 -0
  146. foxes/data/windio/DTU_10MW_turbine.yaml +0 -10
  147. foxes/data/windio/__init__.py +0 -0
  148. foxes/data/windio/windio_5turbines_timeseries.yaml +0 -79
  149. foxes/input/windio/__init__.py +0 -11
  150. foxes/input/windio/read_outputs.py +0 -172
  151. foxes/input/windio/runner.py +0 -183
  152. foxes/input/windio/windio.py +0 -193
  153. foxes/utils/windrose_plot.py +0 -152
  154. {foxes-1.1.1.dist-info → foxes-1.2.1.dist-info}/LICENSE +0 -0
  155. {foxes-1.1.1.dist-info → foxes-1.2.1.dist-info}/top_level.txt +0 -0
@@ -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):
@@ -4,6 +4,7 @@ from scipy.spatial.distance import cdist
4
4
  from foxes.core import WakeFrame, TData
5
5
  from foxes.utils import wd2uv
6
6
  from foxes.algorithms.iterative import Iterative
7
+ from foxes.config import config
7
8
  import foxes.variables as FV
8
9
  import foxes.constants as FC
9
10
 
@@ -98,12 +99,14 @@ class DynamicWakes(WakeFrame):
98
99
  f"{self.name}: Expecting 'dt_min' for single step timeseries"
99
100
  )
100
101
  self._dt = (
101
- (times[1:] - times[:-1]).astype("timedelta64[s]").astype(FC.ITYPE)
102
+ (times[1:] - times[:-1])
103
+ .astype("timedelta64[s]")
104
+ .astype(config.dtype_int)
102
105
  )
103
106
  else:
104
107
  n = max(len(times) - 1, 1)
105
108
  self._dt = np.full(n, self.dt_min * 60, dtype="timedelta64[s]").astype(
106
- FC.ITYPE
109
+ config.dtype_int
107
110
  )
108
111
  self._dt = np.append(self._dt, self._dt[-1, None], axis=0)
109
112
 
@@ -141,7 +144,7 @@ class DynamicWakes(WakeFrame):
141
144
  The turbine order, shape: (n_states, n_turbines)
142
145
 
143
146
  """
144
- order = np.zeros((fdata.n_states, fdata.n_turbines), dtype=FC.ITYPE)
147
+ order = np.zeros((fdata.n_states, fdata.n_turbines), dtype=config.dtype_int)
145
148
  order[:] = np.arange(fdata.n_turbines)[None, :]
146
149
  return order
147
150
 
@@ -163,10 +166,15 @@ class DynamicWakes(WakeFrame):
163
166
  # compute wakes that start within this chunk: x, y, z, length
164
167
  data = algo.get_from_chunk_store(name=key, mdata=mdata, error=False)
165
168
  if data is None:
166
- data = np.full((n_states, self.max_age, 4), np.nan, dtype=FC.DTYPE)
169
+ data = np.full(
170
+ (n_states, self.max_age, 4), np.nan, dtype=config.dtype_double
171
+ )
167
172
  data[:, 0, :3] = rxyh
168
173
  data[:, 0, 3] = 0
169
- tdt = {v: np.zeros((n_states, 1, 1), dtype=FC.DTYPE) for v in tdi.keys()}
174
+ tdt = {
175
+ v: np.zeros((n_states, 1, 1), dtype=config.dtype_double)
176
+ for v in tdi.keys()
177
+ }
170
178
  pts = data[:, 0, :3].copy()
171
179
  for age in range(self.max_age - 1):
172
180
  if age == n_states:
@@ -259,7 +267,7 @@ class DynamicWakes(WakeFrame):
259
267
  n_pts = len(pts)
260
268
 
261
269
  tdt = {
262
- v: np.zeros((n_states, n_pts, 1), dtype=FC.DTYPE)
270
+ v: np.zeros((n_states, n_pts, 1), dtype=config.dtype_double)
263
271
  for v in algo.states.output_point_vars(algo)
264
272
  }
265
273
 
@@ -368,9 +376,9 @@ class DynamicWakes(WakeFrame):
368
376
  i0 = mdata.states_i0(counter=True)
369
377
 
370
378
  # initialize:
371
- wcoos = np.full((n_states, n_points, 3), 1e20, dtype=FC.DTYPE)
379
+ wcoos = np.full((n_states, n_points, 3), 1e20, dtype=config.dtype_double)
372
380
  wcoos[:, :, 2] = points[:, :, 2] - rxyh[:, None, 2]
373
- wake_si = np.zeros((n_states, n_points), dtype=FC.ITYPE)
381
+ wake_si = np.zeros((n_states, n_points), dtype=config.dtype_int)
374
382
  wake_si[:] = i0 + np.arange(n_states)[:, None]
375
383
 
376
384
  # find nearest wake point:
@@ -400,7 +408,7 @@ class DynamicWakes(WakeFrame):
400
408
  if np.any(~sel):
401
409
  nx[~sel] -= wdata[sts[~sel], ags[~sel] - 1, :2]
402
410
  dx = np.linalg.norm(nx, axis=-1)
403
- nx /= dx[:, None]
411
+ nx /= dx[:, None] + 1e-14
404
412
 
405
413
  projx = np.einsum("sd,sd->s", dp, nx)
406
414
  sel = (projx > -dx) & (projx < dx)
@@ -1,9 +1,10 @@
1
1
  import numpy as np
2
2
 
3
- import foxes.constants as FC
4
- from .rotor_wd import RotorWD
3
+ from foxes.config import config
5
4
  from foxes.core import WakeFrame
6
5
 
6
+ from .rotor_wd import RotorWD
7
+
7
8
 
8
9
  class FarmOrder(WakeFrame):
9
10
  """
@@ -90,7 +91,7 @@ class FarmOrder(WakeFrame):
90
91
  The turbine order, shape: (n_states, n_turbines)
91
92
 
92
93
  """
93
- order = np.zeros((fdata.n_states, fdata.n_turbines), dtype=FC.ITYPE)
94
+ order = np.zeros((fdata.n_states, fdata.n_turbines), dtype=config.dtype_int)
94
95
  order[:] = np.arange(fdata.n_turbines)[None, :]
95
96
 
96
97
  return order
@@ -2,6 +2,8 @@ import numpy as np
2
2
 
3
3
  from foxes.core import WakeFrame
4
4
  from foxes.utils import wd2uv
5
+ from foxes.config import config
6
+
5
7
  import foxes.variables as FV
6
8
  import foxes.constants as FC
7
9
 
@@ -104,7 +106,7 @@ class RotorWD(WakeFrame):
104
106
 
105
107
  wd = fdata[self.var_wd][:, downwind_index]
106
108
 
107
- nax = np.zeros((n_states, 3, 3), dtype=FC.DTYPE)
109
+ nax = np.zeros((n_states, 3, 3), dtype=config.dtype_double)
108
110
  n = nax[:, 0, :2]
109
111
  n[:] = wd2uv(wd, axis=-1)
110
112
  m = nax[:, 1, :2]
@@ -3,9 +3,10 @@ from scipy.spatial.distance import cdist
3
3
 
4
4
  from foxes.utils import wd2uv
5
5
  from foxes.core.data import TData
6
+ from foxes.config import config
7
+ from foxes.algorithms.sequential import Sequential
6
8
  import foxes.variables as FV
7
9
  import foxes.constants as FC
8
- from foxes.algorithms.sequential import Sequential
9
10
 
10
11
  from .farm_order import FarmOrder
11
12
 
@@ -80,19 +81,25 @@ class SeqDynamicWakes(FarmOrder):
80
81
  f"{self.name}: Expecting 'dt_min' for single step timeseries"
81
82
  )
82
83
  self._dt = (
83
- (times[1:] - times[:-1]).astype("timedelta64[s]").astype(FC.ITYPE)
84
+ (times[1:] - times[:-1])
85
+ .astype("timedelta64[s]")
86
+ .astype(config.dtype_int)
84
87
  )
85
88
  else:
86
89
  n = max(len(times) - 1, 1)
87
90
  self._dt = np.full(n, self.dt_min * 60, dtype="timedelta64[s]").astype(
88
- FC.ITYPE
91
+ config.dtype_int
89
92
  )
90
93
 
91
94
  # init wake traces data:
92
- self._traces_p = np.zeros((algo.n_states, algo.n_turbines, 3), dtype=FC.DTYPE)
93
- self._traces_v = np.zeros((algo.n_states, algo.n_turbines, 3), dtype=FC.DTYPE)
95
+ self._traces_p = np.zeros(
96
+ (algo.n_states, algo.n_turbines, 3), dtype=config.dtype_double
97
+ )
98
+ self._traces_v = np.zeros(
99
+ (algo.n_states, algo.n_turbines, 3), dtype=config.dtype_double
100
+ )
94
101
  self._traces_l = np.full(
95
- (algo.n_states, algo.n_turbines), np.nan, dtype=FC.DTYPE
102
+ (algo.n_states, algo.n_turbines), np.nan, dtype=config.dtype_double
96
103
  )
97
104
 
98
105
  def calc_order(self, algo, mdata, fdata):
@@ -192,7 +199,7 @@ class SeqDynamicWakes(FarmOrder):
192
199
  del dists
193
200
 
194
201
  # project:
195
- wcoos = np.full((n_states, n_points, 3), 1e20, dtype=FC.DTYPE)
202
+ wcoos = np.full((n_states, n_points, 3), 1e20, dtype=config.dtype_double)
196
203
  wcoos[0, :, 2] = points[0, :, 2] - fdata[FV.TXYH][0, downwind_index, None, 2]
197
204
  nx = self._traces_v[tri, downwind_index, :2]
198
205
  mv = np.linalg.norm(nx, axis=-1)
@@ -4,6 +4,7 @@ from scipy.interpolate import interpn
4
4
  from foxes.core import WakeFrame
5
5
  from foxes.utils import wd2uv
6
6
  from foxes.core.data import TData
7
+ from foxes.config import config
7
8
  import foxes.variables as FV
8
9
  import foxes.constants as FC
9
10
 
@@ -64,7 +65,7 @@ class Streamlines2D(WakeFrame):
64
65
  N = int(self.max_length_km * 1e3 / self.step)
65
66
 
66
67
  # calc data: x, y, z, wd
67
- data = np.zeros((n_states, n_turbines, N, 4), dtype=FC.DTYPE)
68
+ data = np.zeros((n_states, n_turbines, N, 4), dtype=config.dtype_double)
68
69
  for i in range(N):
69
70
 
70
71
  # set streamline start point data (rotor centre):
@@ -86,7 +87,9 @@ class Streamlines2D(WakeFrame):
86
87
  tdata = TData.from_points(
87
88
  data[:, :, i, :3],
88
89
  data={
89
- v: np.full((n_states, n_turbines, 1), np.nan, dtype=FC.DTYPE)
90
+ v: np.full(
91
+ (n_states, n_turbines, 1), np.nan, dtype=config.dtype_double
92
+ )
90
93
  for v in svars
91
94
  },
92
95
  dims={v: (FC.STATE, FC.TARGET, FC.TPOINT) for v in svars},
@@ -151,7 +154,7 @@ class Streamlines2D(WakeFrame):
151
154
  del dists, selp
152
155
 
153
156
  # calculate coordinates:
154
- coos = np.full((n_states, n_points, 3), np.nan, dtype=FC.DTYPE)
157
+ coos = np.full((n_states, n_points, 3), np.nan, dtype=config.dtype_double)
155
158
  coos[:, :, 2] = points[:, :, 2] - data[:, :, 2]
156
159
  delta = points[:, :, :2] - data[:, :, :2]
157
160
  nx = wd2uv(data[:, :, 3])
@@ -193,7 +196,7 @@ class Streamlines2D(WakeFrame):
193
196
 
194
197
  # calculate streamline x coordinates for turbines rotor centre points:
195
198
  # n_states, n_turbines_source, n_turbines_target
196
- coosx = np.zeros((n_states, n_turbines, n_turbines), dtype=FC.DTYPE)
199
+ coosx = np.zeros((n_states, n_turbines, n_turbines), dtype=config.dtype_double)
197
200
  for ti in range(n_turbines):
198
201
  coosx[:, ti, :] = self.get_wake_coos(algo, mdata, fdata, tdata, ti)[
199
202
  :, :, 0, 0
@@ -201,7 +204,7 @@ class Streamlines2D(WakeFrame):
201
204
 
202
205
  # derive turbine order:
203
206
  # TODO: Remove loop over states
204
- order = np.zeros((n_states, n_turbines), dtype=FC.ITYPE)
207
+ order = np.zeros((n_states, n_turbines), dtype=config.dtype_int)
205
208
  for si in range(n_states):
206
209
  order[si] = np.lexsort(keys=coosx[si])
207
210
 
@@ -273,7 +276,7 @@ class Streamlines2D(WakeFrame):
273
276
  xs = self.step * np.arange(n_spts)
274
277
 
275
278
  # interpolate to x of interest:
276
- qts = np.zeros((n_states, n_points, 2), dtype=FC.DTYPE)
279
+ qts = np.zeros((n_states, n_points, 2), dtype=config.dtype_double)
277
280
  qts[:, :, 0] = np.arange(n_states)[:, None]
278
281
  qts[:, :, 1] = np.minimum(x, xs[-1])
279
282
  qts = qts.reshape(n_states * n_points, 2)