%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                    LATEXtools                         %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  This  file  is  free software ;  it  is distributed  in  %
%%  the hope that  it  will  be  useful,  but  without  any  %
%%  warranty.  You  can  redistribute  it and/or modify  it  %
%%  under  the  terms  of  the  GNU  General Public License  %
%%  as  published  by  the   Free  Software  Foundation  at  %
%%       http://www.gnu.org/copyleft/gpl.html                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% function [time,lon,lat,u,v]=plot_AVISO
%%
%% Plots the current vector from MOOSE radar data
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 18/10/15 : andrea.doglioli@univ-amu.fr : creation
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [time,lon,lat,u,v]=plot_AVISO(fname,myscale,refquiver_lon,refquiver_lat,refquiver_mag)

%fname=uigetfile;
load([fname]);

hold on
%%% to have a scaled vector with respect the legend
if exist('var1','var')
u=var1.u*myscale;
v=var1.v*myscale;
skip=1;

m_quiver(lon(1:skip:end),lat(1:skip:end),u(1:skip:end),v(1:skip:end),0,'color','k','LineWidth',1);

%refquiver_mag=0.5;
%refquiver_lon=8;
%refquiver_lat=44.3;

m_quiver(refquiver_lon,refquiver_lat,refquiver_mag*myscale,0,0,'color','k','LineWidth',1)
m_text(refquiver_lon,refquiver_lat-0.07,[num2str(refquiver_mag),' m/s'],'color','k')

elseif exist('var2','var')

[C,hc]=m_contourf(lon,lat,var2);
set(hc,'EdgeColor','none') 
shading flat

colorbar

else
disp('AVISO velocity not loaded')
end
%h=quiver(lon,lat,u,v,0);
%set(h,'color','k','linewidth',2);


return
