station=[{'Salmon'},{'Kodiak'},{'PrinceGeorge'},{'Saskatoon'},{'RankinInlet'},{'Kapuskasing'},{'GooseBay'},{'Stokkseyri'},{'Pykkvibaer'},{'Hankasalmi'}];
smoothing=30;
%% Climatology
 
for i=1:length(station)
    station{i}
%ClimatologyWind(station{i},smoothing,2);
ClimatologyWind(DataFolder,station{i},smoothing,3);
end


%% plot data coverage climatology
C=[0 0 0;0 0.5 0; 0 1 0; 1 0 0; 0 0 1; 1 0 1; 0 1 1;1 1 0; 1 0.5 0;0.5 0 0.5];
figure5=figure('Name','DatacoverageClimatology2','units','centimeters','Position',[0 0 50 10],...                    % setter str på figuren du vil se på skjermen. VIKIT Gat units kommer FØR Position
    'PaperUnits','centimeters','PaperPosition', [0 0 50 10],...% setter str på figuren du vil lagre (uavhengig av format) VIKITG at units kommer FØR Position
    'DefaultAxesFontSize',12,'DefaultAxesFontWeight','b');               %setter str på font i figure %

for i=1:length(station)
  %load(['Climatology2_',station{i},'_Smoothing_',int2str(smoothing)]);
  load(fullfile(DataFolder,station{i},['Climatology3_',station{i},'_Smoothing_',int2str(smoothing)]));
  plot(Climatology.DayofYear,Climatology.N,'Color',C(i,:),'linewidth',2)
  hold on
end
legend(station{1},station{2},station{3},station{4},station{5},station{6},station{7},station{8},station{9},station{10},'location','EastOutside')
xlim([1 366])
makePDF(gca,[50, 10],'YearsPerDOY',DataFolder)
%%%

%% plot climatology
station=[{'Salmon'},{'Kodiak'},{'PrinceGeorge'},{'Saskatoon'},{'RankinInlet'},{'Kapuskasing'},{'GooseBay'},{'Stokkseyri'},{'Pykkvibaer'},{'Hankasalmi'}];
yearStart=[2001,2000,2000,1993,2006,1993,1993,1994,1995,1995];
yearEnd=[2013,2013,2016,2016,2016,2016,2016,2016,2016,2016];
smoothing=30;
%C=[0 0 0;0 0.5 0; 0 1 0; 1 0 0; 0 0 1; 1 0 1; 0 1 1;1 1 0; 1 0.5 0;0.5 0 0.5];
figure('Name','smooth meridional climatology','units','centimeters','Position',[0 0 20 50],...                    % setter str på figuren du vil se på skjermen. VIKIT Gat units kommer FØR Position
    'PaperUnits','centimeters','PaperPosition', [0 0 20 50],...% setter str på figuren du vil lagre (uavhengig av format) VIKITG at units kommer FØR Position
    'DefaultAxesFontSize',12,'DefaultAxesFontWeight','b');               %setter str på font i figure %

for i=1:length(station)
  
  %load(['Climatology2_',station{i},'_Smoothing_',int2str(smoothing)]);
  load(fullfile(DataFolder,station{i},['Climatology3_',station{i},'_Smoothing_',int2str(smoothing)]));
  subplot(5,2,i);
  plot(Climatology.DayofYear,Climatology.Smooth,'Color','k','linewidth',2)
  load(fullfile(DataFolder,station{i},[station{i},'Clean.mat']))
  title([station{i},', Lat/Lon = ',num2str(Data.Lat(1)),'/',num2str(Data.Lon(1))]);
  ylabel('Climatology V_x [m/s]')
  xlabel(['day of year ', int2str(yearStart(i)),'-',int2str(yearEnd(i))])
  xlim([1 366])
  ylim([-10,10])
end

%% plot climatology 2
station=[{'Salmon'},{'Kodiak'},{'PrinceGeorge'},{'Saskatoon'},{'RankinInlet'},{'Kapuskasing'},{'GooseBay'},{'Stokkseyri'},{'Pykkvibaer'},{'Hankasalmi'}];
yearStart=[2001,2000,2000,1993,2006,1993,1993,1994,1995,1995];
yearEnd=[2013,2013,2016,2016,2016,2016,2016,2016,2016,2016];
smoothing=30;
%C=[0 0 0;0 0.5 0; 0 1 0; 1 0 0; 0 0 1; 1 0 1; 0 1 1;1 1 0; 1 0.5 0;0.5 0 0.5];
figure('Name','smooth meridional climatology','units','centimeters','Position',[0 0 20 50],...                    % setter str på figuren du vil se på skjermen. VIKIT Gat units kommer FØR Position
    'PaperUnits','centimeters','PaperPosition', [0 0 20 50],...% setter str på figuren du vil lagre (uavhengig av format) VIKITG at units kommer FØR Position
    'DefaultAxesFontSize',12,'DefaultAxesFontWeight','b');               %setter str på font i figure %

for i=1:length(station)
  %load(['Climatology2_',station{i},'_Smoothing_',int2str(smoothing)]);
  load(fullfile(DataFolder,station{i},['Climatology3_',station{i},'_Smoothing_',int2str(smoothing)]));
  subplot(5,2,i);
  errorbar(Climatology.DayofYear,Climatology.WeightedSmooth,Climatology.WeightedClimatology_err,'Color','k')
  hold on
    plot(Climatology.DayofYear,Climatology.WeightedSmooth,'Color','y','linewidth',2)
  hold off
load(fullfile(DataFolder,station{i},[station{i},'Clean.mat']));
  title([station{i},', Lat/Lon = ',num2str(Data.Lat(1)),'/',num2str(Data.Lon(1))]);
  ylabel('Climatology V_x [m/s]')
  xlabel(['day of year ', int2str(yearStart(i)),'-',int2str(yearEnd(i))])
  xlim([1 366])
  ylim([-10,10])
end

makePDF(gca,[20,20],'Climaology_Smooth',DataFolder)

 get_figure([20,20],8,'n')
 for i=1:length(station)
  
  %load(['Climatology2_',station{i},'_Smoothing_',int2str(smoothing)]);
  load(fullfile(DataFolder,station{i},['Climatology3_',station{i},'_Smoothing_',int2str(smoothing)]));
  subplot(5,2,i);
  plot(Climatology.DayofYear,Climatology.WeightedClimatology_err,'Color','k','linewidth',2)
  %hold on
    %plot(Climatology.DayofYear,Climatology.WeightedClimatology_STD,'Color','r','linewidth',2)
  %hold off
load(fullfile(DataFolder,station{i},[station{i},'Clean.mat']));
  title([station{i},', Lat/Lon = ',num2str(Data.Lat(1)),'/',num2str(Data.Lon(1))]);
  ylabel('standard error of weighted mean')
  xlabel(['day of year ', int2str(yearStart(i)),'-',int2str(yearEnd(i))])
  xlim([1 366])
  ylim([0,2])
 end

 makePDF(gca,[20,20],'Climaology_SEWM',DataFolder)

 get_figure([20,20],8,'n')
  for i=1:length(station)
  

  %load(['Climatology2_',station{i},'_Smoothing_',int2str(smoothing)]);
  load(fullfile(DataFolder,station{i},['Climatology3_',station{i},'_Smoothing_',int2str(smoothing)]));
  subplot(5,2,i);
  %plot(Climatology.DayofYear,Climatology.WeightedClimatology_err,'Color','k')
  %hold on
    plot(Climatology.DayofYear,Climatology.WeightedClimatology_STD,'Color','k','linewidth',2)
  %hold off
  load(fullfile(DataFolder,station{i},[station{i},'Clean.mat']));
  title([station{i},', Lat/Lon = ',num2str(Data.Lat(1)),'/',num2str(Data.Lon(1))]);
  ylabel('STD Climatology')
  xlabel(['day of year ', int2str(yearStart(i)),'-',int2str(yearEnd(i))])
  xlim([1 366])
  ylim([0,15])
  end
 
makePDF(gca,[20,20],'Climaology_STD',DataFolder)

%cd C:\Users\kleinkne\Documents\PHD\MODEL\WACCM\waccm_TEM_diff_Climatology
%load('TEM_diff_climat_lat_80')
 %test=SmoothClimatology(squeeze(v_star_climat(80,10,:)),30)
 
%plot(test,'k','linewidth',2)
%ylim([-15,15])
%ylim([-15,15])
%subplot(12,2,9);
%plot(squeeze(v_star_climat(80,10,:)),'k','linewidth',2)
%subplot(12,2,10);
%plot(test,'k','linewidth',2)
%subplot(12,2,11);
%plot(squeeze(v_star_climat(80,10,:)),'k','linewidth',2)
%subplot(12,2,12);
%plot(test,'k','linewidth',2)
%ylim([-15,15])
%ylim([-15,15])