addpath ~/matlab/m_map
addpath ~/matlab/mats
addpath ~/matlab/tools/cbrewer/

%
CNAM0='NBF1850OC_f19_tn11_02';
CNAM='NBF1850_f19_tn11_test_mis3b';
%CNAM='NBF1850OC_f19_tn11_01_115ka';
YEAR1=1800;
YEARN=1999;

%
if_save_fig=0;

%
caxiss=-60:10:60;
Dcaxiss=[-15 15];
range=[-90 0 20 70];
%range=[-70 20 40 80];

%
YTAG=sprintf('%4.4i-%4.4i',YEAR1,YEARN);
Ostrmf=['strmf_' CNAM '-' CNAM0 '_' YTAG];

% grid info
fgrid='../../micom_hydrography/Data/grid.nc';
plon=ncread(fgrid,'plon');plat=ncread(fgrid,'plat');
x=plon;x=x(250:end,:); x(x<0)=x(x<0)+360;plon(250:end,:)=x;

%load data
load(['../Data' filesep 'strmf_' CNAM '_' sprintf('%4.4i',YEAR1) '-' sprintf('%4.4i',YEARN) '.mat'])
strmf1=strmf/1.e9;
sss1=strmf1(20:100,240:330); % the NA region;

load(['../Data' filesep 'strmf_' CNAM0 '_' sprintf('%4.4i',YEAR1) '-' sprintf('%4.4i',YEARN) '.mat'])
strmf0=strmf/1.e9;
sss0=strmf0(20:100,240:330); % the NA region;

Dstrmf=strmf1-strmf0;
%
%-------------------------------------------------------------
%
ff=figure;set(ff,'paperunits','inches','paperposition',[1,1,3,4]);set(0, 'DefaultAxesFontName', 'AvantGarde');
%m_proj('lambert conformal conic','lon',range(1:2),'lat',range(3:4),'rec','off');
m_proj('mercator','lon',range(1:2),'lat',range(3:4));
m_contour(plon',plat',strmf1','levellist',caxiss(find(caxiss<=0)),'color','k','linewidth',0.6,'linestyle','-');
hold on;
m_contour(plon',plat',strmf1','levellist',caxiss(find(caxiss>0)),'color',0.7*ones(1,3),'linewidth',0.6,'linestyle',':');
hold on;
%m_contour(plon',plat',strmf','levellist',0,'color','k','linewidth',1.2);
m_contour(plon',plat',strmf0','levellist',caxiss(find(caxiss<=0)),'color','r','linewidth',0.6,'linestyle','-');
hold on;
m_contour(plon',plat',strmf0','levellist',caxiss(find(caxiss>0)),'color',[255 153 153]/255,'linewidth',0.6,'linestyle',':');
set(gca,'tickdir','out','xminortick','on','yminortick','on','fontsize',8);
   
%nnn=15*2; 
%caxis(Dcaxiss);cmap=cbsafemap(nnn,'RdBu');cmap(nnn/2,:)=[1 1 1];cmap(nnn/2+1,:)=[1 1 1];colormap(cmap);
%aa=colorbar;set(aa,'position',[0.93 0.35 0.01 0.3],'fontsize',6,'ticklength',4*get(aa,'ticklength'));xlabel(aa,'(Sv)');
%title({CNAM,['[' sprintf('%3.1f',max(sss1(:))) ', ' sprintf('%3.1f',min(sss1(:))) '] Sv' ]},'interpreter','none','fontsize',12);
    
m_coast('patch',[0.6 0.6 0.6],'linewidth',0.2);
m_grid('xtick',-90:30:0,'yticklabel',[],'fontname','avantgarde');

%
if if_save_fig
  print('-dpng','-r600',[Ostrmf '.png']);
  print('-depsc',[Ostrmf '.eps']);
end

