% FS_MAP_WITH_CAST - plot map of the study region
%
%  This script is designed to plot up a map of the 
%  Florida Current study region and add on the cable 
%  locations.  
%

% requires m_map toolbox
% cruise specific?

% 
% VERSION: 
%	$Revision: 1.7 $
%	$Date: 2008/02/20 17:35:05 $
%	$Id: FS_map_with_cast.m,v 1.7 2008/02/20 17:35:05 duncombe Exp duncombe $
%
% CHANGELOG: 
% 

load bathyabaco 
%  load /home/phod/meinen/abaco/bathy/SSbathy_subset
%  lon=xbathy;lat=ybathy;z=SSbathy;clear xbathy ybathy SSbathy

%%%% Locations needed for adding the cable lines

% Eight Mile Rock  (found on internet with google search)
lonEMR=-78.7833;
latEMR=26.5167;

% Jupiter Inlet (found on internet with google search)
lonJI=-80.0634;
latJI=26.9437;

% West Palm Beach (found in my 1950 World Atlas)
lonWPB=-80.0667;
latWPB=26.7000;

% Vero Beach (found in my 1950 World Atlas)
lonVB=-80.4167;
latVB=27.6167;

% Settlement Point (found in my 1950 World Atlas)
lonSP=-79.0000;
latSP=26.7000;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Make the figure
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% fig1=makefigexact4(4.2577,3); % Note this size ratio was chosen to make the map close to Mercator
fig1=makefig;
m_proj('mercator','lat',[25 30],'long',[-82 -76]);
delete(fig1)


%makefigexact4(4.2577,3); % Note this size ratio was chosen to make the map close to Mercator

mymap=gray(20);
mymap(1:6,:)=[];
mymap(end,:)=[];
%  mymap(end,:)=[0 0.6 0];
mymap(end,:)=[1 1 1];
colormap(mymap);


% First plot the topography

contourf(lon,lat,z,[-6000:500:500]);caxis([-6000 500]);hold on
axis([-82 -76 25 30]);
set(gca,'fontsize',14);
shading flat

%% Try adding and filling a coast

[ncst,k,Area]=new_get_coasts('f','C:\matlab\m_map\private\gshhs_f.b');
inan=find(isnan(ncst(:,1)));
%  for i=1:(length(inan)-1)
for i=1:10
  x=(inan(i)+1):(inan(i+1)-1);
  hand(i)=fill(ncst(x,1),ncst(x,2),[0 0.6 0]);hold on
  set(hand(i),'edgecolor',[0 0.6 0]);
end


% Now plot the cable lines

% lhand1=plot([lonWPB lonEMR],[latWPB latEMR],'r-','linewidth',2);
% lhand2=plot([lonVB lonEMR],[latVB latEMR],'b--','linewidth',1);
% lhand3=plot([lonSP lonJI],[latSP latJI],'m-.','linewidth',1);


% hand1a=text(lonSP-0.05,latSP+0.22,'Settlement');
% set(hand1a,'fontsize',11,'color','b','fontweight','bold');
% hand1b=text(lonSP+0.05,latSP+0.05,'Point');
% set(hand1b,'fontsize',11,'color','b','fontweight','bold');
% hand2a=text(lonJI-0.87,latJI+0.15,'Jupiter');
% set(hand2a,'fontsize',11,'color','b','fontweight','bold');
% hand2b=text(lonJI-0.55,latJI-0.05,'Inlet');
% set(hand2b,'fontsize',11,'color','b','fontweight','bold');
% hand3a=text(lonVB-0.55,latVB+0.05,'Vero');
% set(hand3a,'fontsize',11,'color','b','fontweight','bold');
% hand3b=text(lonVB-0.66,latVB-0.12,'Beach');
% set(hand3b,'fontsize',11,'color','b','fontweight','bold');
% hand4a=text(lonWPB-0.70,latWPB-0.05,'West');
% set(hand4a,'fontsize',12,'color','r','fontweight','bold');
% hand4b=text(lonWPB-0.70,latWPB-0.25,'Palm');
% set(hand4b,'fontsize',12,'color','r','fontweight','bold');
% hand4c=text(lonWPB-0.80,latWPB-0.45,'Beach');
% set(hand4c,'fontsize',12,'color','r','fontweight','bold');
% hand5a=text(lonEMR-0.25,latEMR-0.15,'Eight Mile');
% set(hand5a,'fontsize',12,'color','r','fontweight','bold');
% hand5b=text(lonEMR-0.15,latEMR-0.35,'Rock');
% set(hand5b,'fontsize',12,'color','r','fontweight','bold');

% hleg=legend([lhand1 lhand2 lhand3],'Present cable','Future backup cable','Historically used cable');
% 
% set(hleg,'units','inches');
% dumpos=get(hleg,'position');
% set(hleg,'position',[dumpos(1)-3.75 dumpos(2)-0.85 dumpos(3:4)]);

set(gca,'xtick',[-82:2:-76]);
xtl=[['82',setstr(176),'W'];...
     ['80',setstr(176),'W'];...
     ['78',setstr(176),'W'];...
     ['76',setstr(176),'W']];
set(gca,'xticklabel',xtl);

set(gca,'ytick',[26:2:30]);
ytl=[['26',setstr(176),'N'];...
     ['28',setstr(176),'N'];...
     ['30',setstr(176),'N']];
set(gca,'yticklabel',ytl);

% %%%%% Now add the small locator map
% 
% ax=makeaxis(3,4,1.1,1.1);
% 
% jack=plot([-90 -70 NaN NaN],[NaN NaN 20 40],'k-');hold on
% wlhand=world_landmask;
% for i=1:length(wlhand)
%   set(wlhand(i),'facecolor',[0 0.6 0],'edgecolor',[0 0.6 0]);
% end
% clear i
% 
% plot([-82 -76 -76 -82 -82],[25 25 30 30 25],'k-','linewidth',1);
% 
% set(gca,'xtick',[],'ytick',[]);

% Aqui graficamos los vectores de corriente (ver funcion quiver.m) para un
% crucero determinado (ej. dropsonde de 8/31/2005)

drop_cruise='dropsonde_2005_08_31';
phod_dir='\\Phodnet\data\cruisedat\Florida_Current\DROPSONDE\';

a=load([phod_dir, drop_cruise, '/Processed/',drop_cruise,'.dat']); 
% Cast Position
x=a(:,8); % lon_cast
y=a(:,9); %lat_cast
hold on
plot(x,y,'r.')

% % Cast Mean Velocity (Vector)
% U=a(:,15);
% V=a(:,16);
% quiver(x,y,U,V,2)
% hold off
% title('Vertical mean velocities from dropsonde on Aug 31, 2005')

