
   clear all; close all;

%-------------------------------------------------------------------------------
   root_dir=['/loceanfs/pulsation/cholod/data/MLD_Climato'];

   mld_list = {'mld','mld_smth','mld_raw','mld_dev'};
   file_list = {'mld_DR003_c1m_reg2.0.nc','mld_DT02_c1m_reg2.0.nc','mld_DReqDTm02_c1m_reg2.0.nc'};
   title_list1 = {'MLDR10_3 (m)','MLD_DT02 (m)',''};

   view='peru12';
%  view='zoom1';
%-------------------------------------------------------------------------------

   for num_mld=1:1 
%  num_mld=1;
   mld=char(mld_list(num_mld));
      for num_file=1:2
%     num_file=1
         file=char(file_list(num_file));

         title_list2=regexprep(title_list1,'_','\\_');

         fo=[root_dir '/' file];
 
         no=netcdf(fo,'r');
         lat=no{'lat'}(:);
         lon=no{'lon'}(:);
         mld2=no{mld}(:,:,:);
         ave_mld=squeeze(mean(mld2,1));
         ave_mld(ave_mld>10000)=NaN;

         opengl neverselect % pour pb cartes graphiques

         for num_fig=1:2
%        num_fig=2
            figure(num_fig) ;
            pcolor(lon-360,lat,ave_mld);   
            shading flat;

      switch view
%%% vue zone peru12
         case 'peru12'
            file_name_view1='';
            axis1=[-100 -70 -30 10];
            PlotBoxAspectRatio1=[0.6 1 1];
            caxis1=[0 70]; % pour mld
%%% vue zoom equateur
         case 'zoom1'
            file_name_view1='_zoom1';
            axis1=[-100 -70 -5 5];
            PlotBoxAspectRatio1=[1 0.4 1];
            caxis1=[10 25]; % pour mld
      end

            set(gca,'PlotBoxAspectRatio',PlotBoxAspectRatio1);
            set(gca,'FontS',12);
            caxis(caxis1);         
            axis(axis1);
            if (num_fig == 2)
               shading interp          
            end
            file_string=regexprep(file,'_','\\_');
            title([file_string ' (' mld ')'], 'FontSize',16);
            disp([file ' (' mld ')']);
            hcc=colorbar; set(hcc,'FontS',12);

            if ((num_mld==1) & (num_file==1))
               sav_position=get(gca,'Position');
               sav_outerposition=get(gca,'OuterPosition');
            else
               set(gca,'Position',sav_position);
               set(gca,'OuterPosition',sav_outerposition);
            end

      switch view
      % Pour virer le white space inutile sur les figures générées par matlab en png, jpeg, tiff
      %          (pas le cas en eps mais pas la même qualité et images bcp + lourdes)
%%% vue zone peru12
         case 'peru12'
            set(gca, 'Position', get(gca, 'OuterPosition') - get(gca, 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 1 0; 0 0 0 1]);
	    set(gcf, 'PaperUnits', 'inches');
	    set(gcf, 'PaperSize', [6.25 7.5]);
	    set(gcf, 'PaperPositionMode', 'manual');
	    set(gcf, 'PaperPosition', [0 0 6.25 7.5]);
%%% vue zoom equateur
         case 'zoom1'
            set(gca, 'Position', get(gca, 'OuterPosition') - get(gca, 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 1 0; 0 0 0 1]);
      end

            print ('-dpng',  [ file '-' mld '_' num2str(num_fig) file_name_view1 '.png'])
            print ('-depsc2',[ file '-' mld '_' num2str(num_fig) file_name_view1 '.eps'])
         end

      end
   end

%quit
