%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                    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 =['1021';'1022';'1023';'1025';'1026';'1028';'1029';'1030';'1031';'1101';'1102';'1103';'1104';'1105';'1106'];
pipo2=['21-oct';'22-oct';'23-oct';'25-oct';'26-oct';'28-oct';'29-oct';'30-oct';'31-oct';'01-nov';'02-nov';'03-nov';'04-nov';'05-nov';'06-nov'];

Transect_Names = {'transect1-Tstart-T0' 'transect2-T0-T1'       'transect3-T1-T3'     'transect4-T3-T5'      'transect5-T5-T0'       'transect6-T0-T13'     'transect7-T13-T14'    'transect8-T14-T15'    'transect9-T15-T7'     'transect10-T7-T14'    'transect11-T14-T16'   'transect12-T16-T17'   'transect13-T17-T9'    'transect14-T9-T15'    'transect15-T15-T18'   'transect16-T18-T19'   'transect17-T19-T20'   'transect6-7-8-9'};

Transect_Start = {'30-Oct-2015 00:00:00' '30-Oct-2015 09:50:00' '30-Oct-2015 14:31:19' '30-Oct-2015 23:49:11' '31-Oct-2015 06:26:39' '03-Nov-2015 06:55:00' '03-Nov-2015 16:22:47' '03-Nov-2015 20:31:25' '03-Nov-2015 23:21:47' '04-Nov-2015 02:52:04' '04-Nov-2015 08:52:09' '04-Nov-2015 15:30:00' '04-Nov-2015 20:07:07' '04-Nov-2015 23:30:00' '05-Nov-2015 07:40:00' '05-Nov-2015 17:26:00' '05-Nov-2015 20:30:00' '03-Nov-2015 06:55:00'};

Transect_Stop =  {'30-Oct-2015 05:44:00' '30-Oct-2015 12:05:00' '30-Oct-2015 23:22:06' '31-Oct-2015 05:59:18' '31-Oct-2015 11:34:54' '03-Nov-2015 15:17:00' '03-Nov-2015 18:05:16' '03-Nov-2015 23:02:43' '04-Nov-2015 02:25:04' '04-Nov-2015 06:23:39' '04-Nov-2015 11:16:51' '04-Nov-2015 16:45:00' '04-Nov-2015 22:55:40' '05-Nov-2015 05:00:00' '05-Nov-2015 09:30:00' '05-Nov-2015 19:34:00' '06-Nov-2015 01:46:00' '04-Nov-2015 02:25:04'};

fname_ADCP='ADCP_STA_30pgood';

fname_CYTO=[dirin_CYTO filesep 'OSCAHR_CS_Cyto_Abundances.mat'];

mygroup='ProchloNml';
mygroup='PicoTotalNmL';


%- Options
mycolor=['r';'b';'k';'m'];
%chosen_depth=-18;
myscale=0.3;
legend_unit=0.2;
legend_lon=7.2;
legend_lat=44;

%for i=12:14
%pipo2(i,:)
%time_interval=[datenum([pipo2(i,:),'-2015']) datenum([pipo2(i,:),'-2015'])+1];
%time_interval=[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'];

for transchoice=7:14

time_interval=[datenum(Transect_Start(transchoice)) datenum(Transect_Stop(transchoice))]

daymonth=datestr(round(mean(time_interval)),'mmdd')

fname=[dirin_FSLE filesep '2015',daymonth,'_nrt_med_2014_d0_lambda_only.mat'];



%- Plot the figure
h=figure('Visible','off'); hold on;  
m_proj('mercator','lon',[lonmin lonmax],'lat',[latmin latmax])
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%

plot_ADCP(dirin_ADCP,fname_ADCP,time_interval,myscale,'r',legend_unit,legend_lon,legend_lat,-18);
plot_ADCP(dirin_ADCP,fname_ADCP,time_interval,myscale,'b',legend_unit,legend_lon,legend_lat,-34);

plot_CYTO(fname_CYTO,mygroup,time_interval,'k');

% plot the manifolds
plot_FSLE(fname,0.01);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%- Figure title -%
title(daymonth, '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_ADCP_CYTO_',Transect_Names{transchoice},'.png'],'-dpng','-r200');
%
end
%
disp(' ');
disp('----- END ---')
