Listing, Retrieving, and Filtering¶
We assume that you have generated a SDK for the WindTurbine model and have a client ready to go.
from wind_turbine import WindTurbineClient
pygen = WindTurbineClient.from_toml("config.toml")
Listing Instances¶
Lets list the available wind turbines:
turbines = pygen.wind_turbine.list()
turbines
| space | external_id | capacity | name | blades | datasheets | nacelle | rotor | windfarm | data_record | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | sp_wind | hornsea_1_mill_3 | 7.0 | hornsea_1_mill_3 | [hornsea_1_mill_3_blade_A, hornsea_1_mill_3_bl... | [windmill_schematics] | hornsea_1_mill_3_nacelle | hornsea_1_mill_3_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 1 | sp_wind | hornsea_1_mill_2 | 7.0 | hornsea_1_mill_2 | [hornsea_1_mill_2_blade_B, hornsea_1_mill_2_bl... | [windmill_schematics] | hornsea_1_mill_2_nacelle | hornsea_1_mill_2_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 2 | sp_wind | hornsea_1_mill_1 | 7.0 | hornsea_1_mill_1 | [hornsea_1_mill_1_blade_A, hornsea_1_mill_1_bl... | [windmill_schematics] | hornsea_1_mill_1_nacelle | hornsea_1_mill_1_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 3 | sp_wind | hornsea_1_mill_4 | 7.0 | hornsea_1_mill_4 | [hornsea_1_mill_4_blade_C, hornsea_1_mill_4_bl... | [windmill_schematics] | hornsea_1_mill_4_nacelle | hornsea_1_mill_4_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 4 | sp_wind | hornsea_1_mill_5 | 7.0 | hornsea_1_mill_5 | [hornsea_1_mill_5_blade_B, hornsea_1_mill_5_bl... | [windmill_schematics] | hornsea_1_mill_5_nacelle | hornsea_1_mill_5_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
turbines[0]
| value | |
|---|---|
| space | sp_wind |
| external_id | hornsea_1_mill_3 |
| data_record | {'version': 4, 'last_updated_time': 2024-11-16... |
| node_type | None |
| capacity | 7.0 |
| description | None |
| name | hornsea_1_mill_3 |
| blades | [hornsea_1_mill_3_blade_A, hornsea_1_mill_3_bl... |
| datasheets | [windmill_schematics] |
| metmast | None |
| nacelle | hornsea_1_mill_3_nacelle |
| power_curve | None |
| rotor | hornsea_1_mill_3_rotor |
| windfarm | Hornsea 1 |
Notice that the metmast is None for all the turbines. This is because in the model the connection between trubine and metmast is modeled as an edge. We can include the edge id
by setting the parameter retrieve_connections="identifier.
turbines = pygen.wind_turbine.list(retrieve_connections="identifier", limit=2)
turbines
| space | external_id | capacity | name | blades | datasheets | metmast | nacelle | rotor | windfarm | data_record | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | sp_wind | hornsea_1_mill_3 | 7.0 | hornsea_1_mill_3 | [hornsea_1_mill_3_blade_A, hornsea_1_mill_3_bl... | [windmill_schematics] | [{'space': 'sp_wind', 'external_id': 'turbine3... | hornsea_1_mill_3_nacelle | hornsea_1_mill_3_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 1 | sp_wind | hornsea_1_mill_2 | 7.0 | hornsea_1_mill_2 | [hornsea_1_mill_2_blade_B, hornsea_1_mill_2_bl... | [windmill_schematics] | [{'space': 'sp_wind', 'external_id': 'turbine2... | hornsea_1_mill_2_nacelle | hornsea_1_mill_2_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
turbines[0].metmast[0]
| value | |
|---|---|
| space | sp_wind |
| external_id | turbine3_to_utsira |
| edge_type | {'space': 'sp_pygen_power_enterprise', 'extern... |
| start_node | {'space': 'sp_wind', 'external_id': 'hornsea_1... |
| end_node | {'space': 'sp_wind', 'external_id': 'utsira_st... |
| data_record | {'version': 1, 'last_updated_time': 2024-11-16... |
| distance | 700.0 |
Now we include the edge between the turbine and the metmast.
We can also get the full objects of one connection from turbines by setting the retrieve_connnections="full"
turbines = pygen.wind_turbine.list(retrieve_connections="full")
turbines
| space | external_id | capacity | name | blades | datasheets | metmast | nacelle | rotor | windfarm | data_record | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | sp_wind | hornsea_1_mill_3 | 7.0 | hornsea_1_mill_3 | [{'space': 'sp_wind', 'external_id': 'hornsea_... | [{'space': 'sp_wind', 'external_id': 'windmill... | [{'space': 'sp_wind', 'external_id': 'turbine3... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 1 | sp_wind | hornsea_1_mill_2 | 7.0 | hornsea_1_mill_2 | [{'space': 'sp_wind', 'external_id': 'hornsea_... | [{'space': 'sp_wind', 'external_id': 'windmill... | [{'space': 'sp_wind', 'external_id': 'turbine2... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 2 | sp_wind | hornsea_1_mill_1 | 7.0 | hornsea_1_mill_1 | [{'space': 'sp_wind', 'external_id': 'hornsea_... | [{'space': 'sp_wind', 'external_id': 'windmill... | [{'space': 'sp_wind', 'external_id': 'turbine1... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 3 | sp_wind | hornsea_1_mill_4 | 7.0 | hornsea_1_mill_4 | [{'space': 'sp_wind', 'external_id': 'hornsea_... | [{'space': 'sp_wind', 'external_id': 'windmill... | [{'space': 'sp_wind', 'external_id': 'turbine4... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 4 | sp_wind | hornsea_1_mill_5 | 7.0 | hornsea_1_mill_5 | [{'space': 'sp_wind', 'external_id': 'hornsea_... | [{'space': 'sp_wind', 'external_id': 'windmill... | [{'space': 'sp_wind', 'external_id': 'turbine5... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
We can do a quick inspect the retrieved blades, nacelle and so on
turbines.blades
| space | external_id | is_damaged | name | data_record | |
|---|---|---|---|---|---|
| 0 | sp_wind | hornsea_1_mill_3_blade_A | False | A | {'version': 1, 'last_updated_time': 2024-11-16... |
| 1 | sp_wind | hornsea_1_mill_3_blade_B | False | B | {'version': 1, 'last_updated_time': 2024-11-16... |
| 2 | sp_wind | hornsea_1_mill_3_blade_C | False | C | {'version': 1, 'last_updated_time': 2024-11-16... |
| 3 | sp_wind | hornsea_1_mill_2_blade_B | True | B | {'version': 1, 'last_updated_time': 2024-11-16... |
| 4 | sp_wind | hornsea_1_mill_2_blade_C | False | C | {'version': 1, 'last_updated_time': 2024-11-16... |
| 5 | sp_wind | hornsea_1_mill_2_blade_A | False | A | {'version': 1, 'last_updated_time': 2024-11-16... |
| 6 | sp_wind | hornsea_1_mill_1_blade_A | True | A | {'version': 1, 'last_updated_time': 2024-11-16... |
| 7 | sp_wind | hornsea_1_mill_1_blade_B | False | B | {'version': 1, 'last_updated_time': 2024-11-16... |
| 8 | sp_wind | hornsea_1_mill_1_blade_C | False | C | {'version': 1, 'last_updated_time': 2024-11-16... |
| 9 | sp_wind | hornsea_1_mill_4_blade_C | True | C | {'version': 1, 'last_updated_time': 2024-11-16... |
| 10 | sp_wind | hornsea_1_mill_4_blade_A | False | A | {'version': 1, 'last_updated_time': 2024-11-16... |
| 11 | sp_wind | hornsea_1_mill_4_blade_B | False | B | {'version': 1, 'last_updated_time': 2024-11-16... |
| 12 | sp_wind | hornsea_1_mill_5_blade_B | False | B | {'version': 1, 'last_updated_time': 2024-11-16... |
| 13 | sp_wind | hornsea_1_mill_5_blade_A | False | A | {'version': 1, 'last_updated_time': 2024-11-16... |
| 14 | sp_wind | hornsea_1_mill_5_blade_C | False | C | {'version': 1, 'last_updated_time': 2024-11-16... |
turbines.nacelle
| space | external_id | acc_from_back_side_x | acc_from_back_side_y | acc_from_back_side_z | gearbox | generator | high_speed_shaft | main_shaft | power_inverter | yaw_direction | yaw_error | data_record | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | sp_wind | hornsea_1_mill_3_nacelle | V52-WindTurbine.Acc1N | V52-WindTurbine.Acc2N | V52-WindTurbine.Acc3N | hornsea_1_mill_3_nacelle_gearbox | hornsea_1_mill_3_nacelle_generator | hornsea_1_mill_3_nacelle_highspeedshaft | hornsea_1_mill_3_nacelle_mainshaft | hornsea_1_mill_3_nacelle_powerinverter | V52-WindTurbine.yaw | V52-WindTurbine.YawErr | {'version': 1, 'last_updated_time': 2024-11-16... |
| 1 | sp_wind | hornsea_1_mill_2_nacelle | V52-WindTurbine.Acc1N | V52-WindTurbine.Acc2N | V52-WindTurbine.Acc3N | hornsea_1_mill_2_nacelle_gearbox | hornsea_1_mill_2_nacelle_generator | hornsea_1_mill_2_nacelle_highspeedshaft | hornsea_1_mill_2_nacelle_mainshaft | hornsea_1_mill_2_nacelle_powerinverter | V52-WindTurbine.yaw | V52-WindTurbine.YawErr | {'version': 1, 'last_updated_time': 2024-11-16... |
| 2 | sp_wind | hornsea_1_mill_1_nacelle | V52-WindTurbine.Acc1N | V52-WindTurbine.Acc2N | V52-WindTurbine.Acc3N | hornsea_1_mill_1_nacelle_gearbox | hornsea_1_mill_1_nacelle_generator | hornsea_1_mill_1_nacelle_highspeedshaft | hornsea_1_mill_1_nacelle_mainshaft | hornsea_1_mill_1_nacelle_powerinverter | V52-WindTurbine.yaw | V52-WindTurbine.YawErr | {'version': 1, 'last_updated_time': 2024-11-16... |
| 3 | sp_wind | hornsea_1_mill_4_nacelle | V52-WindTurbine.Acc1N | V52-WindTurbine.Acc2N | V52-WindTurbine.Acc3N | hornsea_1_mill_4_nacelle_gearbox | hornsea_1_mill_4_nacelle_generator | hornsea_1_mill_4_nacelle_highspeedshaft | hornsea_1_mill_4_nacelle_mainshaft | hornsea_1_mill_4_nacelle_powerinverter | V52-WindTurbine.yaw | V52-WindTurbine.YawErr | {'version': 1, 'last_updated_time': 2024-11-16... |
| 4 | sp_wind | hornsea_1_mill_5_nacelle | V52-WindTurbine.Acc1N | V52-WindTurbine.Acc2N | V52-WindTurbine.Acc3N | hornsea_1_mill_5_nacelle_gearbox | hornsea_1_mill_5_nacelle_generator | hornsea_1_mill_5_nacelle_highspeedshaft | hornsea_1_mill_5_nacelle_mainshaft | hornsea_1_mill_5_nacelle_powerinverter | V52-WindTurbine.yaw | V52-WindTurbine.YawErr | {'version': 1, 'last_updated_time': 2024-11-16... |
turbines.metmast
| space | external_id | edge_type | start_node | end_node | distance | data_record | |
|---|---|---|---|---|---|---|---|
| 0 | sp_wind | turbine3_to_utsira | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'utsira_st... | 700.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 1 | sp_wind | turbine3_to_hitra | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'hitra_sta... | 1100.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 2 | sp_wind | turbine3_to_smola | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'smola_sta... | 1500.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 3 | sp_wind | turbine2_to_utsira | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'utsira_st... | 1200.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 4 | sp_wind | turbine2_to_hitra | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'hitra_sta... | 900.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 5 | sp_wind | turbine2_to_smola | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'smola_sta... | 1300.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 6 | sp_wind | turbine1_to_utsira | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'utsira_st... | 1000.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 7 | sp_wind | turbine1_to_hitra | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'hitra_sta... | 800.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 8 | sp_wind | turbine1_to_smola | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'smola_sta... | 1200.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 9 | sp_wind | turbine4_to_utsira | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'utsira_st... | 1500.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 10 | sp_wind | turbine4_to_hitra | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'hitra_sta... | 1300.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 11 | sp_wind | turbine4_to_smola | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'smola_sta... | 1700.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 12 | sp_wind | turbine5_to_utsira | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'utsira_st... | 2100.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 13 | sp_wind | turbine5_to_hitra | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'hitra_sta... | 1700.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
| 14 | sp_wind | turbine5_to_smola | {'space': 'sp_pygen_power_enterprise', 'extern... | {'space': 'sp_wind', 'external_id': 'hornsea_1... | {'space': 'sp_wind', 'external_id': 'smola_sta... | 1900.0 | {'version': 1, 'last_updated_time': 2024-11-16... |
We can also inspect the individual turbines
turbine = turbines[0]
turbine
| value | |
|---|---|
| space | sp_wind |
| external_id | hornsea_1_mill_3 |
| data_record | {'version': 4, 'last_updated_time': 2024-11-16... |
| node_type | None |
| capacity | 7.0 |
| description | None |
| name | hornsea_1_mill_3 |
| blades | [{'space': 'sp_wind', 'external_id': 'hornsea_... |
| datasheets | [{'space': 'sp_wind', 'external_id': 'windmill... |
| metmast | [{'space': 'sp_wind', 'external_id': 'turbine3... |
| nacelle | {'space': 'sp_wind', 'external_id': 'hornsea_1... |
| power_curve | None |
| rotor | {'space': 'sp_wind', 'external_id': 'hornsea_1... |
| windfarm | Hornsea 1 |
turbine.blades[0]
| value | |
|---|---|
| space | sp_wind |
| external_id | hornsea_1_mill_3_blade_A |
| data_record | {'version': 1, 'last_updated_time': 2024-11-16... |
| node_type | None |
| is_damaged | False |
| name | A |
| sensor_positions | None |
Retrieving Instances¶
We can get one or more items by using the .retrieve() method
blade1 = pygen.blade.retrieve(external_id="hornsea_1_mill_3_blade_A")
blade1
| value | |
|---|---|
| space | sp_wind |
| external_id | hornsea_1_mill_3_blade_A |
| data_record | {'version': 1, 'last_updated_time': 2024-11-16... |
| node_type | None |
| is_damaged | False |
| name | A |
| sensor_positions | None |
Retrieving Subclasses¶
If you have an interface, for example, GeneratingUnit in our model, .retrieve have parameter to `retrieve as the subclass type
units = pygen.generating_unit.list()
units
| space | external_id | capacity | description | name | data_record | |
|---|---|---|---|---|---|---|
| 0 | sp_wind | solarpanel_pizarro | 4.0 | Solar Panel | The Pizarro Solar Panel | {'version': 6, 'last_updated_time': 2024-12-17... |
| 1 | sp_wind | solarpanel_witznitz | 9.0 | Solar Panel | The Witznitz Solar Panel | {'version': 6, 'last_updated_time': 2024-12-17... |
| 2 | sp_wind | hornsea_1_mill_3 | 7.0 | None | hornsea_1_mill_3 | {'version': 8, 'last_updated_time': 2024-12-17... |
| 3 | sp_wind | hornsea_1_mill_2 | 7.0 | None | hornsea_1_mill_2 | {'version': 8, 'last_updated_time': 2024-12-17... |
| 4 | sp_wind | hornsea_1_mill_1 | 7.0 | None | hornsea_1_mill_1 | {'version': 8, 'last_updated_time': 2024-12-17... |
| 5 | sp_wind | hornsea_1_mill_4 | 7.0 | None | hornsea_1_mill_4 | {'version': 8, 'last_updated_time': 2024-12-17... |
| 6 | sp_wind | hornsea_1_mill_5 | 7.0 | None | hornsea_1_mill_5 | {'version': 8, 'last_updated_time': 2024-12-17... |
units = pygen.generating_unit.retrieve(units.as_external_ids(), as_child_class=["SolarPanel", "WindTurbine"])
units
| space | external_id | capacity | description | name | efficiency | orientation | blades | datasheets | nacelle | rotor | windfarm | data_record | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | sp_wind | solarpanel_pizarro | 4.0 | Solar Panel | The Pizarro Solar Panel | pizarro_efficiency | pizarro_orientation | NaN | NaN | NaN | NaN | NaN | {'version': 6, 'last_updated_time': 2024-12-17... |
| 1 | sp_wind | solarpanel_witznitz | 9.0 | Solar Panel | The Witznitz Solar Panel | witznitz_efficiency | witznitz_orientation | NaN | NaN | NaN | NaN | NaN | {'version': 6, 'last_updated_time': 2024-12-17... |
| 2 | sp_wind | hornsea_1_mill_3 | 7.0 | None | hornsea_1_mill_3 | NaN | NaN | [hornsea_1_mill_3_blade_A, hornsea_1_mill_3_bl... | [windmill_schematics] | hornsea_1_mill_3_nacelle | hornsea_1_mill_3_rotor | Hornsea 1 | {'version': 8, 'last_updated_time': 2024-12-17... |
| 3 | sp_wind | hornsea_1_mill_2 | 7.0 | None | hornsea_1_mill_2 | NaN | NaN | [hornsea_1_mill_2_blade_B, hornsea_1_mill_2_bl... | [windmill_schematics] | hornsea_1_mill_2_nacelle | hornsea_1_mill_2_rotor | Hornsea 1 | {'version': 8, 'last_updated_time': 2024-12-17... |
| 4 | sp_wind | hornsea_1_mill_1 | 7.0 | None | hornsea_1_mill_1 | NaN | NaN | [hornsea_1_mill_1_blade_A, hornsea_1_mill_1_bl... | [windmill_schematics] | hornsea_1_mill_1_nacelle | hornsea_1_mill_1_rotor | Hornsea 1 | {'version': 8, 'last_updated_time': 2024-12-17... |
| 5 | sp_wind | hornsea_1_mill_4 | 7.0 | None | hornsea_1_mill_4 | NaN | NaN | [hornsea_1_mill_4_blade_C, hornsea_1_mill_4_bl... | [windmill_schematics] | hornsea_1_mill_4_nacelle | hornsea_1_mill_4_rotor | Hornsea 1 | {'version': 8, 'last_updated_time': 2024-12-17... |
| 6 | sp_wind | hornsea_1_mill_5 | 7.0 | None | hornsea_1_mill_5 | NaN | NaN | [hornsea_1_mill_5_blade_B, hornsea_1_mill_5_bl... | [windmill_schematics] | hornsea_1_mill_5_nacelle | hornsea_1_mill_5_rotor | Hornsea 1 | {'version': 8, 'last_updated_time': 2024-12-17... |
type(units[0])
wind_turbine.data_classes._solar_panel.SolarPanel
type(units[3])
wind_turbine.data_classes._wind_turbine.WindTurbine
Inspect Data Records¶
We can investigate the data records by using the data_records property. Note the data records contains information about when the entry was made into CDF, the version of it and so on
units.data_records
| version | last_updated_time | created_time | deleted_time | |
|---|---|---|---|---|
| 0 | 6 | 2024-12-17 09:57:38.908000+00:00 | 2024-11-16 14:08:01.544000+00:00 | None |
| 1 | 6 | 2024-12-17 09:57:38.908000+00:00 | 2024-11-16 14:08:01.544000+00:00 | None |
| 2 | 8 | 2024-12-17 09:57:38.908000+00:00 | 2024-11-16 14:08:01.544000+00:00 | None |
| 3 | 8 | 2024-12-17 09:57:38.908000+00:00 | 2024-11-16 14:08:01.544000+00:00 | None |
| 4 | 8 | 2024-12-17 09:57:38.908000+00:00 | 2024-11-16 14:08:01.544000+00:00 | None |
| 5 | 8 | 2024-12-17 09:57:38.908000+00:00 | 2024-11-16 14:08:01.544000+00:00 | None |
| 6 | 8 | 2024-12-17 09:57:38.908000+00:00 | 2024-11-16 14:08:01.544000+00:00 | None |
Retrieving Connections¶
The retrieve method has the argument retrieve_connections you can use to include connections.
For example, you can retrieve the wind turbine hornsea_1_mill with nacelle, rotor, datasheets, metmast, and blades.
turbine = pygen.wind_turbine.retrieve("hornsea_1_mill_1", retrieve_connections="full")
turbine
| value | |
|---|---|
| space | sp_wind |
| external_id | hornsea_1_mill_1 |
| data_record | {'version': 8, 'last_updated_time': 2024-12-17... |
| node_type | None |
| capacity | 7.0 |
| description | None |
| name | hornsea_1_mill_1 |
| blades | [{'space': 'sp_wind', 'external_id': 'hornsea_... |
| datasheets | [{'space': 'sp_wind', 'external_id': 'windmill... |
| metmast | [{'space': 'sp_wind', 'external_id': 'turbine1... |
| nacelle | {'space': 'sp_wind', 'external_id': 'hornsea_1... |
| power_curve | None |
| rotor | {'space': 'sp_wind', 'external_id': 'hornsea_1... |
| windfarm | Hornsea 1 |
To dictionary and JSON¶
Note that all the data classes returned by the API is pydantic data classes. That means that methods such as .model_dump() and .model_dump_json() are readaliy available.
turbine = pygen.wind_turbine.retrieve("hornsea_1_mill_4")
turbine.model_dump()
{'space': 'sp_wind',
'external_id': 'hornsea_1_mill_4',
'data_record': {'version': 4,
'last_updated_time': datetime.datetime(2024, 11, 16, 14, 59, 42, 454000, tzinfo=TzInfo(UTC)),
'created_time': datetime.datetime(2024, 11, 16, 14, 8, 1, 544000, tzinfo=TzInfo(UTC)),
'deleted_time': None},
'node_type': None,
'capacity': 7.0,
'description': None,
'name': 'hornsea_1_mill_4',
'blades': ['hornsea_1_mill_4_blade_C',
'hornsea_1_mill_4_blade_A',
'hornsea_1_mill_4_blade_B'],
'datasheets': ['windmill_schematics'],
'metmast': ['utsira_station', 'hitra_station', 'smola_station'],
'nacelle': 'hornsea_1_mill_4_nacelle',
'power_curve': None,
'rotor': 'hornsea_1_mill_4_rotor',
'windfarm': 'Hornsea 1'}
Note that for simplicity there pygen wraps the model_dump with the method dump.
turbine.dump()
{'space': 'sp_wind',
'externalId': 'hornsea_1_mill_4',
'data_record': {'version': 4,
'last_updated_time': datetime.datetime(2024, 11, 16, 14, 59, 42, 454000, tzinfo=TzInfo(UTC)),
'created_time': datetime.datetime(2024, 11, 16, 14, 8, 1, 544000, tzinfo=TzInfo(UTC)),
'deleted_time': None},
'node_type': None,
'capacity': 7.0,
'description': None,
'name': 'hornsea_1_mill_4',
'blades': ['hornsea_1_mill_4_blade_C',
'hornsea_1_mill_4_blade_A',
'hornsea_1_mill_4_blade_B'],
'datasheets': ['windmill_schematics'],
'metmast': ['utsira_station', 'hitra_station', 'smola_station'],
'nacelle': 'hornsea_1_mill_4_nacelle',
'powerCurve': None,
'rotor': 'hornsea_1_mill_4_rotor',
'windfarm': 'Hornsea 1'}
turbine.model_dump_json()
'{"space":"sp_wind","external_id":"hornsea_1_mill_4","data_record":{"version":4,"last_updated_time":"2024-11-16T14:59:42.454000Z","created_time":"2024-11-16T14:08:01.544000Z","deleted_time":null},"node_type":null,"capacity":7.0,"description":null,"name":"hornsea_1_mill_4","blades":["hornsea_1_mill_4_blade_C","hornsea_1_mill_4_blade_A","hornsea_1_mill_4_blade_B"],"datasheets":["windmill_schematics"],"metmast":["utsira_station","hitra_station","smola_station"],"nacelle":"hornsea_1_mill_4_nacelle","power_curve":null,"rotor":"hornsea_1_mill_4_rotor","windfarm":"Hornsea 1"}'
Furhermore, note that properties such as space, version, last_updated_time are showing up when we call model_dump() and model_json_dump(). The reason is that, when we display an object in a Jupyter notebook, the data classes from pygen is set up to automatically call .to_pandas(). The .to_pandas() method skips the node properties by default to avoid cluttering the properties that are special to the node type. We can include them by setting the parameter include_instance_properties to True
turbine.to_pandas()
space sp_wind
external_id hornsea_1_mill_4
data_record {'version': 4, 'last_updated_time': 2024-11-16...
node_type None
capacity 7.0
description None
name hornsea_1_mill_4
blades [hornsea_1_mill_4_blade_C, hornsea_1_mill_4_bl...
datasheets [windmill_schematics]
metmast [utsira_station, hitra_station, smola_station]
nacelle hornsea_1_mill_4_nacelle
power_curve None
rotor hornsea_1_mill_4_rotor
windfarm Hornsea 1
dtype: object
Filtering Instances: List¶
pygen automatically generates filters for the list method based on the propery types of the fields in the views.
For example, if we want to find all turbines with capacity above 6.0 we can do it as follows
pygen.wind_turbine.list(min_capacity=6.0)
| space | external_id | capacity | name | blades | datasheets | nacelle | rotor | windfarm | data_record | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | sp_wind | hornsea_1_mill_3 | 7.0 | hornsea_1_mill_3 | [hornsea_1_mill_3_blade_A, hornsea_1_mill_3_bl... | [windmill_schematics] | hornsea_1_mill_3_nacelle | hornsea_1_mill_3_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 1 | sp_wind | hornsea_1_mill_2 | 7.0 | hornsea_1_mill_2 | [hornsea_1_mill_2_blade_B, hornsea_1_mill_2_bl... | [windmill_schematics] | hornsea_1_mill_2_nacelle | hornsea_1_mill_2_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 2 | sp_wind | hornsea_1_mill_1 | 7.0 | hornsea_1_mill_1 | [hornsea_1_mill_1_blade_A, hornsea_1_mill_1_bl... | [windmill_schematics] | hornsea_1_mill_1_nacelle | hornsea_1_mill_1_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 3 | sp_wind | hornsea_1_mill_4 | 7.0 | hornsea_1_mill_4 | [hornsea_1_mill_4_blade_C, hornsea_1_mill_4_bl... | [windmill_schematics] | hornsea_1_mill_4_nacelle | hornsea_1_mill_4_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 4 | sp_wind | hornsea_1_mill_5 | 7.0 | hornsea_1_mill_5 | [hornsea_1_mill_5_blade_B, hornsea_1_mill_5_bl... | [windmill_schematics] | hornsea_1_mill_5_nacelle | hornsea_1_mill_5_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
Or lets us find all turbines located at the windfarm Hornsea 1
pygen.wind_turbine.list(windfarm="Hornsea 1")
| space | external_id | capacity | name | blades | datasheets | nacelle | rotor | windfarm | data_record | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | sp_wind | hornsea_1_mill_3 | 7.0 | hornsea_1_mill_3 | [hornsea_1_mill_3_blade_A, hornsea_1_mill_3_bl... | [windmill_schematics] | hornsea_1_mill_3_nacelle | hornsea_1_mill_3_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 1 | sp_wind | hornsea_1_mill_2 | 7.0 | hornsea_1_mill_2 | [hornsea_1_mill_2_blade_B, hornsea_1_mill_2_bl... | [windmill_schematics] | hornsea_1_mill_2_nacelle | hornsea_1_mill_2_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 2 | sp_wind | hornsea_1_mill_1 | 7.0 | hornsea_1_mill_1 | [hornsea_1_mill_1_blade_A, hornsea_1_mill_1_bl... | [windmill_schematics] | hornsea_1_mill_1_nacelle | hornsea_1_mill_1_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 3 | sp_wind | hornsea_1_mill_4 | 7.0 | hornsea_1_mill_4 | [hornsea_1_mill_4_blade_C, hornsea_1_mill_4_bl... | [windmill_schematics] | hornsea_1_mill_4_nacelle | hornsea_1_mill_4_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
| 4 | sp_wind | hornsea_1_mill_5 | 7.0 | hornsea_1_mill_5 | [hornsea_1_mill_5_blade_B, hornsea_1_mill_5_bl... | [windmill_schematics] | hornsea_1_mill_5_nacelle | hornsea_1_mill_5_rotor | Hornsea 1 | {'version': 4, 'last_updated_time': 2024-11-16... |
The available filters depends on the data type of the properties in the data model.
Typical filtering for the different data types are:
- Text -> Equals, Prefix, and In filters
- Number -> Range filter
- Boolean -> Equals filter
- Date and Timestamp -> Range filter
- Direct relation -> Equals and In filters
Next section: Searching
