foxes 0.7.3.1__py3-none-any.whl → 0.7.4.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.
- foxes/VERSION +1 -1
- foxes/constants.py +1 -1
- foxes/core/wind_farm.py +1 -1
- foxes/input/windio/__init__.py +1 -0
- foxes/input/windio/get_states.py +82 -13
- foxes/input/windio/read_attributes.py +99 -82
- foxes/input/windio/read_farm.py +12 -12
- foxes/input/windio/read_fields.py +37 -27
- foxes/input/windio/read_outputs.py +125 -0
- foxes/input/windio/runner.py +72 -8
- foxes/input/windio/windio.py +24 -16
- foxes/models/wake_models/wind/bastankhah14.py +1 -1
- foxes/output/__init__.py +1 -0
- foxes/output/slice_data.py +41 -11
- foxes/output/state_turbine_table.py +78 -0
- {foxes-0.7.3.1.dist-info → foxes-0.7.4.3.dist-info}/METADATA +1 -1
- {foxes-0.7.3.1.dist-info → foxes-0.7.4.3.dist-info}/RECORD +21 -19
- {foxes-0.7.3.1.dist-info → foxes-0.7.4.3.dist-info}/WHEEL +1 -1
- {foxes-0.7.3.1.dist-info → foxes-0.7.4.3.dist-info}/LICENSE +0 -0
- {foxes-0.7.3.1.dist-info → foxes-0.7.4.3.dist-info}/top_level.txt +0 -0
- {foxes-0.7.3.1.dist-info → foxes-0.7.4.3.dist-info}/zip-safe +0 -0
|
@@ -20,6 +20,7 @@ wio2foxes = {
|
|
|
20
20
|
"turbulence_intensity": FV.TI,
|
|
21
21
|
"LMO": FV.MOL,
|
|
22
22
|
"z0": FV.Z0,
|
|
23
|
+
"reference_height": FV.H,
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
""" Mapping from foxes to windio variables
|
|
@@ -27,8 +28,7 @@ wio2foxes = {
|
|
|
27
28
|
"""
|
|
28
29
|
foxes2wio = {d: k for k, d in wio2foxes.items()}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
def _read_nondimensional_coordinate(name, wio_data, coords, fields, dims):
|
|
31
|
+
def _read_nondimensional_coordinate(name, wio_data, coords):
|
|
32
32
|
"""read nondimensional coordinate
|
|
33
33
|
:group: input.windio
|
|
34
34
|
"""
|
|
@@ -37,8 +37,7 @@ def _read_nondimensional_coordinate(name, wio_data, coords, fields, dims):
|
|
|
37
37
|
return True
|
|
38
38
|
return False
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
def _read_dimensional_coordinate(name, wio_data, coords, fields, dims):
|
|
40
|
+
def _read_dimensional_coordinate(name, wio_data, coords):
|
|
42
41
|
"""read dimensional coordinate
|
|
43
42
|
:group: input.windio
|
|
44
43
|
"""
|
|
@@ -49,17 +48,15 @@ def _read_dimensional_coordinate(name, wio_data, coords, fields, dims):
|
|
|
49
48
|
return True
|
|
50
49
|
return False
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
def _read_multi_dimensional_coordinate(*args, **kwargs):
|
|
51
|
+
def _read_multi_dimensional_coordinate(name, wio_data, coords):
|
|
54
52
|
"""Read multi dimensional coordinate
|
|
55
53
|
:group: input.windio
|
|
56
54
|
"""
|
|
57
55
|
return _read_nondimensional_coordinate(
|
|
58
|
-
|
|
59
|
-
) or _read_dimensional_coordinate(
|
|
56
|
+
name, wio_data, coords
|
|
57
|
+
) or _read_dimensional_coordinate(name, wio_data, coords)
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
def _read_nondimensional_data(name, wio_data, coords, fields, dims):
|
|
59
|
+
def _read_nondimensional_data(name, wio_data, fields, dims):
|
|
63
60
|
"""read nondimensional data
|
|
64
61
|
:group: input.windio
|
|
65
62
|
"""
|
|
@@ -70,8 +67,7 @@ def _read_nondimensional_data(name, wio_data, coords, fields, dims):
|
|
|
70
67
|
return True
|
|
71
68
|
return False
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
def _read_dimensional_data(name, wio_data, coords, fields, dims):
|
|
70
|
+
def _read_dimensional_data(name, wio_data, fields, dims):
|
|
75
71
|
"""read dimensional data
|
|
76
72
|
:group: input.windio
|
|
77
73
|
"""
|
|
@@ -87,17 +83,22 @@ def _read_dimensional_data(name, wio_data, coords, fields, dims):
|
|
|
87
83
|
return True
|
|
88
84
|
return False
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
def _read_multi_dimensional_data(*args, **kwargs):
|
|
86
|
+
def _read_multi_dimensional_data(name, wio_data, fields, dims):
|
|
92
87
|
"""Read multi dimensional data
|
|
93
88
|
:group: input.windio
|
|
94
89
|
"""
|
|
95
|
-
return _read_nondimensional_data(
|
|
96
|
-
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
90
|
+
return _read_nondimensional_data(
|
|
91
|
+
name, wio_data, fields, dims
|
|
92
|
+
) or _read_dimensional_data(name, wio_data, fields, dims)
|
|
93
|
+
|
|
94
|
+
def read_wind_resource_field(
|
|
95
|
+
name,
|
|
96
|
+
wio_data,
|
|
97
|
+
coords,
|
|
98
|
+
fields,
|
|
99
|
+
dims,
|
|
100
|
+
verbosity,
|
|
101
|
+
):
|
|
101
102
|
"""
|
|
102
103
|
Reads wind resource data into fields and dims
|
|
103
104
|
|
|
@@ -113,6 +114,8 @@ def read_wind_resource_field(name, wio_data, coords, fields, dims):
|
|
|
113
114
|
The fields dict, filled on the fly
|
|
114
115
|
dims: dict
|
|
115
116
|
The dimensions dict, filled on the fly
|
|
117
|
+
verbosity: int
|
|
118
|
+
The verbosity level, 0=silent
|
|
116
119
|
|
|
117
120
|
Returns
|
|
118
121
|
-------
|
|
@@ -129,12 +132,19 @@ def read_wind_resource_field(name, wio_data, coords, fields, dims):
|
|
|
129
132
|
"friction_velocity",
|
|
130
133
|
"k",
|
|
131
134
|
"epsilon",
|
|
135
|
+
"ABL_height",
|
|
136
|
+
"lapse_rate",
|
|
137
|
+
"capping_inversion_thickness",
|
|
138
|
+
"capping_inversion_strength",
|
|
132
139
|
]:
|
|
133
|
-
|
|
140
|
+
if verbosity > 2:
|
|
141
|
+
print(f" Ignoring variable '{name}'")
|
|
134
142
|
return False
|
|
135
143
|
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
if verbosity > 2:
|
|
145
|
+
print(f" Reading variable '{name}'")
|
|
146
|
+
if name in ["time", "wind_turbine"] and _read_multi_dimensional_coordinate(
|
|
147
|
+
name, wio_data, coords
|
|
138
148
|
):
|
|
139
149
|
return True
|
|
140
150
|
|
|
@@ -145,8 +155,8 @@ def read_wind_resource_field(name, wio_data, coords, fields, dims):
|
|
|
145
155
|
"y",
|
|
146
156
|
"height",
|
|
147
157
|
] and (
|
|
148
|
-
_read_multi_dimensional_coordinate(name, wio_data, coords
|
|
149
|
-
or _read_multi_dimensional_data(name, wio_data,
|
|
158
|
+
_read_multi_dimensional_coordinate(name, wio_data, coords)
|
|
159
|
+
or _read_multi_dimensional_data(name, wio_data, fields, dims)
|
|
150
160
|
):
|
|
151
161
|
return True
|
|
152
162
|
|
|
@@ -156,8 +166,8 @@ def read_wind_resource_field(name, wio_data, coords, fields, dims):
|
|
|
156
166
|
"turbulence_intensity",
|
|
157
167
|
"LMO",
|
|
158
168
|
"z0",
|
|
159
|
-
"
|
|
160
|
-
] and _read_multi_dimensional_data(name, wio_data,
|
|
169
|
+
"reference_height",
|
|
170
|
+
] and _read_multi_dimensional_data(name, wio_data, fields, dims):
|
|
161
171
|
return True
|
|
162
172
|
|
|
163
173
|
else:
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from foxes.utils import Dict
|
|
5
|
+
import foxes.variables as FV
|
|
6
|
+
import foxes.constants as FC
|
|
7
|
+
|
|
8
|
+
def _read_turbine_outputs(wio_outs, odir, out_dicts, verbosity):
|
|
9
|
+
""" Reads the turbine outputs request """
|
|
10
|
+
if "turbine_outputs" in wio_outs and wio_outs["turbine_outputs"].get("report", True):
|
|
11
|
+
turbine_outputs = Dict(wio_outs["turbine_outputs"], name="turbine_outputs")
|
|
12
|
+
turbine_nc_filename = turbine_outputs.pop("turbine_nc_filename", "turbine_outputs.nc")
|
|
13
|
+
output_variables = turbine_outputs["output_variables"]
|
|
14
|
+
if verbosity > 2:
|
|
15
|
+
print(" Reading turbine_outputs")
|
|
16
|
+
print(" File name:", turbine_nc_filename)
|
|
17
|
+
print(" output_variables:", output_variables)
|
|
18
|
+
|
|
19
|
+
vmap = Dict(
|
|
20
|
+
power=FV.P,
|
|
21
|
+
rotor_effective_velocity=FV.REWS,
|
|
22
|
+
)
|
|
23
|
+
ivmap = {d: k for k, d in vmap.items()}
|
|
24
|
+
ivmap.update({
|
|
25
|
+
FC.STATE: "time",
|
|
26
|
+
FC.TURBINE: "turbine",
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
out_dicts.append(Dict({
|
|
30
|
+
"output_type": "StateTurbineTable",
|
|
31
|
+
"farm_results": True,
|
|
32
|
+
"algo": False,
|
|
33
|
+
"run_func": "get_dataset",
|
|
34
|
+
"run_kwargs": dict(
|
|
35
|
+
variables=[vmap[v] for v in output_variables],
|
|
36
|
+
name_map=ivmap,
|
|
37
|
+
to_file=odir/turbine_nc_filename,
|
|
38
|
+
verbosity=verbosity,
|
|
39
|
+
),
|
|
40
|
+
"output_yaml_update": {
|
|
41
|
+
"power_table": f"include {turbine_nc_filename}",
|
|
42
|
+
},
|
|
43
|
+
}, name = "turbine_outputs"))
|
|
44
|
+
|
|
45
|
+
def _read_flow_field(wio_outs, odir, out_dicts, verbosity):
|
|
46
|
+
""" Reads the flow field request """
|
|
47
|
+
if "flow_field" in wio_outs and wio_outs["flow_field"].get("report", True):
|
|
48
|
+
flow_field = Dict(wio_outs["flow_field"], name="flow_field")
|
|
49
|
+
flow_nc_filename = flow_field.pop("flow_nc_filename", "flow_field.nc")
|
|
50
|
+
output_variables = flow_field.pop("output_variables")
|
|
51
|
+
z_planes = Dict(flow_field.pop("z_planes"), name="z_planes")
|
|
52
|
+
z_sampling = z_planes["z_sampling"]
|
|
53
|
+
xy_sampling = z_planes["xy_sampling"]
|
|
54
|
+
if verbosity > 2:
|
|
55
|
+
print(" Reading flow_field")
|
|
56
|
+
print(" File name :", flow_nc_filename)
|
|
57
|
+
print(" output_variables:", output_variables)
|
|
58
|
+
print(" z_sampling :", z_sampling)
|
|
59
|
+
print(" xy_sampling :", xy_sampling)
|
|
60
|
+
|
|
61
|
+
vmap = Dict(
|
|
62
|
+
wind_speed=FV.WS,
|
|
63
|
+
wind_direction=FV.WD,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
if xy_sampling == "default":
|
|
67
|
+
out_dicts.append(Dict({
|
|
68
|
+
"output_type": "SliceData",
|
|
69
|
+
"farm_results": True,
|
|
70
|
+
"algo": True,
|
|
71
|
+
"verbosity_delta": 3,
|
|
72
|
+
"run_func": "get_states_data_xy",
|
|
73
|
+
"run_kwargs": dict(
|
|
74
|
+
resolution=30.,
|
|
75
|
+
variables=[vmap[v] for v in output_variables],
|
|
76
|
+
z=None if z_sampling == "hub_height" else z_sampling,
|
|
77
|
+
to_file=odir/flow_nc_filename,
|
|
78
|
+
verbosity=verbosity,
|
|
79
|
+
),
|
|
80
|
+
"output_yaml_update": {
|
|
81
|
+
"flow_field": f"include {flow_nc_filename}",
|
|
82
|
+
},
|
|
83
|
+
}, name = "flow_field"))
|
|
84
|
+
else:
|
|
85
|
+
raise NotImplementedError(f"xy_sampling '{xy_sampling}' is not supported (yet)")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def read_outputs(wio_outs, algo_dict, verbosity):
|
|
89
|
+
"""
|
|
90
|
+
Reads the windio outputs
|
|
91
|
+
|
|
92
|
+
Parameters
|
|
93
|
+
----------
|
|
94
|
+
wio_outs: dict
|
|
95
|
+
The windio output data
|
|
96
|
+
algo_dict: dict
|
|
97
|
+
The algorithm dictionary
|
|
98
|
+
verbosity: int
|
|
99
|
+
The verbosity level, 0=silent
|
|
100
|
+
|
|
101
|
+
Returns
|
|
102
|
+
-------
|
|
103
|
+
out_dicts: list of dict
|
|
104
|
+
The output dictionaries
|
|
105
|
+
odir: pathlib.Path
|
|
106
|
+
Path to the output folder
|
|
107
|
+
|
|
108
|
+
:group: input.windio
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
out_dicts = []
|
|
112
|
+
odir = Path(wio_outs.pop("output_folder", "results"))
|
|
113
|
+
odir.mkdir(exist_ok=True, parents=True)
|
|
114
|
+
if verbosity > 2:
|
|
115
|
+
print(" Reading outputs")
|
|
116
|
+
print(" Output folder:", odir)
|
|
117
|
+
print(" Contents:", [k for k in wio_outs.keys()])
|
|
118
|
+
|
|
119
|
+
# read turbine_outputs:
|
|
120
|
+
_read_turbine_outputs(wio_outs, odir, out_dicts, verbosity)
|
|
121
|
+
|
|
122
|
+
# read flow field:
|
|
123
|
+
_read_flow_field(wio_outs, odir, out_dicts, verbosity)
|
|
124
|
+
|
|
125
|
+
return out_dicts, odir
|
foxes/input/windio/runner.py
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
import yaml
|
|
2
|
+
|
|
1
3
|
from foxes.core import Algorithm
|
|
2
4
|
from foxes.output import Output
|
|
3
5
|
|
|
4
6
|
|
|
7
|
+
def _write_yaml(data, fpath):
|
|
8
|
+
""" Write the data to yaml """
|
|
9
|
+
rmap = {
|
|
10
|
+
"include": "!include",
|
|
11
|
+
}
|
|
12
|
+
with open(fpath, "w") as file:
|
|
13
|
+
yaml.dump(data, file)
|
|
14
|
+
with open(fpath, "r") as f:
|
|
15
|
+
s = f.read()
|
|
16
|
+
with open(fpath, 'w') as f:
|
|
17
|
+
for k1, k2 in rmap.items():
|
|
18
|
+
s = s.replace(k1, k2)
|
|
19
|
+
f.write(s)
|
|
20
|
+
|
|
5
21
|
class WindioRunner:
|
|
6
22
|
"""
|
|
7
23
|
Runner for windio input
|
|
@@ -10,12 +26,20 @@ class WindioRunner:
|
|
|
10
26
|
----------
|
|
11
27
|
algo: foxes.core.Algorithm
|
|
12
28
|
The algorithm object
|
|
29
|
+
output_dir: pathlib.Path
|
|
30
|
+
Path to the output folder
|
|
13
31
|
output_dicts: list of dict
|
|
14
32
|
The output dictionaries
|
|
15
33
|
farm_results: xarray.Dataset
|
|
16
34
|
The farm results
|
|
17
35
|
output_results: list
|
|
18
36
|
The output results
|
|
37
|
+
wio_input_data: dict
|
|
38
|
+
The wind_energy_system windio input data
|
|
39
|
+
file_name_input_yaml: str
|
|
40
|
+
Name of the written input data file
|
|
41
|
+
file_name_output_yaml: str
|
|
42
|
+
Name of the written output data file
|
|
19
43
|
verbosity: int
|
|
20
44
|
The verbosity level, 0 = silent
|
|
21
45
|
|
|
@@ -23,7 +47,16 @@ class WindioRunner:
|
|
|
23
47
|
|
|
24
48
|
"""
|
|
25
49
|
|
|
26
|
-
def __init__(
|
|
50
|
+
def __init__(
|
|
51
|
+
self,
|
|
52
|
+
algo_dict,
|
|
53
|
+
output_dir=".",
|
|
54
|
+
output_dicts=[],
|
|
55
|
+
wio_input_data=None,
|
|
56
|
+
file_name_input_yaml="recorded_input.yaml",
|
|
57
|
+
file_name_output_yaml="recorded_output.yaml",
|
|
58
|
+
verbosity=1,
|
|
59
|
+
):
|
|
27
60
|
"""
|
|
28
61
|
Conbstructor
|
|
29
62
|
|
|
@@ -31,29 +64,48 @@ class WindioRunner:
|
|
|
31
64
|
----------
|
|
32
65
|
algo_dict: dict
|
|
33
66
|
The algorithm dictionary
|
|
67
|
+
output_dir: pathlib.Path
|
|
68
|
+
Path to the output folder
|
|
34
69
|
output_dicts: list of dict
|
|
35
70
|
The output dictionaries
|
|
71
|
+
wio_input_data: dict
|
|
72
|
+
The wind_energy_system windio input data
|
|
73
|
+
file_name_input_yaml: str
|
|
74
|
+
Name of the written input data file
|
|
75
|
+
file_name_output_yaml: str
|
|
76
|
+
Name of the written output data file
|
|
36
77
|
verbosity: int
|
|
37
78
|
The verbosity level, 0 = silent
|
|
38
79
|
|
|
39
80
|
"""
|
|
40
81
|
self.algo = algo_dict
|
|
82
|
+
self.output_dir = output_dir
|
|
41
83
|
self.output_dicts = output_dicts
|
|
84
|
+
self.wio_input_data = wio_input_data
|
|
85
|
+
self.file_name_input_yaml = file_name_input_yaml
|
|
86
|
+
self.file_name_output_yaml = file_name_output_yaml
|
|
42
87
|
self.verbosity = verbosity
|
|
43
88
|
self.farm_results = None
|
|
44
89
|
self.output_results = None
|
|
45
90
|
|
|
46
91
|
self.__initialized = False
|
|
47
|
-
|
|
48
|
-
|
|
92
|
+
|
|
93
|
+
self._output_yaml = {}
|
|
94
|
+
if wio_input_data is not None and len(wio_input_data):
|
|
95
|
+
fpath = output_dir/file_name_input_yaml
|
|
96
|
+
self.print(f"Writing file", fpath)
|
|
97
|
+
_write_yaml(wio_input_data, fpath)
|
|
98
|
+
self._output_yaml["wind_energy_system"] = f"include {file_name_input_yaml}"
|
|
99
|
+
|
|
100
|
+
def print(self, *args, level=1, **kwargs):
|
|
49
101
|
"""Print based on verbosity"""
|
|
50
|
-
if self.verbosity
|
|
102
|
+
if self.verbosity >= level:
|
|
51
103
|
print(*args, **kwargs)
|
|
52
104
|
|
|
53
105
|
def initialize(self):
|
|
54
106
|
"""Initializes the runner"""
|
|
55
107
|
if isinstance(self.algo, dict):
|
|
56
|
-
self.print(f"Creating algorithm '{self.algo['algo_type']}'")
|
|
108
|
+
self.print(f"Creating algorithm '{self.algo['algo_type']}'", level=2)
|
|
57
109
|
self.algo = Algorithm.new(**self.algo)
|
|
58
110
|
if not self.algo.initialized:
|
|
59
111
|
self.algo.initialize()
|
|
@@ -68,7 +120,7 @@ class WindioRunner:
|
|
|
68
120
|
"""Runs the farm calculation"""
|
|
69
121
|
if not self.__initialized:
|
|
70
122
|
self.initialize()
|
|
71
|
-
print("Running farm_calc")
|
|
123
|
+
self.print("Running farm_calc")
|
|
72
124
|
self.farm_results = self.algo.calc_farm()
|
|
73
125
|
|
|
74
126
|
def run_outputs(self):
|
|
@@ -79,10 +131,22 @@ class WindioRunner:
|
|
|
79
131
|
run_fname = odict.pop("run_func")
|
|
80
132
|
run_args = odict.pop("run_args", ())
|
|
81
133
|
run_kwargs = odict.pop("run_kwargs", {})
|
|
82
|
-
|
|
134
|
+
|
|
135
|
+
_odict = odict.copy()
|
|
136
|
+
if "output_yaml_update" in _odict:
|
|
137
|
+
self._output_yaml.update(_odict.pop("output_yaml_update"))
|
|
138
|
+
if _odict.pop("farm_results", False):
|
|
139
|
+
_odict["farm_results"] = self.farm_results
|
|
140
|
+
if _odict.pop("algo", False):
|
|
141
|
+
_odict["algo"] = self.algo
|
|
142
|
+
o = Output.new(**_odict)
|
|
83
143
|
f = getattr(o, run_fname)
|
|
84
144
|
self.output_results.append(f(*run_args, **run_kwargs))
|
|
85
|
-
|
|
145
|
+
|
|
146
|
+
fpath = self.output_dir/self.file_name_output_yaml
|
|
147
|
+
self.print(f"Writing file", fpath)
|
|
148
|
+
_write_yaml(self._output_yaml, fpath)
|
|
149
|
+
|
|
86
150
|
def run(self):
|
|
87
151
|
"""Runs all calculations"""
|
|
88
152
|
self.run_farm_calc()
|
foxes/input/windio/windio.py
CHANGED
|
@@ -17,25 +17,25 @@ from .runner import WindioRunner
|
|
|
17
17
|
def _read_site(wio, algo_dict, verbosity):
|
|
18
18
|
"""Reads the site information"""
|
|
19
19
|
wio_site = Dict(wio["site"], name="site")
|
|
20
|
-
if verbosity >
|
|
20
|
+
if verbosity > 1:
|
|
21
21
|
print("Reading site")
|
|
22
22
|
print(" Name:", wio_site.pop("name", None))
|
|
23
23
|
print(" Contents:", [k for k in wio_site.keys()])
|
|
24
24
|
|
|
25
25
|
# ignore boundaries:
|
|
26
|
-
if verbosity >
|
|
26
|
+
if verbosity > 2:
|
|
27
27
|
print(" Ignoring boundaries")
|
|
28
28
|
|
|
29
29
|
# read energy_resource:
|
|
30
30
|
energy_resource = Dict(wio_site["energy_resource"], name="energy_resource")
|
|
31
|
-
if verbosity >
|
|
31
|
+
if verbosity > 2:
|
|
32
32
|
print(" Reading energy_resource")
|
|
33
33
|
print(" Name:", energy_resource.pop("name", None))
|
|
34
34
|
print(" Contents:", [k for k in energy_resource.keys()])
|
|
35
35
|
|
|
36
36
|
# read wind_resource:
|
|
37
37
|
wind_resource = Dict(energy_resource["wind_resource"], name="wind_resource")
|
|
38
|
-
if verbosity >
|
|
38
|
+
if verbosity > 2:
|
|
39
39
|
print(" Reading wind_resource")
|
|
40
40
|
print(" Name:", wind_resource.pop("name", None))
|
|
41
41
|
print(" Contents:", [k for k in wind_resource.keys()])
|
|
@@ -45,16 +45,17 @@ def _read_site(wio, algo_dict, verbosity):
|
|
|
45
45
|
fields = Dict(name="fields")
|
|
46
46
|
dims = Dict(name="dims")
|
|
47
47
|
for n, d in wind_resource.items():
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
read_wind_resource_field(n, d, coords, fields, dims)
|
|
51
|
-
if verbosity > 1:
|
|
48
|
+
read_wind_resource_field(n, d, coords, fields, dims, verbosity)
|
|
49
|
+
if verbosity > 2:
|
|
52
50
|
print(" Coords:")
|
|
53
51
|
for c, d in coords.items():
|
|
54
52
|
print(f" {c}: Shape {d.shape}")
|
|
55
53
|
print(" Fields:")
|
|
56
54
|
for f, d in dims.items():
|
|
57
|
-
|
|
55
|
+
if len(d):
|
|
56
|
+
print(f" {f}: Dims {d}, shape {fields[f].shape}")
|
|
57
|
+
else:
|
|
58
|
+
print(f" {f} = {fields[f]}")
|
|
58
59
|
|
|
59
60
|
algo_dict["states"] = get_states(coords, fields, dims, verbosity)
|
|
60
61
|
|
|
@@ -62,7 +63,7 @@ def _read_site(wio, algo_dict, verbosity):
|
|
|
62
63
|
def _read_farm(wio, algo_dict, verbosity):
|
|
63
64
|
"""Reads the wind farm information"""
|
|
64
65
|
wio_farm = Dict(wio["wind_farm"], name="wind_farm")
|
|
65
|
-
if verbosity >
|
|
66
|
+
if verbosity > 1:
|
|
66
67
|
print("Reading wind farm")
|
|
67
68
|
print(" Name:", wio_farm.pop("name", None))
|
|
68
69
|
print(" Contents:", [k for k in wio_farm.keys()])
|
|
@@ -82,7 +83,7 @@ def _read_farm(wio, algo_dict, verbosity):
|
|
|
82
83
|
|
|
83
84
|
# read layouts:
|
|
84
85
|
layouts = Dict(wio_farm["layouts"], name="layouts")
|
|
85
|
-
if verbosity >
|
|
86
|
+
if verbosity > 2:
|
|
86
87
|
print(" Reading layouts")
|
|
87
88
|
print(" Contents:", [k for k in layouts.keys()])
|
|
88
89
|
for lname, ldict in layouts.items():
|
|
@@ -123,7 +124,7 @@ def read_windio(windio_yaml, verbosity=1):
|
|
|
123
124
|
yml_utils = import_module("windIO.utils.yml_utils", hint="pip install windio")
|
|
124
125
|
wio = yml_utils.load_yaml(wio_file)
|
|
125
126
|
|
|
126
|
-
if verbosity >
|
|
127
|
+
if verbosity > 1:
|
|
127
128
|
print(" Name:", wio.pop("name", None))
|
|
128
129
|
print(" Contents:", [k for k in wio.keys()])
|
|
129
130
|
|
|
@@ -132,20 +133,27 @@ def read_windio(windio_yaml, verbosity=1):
|
|
|
132
133
|
mbook=ModelBook(),
|
|
133
134
|
farm=WindFarm(),
|
|
134
135
|
wake_models=[],
|
|
135
|
-
verbosity=verbosity
|
|
136
|
+
verbosity=verbosity-3,
|
|
136
137
|
)
|
|
137
138
|
|
|
138
139
|
_read_site(wio, algo_dict, verbosity)
|
|
139
140
|
_read_farm(wio, algo_dict, verbosity)
|
|
140
|
-
|
|
141
|
+
|
|
142
|
+
out_dicts, odir = read_attributes(
|
|
141
143
|
wio,
|
|
142
144
|
algo_dict,
|
|
143
145
|
verbosity,
|
|
144
146
|
)
|
|
145
147
|
|
|
146
|
-
if verbosity >
|
|
148
|
+
if verbosity > 1:
|
|
147
149
|
print("Creating windio runner")
|
|
148
|
-
runner = WindioRunner(
|
|
150
|
+
runner = WindioRunner(
|
|
151
|
+
algo_dict,
|
|
152
|
+
output_dir=odir,
|
|
153
|
+
output_dicts=out_dicts,
|
|
154
|
+
wio_input_data=wio,
|
|
155
|
+
verbosity=verbosity
|
|
156
|
+
)
|
|
149
157
|
|
|
150
158
|
return runner
|
|
151
159
|
|
foxes/output/__init__.py
CHANGED
|
@@ -14,6 +14,7 @@ from .animation import Animator
|
|
|
14
14
|
from .calc_points import PointCalculator
|
|
15
15
|
from .slice_data import SliceData
|
|
16
16
|
from .rotor_point_plots import RotorPointPlot
|
|
17
|
+
from .state_turbine_table import StateTurbineTable
|
|
17
18
|
|
|
18
19
|
from .flow_plots_2d import FlowPlots2D, SeqFlowAnimationPlugin
|
|
19
20
|
from . import grids
|
foxes/output/slice_data.py
CHANGED
|
@@ -20,12 +20,21 @@ class SliceData(Output):
|
|
|
20
20
|
The farm results
|
|
21
21
|
runner: foxes.utils.runners.Runner, optional
|
|
22
22
|
The runner
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
verbosity_delta: int
|
|
24
|
+
Verbosity threshold for printing calculation info
|
|
25
|
+
|
|
26
|
+
:group: output
|
|
25
27
|
|
|
26
28
|
"""
|
|
27
29
|
|
|
28
|
-
def __init__(
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
algo,
|
|
33
|
+
farm_results,
|
|
34
|
+
runner=None,
|
|
35
|
+
verbosity_delta=1,
|
|
36
|
+
**kwargs,
|
|
37
|
+
):
|
|
29
38
|
"""
|
|
30
39
|
Constructor.
|
|
31
40
|
|
|
@@ -37,6 +46,8 @@ class SliceData(Output):
|
|
|
37
46
|
The farm results
|
|
38
47
|
runner: foxes.utils.runners.Runner, optional
|
|
39
48
|
The runner
|
|
49
|
+
verbosity_delta: int
|
|
50
|
+
Verbosity threshold for printing calculation info
|
|
40
51
|
kwargs: dict, optional
|
|
41
52
|
Additional parameters for the base class
|
|
42
53
|
|
|
@@ -45,6 +56,7 @@ class SliceData(Output):
|
|
|
45
56
|
self.algo = algo
|
|
46
57
|
self.fres = farm_results
|
|
47
58
|
self.runner = runner
|
|
59
|
+
self.verbosity_delta = verbosity_delta
|
|
48
60
|
|
|
49
61
|
def _data_mod(
|
|
50
62
|
self,
|
|
@@ -134,7 +146,7 @@ class SliceData(Output):
|
|
|
134
146
|
g_pts=g_pts,
|
|
135
147
|
sel={FC.STATE: states_sel} if states_sel is not None else None,
|
|
136
148
|
isel={FC.STATE: states_isel} if states_isel is not None else None,
|
|
137
|
-
verbosity=verbosity,
|
|
149
|
+
verbosity=verbosity-self.verbosity_delta,
|
|
138
150
|
**kwargs,
|
|
139
151
|
)
|
|
140
152
|
states = point_results[FC.STATE].to_numpy()
|
|
@@ -282,7 +294,16 @@ class SliceData(Output):
|
|
|
282
294
|
|
|
283
295
|
"""
|
|
284
296
|
gdata = grids.get_grid_xy(
|
|
285
|
-
self.fres,
|
|
297
|
+
self.fres,
|
|
298
|
+
resolution,
|
|
299
|
+
xmin,
|
|
300
|
+
ymin,
|
|
301
|
+
xmax,
|
|
302
|
+
ymax,
|
|
303
|
+
z,
|
|
304
|
+
xspace,
|
|
305
|
+
yspace,
|
|
306
|
+
verbosity-self.verbosity_delta,
|
|
286
307
|
)
|
|
287
308
|
|
|
288
309
|
data = self._calc_mean_data(
|
|
@@ -424,7 +445,7 @@ class SliceData(Output):
|
|
|
424
445
|
y,
|
|
425
446
|
xspace,
|
|
426
447
|
zspace,
|
|
427
|
-
verbosity,
|
|
448
|
+
verbosity-self.verbosity_delta,
|
|
428
449
|
)
|
|
429
450
|
gdatb = (gdata[0], gdata[2], gdata[1], gdata[3])
|
|
430
451
|
|
|
@@ -567,7 +588,7 @@ class SliceData(Output):
|
|
|
567
588
|
x,
|
|
568
589
|
yspace,
|
|
569
590
|
zspace,
|
|
570
|
-
verbosity,
|
|
591
|
+
verbosity-self.verbosity_delta,
|
|
571
592
|
)
|
|
572
593
|
gdatb = (gdata[1], gdata[2], gdata[0], gdata[3])
|
|
573
594
|
|
|
@@ -632,7 +653,7 @@ class SliceData(Output):
|
|
|
632
653
|
algo=self.algo,
|
|
633
654
|
farm_results=self.fres,
|
|
634
655
|
g_pts=g_pts,
|
|
635
|
-
verbosity=verbosity,
|
|
656
|
+
verbosity=verbosity-self.verbosity_delta,
|
|
636
657
|
**kwargs,
|
|
637
658
|
)
|
|
638
659
|
states = point_results[FC.STATE].to_numpy()
|
|
@@ -773,7 +794,16 @@ class SliceData(Output):
|
|
|
773
794
|
|
|
774
795
|
"""
|
|
775
796
|
gdata = grids.get_grid_xy(
|
|
776
|
-
self.fres,
|
|
797
|
+
self.fres,
|
|
798
|
+
resolution,
|
|
799
|
+
xmin,
|
|
800
|
+
ymin,
|
|
801
|
+
xmax,
|
|
802
|
+
ymax,
|
|
803
|
+
z,
|
|
804
|
+
xspace,
|
|
805
|
+
yspace,
|
|
806
|
+
verbosity-self.verbosity_delta,
|
|
777
807
|
)
|
|
778
808
|
|
|
779
809
|
data = self._calc_states_data(
|
|
@@ -911,7 +941,7 @@ class SliceData(Output):
|
|
|
911
941
|
y,
|
|
912
942
|
xspace,
|
|
913
943
|
zspace,
|
|
914
|
-
verbosity,
|
|
944
|
+
verbosity-self.verbosity_delta,
|
|
915
945
|
)
|
|
916
946
|
gdatb = (gdata[0], gdata[2], gdata[1], gdata[3])
|
|
917
947
|
|
|
@@ -1050,7 +1080,7 @@ class SliceData(Output):
|
|
|
1050
1080
|
x,
|
|
1051
1081
|
yspace,
|
|
1052
1082
|
zspace,
|
|
1053
|
-
verbosity,
|
|
1083
|
+
verbosity-self.verbosity_delta,
|
|
1054
1084
|
)
|
|
1055
1085
|
gdatb = (gdata[1], gdata[2], gdata[0], gdata[3])
|
|
1056
1086
|
|