%% Procedure makes 5-min avaraged file and shift 15 vinutes forward
%
% The 15-minute forward shift is used for
% PC coefficient derivation 
% as the groung magnetic field reacts 15-20 minute late
% after influence of IMF
%%
clear;
% =============================================
disp('1997');
load('Ekl_1997.mat')
ekls = avr5min(Ekl_1997);
last_1997 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_1997 = [NaN NaN NaN ekls(1: length(ekls)-3)];
save('ekls_1997.mat','ekls_1997');
clear Ekl* ekl*;
% =============================================
disp('1998');
load('Ekl_1998.mat')
ekls = avr5min(Ekl_1998);
last_1998 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_1998 = [last_1997 ekls(1: length(ekls)-3)];
save('ekls_1998.mat','ekls_1998');
clear Ekl* ekl*;
% =============================================
disp('1999');
load('Ekl_1999.mat')
ekls = avr5min(Ekl_1999);
last_1999 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_1999 = [last_1998 ekls(1: length(ekls)-3)];
save('ekls_1999.mat','ekls_1999');
clear Ekl* ekl*;
% =============================================
disp('2000');
load('Ekl_2000.mat')
ekls = avr5min(Ekl_2000);
last_2000 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_2000 = [last_1999 ekls(1: length(ekls)-3)];
save('ekls_2000.mat','ekls_2000');
clear Ekl* ekl*;
% =============================================
disp('2001');
load('Ekl_2001.mat')
ekls = avr5min(Ekl_2001);
last_2001 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_2001 = [last_2000 ekls(1: length(ekls)-3)];
save('ekls_2001.mat','ekls_2001');
clear Ekl* ekl*;
% =============================================
disp('2002');
load('Ekl_2002.mat')
ekls = avr5min(Ekl_2002);
last_2002 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_2002 = [last_2001 ekls(1: length(ekls)-3)];
save('ekls_2002.mat','ekls_2002');
clear Ekl* ekl*;
% =============================================
disp('2003');
load('Ekl_2003.mat')
ekls = avr5min(Ekl_2003);
last_2003 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_2003 = [last_2002 ekls(1: length(ekls)-3)];
save('ekls_2003.mat','ekls_2003');
clear Ekl* ekl*;
% =============================================
disp('2004');
load('Ekl_2004.mat')
ekls = avr5min(Ekl_2004);
last_2004 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_2004 = [last_2003 ekls(1: length(ekls)-3)];
save('ekls_2004.mat','ekls_2004');
clear Ekl* ekl*;
% =============================================
disp('2005');
load('Ekl_2005.mat')
ekls = avr5min(Ekl_2005);
last_2005 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_2005 = [last_2004 ekls(1: length(ekls)-3)];
save('ekls_2005.mat','ekls_2005');
clear Ekl* ekl*;
% =============================================
disp('2006');
load('Ekl_2006.mat')
ekls = avr5min(Ekl_2006);
last_2006 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_2006 = [last_2005 ekls(1: length(ekls)-3)];
save('ekls_2006.mat','ekls_2006');
clear Ekl* ekl*;
% =============================================
disp('2007');
load('Ekl_2007.mat')
ekls = avr5min(Ekl_2007);
last_2007 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_2007 = [last_2006 ekls(1: length(ekls)-3)];
save('ekls_2007.mat','ekls_2007');
clear Ekl* ekl*;
% =============================================
disp('2008');
load('Ekl_2008.mat')
ekls = avr5min(Ekl_2008);
last_2008 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_2008 = [last_2007 ekls(1: length(ekls)-3)];
save('ekls_2008.mat','ekls_2008');
clear Ekl* ekl*;
% =============================================
disp('2009');
load('Ekl_2009.mat')
ekls = avr5min(Ekl_2009);
last_2009 = ekls(length(ekls)-2:length(ekls)); % last 15 minutes
ekls_2009 = [last_2008 ekls(1: length(ekls)-3)];
save('ekls_2009.mat','ekls_2009');
clear;
