%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                    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 SST satellite
%%
%% INPUT : coastline .mat file
%%
%% OUTPUT: m_map figure 
%%
%% ALGORITHM: calcuate de projection and
%%            plot
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 03/05/16 : andrea.doglioli@univ-amu.fr : first official release
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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'];
pipo=['1103';'1104';'1105';'1106'];
pipo2=['03-nov';'04-nov';'05-nov';'06-nov'];

%fname_TSG='TSG/OSCAHR_TSG.mat'
fname_TSG='TSG/OSCAHR_TSG_corr.mat'

sst_interval=[17 19.5];

for i=1:8
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
time_interval_sst=[datenum([pipo2(i,:),'-2015 00:01:00']) datenum([pipo2(i,:),'-2015 23:59:00'])];

fname_SST_L4=[dirin_SST filesep '2015',pipo(i,:),'000000-GOS-L4_GHRSST-SSTfnd-OISST_UHR_NRT-MED-v02.0-fv02.0.mat']
interval_sst=[datenum([pipo2(i,:),'-2015 00:01:00']) datenum([pipo2(i,:),'-2015 23:59:00'])];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%- User coast in dirin -%
UserCoast='GOL.mat'; % in "sub_functions" directory
UserCoast2='NWMed.mat';
%
%- Plot the figures
m_proj(projection,'lon',[lonmin lonmax],'lat',[latmin latmax])

h=figure('Visible','on'); hold on; 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
plot_SST(fname_SST_L4,sst_interval);

%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',sst_interval,time_interval_sst,'k')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%- 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('Longitude');
ylabel('Latitude');

title(['SST_L4 ',fname_SST_L4(1:8)]);

add_regional_map

print(h,[figdir,'map_SST_TSG_',fname_SST_L4(1:8)],'-dpng','-r200')

%disp('pause');pause
%close

end

