%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                    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 plot_FSLE(dirin,year,month,day)
%%
%% script for plotting data of FSLE
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 03/05/16 AD: implemented 
%% 27/07/15 AD: adapted for OSCAHR: plot the SPASSO output files
%% 24/06/13 : andrea.doglioli@univ-amu.fr : first official release
%%
%% Credits: F.Nencioli, A.Doglioli
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function plot_FSLE(fname,threshold)

[fsle_lon, fsle_lat]=load_FSLE(fname,threshold);

hold on

m_plot(fsle_lon, fsle_lat,'.','color',[.5 .5 .5],'markersize',5);

return


load([fname]);

hold on

  [i,j]=find(-60*60*24*lambda>threshold);
  m_plot(lonvv(j),latvv(i),'.','color',[.7 .7 .7],'markersize',3)

return

%%% OLD VERSION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Select the right folder for the FSLE data

%dirin=sprintf('%sMatFiles_%.4d%.2d%.2d/',dirin,year,month,day); 
% To be changed to relative path

%name=sprintf('fsle_%.4d%.2d%.2d.mat',year,month,day);

% Call function to load FSLE_data
[fsle_lon,fsle_lat]=load_FSLE(dirin,name);

m_plot(fsle_lon,fsle_lat,'.','color',[.7 .7 .7],'markersize',5);
%m_contour(fsle_lon,fsle_lat,lambda);

if nargin > 4
    m_text(lon_text,lat_text,['FSLE update: ',name(6:13)],...
           'FontWeight','Bold','Color','k','BackgroundColor',[.9 .9 .9])
end


return
