%make a movie of absolute velocity in the southern ocean based on aviso satellite data

%define input
 ifil='../../data/processed/aviso_abs_geouv_1993_1998.nc';

%plotting details
 xlims=[0 40];
 ylims=[-45 -30];
 in=[0:0.05:0.8];

%get grid once
 x=ncread(ifil,'NBLONGITUDES');
 y=ncread(ifil,'NBLATITUDES');
 [X,Y]=meshgrid(x,y); 

%some ini
 n=0;
 
 u=ncread(ifil,'U'); 
 v=ncread(ifil,'V');
 u=double((u.^2+v.^2).^0.5); clear v;
 I=find(u<-1e10); u(I)=NaN;

 t=ncread(ifil,'TAXIS');

 for k=122 %1:length(t)
   timeStr=datevec(datenum(1901,1,15)+t(k));
    n=n+1;
    figure; drawnow
         m_proj('Mercator','long',xlims,'lat', ylims);
        %  m_proj('stereographic','lat',-90,'long',0,'radius',60);
          hold on
          [xxtt,yytt]=m_ll2xy(X,Y);
          flat_pcolor(xxtt,yytt,squee(u(:,:,k))'), shading flat;
          amcolormap(jet,in); amcaxis(in);

          [cc]=amcolorbar('horiz',in);
          set(cc,'linewidth',2,'tickdir','out','fontweight','bold', ...
                  'xtick',in(1:2:end),'xticklabel',in(1:2:end),'position', ...
                  [0.130+0.15 0.1100+0.1 0.7750-0.3 0.0611/4], ...
                  'fontsize',10)

          m_grid('box','fancy','tickdir','in','linestyle','none', ...
                 'fontsize',12);

         % m_coast('patch',[0.7 0.7 0.7])
          m_gshhs_f('patch',[0.7 0.7 0.7])
          title(datestr(timeStr,1),'fontsize',14)
          legend('off')
   print -bestfit -dpdf -r300 ../ps/aviso_aghul_3may95.pdf
   eval(['print -dtiff ../tmp/aviso_uabs_' num2str(n+1000) '.tiff'])
  keyboard
  close
end

!rm -f filelist.asc
!ls ../tmp/*.tiff > filelist.asc
!rm -f ../mov/uabs.flc
!ppm2fli -ftifftopnm -s350 -N -g1200x900 filelist.asc ../mov/uabsAviso01.flc
%!rm -f filelist.asc
%!rm ../tmp/*.tiff
