Scripting to Input Hourly Electric Load Data

3 posts / 0 new
Last post
pspitsen
Scripting to Input Hourly Electric Load Data

Hi,

I am writing a script to input different hourly load profiles, but am having trouble getting SAM to recognize the input data. I have tried csv files with either 8760 rows or 8761 rows (where the first row is a place holder) of data organized in a single column, however neither work.

The code I have been trying is:

active_case('untitled');
set('load_model', 1);
set('normalize_to_utility_bill', 0);
set('load', real_array(read_text_file('C:/Users/pspitsen/Desktop/load.csv')));
simulate();

I attached my LK script and my load csv for reference.

Any help would be greatly appreciated. Thanks!

Paul Gilman

Hello,

I assume that you are writing an LK script in the SAM user interface, not in SDKtool.

Try this instead:

fname = 'C:/Users/pspitsen/Desktop/load.csv';
arr = csvread( fname, {'skip'=1,'numeric'=true,'table'=false} );
for (i=0;i<#arr;i++) //convert 2D array to 1D
arr[i]=arr[i][0];
set('load_user_data',arr);

Also, if you want the results in SAM to change when you use the simulate() function, you can use its parameters like this:

msg = ''; // string to store simulation messages
simulate( msg, true ); // set second parameter to true to update SAM's results page
outln( msg );

Best regards,
Paul.

alexaura

Thanks for the sample code, it really helped in the work!

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer