%%  paper dynamics of Strokkur/Geyser
% plot the weather data recorded at Gullfoss and Hjardarland stations 
% 

clear, close all
F = 1; 

% load weather data collected from the urdur website and obtain from IMO 
% select end date on 23.06.2018 at 23:00
DATA_Gullfoss = xlsread('weather.xlsx','urdur_gullfoss');
DATA_Hjardarland = xlsread('weather.xlsx','urdur_hjardarland');
DATA_Hjardarland2 = xlsread('weather.xlsx','urdur_hjardarland2');
DATA_Hjardarland_IMOS = xlsread('weather.xlsx','gudrun');
DATA_Hjardarland_IMOS = DATA_Hjardarland_IMOS(1:119,:);

Gullfoss = zeros(size(DATA_Gullfoss,1),size(DATA_Gullfoss,2)+1);
Gullfoss(:,1:end-1) = DATA_Gullfoss;

Hjardarland = zeros(size(DATA_Hjardarland,1), size(DATA_Hjardarland,2)+1);
Hjardarland(:,1:end-1) = DATA_Hjardarland;

Hjardarland2 = zeros(size(DATA_Hjardarland2,1), size(DATA_Hjardarland2,2)+1);
Hjardarland2(:,1:end-1) = DATA_Hjardarland2;

Hjardarland_IMOS = zeros(size(DATA_Hjardarland_IMOS,1), size(DATA_Hjardarland_IMOS,2)+1);
Hjardarland_IMOS(:,1:end-1) = DATA_Hjardarland_IMOS;


%create a matrix index with starting date: 18.06.2018 at 00 
% and ending date 23.06.2018 at 23:00
DATA = NaN(6*24, 3); 
id = 0;
for iday = 18:23
    for ihour = 0:23
                id = id+1;
                DATA(id,1) = iday;
                DATA(id,2) = ihour;
                DATA(id,3) = id-1;
    end 
end 


for i = 1:length(Gullfoss) 

    id_day  = find(DATA(:,1)==Gullfoss(i,3));
    id_hour = find(DATA(id_day,2)==Gullfoss(i,4));
    
    idDATA = id_day(id_hour); 
    Gullfoss(i,end) = DATA(idDATA,3);  
end

for i = 1:length(Hjardarland) 

    id_day  = find(DATA(:,1)==Hjardarland(i,3));
    id_hour = find(DATA(id_day,2)==Hjardarland(i,4));
    
    idDATA = id_day(id_hour); 
    Hjardarland(i,end) = DATA(idDATA,3);  
end

for i = 1:length(Hjardarland2) 

    id_day  = find(DATA(:,1)==Hjardarland2(i,3));
    id_hour = find(DATA(id_day,2)==Hjardarland2(i,4));
    
    idDATA = id_day(id_hour); 
    Hjardarland2(i,end) = DATA(idDATA,3);  
end

for i = 1:length(Hjardarland_IMOS) 

    id_day  = find(DATA(:,1)==Hjardarland_IMOS(i,3));
    id_hour = find(DATA(id_day,2)==Hjardarland_IMOS(i,4));
    
    idDATA = id_day(id_hour); 
    Hjardarland_IMOS(i,end) = DATA(idDATA,3);  
end


%% plot data - together data from Hjardarland and Gullfoss 
figure()
% temperature 
subplot(4,1,1)
plot(Gullfoss(:,end), Gullfoss(:,5),'-b')
hold on 
plot(Hjardarland2(:,end), Hjardarland2(:,5),'-r')
xlabel('Time (hours)')
ylabel('Temperature (ºC)')
% vertical lines to separate days
plot(24*ones(21,1), -2:18,'.k')
plot(2*24*ones(21,1), -2:18,'.k')
plot(3*24*ones(21,1), -2:18,'.k')
plot(4*24*ones(21,1), -2:18,'.k')
plot(5*24*ones(21,1), -2:18,'.k')
xlim([0 144])
ylim([-2 18])

% relative humidity
subplot(4,1,2)
plot(Gullfoss(:,end), Gullfoss(:,end-1),'-b')
hold on 
plot(Hjardarland2(:,end), Hjardarland2(:,end-1),'-r')
xlabel('Time (hours)')
ylabel('Relative humidity (%)')
% vertical lines to separate days
plot(24*ones(21,1), 10:5:110,'.k')
plot(2*24*ones(21,1), 10:5:110,'.k')
plot(3*24*ones(21,1), 10:5:110,'.k')
plot(4*24*ones(21,1), 10:5:110,'.k')
plot(5*24*ones(21,1), 10:5:110,'.k')
xlim([0 144])
ylim([10 110])

% wind speed and gust
subplot(4,1,3)
plot(Gullfoss(:,end), Gullfoss(:,6),'-b')
hold on 
%plot(Gullfoss(:,end), Gullfoss(:,7),'.b')
plot(Hjardarland2(:,end), Hjardarland2(:,6),'-r')
%plot(Hjardarland2(:,end), Hjardarland2(:,7),'.r')
xlabel('Time (hours)')
ylabel('wind speed (m/s)')
% vertical lines to separate days
plot(24*ones(17,1), -1:15,'.k')
plot(2*24*ones(17,1), -1:15,'.k')
plot(3*24*ones(17,1), -1:15,'.k')
plot(4*24*ones(17,1), -1:15,'.k')
plot(5*24*ones(17,1), -1:15,'.k')
xlim([0 144])
ylim([-1 15])

% accumulated rain 
subplot(4,1,4)
plot(Hjardarland(:,end), Hjardarland(:,8),'or')
hold on
xlabel('Time (hours)')
ylabel('accumulated rain (mm)')
plot(24*ones(19,1), -0.2:0.1:1.6,'.k')
plot(2*24*ones(19,1), -0.2:0.1:1.6,'.k')
plot(3*24*ones(19,1), -0.2:0.1:1.6,'.k')
plot(4*24*ones(19,1), -0.2:0.1:1.6,'.k')
plot(5*24*ones(19,1), -0.2:0.1:1.6,'.k')
xlim([0 144])
ylim([-0.2 1.6])

