-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raise informative errors if v3 input files passed in (#829)
* Check floris input file for v3 fields. * turbine checks for v3. * convert to v4 compatibility to avoid v3 deprecation errors. * Add utility for converting floris input files from v3 to v4. * Ruff and isort. * absolute power copied in from nrel_5MW. * Explain user needs to update their multidim csv file. * Errors/printouts for attempting to convert multidimensional turbines.
- Loading branch information
Showing
5 changed files
with
283 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
import yaml | ||
|
||
from floris.utilities import load_yaml | ||
|
||
|
||
""" | ||
This script is intended to be called with an argument and converts a floris input | ||
yaml file specified for FLORIS v3 to one specified for FLORIS v4. | ||
Usage: | ||
python convert_floris_input_v3_to_v4.py <path/to/floris_input>.yaml | ||
The resulting floris input file is placed in the same directory as the original yaml, | ||
and is appended _v4. | ||
""" | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
raise Exception( | ||
"Usage: python convert_floris_input_v3_to_v4.py <path/to/floris_input>.yaml" | ||
) | ||
|
||
input_yaml = sys.argv[1] | ||
|
||
# Handling the path and new filename | ||
input_path = Path(input_yaml) | ||
split_input = input_path.parts | ||
[filename_v3, extension] = split_input[-1].split(".") | ||
filename_v4 = filename_v3 + "_v4" | ||
split_output = list(split_input[:-1]) + [filename_v4+"."+extension] | ||
output_path = Path(*split_output) | ||
|
||
# Load existing v3 model | ||
v3_floris_input_dict = load_yaml(input_yaml) | ||
v4_floris_input_dict = v3_floris_input_dict.copy() | ||
|
||
# Change turbulence_intensity field to turbulence_intensities as list | ||
if "turbulence_intensities" in v3_floris_input_dict["flow_field"]: | ||
if "turbulence_intensity" in v3_floris_input_dict["flow_field"]: | ||
del v4_floris_input_dict["flow_field"]["turbulence_intensity"] | ||
elif "turbulence_intensity" in v3_floris_input_dict["flow_field"]: | ||
v4_floris_input_dict["flow_field"]["turbulence_intensities"] = ( | ||
[v3_floris_input_dict["flow_field"]["turbulence_intensity"]] | ||
) | ||
del v4_floris_input_dict["flow_field"]["turbulence_intensity"] | ||
|
||
# Change multidim_cp_ct velocity model to gauss | ||
if v3_floris_input_dict["wake"]["model_strings"]["velocity_model"] == "multidim_cp_ct": | ||
print( | ||
"multidim_cp_ct velocity model specified. Changing to gauss, " | ||
+ "but note that other velocity models are also compatible with multidimensional " | ||
+ "turbines in FLORIS v4. " | ||
+ "You will also need to convert your multidimensional turbine yaml files and their " | ||
+ "corresponding power/thrust csv files to be compatible with FLORIS v4 and to reflect " | ||
+ " the absolute power curve, rather than the power coefficient curve." | ||
) | ||
v4_floris_input_dict["wake"]["model_strings"]["velocity_model"] = "gauss" | ||
|
||
yaml.dump( | ||
v4_floris_input_dict, | ||
open(output_path, "w"), | ||
sort_keys=False | ||
) | ||
|
||
print(output_path, "created.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.