%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                        %
%    This program plot Map low mid high  %
%    and total cloud of ISCCP files.     %
%                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




close ('all');
clear all;

%%% colormap vector
a=[0.75 0 1; 0.5 0 1; 0 0 1; 0 0.5 1; 0 1 1; 0 1 0.5; 0 1 0; 0.5 1 0; 1 1 0; 1 0.5 0; 1 0 0; 1 0 0.5];

%%% Load the file
ncload('/bdd/CFMIP/GOCCP/ISCCP/ISCCP_totlowmidhgh_cldcover_198307-200806.nc')

%%% Averaging the variables
cldtot(cldtot==-1000)=nan;   %%% -1000 = NaN value
lowcld(lowcld==-1000)=nan;   %%% -1000 = NaN value
midcld(midcld==-1000)=nan;   %%% -1000 = NaN value
highcld(highcld==-1000)=nan;   %%% -1000 = NaN value

  tot=squeeze(nanmean(cldtot,1));
  low=squeeze(nanmean(lowcld,1));
  mid=squeeze(nanmean(midcld,1));
  high=squeeze(nanmean(highcld,1));



%%% plot the figure

figure(1)
%%% Map (hammer graph)
subplot(4,2,1)
m_proj('hammer-aitoff','clongitude',0);
m_pcolor(lon,lat,tot)

% some latitude line to make easier the reading of the plot
 y(1:length(lon))=0;
m_line(lon,y','color','black')
 y(1:length(lon))=30;
m_line(lon,y','color','black')
 y(1:length(lon))=60;
m_line(lon,y','color','black')
 y(1:length(lon))=-60;
m_line(lon,y','color','black')
 y(1:length(lon))=-30;
m_line(lon,y','color','black')

m_coast('color','black') ; % pour les cotes continents
caxis([0 100])
m_grid('xtick', [], 'ytick', []);
shading flat;     % pour ne pas mettre de grille
title('TOTAL CLOUD ISCCP 198307 - 200806')
colorbar('southoutside')


subplot(4,2,3)
m_proj('hammer-aitoff','clongitude',0);
m_pcolor(lon,lat,high)
 
 y(1:length(lon))=0;
m_line(lon,y','color','black')
 y(1:length(lon))=30;
m_line(lon,y','color','black')
 y(1:length(lon))=60;
m_line(lon,y','color','black')
 y(1:length(lon))=-60;
m_line(lon,y','color','black')
 y(1:length(lon))=-30;
m_line(lon,y','color','black')

m_coast('color','black') ; % pour les cotes continents
caxis([0 100])
m_grid('xtick', [], 'ytick', []);
shading flat;     % pour ne pas mettre de grille
title('HIGH CLOUD ISCCP 198307 - 200806')
colorbar('southoutside')



subplot(4,2,5)
m_proj('hammer-aitoff','clongitude',0);
m_pcolor(lon,lat,mid)

 y(1:length(lon))=0;
m_line(lon,y','color','black')
 y(1:length(lon))=30;
m_line(lon,y','color','black')
 y(1:length(lon))=60;
m_line(lon,y','color','black')
 y(1:length(lon))=-60;
m_line(lon,y','color','black')
 y(1:length(lon))=-30;
m_line(lon,y','color','black')

m_coast('color','black') ; % pour les cotes continents
m_grid('xtick', [], 'ytick', []);
caxis([0 100])
shading flat;   
title('MID CLOUD ISCCP 198307 - 200806')
colorbar('southoutside')


subplot(4,2,7)
m_proj('hammer-aitoff','clongitude',0);
m_pcolor(lon,lat,low)

 y(1:length(lon))=0;
m_line(lon,y','color','black')
 y(1:length(lon))=30;
m_line(lon,y','color','black')
 y(1:length(lon))=60;
m_line(lon,y','color','black')
 y(1:length(lon))=-60;
m_line(lon,y','color','black')
 y(1:length(lon))=-30;
m_line(lon,y','color','black')

m_coast('color','black') ; % pour les cotes continents
m_grid('xtick', [], 'ytick', []);
caxis([0 100])
shading flat;
%colorbar('southoutside')
title('LOW CLOUD ISCCP 198307 - 200806')
colorbar('southoutside')


%%% Map (hammer graph)
subplot(4,2,2)
m_proj('miller','clongitude',0);
m_pcolor(lon,lat,tot)

% some latitude line to make easier the reading of the plot
 y(1:length(lon))=0;
m_line(lon,y','color','black')
 y(1:length(lon))=30;
m_line(lon,y','color','black')
 y(1:length(lon))=60;
m_line(lon,y','color','black')
 y(1:length(lon))=-60;
m_line(lon,y','color','black')
 y(1:length(lon))=-30;
m_line(lon,y','color','black')

m_coast('color','black') ; % pour les cotes continents
caxis([0 100])
m_grid('xtick', [], 'ytick', []);
shading flat;     % pour ne pas mettre de grille
title('TOTAL CLOUD ISCCP 198307 - 200806')
colorbar('southoutside')


subplot(4,2,4)
m_proj('miller','clongitude',0);
m_pcolor(lon,lat,high)
 
 y(1:length(lon))=0;
m_line(lon,y','color','black')
 y(1:length(lon))=30;
m_line(lon,y','color','black')
 y(1:length(lon))=60;
m_line(lon,y','color','black')
 y(1:length(lon))=-60;
m_line(lon,y','color','black')
 y(1:length(lon))=-30;
m_line(lon,y','color','black')

m_coast('color','black') ; % pour les cotes continents
caxis([0 100])
m_grid('xtick', [], 'ytick', []);
shading flat;     % pour ne pas mettre de grille
title('HIGH CLOUD ISCCP 198307 - 200806')
colorbar('southoutside')



subplot(4,2,6)
m_proj('miller','clongitude',0);
m_pcolor(lon,lat,mid)

 y(1:length(lon))=0;
m_line(lon,y','color','black')
 y(1:length(lon))=30;
m_line(lon,y','color','black')
 y(1:length(lon))=60;
m_line(lon,y','color','black')
 y(1:length(lon))=-60;
m_line(lon,y','color','black')
 y(1:length(lon))=-30;
m_line(lon,y','color','black')

m_coast('color','black') ; % pour les cotes continents
m_grid('xtick', [], 'ytick', []);
caxis([0 100])
shading flat;   
title('MID CLOUD ISCCP 198307 - 200806')
colorbar('southoutside')


subplot(4,2,8)
m_proj('miller','clongitude',0);
m_pcolor(lon,lat,low)

 y(1:length(lon))=0;
m_line(lon,y','color','black')
 y(1:length(lon))=30;
m_line(lon,y','color','black')
 y(1:length(lon))=60;
m_line(lon,y','color','black')
 y(1:length(lon))=-60;
m_line(lon,y','color','black')
 y(1:length(lon))=-30;
m_line(lon,y','color','black')

m_coast('color','black') ; % pour les cotes continents
m_grid('xtick', [], 'ytick', []);
caxis([0 100])
shading flat;
colorbar('southoutside')
  colormap(a)   
title('LOW CLOUD ISCCP 198307 - 200806')


