%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                    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                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Script for draw a geographical map with FSLE manifolds
%%
%% INPUT : coastline .mat file
%%
%% OUTPUT: m_map figure 
%%
%% ALGORITHM: calcuate de projection and
%%            plot
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 03/05/16 AD: new version
%% 24/06/13 : andrea.doglioli@univ-amu.fr : first official release
%%
%% Credits: F.Nencioli, A.Doglioli, L.Rousselet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
help map_FSLE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;close all;
%%
LATEXtools_param
LATEXtools_cruise
%
pipo=['1030';'1031';'1101';'1102';'1103';'1104';'1105';'1106'];
pipo2=['30-oct';'31-oct';'01-nov';'02-nov';'03-nov';'04-nov';'05-nov';'06-nov'];

fname_TSG='TSG/OSCAHR_TSG.mat'

for i=1:8
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
interval_sst=[datenum([pipo2(i,:),'-2015 00:01:00']) datenum([pipo2(i,:),'-2015 23:59:00'])];
fname=[dirin_FSLE filesep '2015',pipo(i,:),'_nrt_med_2014_d0_lambda_only.mat']

%- Plot the figure
h=figure('Visible','on'); hold on;  
m_proj('mercator','lon',[lonmin lonmax],'lat',[latmin latmax])
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
plot_TSG(fname_TSG,'pos',[datenum('30-oct-2015 00:01:00') datenum('06-nov-2015 23:59:00')],'k-')
plot_TSG(fname_TSG,'sst',interval_sst,'k')

% plot the manifolds
plot_FSLE(fname,0.01);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%- Figure title -%
title([fname], 'Interpreter','none')
%
%- NW Mediterranean High Resolution Isobaths -%
plot_BATHY(dirin_BATHY,[200 500]);
%
%- User's High Resolution Coastline -%
m_usercoast(UserCoast,'patch',[.7 .7 .7],'edgecolor','k');
%m_coast('patch',[.7 .7 .7],'edgecolor','k');
%
%- Geographical Axis -%
m_grid('box','fancy','tickdir','in');
xlabel('Longtitude');
ylabel('Latitude');
%
%- Figure Printing -%
print(h,[figdir,'map_FSLE_SSTtsg_',pipo(i,:),'.png'],'-dpng','-r200');
%
end
%
disp(' ');
disp('----- END ---')
