foxes 1.2.2__py3-none-any.whl → 1.2.3__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.
- examples/field_data_nc/run.py +11 -4
- examples/streamline_wakes/run.py +6 -3
- foxes/algorithms/downwind/downwind.py +1 -0
- foxes/config/__init__.py +1 -1
- foxes/config/config.py +80 -14
- foxes/constants.py +12 -1
- foxes/core/algorithm.py +13 -8
- foxes/core/engine.py +30 -0
- foxes/core/farm_controller.py +41 -24
- foxes/core/states.py +1 -1
- foxes/core/wind_farm.py +109 -0
- foxes/engines/dask.py +88 -4
- foxes/engines/default.py +45 -2
- foxes/engines/mpi.py +5 -16
- foxes/engines/multiprocess.py +1 -10
- foxes/engines/numpy.py +30 -0
- foxes/engines/pool.py +48 -0
- foxes/engines/ray.py +1 -1
- foxes/engines/single.py +30 -0
- foxes/input/farm_layout/from_csv.py +2 -2
- foxes/input/farm_layout/from_file.py +2 -2
- foxes/input/farm_layout/from_json.py +2 -2
- foxes/input/states/__init__.py +0 -1
- foxes/input/states/create/random_abl_states.py +2 -2
- foxes/input/states/field_data_nc.py +286 -141
- foxes/input/states/multi_height.py +3 -3
- foxes/input/states/states_table.py +3 -3
- foxes/input/yaml/dict.py +83 -46
- foxes/input/yaml/windio/__init__.py +2 -1
- foxes/input/yaml/windio/read_attributes.py +17 -34
- foxes/input/yaml/windio/read_farm.py +57 -3
- foxes/input/yaml/windio/read_outputs.py +116 -56
- foxes/input/yaml/windio/{get_states.py → read_site.py} +69 -0
- foxes/input/yaml/windio/windio.py +42 -119
- foxes/input/yaml/yaml.py +3 -3
- foxes/models/model_book.py +1 -0
- foxes/models/point_models/__init__.py +1 -0
- foxes/models/point_models/ustar2ti.py +84 -0
- foxes/models/turbine_models/lookup_table.py +2 -2
- foxes/models/turbine_models/sector_management.py +2 -2
- foxes/models/turbine_models/table_factors.py +2 -2
- foxes/models/turbine_types/CpCt_file.py +2 -2
- foxes/models/turbine_types/CpCt_from_two.py +3 -3
- foxes/models/turbine_types/PCt_file.py +2 -2
- foxes/models/turbine_types/PCt_from_two.py +3 -3
- foxes/models/turbine_types/TBL_file.py +2 -2
- foxes/models/turbine_types/wsrho2PCt_from_two.py +3 -3
- foxes/models/turbine_types/wsti2PCt_from_two.py +3 -3
- foxes/output/__init__.py +1 -0
- foxes/output/output.py +5 -3
- foxes/output/slice_data.py +1 -1
- foxes/output/slices_data.py +323 -0
- foxes/output/state_turbine_table.py +11 -0
- foxes/utils/load.py +12 -4
- foxes/utils/xarray_utils.py +14 -3
- foxes/variables.py +5 -0
- {foxes-1.2.2.dist-info → foxes-1.2.3.dist-info}/METADATA +6 -2
- {foxes-1.2.2.dist-info → foxes-1.2.3.dist-info}/RECORD +62 -61
- foxes/input/states/slice_data_nc.py +0 -687
- {foxes-1.2.2.dist-info → foxes-1.2.3.dist-info}/LICENSE +0 -0
- {foxes-1.2.2.dist-info → foxes-1.2.3.dist-info}/WHEEL +0 -0
- {foxes-1.2.2.dist-info → foxes-1.2.3.dist-info}/entry_points.txt +0 -0
- {foxes-1.2.2.dist-info → foxes-1.2.3.dist-info}/top_level.txt +0 -0
foxes/engines/default.py
CHANGED
|
@@ -12,6 +12,50 @@ class DefaultEngine(Engine):
|
|
|
12
12
|
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
+
def map(
|
|
16
|
+
self,
|
|
17
|
+
func,
|
|
18
|
+
inputs,
|
|
19
|
+
*args,
|
|
20
|
+
**kwargs,
|
|
21
|
+
):
|
|
22
|
+
"""
|
|
23
|
+
Runs a function on a list of files
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
func: Callable
|
|
28
|
+
Function to be called on each file,
|
|
29
|
+
func(input, *args, **kwargs) -> data
|
|
30
|
+
inputs: array-like
|
|
31
|
+
The input data list
|
|
32
|
+
args: tuple, optional
|
|
33
|
+
Arguments for func
|
|
34
|
+
kwargs: dict, optional
|
|
35
|
+
Keyword arguments for func
|
|
36
|
+
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
39
|
+
results: list
|
|
40
|
+
The list of results
|
|
41
|
+
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
self.finalize()
|
|
45
|
+
|
|
46
|
+
with Engine.new(
|
|
47
|
+
"process",
|
|
48
|
+
n_procs=self.n_procs,
|
|
49
|
+
chunk_size_states=self.chunk_size_states,
|
|
50
|
+
chunk_size_points=self.chunk_size_points,
|
|
51
|
+
verbosity=self.verbosity,
|
|
52
|
+
) as e:
|
|
53
|
+
results = e.map(func, inputs, *args, **kwargs)
|
|
54
|
+
|
|
55
|
+
self.initialize()
|
|
56
|
+
|
|
57
|
+
return results
|
|
58
|
+
|
|
15
59
|
def run_calculation(
|
|
16
60
|
self,
|
|
17
61
|
algo,
|
|
@@ -48,8 +92,7 @@ class DefaultEngine(Engine):
|
|
|
48
92
|
|
|
49
93
|
if (algo.n_states >= max_n) or (
|
|
50
94
|
point_data is not None
|
|
51
|
-
and
|
|
52
|
-
and point_data.sizes[FC.TARGET] > self.chunk_size_points
|
|
95
|
+
and algo.n_states * point_data.sizes[FC.TARGET] > 10000
|
|
53
96
|
):
|
|
54
97
|
ename = "process"
|
|
55
98
|
else:
|
foxes/engines/mpi.py
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
from foxes.utils import import_module
|
|
2
2
|
|
|
3
|
-
from .pool import PoolEngine
|
|
4
3
|
from .futures import ProcessEngine
|
|
5
4
|
|
|
6
5
|
|
|
7
|
-
def load_mpi():
|
|
8
|
-
"""On-demand loading of the mpi4py package"""
|
|
9
|
-
global MPIPoolExecutor
|
|
10
|
-
MPIPoolExecutor = import_module(
|
|
11
|
-
"mpi4py.futures", hint="pip install mpi4py"
|
|
12
|
-
).MPIPoolExecutor
|
|
13
|
-
|
|
14
|
-
|
|
15
6
|
class MPIEngine(ProcessEngine):
|
|
16
7
|
"""
|
|
17
8
|
The MPI engine for foxes calculations.
|
|
@@ -26,13 +17,11 @@ class MPIEngine(ProcessEngine):
|
|
|
26
17
|
|
|
27
18
|
"""
|
|
28
19
|
|
|
29
|
-
def initialize(self):
|
|
30
|
-
"""
|
|
31
|
-
Initializes the engine.
|
|
32
|
-
"""
|
|
33
|
-
load_mpi()
|
|
34
|
-
PoolEngine.initialize(self)
|
|
35
|
-
|
|
36
20
|
def _create_pool(self):
|
|
37
21
|
"""Creates the pool"""
|
|
22
|
+
MPIPoolExecutor = import_module(
|
|
23
|
+
"mpi4py.futures",
|
|
24
|
+
pip_hint="pip install mpi4py",
|
|
25
|
+
conda_hint="conda install mpi4py -c conda-forge",
|
|
26
|
+
).MPIPoolExecutor
|
|
38
27
|
self._pool = MPIPoolExecutor(max_workers=self.n_procs)
|
foxes/engines/multiprocess.py
CHANGED
|
@@ -2,15 +2,6 @@ from foxes.utils import import_module
|
|
|
2
2
|
|
|
3
3
|
from .pool import PoolEngine
|
|
4
4
|
|
|
5
|
-
Pool = None
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def load_multiprocess():
|
|
9
|
-
"""On-demand loading of the multiprocess package"""
|
|
10
|
-
global Pool
|
|
11
|
-
if Pool is None:
|
|
12
|
-
Pool = import_module("multiprocess", hint="pip install multiprocess").Pool
|
|
13
|
-
|
|
14
5
|
|
|
15
6
|
class MultiprocessEngine(PoolEngine):
|
|
16
7
|
"""
|
|
@@ -22,7 +13,7 @@ class MultiprocessEngine(PoolEngine):
|
|
|
22
13
|
|
|
23
14
|
def _create_pool(self):
|
|
24
15
|
"""Creates the pool"""
|
|
25
|
-
|
|
16
|
+
Pool = import_module("multiprocess").Pool
|
|
26
17
|
self._pool = Pool(processes=self.n_procs)
|
|
27
18
|
|
|
28
19
|
def _submit(self, f, *args, **kwargs):
|
foxes/engines/numpy.py
CHANGED
|
@@ -16,6 +16,36 @@ class NumpyEngine(Engine):
|
|
|
16
16
|
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
+
def map(
|
|
20
|
+
self,
|
|
21
|
+
func,
|
|
22
|
+
inputs,
|
|
23
|
+
*args,
|
|
24
|
+
**kwargs,
|
|
25
|
+
):
|
|
26
|
+
"""
|
|
27
|
+
Runs a function on a list of files
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
func: Callable
|
|
32
|
+
Function to be called on each file,
|
|
33
|
+
func(input, *args, **kwargs) -> data
|
|
34
|
+
inputs: array-like
|
|
35
|
+
The input data list
|
|
36
|
+
args: tuple, optional
|
|
37
|
+
Arguments for func
|
|
38
|
+
kwargs: dict, optional
|
|
39
|
+
Keyword arguments for func
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
results: list
|
|
44
|
+
The list of results
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
return [func(input, *args, **kwargs) for input in inputs]
|
|
48
|
+
|
|
19
49
|
def run_calculation(
|
|
20
50
|
self,
|
|
21
51
|
algo,
|
foxes/engines/pool.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import numpy as np
|
|
1
2
|
import xarray as xr
|
|
2
3
|
from abc import abstractmethod
|
|
3
4
|
from tqdm import tqdm
|
|
@@ -15,6 +16,11 @@ def _run(algo, model, data, iterative, chunk_store, i0_t0, **cpars):
|
|
|
15
16
|
return results, cstore
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
def _run_map(func, inputs, *args, **kwargs):
|
|
20
|
+
"""Helper function for running map func on proc"""
|
|
21
|
+
return [func(x, *args, **kwargs) for x in inputs]
|
|
22
|
+
|
|
23
|
+
|
|
18
24
|
class PoolEngine(Engine):
|
|
19
25
|
"""
|
|
20
26
|
Abstract engine for pool type parallelizations.
|
|
@@ -82,6 +88,48 @@ class PoolEngine(Engine):
|
|
|
82
88
|
self._shutdown_pool()
|
|
83
89
|
super().__exit__(*exit_args)
|
|
84
90
|
|
|
91
|
+
def map(
|
|
92
|
+
self,
|
|
93
|
+
func,
|
|
94
|
+
inputs,
|
|
95
|
+
*args,
|
|
96
|
+
**kwargs,
|
|
97
|
+
):
|
|
98
|
+
"""
|
|
99
|
+
Runs a function on a list of files
|
|
100
|
+
|
|
101
|
+
Parameters
|
|
102
|
+
----------
|
|
103
|
+
func: Callable
|
|
104
|
+
Function to be called on each file,
|
|
105
|
+
func(input, *args, **kwargs) -> data
|
|
106
|
+
inputs: array-like
|
|
107
|
+
The input data list
|
|
108
|
+
args: tuple, optional
|
|
109
|
+
Arguments for func
|
|
110
|
+
kwargs: dict, optional
|
|
111
|
+
Keyword arguments for func
|
|
112
|
+
|
|
113
|
+
Returns
|
|
114
|
+
-------
|
|
115
|
+
results: list
|
|
116
|
+
The list of results
|
|
117
|
+
|
|
118
|
+
"""
|
|
119
|
+
if len(inputs) == 0:
|
|
120
|
+
return []
|
|
121
|
+
elif len(inputs) == 1:
|
|
122
|
+
return [func(inputs[0], *args, **kwargs)]
|
|
123
|
+
else:
|
|
124
|
+
inptl = np.array_split(inputs, min(self.n_procs, len(inputs)))
|
|
125
|
+
jobs = []
|
|
126
|
+
for subi in inptl:
|
|
127
|
+
jobs.append(self._submit(_run_map, func, subi, *args, **kwargs))
|
|
128
|
+
results = []
|
|
129
|
+
for j in jobs:
|
|
130
|
+
results += self._result(j)
|
|
131
|
+
return results
|
|
132
|
+
|
|
85
133
|
def run_calculation(
|
|
86
134
|
self,
|
|
87
135
|
algo,
|
foxes/engines/ray.py
CHANGED
foxes/engines/single.py
CHANGED
|
@@ -39,6 +39,36 @@ class SingleChunkEngine(Engine):
|
|
|
39
39
|
def __repr__(self):
|
|
40
40
|
return f"{type(self).__name__}()"
|
|
41
41
|
|
|
42
|
+
def map(
|
|
43
|
+
self,
|
|
44
|
+
func,
|
|
45
|
+
inputs,
|
|
46
|
+
*args,
|
|
47
|
+
**kwargs,
|
|
48
|
+
):
|
|
49
|
+
"""
|
|
50
|
+
Runs a function on a list of files
|
|
51
|
+
|
|
52
|
+
Parameters
|
|
53
|
+
----------
|
|
54
|
+
func: Callable
|
|
55
|
+
Function to be called on each file,
|
|
56
|
+
func(input, *args, **kwargs) -> data
|
|
57
|
+
inputs: array-like
|
|
58
|
+
The input data list
|
|
59
|
+
args: tuple, optional
|
|
60
|
+
Arguments for func
|
|
61
|
+
kwargs: dict, optional
|
|
62
|
+
Keyword arguments for func
|
|
63
|
+
|
|
64
|
+
Returns
|
|
65
|
+
-------
|
|
66
|
+
results: list
|
|
67
|
+
The list of results
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
return [func(input, *args, **kwargs) for input in inputs]
|
|
71
|
+
|
|
42
72
|
def run_calculation(
|
|
43
73
|
self,
|
|
44
74
|
algo,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pandas as pd
|
|
2
2
|
|
|
3
3
|
from foxes.core import Turbine
|
|
4
|
-
from foxes.config import
|
|
4
|
+
from foxes.config import get_input_path
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def add_from_csv(
|
|
@@ -76,7 +76,7 @@ def add_from_csv(
|
|
|
76
76
|
else:
|
|
77
77
|
if verbosity:
|
|
78
78
|
print("Reading file", data_source)
|
|
79
|
-
pth =
|
|
79
|
+
pth = get_input_path(data_source)
|
|
80
80
|
data = pd.read_csv(pth, index_col=col_index)
|
|
81
81
|
|
|
82
82
|
tmodels = turbine_parameters.pop("turbine_models", [])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from foxes.data import FARM, StaticData
|
|
2
|
-
from foxes.config import
|
|
2
|
+
from foxes.config import get_input_path
|
|
3
3
|
|
|
4
4
|
from .from_json import add_from_json
|
|
5
5
|
from .from_csv import add_from_csv
|
|
@@ -31,7 +31,7 @@ def add_from_file(farm, file_path, *args, verbosity=1, dbook=None, **kwargs):
|
|
|
31
31
|
|
|
32
32
|
"""
|
|
33
33
|
|
|
34
|
-
fpath =
|
|
34
|
+
fpath = get_input_path(file_path)
|
|
35
35
|
dbook = StaticData() if dbook is None else dbook
|
|
36
36
|
|
|
37
37
|
if not fpath.is_file():
|
|
@@ -3,7 +3,7 @@ import numpy as np
|
|
|
3
3
|
from copy import deepcopy
|
|
4
4
|
|
|
5
5
|
from foxes.core import Turbine
|
|
6
|
-
from foxes.config import
|
|
6
|
+
from foxes.config import get_input_path
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def add_from_json(
|
|
@@ -28,7 +28,7 @@ def add_from_json(
|
|
|
28
28
|
:group: input.farm_layout
|
|
29
29
|
|
|
30
30
|
"""
|
|
31
|
-
fpath =
|
|
31
|
+
fpath = get_input_path(file_path)
|
|
32
32
|
if verbosity:
|
|
33
33
|
print("Reading file", fpath)
|
|
34
34
|
with open(fpath) as f:
|
foxes/input/states/__init__.py
CHANGED
|
@@ -6,7 +6,6 @@ from .single import SingleStateStates
|
|
|
6
6
|
from .scan import ScanStates
|
|
7
7
|
from .states_table import StatesTable, Timeseries, TabStates
|
|
8
8
|
from .field_data_nc import FieldDataNC
|
|
9
|
-
from .slice_data_nc import SliceDataNC
|
|
10
9
|
from .multi_height import MultiHeightStates, MultiHeightTimeseries
|
|
11
10
|
from .multi_height import MultiHeightNCStates, MultiHeightNCTimeseries
|
|
12
11
|
from .one_point_flow import (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pandas as pd
|
|
2
2
|
import numpy as np
|
|
3
3
|
|
|
4
|
-
from foxes.config import config,
|
|
4
|
+
from foxes.config import config, get_output_path
|
|
5
5
|
import foxes.variables as FV
|
|
6
6
|
import foxes.constants as FC
|
|
7
7
|
|
|
@@ -99,7 +99,7 @@ def write_random_abl_states(
|
|
|
99
99
|
|
|
100
100
|
"""
|
|
101
101
|
|
|
102
|
-
fpath =
|
|
102
|
+
fpath = get_output_path(file_path)
|
|
103
103
|
if verbosity:
|
|
104
104
|
print("Writing file", fpath)
|
|
105
105
|
|