WTG Object ServiceΒΆ

The ObjWtgService is giving access to wind turbine generator objects. To make a new wtg object, you can use the ObjectService. Then getting the properties of the wtg with the ObjWtgService.GetWtgObject. These properties can be manipulated and then send back to windPRO with ObjWtgService.SetWtgObject. Adding a path with a wtg file is enough to do a basic calculation. More advanced manipulation is not possible at the moment. Find below a working example that can be run on the test project New Salem.

import windproapi.windproapi
import time
import os
from windproapi.utils import get_windpro_sample_path
from windproapi import WindProApi
from windproapi import nan_to_skipvalue

# Opening windPRO
_windproapi = WindProApi()
working_dir = os.path.join(get_windpro_sample_path('3.6'), 'New Salem\\3.6')
project_path = os.path.join(working_dir, 'New Salem.w36p')

_windproapi.start_windpro_random_port()

# Services
obj_wtg_service = _windproapi.get_service('ObjWtgService')
project_service = _windproapi.get_service('ProjectService')
objects_service = _windproapi.get_service('ObjectsService')

# Loading New Salem project
project_service.LoadFromFile(filename=project_path)

# Getting wind turbine generators already present
objs = objects_service.GetObjects(apiObjType='NewWTG')
wtg_obj = obj_wtg_service.GetWtgObject(objs[0].Handle)
print(wtg_obj)

# Making a new object
new_obj = objects_service.AddObject(apiObjType='NewWTG',
                                    lat=wtg_obj.Lat + 0.03,
                                    lng=wtg_obj.Lng + 0.03,
                                    userDesc='New WTG obj')
wtgObj = obj_wtg_service.GetWtgObject(new_obj.Handle)
wtgObj.UserLabel = 'New WTG obj'

# Adding file name
# This file is read when calculation are done
path_to_WTG = os.path.join(os.path.dirname(__file__), '../data/SIEMENS SWT-2.3_test.wtg')
wtgObj.Filename = path_to_WTG
# Hub height needs to be given explicitely
wtgObj.Hubheight = 92.6
# Needed to handle None values when communicating with zeep
nan_to_skipvalue(wtgObj)
# Set everything back into the wtg object
obj_wtg_service.SetWtgObject(wtgObj)