% map_monterey.m
% Build figure maps for CPF
clear;
% ***********************************************************************
% SET NAMES & PATHS
% ***********************************************************************
parsed = '2016Jul12';
path =    sprintf('../../%s/parsed',parsed);
in_mat = sprintf('%s/CPF%s_GPS.mat',path,parsed);
load(in_mat);
%data_dir = 'C:\Users\jplant\Documents\MATLAB\Tuna\data\';
%data_dir = '.';
%cd(data_dir); % Switch to map directory


%range1 = [35.6 37.9 -123.25 -121]; % BIG
%range2 = [36.6 37.0 -122.25 -121.77]; % ZOOM
%range2 = [24.8 25.4 -81.14 -80.26];
lonmin = -123.0;
lonmax = -121.77;
latmin = 36.5;
latmax = 37.0;
maxP = -1000;

%Extract topograpy data
% mbay      = getbathy(range1, 5); % get topo data from etopo2
% mbay_zoom = getbathy(range2, 5); % get topo data from local netcdf
%  
% save mbay_mapdata

%pause

if exist('mbay','var') ~=1 % var loaded in the work space
   load mbay_mapdata.mat;
end
load mbay_colormaps
% ************************************************************************
% ************************************************************************
% BUILD THE FIGURES IN 2 PARTS. THIS IS ONE WAY TO PRESERVE DIFFERENT
% COLORMAPS FOR DIFFERNT AXES & PLOTS WITHIN A FIGURE WINDOW (TIP FROM JOHN RYAN).
% FIRST BUILD TOPO MAPS WITH ONE COLORMAP FOR PLOT BACKGROUNDS & SAVE AS
% JPEG. Then paste the JPEG image into the axes before plotting with
% differnt colormap

T1 = mbay.topo >= 0; % Mask out the land
mbay.topo(T1) = 100;

T2 = mbay_zoom.topo >= 0; % Mask out the land
mbay_zoom.topo(T2) = 100;

T3 = mbay_zoom.topo <= maxP; % Mask out the land
mbay_zoom.topo(T3) = maxP; 


% % MONTEREY JPEG
% figure(1) % MONTEREY  LOCATION MAP
% %clevs =-6500:500:0;
% contourf(mbay.lon,mbay.lat,mbay.topo,30,'linecolor','none');
% 
% mbay_ax = [xlim ylim]; % get axis bounds for later
% caxis([min(mbay.topo(:)) 0]);
% set(gcf,'Colormap',mbay_cmap);%,'Menubar','none','ToolBar','none')
% 
% 
% set(gca,'XLim',range1(3:4),'YLim',range1(1:2));%, ...
% %     'XTick',[-85 -80 -75 -70], ...
% %     'Ytick',[22 25 28 31]);

% ************************************************************************% FLORIDA ZOOM JPEG
figure; % MONTEREY  LOCATION MAP
clevs = -1000:100:0;
ax1=contourf(mbay_zoom.lon,mbay_zoom.lat,mbay_zoom.topo,40);%,'linecolor','none');
%mbay_zoom_ax = [xlim ylim]; % get axis bounds for later
set(gca,'xlim',([lonmin lonmax]),'ylim',([latmin latmax]));
%caxis([min(mbay_zoom.topo(:)) 0]);
caxis([maxP 0]);
set(gcf,'Colormap',mbay_cmap);%,'Menubar','none','ToolBar','none')
%, ...
%     'XTick',[-85 -80 -75 -70], ...
%     'Ytick',[22 25 28 31]);
cb = colorbar;
set(cb,'ytick',[-1000 -800 -700 -600 -500 -400 -300 -200 -100 -75 -50 -25 0]);

x = [-122.33 -122.55];
y = [36.95 36.55];
hold on
plot (x,y,'r-');
plot (x,y,'rx');



