

   clear all; close all;

   addpath ./utils

%-------------------------------------------------------------------------------
%  Period
%-------------------------------------------------------------------------------
   multi_year='TRUE';
%  multi_year='FALS';
   ys=2003;
   ye1=2007;

%-------------------------------------------------------------------------------
%  Divers
%-------------------------------------------------------------------------------
   temp='thetao';
   Tmin=8; Tmax=22; Tinc=1;
   levels=[1:75];
%  shade diff temperature
   minmaxT=3;
   divisionT=0.25;
%  shade Currents (cm)
   minmaxU=10;
   divisionU=1;

   sizefont1=12;
%-------------------------------------------------------------------------------
%  Experiences
%-------------------------------------------------------------------------------

   config(1).name='peru12_nemo';
   config(1).grid='roms12nemo';
   config(1).exp={'p12n_bdy_tr12n_quik' 'p12n_bdy_tr12n_quik_ND' 'p12n_bdy_tr12n_quik_blp1' 'p12n_bdy_tr12n_quik_wnd_erai' ...
                 'p12n_bdy_soda2' 'p12n_bdy_soda2_B' 'p12n_bdy_soda2_B_rfact' 'p12n_bdy_soda2_B_steps' 'p12n_bdy_soda2_B_T-1degre'...
                 'p12n_bdy_soda2_B_T-1.5degre' 'p12n_bdy_soda3' 'p12n_bdy_soda3_T-1.5degre' 'p12n_bdy_tr12n_quik_Tp1.5degre' ...
                 'erai70b' 'erai74c'};
%  config(1).time='time_average_1mo';

   config(2).name='trop12_nemo/peru';
   config(2).grid='roms12nemo';
   config(2).exp={'tr12_quik' 'tr12_erainocrt' 'tr12n_n02' 'tr12n_n03'};
%  config(2).time='time_average_5d';

   config(3).name='trop025peru12_nemo/peru';
   config(3).grid='roms12nemo';
   config(3).exp={'tr025p12_quik'};
%  config(3).time='time_average_5d';

   config(4).name='peru12_nemo';
   config(4).grid='roms12nemo';
%  config(4).exp={'erai70b' 'erai74c'};
   config(4).exp={'erai70a' 'erai70b' 'erai70c' 'erai72c' 'erai73c' 'erai73c2' 'erai74c' 'erai75c'};
%  config(4).exp={'erai70c' 'erai72c' 'erai73c' 'erai73c2' 'erai75c'};
%  config(4).time='time_average_5d';

%-------------------------------------------------------------------------------
%  If compare to another experience  (exp2)
%-------------------------------------------------------------------------------
%  DIFF='FALS';
   DIFF='TRUE';
   
% CHOOSE EXPERIENCE REF
   config2_num=1;
   exp2_num=11;

   config2=config(config2_num).name;
   grid2=config(config2_num).grid;
   exp2=config(config2_num).exp{exp2_num};
%  time2=config(config2_num).time;


%-------------------------------------------------------------------------------
%  param pour get_section_meanlongshore_nemo
%-------------------------------------------------------------------------------
   season=[5]; 
   vname='r2v'; 
   dist=3e5;
   latpm=3;
   latsec=-10;
   latmin=latsec-latpm;
   latmax=latsec+latpm;
   
%-------------------------------------------------------------------------------
%   Loop plot multi year 
%                 -->  multi exp
%-------------------------------------------------------------------------------
   if strcmp(multi_year,'TRUE')   % ruse pour réaliser soit une boucle de ys à ye1 soit un seul passage pour ys-ye1
      ye=ys;
   else
      ye=ye1;
   end

   for year=ys:1:ye  
      if strcmp(multi_year,'TRUE')
         period=[num2str(ys) '-' num2str(ye1)];
         rep=[num2str(ys) '0101_' num2str(ye1) '1231'];
      else
         period=num2str(year);
         rep=[period '0101_' period '1231'];
      end

% Lecture exp2
      if strcmp(DIFF,'TRUE')
         dirfile2=['/loceanfs/pulsation/cholod/' config2 '/outputs/' exp2 '/' rep '/']; 
         Mfileu2=[dirfile2 exp2 '_1s_' rep '_grid_U_3D.nc']; 
         Mfilev2=[dirfile2 exp2 '_1s_' rep '_grid_V_3D.nc']; 
         Mfilet2=[dirfile2 exp2 '_1s_' rep '_grid_T_3D.nc'];  
         disp(['Mfileu2 = ',Mfileu2]);
         disp(['Mfilev2 = ',Mfilev2]);
         disp(['Mfilet2 = ',Mfilet2]);
         str2=['ncdump -h ',Mfilet2, '| grep UNLIMITED| awk -v var=1 -F" " ''{print $var}'''];
         [status,time22]=system(str2);    
         time2=strrep( sprintf(time22),sprintf('\n'),'');             
         disp([time2 ' = Time axis for ' Mfilet2]);
         ctlMu2=rnt_timectl({Mfileu2}, time2);
         ctlMv2=rnt_timectl({Mfilev2}, time2);
         ctlMt2=rnt_timectl({Mfilet2}, time2);
         exp2_title=regexprep(exp2,'_','\\_');
      end

      nc=netcdf(Mfilet2,'r');
      zl=-1*nc{'deptht'}(:);
      close(nc);
      NN=length(zl);

      grd=rnt_gridload_xa(grid2); 
      [Mvar2,Mmask,Mh,distx]=get_section_meanlongshore_nemo(grd,ctlMu2,ctlMv2,ctlMt2,vname,season,dist,latmin,latmax,NN);
      [MTemp2,Mmask,Mh,distx]=get_section_meanlongshore_nemo(grd,ctlMu2,ctlMv2,ctlMt2,temp,season,dist,latmin,latmax,NN);

% Lecture OBS  (CARS & LEVITUS) 
%     On bluff les courants avec ceux de exp1 pour CARS et LEVITUS
      MfiletCARS='/loceanfs/pulsation/cholod/data/CARS/cars_mon_clim_MEAN_PERU12_time5.nc';
      disp(['MfiletCARS = ',MfiletCARS]);
      ctlMtCARS=rnt_timectl({MfiletCARS}, 'time_counter');
      [MTempCARS,Mmask,Mh,distx]=get_section_meanlongshore_nemo(grd,ctlMu2,ctlMv2,ctlMtCARS,temp,season,dist,latmin,latmax,NN);

      MfiletLEVITUS='/loceanfs/pulsation/cholod/data/LEVITUS/levitus_annual_mean_PERU12_time5.nc';
      disp(['MfiletLEVITUS = ',MfiletLEVITUS]);
      ctlMtLEVITUS=rnt_timectl({MfiletLEVITUS}, 'time_counter');
      [MTempLEVITUS,Mmask,Mh,distx]=get_section_meanlongshore_nemo(grd,ctlMu2,ctlMv2,ctlMtLEVITUS,temp,season,dist,latmin,latmax,NN);

% CHOOSE CONFIG
      config_size=size(config);
%     for ii = 1:config_size(2)
      for ii = 1:1
         config1=config(ii).name;
         grid1=config(ii).grid;
         exp1_all=config(ii).exp;
%        time1=config(ii).time;
   
% CHOOSE EXPERIENCE
         exp_size=size(exp1_all);
%        for jj = 1:exp_size(2);
         for jj = 12:12
            exp1=exp1_all{jj};
            exp1_title=regexprep(exp1,'_','\\_');

% Lecture exp1
            dirfile1=['/loceanfs/pulsation/cholod/' config1 '/outputs/' exp1 '/' rep '/']; 
            Mfileu1=[dirfile1 exp1 '_1s_' rep '_grid_U_3D.nc'];
            Mfilev1=[dirfile1 exp1 '_1s_' rep '_grid_V_3D.nc'];
            Mfilet1=[dirfile1 exp1 '_1s_' rep '_grid_T_3D.nc']; 
            disp(['Mfileu1 = ',Mfileu1]);
            disp(['Mfilev1 = ',Mfilev1]);
            disp(['Mfilet1 = ',Mfilet1]);
            str1=['ncdump -h ',Mfilet1, '| grep UNLIMITED| awk -v var=1 -F" " ''{print $var}'''];
            [status,time11]=system(str1);    
            time1=strrep( sprintf(time11),sprintf('\n'),'');             
            disp([time1 ' = Time axis for ' Mfilet1]);
            ctlMu1=rnt_timectl({Mfileu1}, time1);
            ctlMv1=rnt_timectl({Mfilev1}, time1);
            ctlMt1=rnt_timectl({Mfilet1}, time1);

            [Mvar1,Mmask,Mh,distx]=get_section_meanlongshore_nemo(grd,ctlMu1,ctlMv1,ctlMt1,vname,season,dist,latmin,latmax,NN);
            [MTemp1,Mmask,Mh,distx]=get_section_meanlongshore_nemo(grd,ctlMu1,ctlMv1,ctlMt1,temp,season,dist,latmin,latmax,NN);


%-------------------------------------------------------------------------------
%  Shade Currents + plot temperature / depth 0-300m
%-------------------------------------------------------------------------------
               figure;

               Mvar1_cm=Mvar1.*100;
%              shade currents 
               [cttA,httA]=contourf(distx/1000,zl,Mvar1_cm,[-minmaxU:divisionU:minmaxU]);
               hold on
               contour(distx/1000,zl,Mvar1_cm,[-minmaxU:divisionU:minmaxU]); % pour enlever les contours noirs

%              colormap red blue without white & centered
               axis([-291 0 -300 0]);
               caxis([-minmaxU minmaxU]); 
               ncolor=minmaxU*2/divisionU;
               cc=colormap(redblue(ncolor+2));
               borne=minmaxU/divisionU;
               cc1=cc(1:borne,:);
               cc2=cc(borne+3:end,:);
               ccc=vertcat(cc1,cc2);
               colormap(ccc);
               hcc=colorbar; set(hcc,'FontS',sizefont1);

%              shade currents - plot isolevel 0 entre bleu et rouge               
               [cttB,httB]=contour(distx/1000,zl,Mvar1_cm,[-minmaxU:divisionU*5:minmaxU],'-g');
               clabel(cttB,httB,'FontS',sizefont1,'LabelSpacing',250,'Color','g');

%              plot temperature
               [cttC,httC]=contour(distx/1000,zl,MTemp1,[Tmin:Tinc:Tmax]); set(httC,'LineColor','k');
               clabel(cttC,httC,'FontS',sizefont1,'LabelSpacing',250,'Color','k');

               plot(distx/1000,-Mh,'k');

               set(gca,'FontS',sizefont1); set(gca,'PlotBoxAspectRatio',[0.7 1 1]); wysiwyg; box on;
               hx=xlabel(['Distance [km]  (Section ' num2str(latmax) '° to ' num2str(latmin) '°)']); set(hx,'FontS',sizefont1);
               hy=ylabel('Depth [m]'); set(hy,'FontS',sizefont1);
               title(['Current(cm/s) & T(C)  ' period '  ' exp1_title], 'FontSize',sizefont1);
%              on limite la recherche du min et max aux 300 premiers mètres =>  level 34
%              depthw[34]=285.716 m	deptht[34]=300.888 m
               str_min=num2str(min(min(Mvar1_cm(1:34,:))),'min %.1f');
               str_max=num2str(max(max(Mvar1_cm(1:34,:))),'max %.1f');
	       text(-0,-300,['(',str_min,' , ',str_max,')'], 'HorizontalAlignment','right','VerticalAlignment','bottom','FontSize',sizefont1);  
               text(-291,-300,[date], 'HorizontalAlignment','left','VerticalAlignment','bottom','FontSize',sizefont1);  
            
               figname=['along_peru_' exp1 '_' period '_lat' num2str(latsec) '_currents_0-300m' ];
               print ('-dpng',[figname '.png']);
               eval(['!cp VertAvgSectionMmeanNemo.m ' figname '.m'])

%-------------------------------------------------------------------------------
%  Shade Currents + plot temperature / depth 0-300m ...   + CARS
%-------------------------------------------------------------------------------
               [cttD,httD]=contour(distx/1000,zl,MTempCARS,[Tmin:Tinc:Tmax]); set(httD,'LineColor','b');
               clabel(cttD,httD,'FontS',sizefont1,'LabelSpacing',290,'Color','b');

               title(['Current(m/s) & T(C)  ' period '  ' exp1_title ' \color{blue} (CARS)'], 'FontSize',sizefont1);

               figname=['along_peru_' exp1 '_' period '_lat' num2str(latsec) '_currents_0-300m+CARS' ];
               print ('-dpng',[figname '.png']);
               eval(['!cp VertAvgSectionMmeanNemo.m ' figname '.m'])

%-------------------------------------------------------------------------------
%  Shade Diff of Currents / depth 0-300m
%-------------------------------------------------------------------------------
               figure;
               Mvar2_cm=Mvar2.*100;
               Mvardiff_cm=Mvar1_cm-Mvar2_cm;
%              shade diff of currents 
               [cttA,httA]=contourf(distx/1000,zl,Mvardiff_cm,[-minmaxU:divisionU:minmaxU]);
               hold on
               contour(distx/1000,zl,Mvardiff_cm,[-minmaxU:divisionU:minmaxU]); % pour enlever les contours noirs
 
%              colormap red blue without white & centered
               axis([-291 0 -300 0]);
               caxis([-minmaxU minmaxU]); 
               ncolor=minmaxU*2/divisionU;
               cc=colormap(redblue(ncolor+2));
               borne=minmaxU/divisionU;
               cc1=cc(1:borne,:);
               cc2=cc(borne+3:end,:);
               ccc=vertcat(cc1,cc2);
               colormap(ccc);
               hcc=colorbar; set(hcc,'FontS',sizefont1);

%              shade currents - plot isolevel 0 entre bleu et rouge               
               [cttB,httB]=contour(distx/1000,zl,Mvardiff_cm,[-minmaxU:divisionU*5:minmaxU],'-g');
               clabel(cttB,httB,'FontS',sizefont1,'LabelSpacing',250,'Color','g');

               plot(distx/1000,-Mh,'k');

               set(gca,'FontS',sizefont1); set(gca,'PlotBoxAspectRatio',[0.7 1 1]); wysiwyg; box on;
               hx=xlabel(['Distance [km]  (Section ' num2str(latmax) '° to ' num2str(latmin) '°)']); set(hx,'FontS',sizefont1);
               hy=ylabel('Depth [m]'); set(hy,'FontS',sizefont1);
               title(['Current(cm/s) & T(C)  ' period '  ' exp1_title ' - \color{blue}' exp2_title], 'FontSize',sizefont1);
%              on limite la recherche du min et max aux 300 premiers mètres =>  level 34
%              depthw[34]=285.716 m	deptht[34]=300.888 m
               str_min=num2str(min(min(Mvardiff_cm(1:34,:))),'min %.1f');
               str_max=num2str(max(max(Mvardiff_cm(1:34,:))),'max %.1f');
	       text(-0,-300,['(',str_min,' , ',str_max,')'], 'HorizontalAlignment','right','VerticalAlignment','bottom','FontSize',sizefont1);  
               text(-291,-300,[date], 'HorizontalAlignment','left','VerticalAlignment','bottom','FontSize',sizefont1);  
            
               figname=['along_peru_' exp1 '-' exp2 '_' period '_lat' num2str(latsec) '_currents_0-300m' ];
               print ('-dpng',[figname '.png']);
               eval(['!cp VertAvgSectionMmeanNemo.m ' figname '.m'])


%-------------------------------------------------------------------------------
%  Shade Currents + plot temperature / depth 75 levels
%-------------------------------------------------------------------------------
               figure;

               Mvar1_cm=Mvar1.*100;
%              shade currents 
               [cttA,httA]=contourf(distx/1000,levels,Mvar1_cm,[-minmaxU:divisionU:minmaxU]);
               hold on
               contour(distx/1000,levels,Mvar1_cm,[-minmaxU:divisionU:minmaxU]); % pour enlever les contours noirs

%              colormap red blue without white & centered
               set (gca,'YDir','reverse')
               caxis([-minmaxU minmaxU]); 
               ncolor=minmaxU*2/divisionU;
               cc=colormap(redblue(ncolor+2));
               borne=minmaxU/divisionU;
               cc1=cc(1:borne,:);
               cc2=cc(borne+3:end,:);
               ccc=vertcat(cc1,cc2);
               colormap(ccc);
               hcc=colorbar; set(hcc,'FontS',sizefont1);

%   print the depth of level on YTicks
               jj=1;
               YTick=get(gca,'YTick');
%              YTickLabel=get(gca,'YTickLabel')
               dim=size(YTick);
               label  = repmat('z=10 (12345m)', dim(2), 1);
               for ii=YTick
%                 label=YTickLabel(jj,:);
                  label(jj,:)=sprintf('z=%2d (%5.0fm)',ii,zl(ii));
                  jj=jj+1;
               end
               set(gca,'YTickLabel',label)

%              shade currents - plot isolevel 0 entre bleu et rouge               
               [cttB,httB]=contour(distx/1000,levels,Mvar1_cm,[-minmaxU:divisionU*5:minmaxU],'-g');
               clabel(cttB,httB,'FontS',sizefont1,'LabelSpacing',250,'Color','g');

%              plot temperature
               [cttC,httC]=contour(distx/1000,levels,MTemp1,[Tmin:Tinc:Tmax]); set(httC,'LineColor','k');
               clabel(cttC,httC,'FontS',sizefont1,'LabelSpacing',250,'Color','k');

               plot(distx/1000,-Mh,'k');

               set(gca,'FontS',sizefont1); set(gca,'PlotBoxAspectRatio',[0.7 1 1]); wysiwyg; box on;
               hx=xlabel(['Distance [km]  (Section ' num2str(latmax) '° to ' num2str(latmin) '°)']); set(hx,'FontS',sizefont1);
               hy=ylabel('Level'); set(hy,'FontS',sizefont1);
               title(['Current(cm/s) & T(C)  ' period '  ' exp1_title], 'FontSize',sizefont1);
               str_min=num2str(min(min(Mvar1_cm(1:75,:))),'min %.1f');
               str_max=num2str(max(max(Mvar1_cm(1:75,:))),'max %.1f');
	       text(-0,75,['(',str_min,' , ',str_max,')'], 'HorizontalAlignment','right','VerticalAlignment','bottom','FontSize',sizefont1);  
               text(-291,75,[date], 'HorizontalAlignment','left','VerticalAlignment','bottom','FontSize',sizefont1);  
            
               figname=['along_peru_' exp1 '_' period '_lat' num2str(latsec) '_currents_L75' ];
               print ('-dpng',[figname '.png']);
               eval(['!cp VertAvgSectionMmeanNemo.m ' figname '.m'])

%-------------------------------------------------------------------------------
%  Shade Currents + plot temperature / depth 75 levels... + LEVITUS
%-------------------------------------------------------------------------------
               [cttD,httD]=contour(distx/1000,levels,MTempLEVITUS,[Tmin:Tinc:Tmax]); set(httD,'LineColor','b');
               clabel(cttD,httD,'FontS',sizefont1,'LabelSpacing',290,'Color','b');

               title(['Current(m/s) & T(C)  ' period '  ' exp1_title ' \color{blue} (LEVITUS)'], 'FontSize',sizefont1);

               figname=['along_peru_' exp1 '_' period '_lat' num2str(latsec) '_currents_L75+LEVITUS' ];
               print ('-dpng',[figname '.png']);
               eval(['!cp VertAvgSectionMmeanNemo.m ' figname '.m'])

%-------------------------------------------------------------------------------
%  Shade Diff of Currents / depth 75 levels
%-------------------------------------------------------------------------------
               figure;
               Mvar2_cm=Mvar2.*100;
               Mvardiff_cm=Mvar1_cm-Mvar2_cm;
%              shade diff of currents 
               [cttA,httA]=contourf(distx/1000,levels,Mvardiff_cm,[-minmaxU:divisionU:minmaxU]);
               hold on
               contour(distx/1000,levels,Mvardiff_cm,[-minmaxU:divisionU:minmaxU]); % pour enlever les contours noirs
               hold on
 
%              colormap red blue without white & centered
               set (gca,'YDir','reverse')
               caxis([-minmaxU minmaxU]); 
               ncolor=minmaxU*2/divisionU;
               cc=colormap(redblue(ncolor+2));
               borne=minmaxU/divisionU;
               cc1=cc(1:borne,:);
               cc2=cc(borne+3:end,:);
               ccc=vertcat(cc1,cc2);
               colormap(ccc);
               hcc=colorbar; set(hcc,'FontS',sizefont1);

               set(gca,'YTickLabel',label)

%              shade currents - plot isolevel 0 entre bleu et rouge               
               [cttB,httB]=contour(distx/1000,levels,Mvardiff_cm,[-minmaxU:divisionU*5:minmaxU],'-g');
               clabel(cttB,httB,'FontS',sizefont1,'LabelSpacing',250,'Color','g');

               plot(distx/1000,-Mh,'k');

               set(gca,'FontS',sizefont1); set(gca,'PlotBoxAspectRatio',[0.7 1 1]); wysiwyg; box on;
               hx=xlabel(['Distance [km]  (Section ' num2str(latmax) '° to ' num2str(latmin) '°)']); set(hx,'FontS',sizefont1);
               hy=ylabel('Level'); set(hy,'FontS',sizefont1);
               title(['Current(cm/s) & T(C)  ' period '  ' exp1_title ' - \color{blue}' exp2_title], 'FontSize',sizefont1);
               str_min=num2str(min(min(Mvardiff_cm(1:75,:))),'min %.1f');
               str_max=num2str(max(max(Mvardiff_cm(1:75,:))),'max %.1f');
	       text(-0,75,['(',str_min,' , ',str_max,')'], 'HorizontalAlignment','right','VerticalAlignment','bottom','FontSize',sizefont1);  
               text(-291,75,[date], 'HorizontalAlignment','left','VerticalAlignment','bottom','FontSize',sizefont1);  
            
               figname=['along_peru_' exp1 '-' exp2 '_' period '_lat' num2str(latsec) '_currents_L75' ];
               print ('-dpng',[figname '.png']);
               eval(['!cp VertAvgSectionMmeanNemo.m ' figname '.m'])

%-------------------------------------------------------------------------------
%  Shade Diff of Temperature  + plot temperature / depth 0-300m    (exp1-CARS & exp1-exp2)
%-------------------------------------------------------------------------------
            for ref={exp2,'CARS'}
               exp3=ref{1};
               disp(exp3)
               exp3_title=regexprep(exp3,'_','\\_');

               if strcmp(exp3,'CARS')
                  MTemp3=MTempCARS;
               else
                  MTemp3=MTemp2;
               end

               MTempDiff=MTemp1-MTemp3;

               figure;

%              shade diff temperature
               [cttA,httA]=contourf(distx/1000,zl,MTempDiff);
%              [cttA,httA]=contourf(distx/1000,zl,MTempDiff,[-minmaxT:divisionT:minmaxT]);
               hold on
               contour(distx/1000,zl,MTempDiff); % pour enlever les contours noirs
%              contour(distx/1000,zl,MTempDiff,[-minmaxT:divisionT:minmaxT]); % pour enlever les contours noirs

%              colormap red blue without white & centered
               axis([-291 0 -300 0]);
               caxis([-minmaxT minmaxT]); 
               ncolor=minmaxT*2/divisionT;
               cc=colormap(redblue(ncolor+2));
               borne=minmaxT/divisionT;
               cc1=cc(1:borne,:);
               cc2=cc(borne+3:end,:);
               ccc=vertcat(cc1,cc2);
               colormap(ccc);
               hcc=colorbar; set(hcc,'FontS',sizefont1);

%              shade diff temperature - plot isolevel 0 entre bleu et rouge               
               [cttB,httB]=contour(distx/1000,zl,MTempDiff,[-minmaxT:divisionT*4:minmaxT],'-g');
               clabel(cttB,httB,'FontS',sizefont1,'LabelSpacing',250,'Color','g');

%              plot temperature
               [cttC,httC]=contour(distx/1000,zl,MTemp1,[Tmin:Tinc:Tmax]); set(httC,'LineColor','k');
               clabel(cttC,httC,'FontS',sizefont1,'LabelSpacing',250,'Color','k');
               [cttD,httD]=contour(distx/1000,zl,MTemp3,[Tmin:Tinc:Tmax]); set(httD,'LineColor','r');
               clabel(cttD,httD,'FontS',sizefont1,'LabelSpacing',290,'Color','r');

               plot(distx/1000,-Mh,'k');

               set(gca,'FontS',sizefont1); set(gca,'PlotBoxAspectRatio',[0.7 1 1]); wysiwyg; box on;
               hx=xlabel(['Distance [km]  (Section ' num2str(latmax) '° to ' num2str(latmin) '°)']); set(hx,'FontS',sizefont1);
               hy=ylabel('Depth [m]'); set(hy,'FontS',sizefont1);
               title(['T(C)  ' period '  ' exp1_title ' - \color{blue}' exp3_title], 'FontSize',sizefont1);
%              on limite la recherche du min et max aux 300 premiers mètres =>  level 34
%              depthw[34]=285.716 m	deptht[34]=300.888 m
               str_min=num2str(min(min(MTempDiff(1:34,:))),'min %.1f');
               str_max=num2str(max(max(MTempDiff(1:34,:))),'max %.1f');
	       text(-0,-300,['(',str_min,' , ',str_max,')'], 'HorizontalAlignment','right','VerticalAlignment','bottom','FontSize',sizefont1);  
               text(-291,-300,[date], 'HorizontalAlignment','left','VerticalAlignment','bottom','FontSize',sizefont1);  
            
               figname=['along_peru_' exp1 '-' exp3 '_' period '_lat' num2str(latsec) '_temperature_0-300m' ];
               print ('-dpng',[figname '.png']);
               eval(['!cp VertAvgSectionMmeanNemo.m ' figname '.m'])
            end   % ll


%-------------------------------------------------------------------------------
%  Shade Diff of Temperature  + plot temperature / depth 75 levels    (exp1-LEVITUS & exp1-exp2)
%-------------------------------------------------------------------------------
            for ref={exp2,'LEVITUS'}
               exp3=ref{1};
               disp(exp3)
               exp3_title=regexprep(exp3,'_','\\_');

               if strcmp(exp3,'LEVITUS')
                  MTemp3=MTempLEVITUS;
               else
                  MTemp3=MTemp2;
               end

               MTempDiff=MTemp1-MTemp3;

               figure;

%              shade diff temperature
               [cttA,httA]=contourf(distx/1000,levels,MTempDiff);
%              [cttA,httA]=contourf(distx/1000,levels,MTempDiff,[-minmaxT:divisionT:minmaxT]);
               hold on
               contour(distx/1000,levels,MTempDiff); % pour enlever les contours noirs
%              contour(distx/1000,levels,MTempDiff,[-minmaxT:divisionT:minmaxT]); % pour enlever les contours noirs

%              colormap red blue without white & centered
               set (gca,'YDir','reverse')
               caxis([-minmaxT minmaxT]); 
               ncolor=minmaxT*2/divisionT;
               cc=colormap(redblue(ncolor+2));
               borne=minmaxT/divisionT;
               cc1=cc(1:borne,:);
               cc2=cc(borne+3:end,:);
               ccc=vertcat(cc1,cc2);
               colormap(ccc);
               hcc=colorbar; set(hcc,'FontS',sizefont1);

               set(gca,'YTickLabel',label)

%              shade diff temperature - plot isolevels 0 entre bleu et rouge               
               [cttB,httB]=contour(distx/1000,levels,MTempDiff,[-minmaxT:divisionT*4:minmaxT],'-g');
               clabel(cttB,httB,'FontS',sizefont1,'LabelSpacing',250,'Color','g');

%              plot temperature
               [cttC,httC]=contour(distx/1000,levels,MTemp1,[Tmin:Tinc:Tmax]); set(httC,'LineColor','k');
               clabel(cttC,httC,'FontS',sizefont1,'LabelSpacing',250,'Color','k');
               [cttD,httD]=contour(distx/1000,levels,MTemp3,[Tmin:Tinc:Tmax]); set(httD,'LineColor','r');
               clabel(cttD,httD,'FontS',sizefont1,'LabelSpacing',290,'Color','r');

               plot(distx/1000,-Mh,'k');

               set(gca,'FontS',sizefont1); set(gca,'PlotBoxAspectRatio',[0.7 1 1]); wysiwyg; box on;
               hx=xlabel(['Distance [km]  (Section ' num2str(latmax) '° to ' num2str(latmin) '°)']); set(hx,'FontS',sizefont1);
               hy=ylabel('Level'); set(hy,'FontS',sizefont1);
               title(['T(C)  ' period '  ' exp1_title ' - \color{blue}' exp3_title], 'FontSize',sizefont1);
               str_min=num2str(min(min(MTempDiff(1:75,:))),'min %.1f');
               str_max=num2str(max(max(MTempDiff(1:75,:))),'max %.1f');
%              text(-0,75,['(',str_min,' , ',str_max,')'], 'HorizontalAlignment','right','VerticalAlignment','bottom','FontSize',sizefont1);  
%              text(-291,75,[date], 'HorizontalAlignment','left','VerticalAlignment','bottom','FontSize',sizefont1);  
	       text(-0,75,['(',str_min,' , ',str_max,')'], 'HorizontalAlignment','right','VerticalAlignment','bottom','FontSize',sizefont1);  
               text(-291,75,[date], 'HorizontalAlignment','left','VerticalAlignment','bottom','FontSize',sizefont1);  
            
               figname=['along_peru_' exp1 '-' exp3 '_' period '_lat' num2str(latsec) '_temperature_L75' ];
               print ('-dpng',[figname '.png']);
               eval(['!cp VertAvgSectionMmeanNemo.m ' figname '.m'])
            end   % ll



         end   % jj
      end   % ii
   end     %   for year
   

