We will be performing a major infrastructure and web site ugprades on Friday, September 27th 8:00 am - 5:00 pm MST (UTC -7).

The website will be down during that time.

Scripting to Input Hourly Electric Load Data

  • pspitsen
  • Topic Author
More
22 Sep 2017 16:31 #5742 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!


Please Log in or Create an account to join the conversation.

  • pgilman
More
25 Sep 2017 23:10 #5743 by pgilman
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()<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
More
17 Oct 2017 13: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: pgilman
Powered by Kunena Forum