- Posts: 1
Scripting to Input Hourly Electric Load Data
- pspitsen
- Topic Author
Less
More
22 Sep 2017 10:31 #5742
by pspitsen
Scripting to Input Hourly Electric Load Data was created by pspitsen
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!
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!
Please Log in or Create an account to join the conversation.
- Paul Gilman
Less
More
- Posts: 5603
25 Sep 2017 17:10 #5743
by Paul Gilman
Replied by Paul Gilman on topic Scripting to Input Hourly Electric Load Data
Hello,
I assume that you are writing an LK script in the SAM user interface, not in SDKtool.
Try this instead:
Also, if you want the results in SAM to change when you use the
Best regards,
Paul.
I assume that you are writing an LK script in the SAM user interface, not in SDKtool.
Try this instead:
Code:
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
Code:
simulate()<code> function, you can use its parameters like this:
<code>
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.
Please Log in or Create an account to join the conversation.
- alexaura
Less
More
- Posts: 1
17 Oct 2017 07:17 #5744
by alexaura
Replied by alexaura on topic Scripting to Input Hourly Electric Load Data
Thanks for the sample code, it really helped in the work!
Please Log in or Create an account to join the conversation.
Moderators: Paul Gilman