%exploring maximal vertical velocities to compare with ekman 

%some ini
 addpath('funct')
if exist('../data/processed/ref/wmax.mat') ~=2
  T=[]; n=0;
 D=dir('/Volumes/scratch/baedw/data/mod/ref/out/w/*.nc');

 for i=1:length(D)
  display(['loading ' D(i).name])
   ncload(['/Volumes/scratch/baedw/data/mod/ref/out/w/' D(i).name]);
  display('calculating absolute velocity')  
   wt=abs(single(wt))*86400;
  display('massaging calendar data')
   t = get_calendar_date((time./24)  + get_julian_day(1987,1,1,0));
   T = [T; t];
   x=xt_ocean; clear xt_ocean;
   y=yt_ocean; clear yt_ocean;
  display('replaceing dummy values')
   I=find(wt>1e10); wt(I)=NaN; 
  display('finding the ekman velocity')
    wt=max(wt(:,1:10,:,:),[],2);
  display('averaging ekman over a month');
    wt=squee(mean(wt,1));
  %some late ini
    if i==1
     WT = zeros(12,length(y),length(x)); 
    end
  %more calculations
    mo=t(1,2);
    WT(mo,:,:)   = squee(WT(mo,:,:))   + wt(:,:);
 end

   %final calulations
    WT=WT./(length(D)./12);

 save ../data/processed/ref/wmax.mat WT x y t
else
 load ../data/processed/both/wmax.mat
end

keyboard
display('plot')
  figure(1)
   subplot(2,1,1); set(gca,'box','on','linewidth',1.2,'tickdir','out','fontsize',12, ...
                           'xgrid','on','ygrid','on','nextplot','add','xlim',[1 length(DMLDa)])
   plot(DMLDa,'k','linewidth',1.5)
   xlabel('days')
   ylabel('\Delta MLD [K]')
   print -depsc ../ps/dabsEKM_ancy.eps

% climatological monthly sst differences (REF - noED) + => eddies warm || - => eddies cool
  draw_diffsst(x,y,DMLD(7,:,:),[-0.2:0.025:0.2],'July',[12.5 max(x(:))],[min(y(:)) max(y(:))],0)
  print -depsc -r300 ../ps/dabsEKM_jul.eps


  draw_diffsst(x,y,DMLD(11,:,:),[-0.2:0.025:0.2],'November',[12.5 max(x(:))],[min(y(:)) max(y(:))],0)
  print -depsc -r300 ../ps/dabsEKM_nov.eps


 xlim = [12.75 14.5];
 ylim = [55.15 55.5];
  draw_diffek(x,y,DMLD(7,:,:),[-0.2:0.025:0.2],' ',[12.75 14.5],[55.15 55.5],2)
  print -depsc -r300 ../ps/dabsEKM_sw_jul.eps
  print -dtiff -r500 ../ps/dabsEKM_sw_jul.tiff


