%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                        %
%  This program plot Map of Reflectance  %
%  of Parasol files.                     %
%                                        %
%  Just modify the list with yours       %
%                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




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];

%%% Create the JFM list files

 fid=fopen('/home/gcesana/src/Figure_Helene/fig_papier/table/liste_jja_parasol2');
 c=textscan(fid,'%s','delimiter','');      
 list=c{1};

ncload([list{1}])

%%% Initialize lat/lon/alt
lat(1:length(latitude)+1)=90;
lon(1:length(longitude)+1)=-180;

%%% Create top latitude / top longitude
for i=1:length(latitude)
  lat(i+1)=lat(i)-180/length(latitude);
end

for i=1:length(longitude)
  lon(i+1)=lon(i)+360/length(longitude);
end

%%% Initialize tot low mid high vectors
refl(1:length(latitude),1:length(longitude),1:length(list))=0;

for i = 1:length(list)
  list{i}
  ncload([list{i}]);

  reflectance(reflectance==-9999)=nan;
  refl(:,:,i)=reflectance;
 
clear reflectance;
end

meanrefl=squeeze(nanmean(refl,3));   % total cloud vector

figure(1)
%%% Map (hammer graph)
m_proj('hammer-aitoff','clongitude',0);
m_pcolor(longitude,latitude,meanrefl)

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

m_coast('color','black') ; % pour les cotes continents
caxis([0 1])
m_grid('xtick', [], 'ytick', []);
colormap(a)
colorbar
shading flat;     % pour ne pas mettre de grille
title('REFLECTANCE 1DIR OF PARASOL JJA')

