
   clear all; close all;

   ys_fich=2003;         
   ye_fich=2007;         

   exp(1).config='peru12_nemo';
   exp(1).names={'erai70b' 'erai74c' 'p12n_bdy_tr12n_quik' 'p12n_bdy_tr12n_quik_ND' 'p12n_bdy_tr12n_quik_blp1' 'p12n_bdy_soda2' 'p12n_bdy_soda2_B' 'p12n_bdy_soda2_B_rfact' 'p12n_bdy_soda2_B_steps'};

   exp(2).config='trop12_nemo/peru';
   exp(2).names={'tr12_quik'};

   exp(3).config='trop025peru12_nemo/peru';
   exp(3).names={'tr025p12_quik'};

   exp(4).config='/loceanfs/pulsation/cholod/data/AVISO/';
   exp(4).names={'AVISO_PERU12'};

   config_ref=exp(4).config;
   name_ref=exp(4).names{1};

   day_freq='5d';
   grid_type='T_2D';
   ylimA1=[-5 5]; xA1=50; yA1=-4.5;                                         % plot1
   ylimA2=[-0.004 0.004]; xA2=50; yA2=-0.035;                               % plot2
   caxisA3=[-5 5]; xA3=-85; yA3=-33; colormapA3=[cold;flipud(hot)];         % plot3

%  for ii = 1:exp_dim(2)
   for ii = 1:1
      config1=exp(ii).config;
      config2=config_ref;
      names=exp(ii).names;
      names_dim=size(names);

%     for jj = 1:names_dim(2);
      for jj = 6:7
         name1=names{jj};
         name2=name_ref;
         disp([num2str(jj) ' : ' name1 ' - ' name2]);

         name1_title=regexprep(name1,'_','\\_');
         name2_title=regexprep(name2,'_','\\_');
         rep_plot=[num2str(ys_fich) '0101_' num2str(ye_fich) '1231'];
         dur_plot=[num2str(ys_fich) '-' num2str(ye_fich)];

         if strcmp(name1,'AVISO_PERU12')
            dir1=config1;
         else
            dir1=['/loceanfs/pulsation/cholod/' config1 '/outputs/' name1 '/' rep_plot '/'];
         end

         if strcmp(name2,'AVISO_PERU12')
            dir2=config2;
         else
            dir2=['/loceanfs/pulsation/cholod/' config2 '/outputs/' name2 '/' rep_plot '/'];
         end

         labelA=['computed with ' day_freq ' file and ' dur_plot ' mean'];

         filemat1=[dir1 'var_ssh_' name1 '_' rep_plot '.mat'];
         filemat2=[dir2 'var_ssh_' name2 '_' rep_plot '.mat'];

         load(filemat1);
            if ~(strcmp(name1,'AVISO_PERU12') | strcmp(name2,'AVISO_PERU12'))     %   time serie run/AVISO impossible car 7d et 5d
               ke1=ke;
               sgzos1=sgzos;
            end
            mvz1=mvz;
         load(filemat2);
            if ~(strcmp(name1,'AVISO_PERU12') | strcmp(name2,'AVISO_PERU12'))     %   time serie run/AVISO impossible car 7d et 5d
               ke2=ke;
               sgzos2=sgzos;
            end
            mvz2=mvz;

         opengl neverselect

%%%  Plot 1
         if ~(strcmp(name1,'AVISO_PERU12')  | strcmp(name2,'AVISO_PERU12'))    %   time serie run/AVISO impossible car 7d et 5d
            figure;
            plot(time,100*(sqrt(ke1) - sqrt(ke2)));
            grid on;
            hx=xlabel(day_freq); set(hx,'FontS',14);
            set(gca,'FontS',14); set (gca,'ylim',ylimA1);
            title(['diff \sigma\_ssh (cm) ' name1_title ' - ' name2_title ' (' dur_plot ')'],'FontSize',18);
            text(xA1,yA1,labelA, 'HorizontalAlignment','left','FontSize',14);
            fignameA=['diff_plot_var_ssh_' name1 '-' name2 '_' dur_plot '_' day_freq];
            print ('-dpng',fignameA);
         end

%%%  Plot 2
         if ~(strcmp(name1,'AVISO_PERU12')  | strcmp(name2,'AVISO_PERU12'))    %   time serie run/AVISO impossible car 7d et 5d
            figure;
            plot(time,sqrt(sgzos1) - sqrt(sgzos2));
            grid on;
            hx=xlabel(day_freq); set(hx,'FontS',14);
            set(gca,'FontS',14); set (gca,'ylim',ylimA2);  
            title(['diff sqrt(grad ssh) ' name1_title ' - ' name2_title ' (' dur_plot ')'], 'FontSize',18);
            text(xA2,yA2,labelA, 'HorizontalAlignment','left','FontSize',14); 
            fignameA=['diff_plot_grad_ssh_' name1 '-' name2 '_' dur_plot '_' day_freq];
            print ('-dpng',fignameA); 
         end

%%%  Plot 3
         figure;
         pcolor(lon(:,1:361),lat(:,1:361),100*(squeeze(sqrt(mvz1(5,:,1:361)))-squeeze(sqrt(mvz2(5,:,1:361))))); shading flat;  
         set(gca,'FontS',14); set(gca,'PlotBoxAspectRatio',[0.7 1 1]); box on;
         colormap(colormapA3); hcc=colorbar; set(hcc,'FontS',14);
         caxis(caxisA3);
         title(['diff \sigma\_ssh (cm) ' name1_title ' - ' name2_title ' (' dur_plot ')'],'FontSize',18);
         text(xA3,yA3,labelA, 'HorizontalAlignment','center','FontSize',14); 
         fignameA=['diff_map_var_ssh_' name1 '-' name2 '_' dur_plot '_' day_freq];
         print ('-dpng',fignameA); 

     end
   end

%quit
