%   Powered by He Yanchun, PKU,NZC
%   $Revision: 1.0  $  $Date: 2009/03/27 19:13:41 $

%%
clear all;
close all;

%% Define Constants

%% Define Vars

%% Load Data

% loadfilename.mat b
% dat=importdata('filename.dat');
load grid.mat;
% lat=nc_varget('salt.mnltm.nc','lat');
% lon=nc_varget('salt.mnltm.nc','lon');
% salt=nc_varget('salt.mnltm.nc','salt',[6,0,0,0],[1,1,-1,-1]);
% [6,0,0,0],[1,1,-1,-1]) denote the 7th month,1st level
salt=nc_varget('micom_sss_ltmmean_jul_1948-2007.nc','sss');
salt=double(salt);
salt(find(salt<4))=NaN;   %get rid of the missing value.
salt(end+1,:)=salt(1,:);
plat(end+1,:)=plat(1,:);
plon(end+1,:)=plon(1,:);
lat=plat;
lon=plon;
clear plat plon ;
% var(:,end+1)=var(:,1);
% [lon lat]=meshgrid(lon,lat);
%% Compute


%% Plot Figures

Hm_axes=axesm('MapProjection','eqdcylin');
setm(gca,'Frame','on','MeridianLabel','on',...
	'MLabelParallel','south','MLabelLocation',60,...
	'ParallelLabel','on','PLabelLocation',30,...
	'MapLatLimit',[-90 90],'MapLonLimit',[0 360],'Origin',[0 180 0]);
% pcolorm(lat,lon,squeeze(sst(end,:,:)));shading flat;
% [C Hm_ctourf]=contourfm(lat,lon,squeeze(salt(6,1,:,:)),[-3:3:30]);
pcolorm(lat,lon,salt);
% shading interp;
hold on;

% [C Hm_ctour]=contourm(lat,lon,squeeze(salt(6,1,:,:)));
[C Hm_ctour]=contourm(lat,lon,salt);
set(Hm_ctour,'LineColor','k','LineStyle','-','LineWidth',0.5,...
   'LevelListMode','auto','LevelList',[33.0:.5:39],'ShowText','on',...
   'TextStep',5,'TextList',[33.0:.5:39]);
clabel(C,Hm_ctour);
caxis([33 39])
load Odv
colormap(cmap);
axis tight
set(gcf,'Position',[0 400 1024 768],'Renderer','Painters');
h_cb=colorbar('location','southoutside');
pos=get(h_cb,'position');
pos(2)=pos(2)*0.80;
pos(4)=pos(4)/2; % half height of original size.
set(h_cb,'position',pos)

geoshow('landareas.shp','facecolor',[0.6 0.6 0.6]);
set(gca,'dataaspectratio',[1 1 1]);

textm(-74,5,['max  =',num2str(max(max(salt))),' g/kg']);
textm(-80,5,['min   =',num2str(min(min(salt))),' g/kg']);
textm(-86,5,['mean=',num2str(mean(mean(salt(find(~isnan(salt)))))),' g/kg']);
xlabel('','fontsize',12,'fontweight','bold');
ylabel('','fontsize',12,'fontweight','bold');
title(['Micom Monthly Longterm Mean Salinity (1948-2007)',...
    '@ July (units:psu)'],'fontsize',11,'fontweight','bold');

%% Save the Figures and Data

% save filename.mata b;
% print -dpng -r300 micom_sss_mnltm_july_1948-2007.png
% print -deps -r300 filename.eps
