-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into move-data-schema-t…
…o-common
- Loading branch information
Showing
6 changed files
with
811 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ dependencies: | |
- numpy | ||
- pyyaml | ||
- pytest | ||
- pytest-subtests | ||
- xarray |
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 |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
EXTRAS = { | ||
"test": { | ||
'pytest', | ||
'pytest-subtests', | ||
'py_wake', | ||
'topfarm', | ||
}, | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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,123 @@ | ||
import numpy as np | ||
import numpy.testing as npt | ||
import pytest | ||
from windIO.utils.yml_utils import load_yaml, validate_yaml | ||
from windIO.utils import plant_examples_data_path, plant_schemas_path | ||
from test.plant.conftest import SampleInputs | ||
from jsonschema.exceptions import ValidationError | ||
|
||
|
||
def test_wind_farm_input(subtests): | ||
""" | ||
Test a complete wind_farm set of inputs, and ensure that | ||
optional properties can be excluded. | ||
""" | ||
with subtests.test("with valid config"): | ||
config = SampleInputs().wind_farm | ||
assert validate_yaml(config, plant_schemas_path + "wind_farm.yaml") is None | ||
|
||
with subtests.test("remove optional electrical_substations"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_substations"] | ||
assert validate_yaml(config, plant_schemas_path + "wind_farm.yaml") is None | ||
|
||
with subtests.test("remove optional electrical_collection_array"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_collection_array"] | ||
assert validate_yaml(config, plant_schemas_path + "wind_farm.yaml") is None | ||
|
||
|
||
def test_wind_farm_invalid_inputs_layouts(subtests): | ||
""" | ||
Test missing inputs for the wind_farm layouts property. | ||
""" | ||
with subtests.test("missing layouts"): | ||
config = SampleInputs().wind_farm | ||
del config["layouts"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
with subtests.test("missing layouts initial_layout"): | ||
config = SampleInputs().wind_farm | ||
del config["layouts"]["initial_layout"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
with subtests.test("missing layouts initial_layout coordinates"): | ||
config = SampleInputs().wind_farm | ||
del config["layouts"]["initial_layout"]["coordinates"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
|
||
def test_wind_farm_invalid_inputs_turbines(subtests): | ||
""" | ||
Test missing inputs for the wind_farm turbines property. | ||
""" | ||
with subtests.test("missing turbines"): | ||
config = SampleInputs().wind_farm | ||
del config["turbines"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
|
||
def test_wind_farm_invalid_inputs_electrical_substations(subtests): | ||
""" | ||
Test missing inputs for the wind_farm electrical_substation property. | ||
""" | ||
with subtests.test("missing electrical_substation"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_substations"][0]["electrical_substation"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
with subtests.test("missing electrical_substation coordinates"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_substations"][0]["electrical_substation"]["coordinates"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
with subtests.test("remove optional electrical_substation capacity"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_substations"][0]["electrical_substation"]["capacity"] | ||
assert validate_yaml(config, plant_schemas_path + "wind_farm.yaml") is None | ||
|
||
def test_wind_farm_invalid_inputs_electrical_collection_array(subtests): | ||
""" | ||
Test missing inputs for the wind_farm electrical_collection_array property. | ||
""" | ||
with subtests.test("missing electrical_collection_array edges"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_collection_array"]["edges"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
with subtests.test("missing electrical_collection_array cables"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_collection_array"]["cables"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
with subtests.test("missing electrical_collection_array cables cable_type"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_collection_array"]["cables"]["cable_type"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
with subtests.test("missing electrical_collection_array cables cross_section"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_collection_array"]["cables"]["cross_section"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
with subtests.test("missing electrical_collection_array cables capacity"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_collection_array"]["cables"]["capacity"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") | ||
|
||
with subtests.test("missing electrical_collection_array cables cost"): | ||
config = SampleInputs().wind_farm | ||
del config["electrical_collection_array"]["cables"]["cost"] | ||
with pytest.raises(ValidationError): | ||
validate_yaml(config, plant_schemas_path + "wind_farm.yaml") |
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 |
---|---|---|
@@ -1,39 +1,119 @@ | ||
input_format_version: 0 | ||
title: definition of the wind energy conversion system | ||
title: Definition of the wind energy conversion system | ||
description: A file used to define the built environment (and other non-tangible components like O&M) | ||
required: | ||
- name | ||
- layouts | ||
- turbines | ||
optional: | ||
- electrical_substations | ||
- electrical_collection_array | ||
- foundations | ||
- O_&_M | ||
additionalProperties: false | ||
|
||
# PROPERTIES | ||
properties: | ||
#~ | ||
name: | ||
description: Name of the wind farm | ||
type: string | ||
layouts: | ||
description: Position of wind turbines | ||
type: object | ||
required: | ||
- initial_layout | ||
additionalProperties: false | ||
properties: | ||
inital_layout: | ||
$ref: "#/definitions/layout" | ||
initial_layout: | ||
$ref: "#/definitions/initial_layout" | ||
|
||
turbines: | ||
description: Turbine models installed in the WES. | ||
description: Turbine models installed in the WES | ||
type: object | ||
$ref: "turbine.yaml#" | ||
#~ | ||
electrical_substations: | ||
description: Information about electrical substations | ||
type: array | ||
items: | ||
type: object | ||
required: | ||
- electrical_substation | ||
additionalProperties: false | ||
properties: | ||
electrical_substation: | ||
$ref: "#/definitions/electrical_substation" | ||
|
||
electrical_collection_array: | ||
title: Electrical collection array | ||
description: Definition of electrical collection array (cable layout) for wind farm. | ||
type: object | ||
required: | ||
- edges | ||
- cables | ||
additionalProperties: false | ||
properties: | ||
edges: | ||
title: Edges of cable layout | ||
description: List of edges (branches) in the cable layout [[from_node, to_node, cable_type], ...]. | ||
type: array | ||
cables: | ||
title: Cables | ||
description: List of the cables | ||
type: object | ||
required: | ||
- cable_type | ||
- cross_section | ||
- capacity | ||
- cost | ||
additionalProperties: false | ||
properties: | ||
cable_type: | ||
title: Cable type | ||
description: List of aviable cable types | ||
type: array | ||
units: mm2 | ||
cross_section: | ||
title: Cross section | ||
description: List of cables cross section | ||
type: array | ||
units: mm2 | ||
capacity: | ||
title: Cable capacity | ||
description: List of cable capacity | ||
type: array | ||
units: WindTurbine / Cable | ||
cost: | ||
title: Cable cost | ||
description: List of cables cost | ||
type: array | ||
units: euro/meter | ||
|
||
definitions: | ||
inital_layout: | ||
initial_layout: | ||
title: Wind turbine layout | ||
type: object | ||
required: | ||
- coordinates | ||
additionalProperties: false | ||
properties: | ||
coordinates: | ||
title: Wind turbine coordinate | ||
$ref: "common.yaml#/definitions/coordinates" | ||
|
||
|
||
electrical_substation: | ||
title: Electrical substation | ||
type: object | ||
required: | ||
- coordinates | ||
optional: | ||
- capacity | ||
additionalProperties: false | ||
properties: | ||
coordinates: | ||
title: Substation coordinates | ||
$ref: "common.yaml#/definitions/coordinates" | ||
capacity: | ||
title: Substation capacity | ||
description: Capacity of the electrical substation in megawatts | ||
type: number | ||
units: MW |