- Posts: 3
Retrieving hourly system power generated (kW) using PySSC
- colleenmccamy
- Topic Author
Less
More
06 Apr 2023 23:32 #12039
by colleenmccamy
Retrieving hourly system power generated (kW) using PySSC was created by colleenmccamy
Hello!
My team and I are using the PySAM and PySSC libraries to request WIND Toolkit Data inputs and run a simulation to return hourly energy and capacity factors for several coordinate pairs iteratively. Our WIND Toolkit Data input (.srw file) is in hourly time series. However, we run into the issue that we cannot retrieve these hourly parameters other than their annual averages.
Our goal is to retrieve the hourly system power generated (kw) for each hour since Jan 1 within a pandas dataframe. Are there example Python scripts/notebooks of how we could retrieve an this hourly system power generated (kw) and capacity factor with PySam using PySSC?
For some additional context here are some snippets of our code of creating the ssc objects and retrieving the average annual data.
import PySAM
from PySAM.PySSC import PySSC
ssc = PySSC()
lat_in = a provided latitude
lon_in = a provided longitude
## =====> ADDED TO READ DATA FROM Windtoolkit
# Resource inputs for SAM model: ## need to add b
wfd = ssc.data_create()
ssc.data_set_number(wfd, b'lat', lat_in)
ssc.data_set_number(wfd, b'lon', lon_in)
# Create SAM compliant object
data = ssc.data_create()
ssc.data_set_table(data, b'wind_resource_data', wfd)
ssc.data_free(wfd)
- Code from the SAM Code Generator -
# leaving this code out of this question to reduce code length
module = ssc.module_create(b'windpower')
ssc.module_exec_set_print( 0 );
if ssc.module_exec(module, data) == 0:
print ('windpower simulation error')
idx = 1
msg = ssc.module_log(module, 0)
while (msg != None):
print (' : ' + msg.decode("utf - 8"))
msg = ssc.module_log(module, idx)
idx = idx + 1
SystemExit( "Simulation Error" );
ssc.module_free(module)
module = ssc.module_create(b'grid')
ssc.module_exec_set_print( 0 );
if ssc.module_exec(module, data) == 0:
print ('grid simulation error')
idx = 1
msg = ssc.module_log(module, 0)
while (msg != None):
print (' : ' + msg.decode("utf - 8"))
msg = ssc.module_log(module, idx)
idx = idx + 1
SystemExit( "Simulation Error" );
ssc.module_free(module)
annual_energy = ssc.data_get_number(data, b'annual_energy');
print ('Annual AC energy in Year 1 = ', annual_energy)
capacity_factor = ssc.data_get_number(data, b'capacity_factor');
print ('Capacity factor in Year 1 = ', capacity_factor)
ssc.data_free(data);
My team and I are using the PySAM and PySSC libraries to request WIND Toolkit Data inputs and run a simulation to return hourly energy and capacity factors for several coordinate pairs iteratively. Our WIND Toolkit Data input (.srw file) is in hourly time series. However, we run into the issue that we cannot retrieve these hourly parameters other than their annual averages.
Our goal is to retrieve the hourly system power generated (kw) for each hour since Jan 1 within a pandas dataframe. Are there example Python scripts/notebooks of how we could retrieve an this hourly system power generated (kw) and capacity factor with PySam using PySSC?
For some additional context here are some snippets of our code of creating the ssc objects and retrieving the average annual data.
import PySAM
from PySAM.PySSC import PySSC
ssc = PySSC()
lat_in = a provided latitude
lon_in = a provided longitude
## =====> ADDED TO READ DATA FROM Windtoolkit
# Resource inputs for SAM model: ## need to add b
wfd = ssc.data_create()
ssc.data_set_number(wfd, b'lat', lat_in)
ssc.data_set_number(wfd, b'lon', lon_in)
# Create SAM compliant object
data = ssc.data_create()
ssc.data_set_table(data, b'wind_resource_data', wfd)
ssc.data_free(wfd)
- Code from the SAM Code Generator -
# leaving this code out of this question to reduce code length
module = ssc.module_create(b'windpower')
ssc.module_exec_set_print( 0 );
if ssc.module_exec(module, data) == 0:
print ('windpower simulation error')
idx = 1
msg = ssc.module_log(module, 0)
while (msg != None):
print (' : ' + msg.decode("utf - 8"))
msg = ssc.module_log(module, idx)
idx = idx + 1
SystemExit( "Simulation Error" );
ssc.module_free(module)
module = ssc.module_create(b'grid')
ssc.module_exec_set_print( 0 );
if ssc.module_exec(module, data) == 0:
print ('grid simulation error')
idx = 1
msg = ssc.module_log(module, 0)
while (msg != None):
print (' : ' + msg.decode("utf - 8"))
msg = ssc.module_log(module, idx)
idx = idx + 1
SystemExit( "Simulation Error" );
ssc.module_free(module)
annual_energy = ssc.data_get_number(data, b'annual_energy');
print ('Annual AC energy in Year 1 = ', annual_energy)
capacity_factor = ssc.data_get_number(data, b'capacity_factor');
print ('Capacity factor in Year 1 = ', capacity_factor)
ssc.data_free(data);
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5447
07 Apr 2023 16:57 - 07 Apr 2023 16:58 #12045
by pgilman
Replied by pgilman on topic Retrieving hourly system power generated (kW) using PySSC
Hi Colleen,
The 'gen' output variable stores the hourly ac output of the system. The following code should get that data for you:
hourly_energy = ssc.data_get_array(data, b'gen');
Best regards,
Paul.
The 'gen' output variable stores the hourly ac output of the system. The following code should get that data for you:
hourly_energy = ssc.data_get_array(data, b'gen');
Best regards,
Paul.
Last edit: 07 Apr 2023 16:58 by pgilman.
Please Log in or Create an account to join the conversation.
- colleenmccamy
- Topic Author
Less
More
- Posts: 3
11 Apr 2023 20:59 #12052
by colleenmccamy
Replied by colleenmccamy on topic Retrieving hourly system power generated (kW) using PySSC
Hi Paul,
Thank you for providing this information! It works great and we are able to move forward with collecting the timeseries data.
Best,
Colleen McCamy
Thank you for providing this information! It works great and we are able to move forward with collecting the timeseries data.
Best,
Colleen McCamy
Please Log in or Create an account to join the conversation.
Moderators: pgilman