Importing time series to Homer

For our P2 project we are currently working towards a goal of obtaining the most efficient household setup of PV solar, hybrid inverter and storage batteries. This setup is of course connected to the grid.

Using the Homer software to run simulations is very useful in obtaining our main goals in the project, but it also feel pretty useful to have knowledge working with it when returning to work in the industries after receiving our masters.

Anyhow. The timeseries load profile we wanted to use in our project originated from my own personel load profile from a local electricity supplier formerly known as “SE” which know goes by the name “Norlys”. Unfortunately the only way to get one year of hourly usage on your laptop is by manually clicking 3 times each time you download a file, bear in mind that each file only hourly data for one day, so this proces has to be repeated 365 times to download data for a complete year.

Finally with the data downloaded and trying to import it to Homer, it would not work. Homer simply does not recognize the format supplied by Norlys.

I turned to my trusted friend Matlab, and by writing a script suitable for our situation Matlab easily digested through all of the files trimmed and compiled the load data into a single .csv file which then could be easily imported to Homer.

The hardest thing for me was to find out what sort of format Homer would accept. There is little help to find on their website here, but that did not help me all to much, mainly because I don’t know too much about formatting .csv files. (I know it is comma separated 🙂 ) What I did find out eventually was that if I just simply use a one column csv format Homer would recognize it and put all my data in the right spot. So this was what i did, i simply created a single .csv file containing all the hourly load data, and from this data Homer accepted it and added it to the respective dates with no problems whatsoever.

Not sure how well you can use my matlab code for this project, but I will put it up here just in case. I have the script placed in main folder, and “jan”,”feb”…etc. are all subfolders containing the downloaded time series from Norlys. When I refer to the 3rd column, it is simply because this is the place of the load data in the downloaded file, the tweaking must be up to you guys 😉

% Matlab Script
% Creating suitable time series load profile for Homer Pro Grid Software
% Created by Esben Uth
% Energy Department
% Aalborg University Esbjerg
%clean up
%output script start to command line
disp('Conversion started');
%create empty matrix to hold all load data
M = zeros(1,1);
%run through all subfolders
sf = {'jan', 'feb', 'mar', 'apr', 'maj', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'};
for k = 1:12
    %define folder
    myDir = sf{k}; %gets directory
    % count number of files in folder
    myFiles = dir(fullfile(myDir,'*.csv')); %gets all csv files in subfolder
    % start the for loop, extracting data from all the files in the folder.
    for i = 1:length(myFiles)
        %construct file name
        baseFileName = myFiles(i).name;
        fullFileName = fullfile(myDir, baseFileName);
        %read file and move data from .csv file to the T variable
        T = readtable(fullFileName, 'Delimiter', ';', 'PreserveVariableNames', true);
        %convert table to cell
        T = T{:,:};
        %read data from the file
        load_data = T(1:24,3);
        date_data = T(1:24,1);
        %trim data before appending them to the matrix
        load_data = strrep(load_data,',', '.');
        load_data = str2double(load_data);
        date_data = strrep(date_data,'-', '/');
        date_data = str2double(date_data);
        %create temporary matrix
        temp_data = [load_data];
        %append new data to the matrix
        M = [M;temp_data];
        %output part done to command line
        disp(fprintf('File %d of %.0f in %s converted.', i, n_files, sf{k}));
%delete first row of matrix
M(1,:) = [];
%write load data into .csv file
%output script end to command line
disp('Conversion complete');


Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *

This site uses Akismet to reduce spam. Learn how your comment data is processed.