%09/04/2016 AD modified from MVP_plot_transect.m by AdV for compatibility with LATEXtools
%
%
% This file takes L2 transect data and produces the following plots:
%
% 4-part plot:
% [a b]
% [c d]
% a: Transect Lon/Lat on the left. First point in blue, last
% in red. 
% b: Transect's temperature
% c: Transect's salinity
% d: Transect's density
%
% Warning: this function uses m_idist from the m_map toolbox!

%function plot_MVPtransect(pathL2,transectname,color_axes)

clear;close all;
LATEXtools_param
LATEXtools_cruise
MVP_cruise_params;

for itrans=1:11

transchoice=itrans;
transectname=[Transect_Names{transchoice}];%'Transect_03_qc_2'; 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[MVP_lon,MVP_lat,MVP_dist,MVP_pres,MVP_temp,MVP_sal,MVP_dens,MVP_fluo]=load_MVPtransect(pathL2,transectname);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

pipo=0
if pipo==1

h=figure('Visible','off'); hold on; 
m_proj(projection,'lon',[lonmin lonmax],'lat',[latmin latmax])
plot_BATHY(dirin_BATHY,[200 500 1000 2000]);

% Plot satellite tracks
plot_SaralAltika(fname_SaralAltika,lonmin,lonmax,latmin,latmax,'y*-');
plot_SaralAltika(fname_SaralAltika2,lonmin,lonmax,latmin,latmax,'y*-');
%plot_JASON2(fname_jason2,lonmin,lonmax,latmin,latmax,'g*-');

%subplot(2,2,1) % Plot the profile positions...
m_plot(MVP_lon(1),MVP_lat(1),'bx','markersize',10,'linewidth',2); hold on
m_plot(MVP_lon(2:end-1),MVP_lat(2:end-1),'kx');
m_plot(MVP_lon(end),MVP_lat(end),'rx','markersize',10,'linewidth',2);
xlabel('Longitude '); ylabel('Latitude ');
title([transectname,' Positions'],'Interpreter','none');

%- User's High Resolution Coastline -%
m_usercoast(UserCoast,'patch',[.7 .7 .7],'edgecolor','k');
%- Geographical Axis -%
m_grid('box','fancy','tickdir','in');
xlabel('Longtitude');
ylabel('Latitude');
%
print(h,[figdir,'MVP_',transectname,'_positions'],'-dpng','-r200')
%close
end
%%%%%%%%%


ii = find(~isnan(MVP_temp(:)));

for ifig=2:5

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

%subplot(2,2,2) % Plot the temperature...
if ifig==2
  varname='Temperature'
  scatter(MVP_dist(ii),MVP_pres(ii),30,MVP_temp(ii),'filled');
%  contourf(MVP_dist,MVP_pres,MVP_temp);
  colormap jet
elseif ifig==3
  varname='Salinity'
  scatter(MVP_dist(ii),MVP_pres(ii),30,MVP_sal(ii),'filled');
%  contourf(MVP_dist,MVP_pres,MVP_sal);
  colormap jet
elseif ifig==4
  varname='Density'
  scatter(MVP_dist(ii),MVP_pres(ii),30,MVP_dens(ii),'filled');
%  contourf(MVP_dist,MVP_pres,MVP_dens);
  colormap autumn
elseif ifig==5
  varname='Fluo'

dist=MVP_dist(ii);
pres=MVP_pres(ii);
fluo=MVP_fluo(ii);

iii=find(fluo<0.2 & fluo>0.01);

 % scatter(MVP_dist(ii),MVP_pres(ii),5,fluo(ii),'filled');
 scatter(dist(iii),pres(iii),30,fluo(iii),'filled');

%  contourf(MVP_dist,MVP_pres,MVP_fluo);
  colormap default
end
%  plot(MVP_dist(ii),MVP_pres(ii),'m.');

daspect([1 8 1]) 
%axis([-1 max(MVP_dist(ii))+1 0 presMax]) 
axis([-1 max(MVP_dist(ii))+1 0 60]) 
%axis([-1 max(MVP_dist(ii))+1 60 presMax]) 
axis ij;

xlabel('Distance (km) '); 
ylabel('Pressure (dBar) '); 
title([transectname,'   ',varname],'Interpreter','none');
colorbar; 
%caxis([color_axes(1,1) color_axes(1,2)]);

%print(h,[figdir,'MVP_',transectname,'_',varname],'-dpng','-r200')
print(h,[figdir,'MVP_',transectname,'_0-60_',varname],'-dpng','-r200')
%print(h,[figdir,'MVP_',transectname,'_60-350_',varname],'-dpng','-r200')

end%for ifig

end%for itrans=5:11

%%%%%%%%%

