%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                    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 drawing a geographical map with satellite CHL-a  
%% and CHL-a from onboard fluorimeter
%% 
%% INPUT : coastline .mat file
%%         colormap_Pierre.txt
%%
%% OUTPUT: PNG file with a m_map plot
%%
%% ALGORITHM: computation of the projection and plotting
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% 03/05/16 AD: new version
%% 24/06/13 : andrea.doglioli@univ-amu.fr : first official release
%%
%% Credits: F.Nencioli, A.Doglioli, L.Rousselet
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;close all;
%%
scriptname=mfilename;eval(['help ',scriptname]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
LATEXtools_param
LATEXtools_cruise
%
date_num =['1021';'1022';'1023';'1025';'1026';'1028';'1029';'1030';'1031';'1101';'1102';'1103';'1104';'1105';'1106'];
date_txt=['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'];

fname_TSG='TSG/OSCAHR_TSG_corr.mat'

chl_interval=[0.1 0.34];
chl_interval=log(chl_interval);

for i=8:15
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fname_CHL_L3=['2015',date_num(i,:),'_d-OC_CNR-L3-CHL-MedOC3AD4_A_1KM-MED-NRT-v02.mat']


time_interval=[datenum([date_txt(i,:),'-2015 00:01:00']) datenum([date_txt(i,:),'-2015 23:59:00'])];

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

plot_CHL(fname_CHL_L3,chl_interval);

if i>9 %%%only second leg
   plot_TSG(fname_TSG,'chla',chl_interval,time_interval,'k')
end%if
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%- Figure title -%
title([date_txt(i,:)], 'Interpreter','none')

%- User's High Resolution Coastline -%
m_usercoast(UserCoast,'patch',[.7 .7 .7],'edgecolor','k');

%- NW Mediterranean High Resolution Isobaths -%
plot_BATHY(dirin_BATHY,[200 500 1000 2000]);

%- Geographical Axis -%
m_grid('box','fancy','tickdir','in');
xlabel('Longtitude');
ylabel('Latitude');

%- ColorMap
mycmap=load('colormap_Pierre.txt');
set(h,'Colormap',mycmap);

%- Some customing
add_reference_frame

add_regional_map

%- Figure Printing -%
print(h,[figdir,scriptname,'_',date_num(i,:),'.png'],'-dpng','-r200');
%
end
%
disp(' ');
disp('----- END ---')

