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

clear all;
close all;

%% Define Constants

%% Define Vars

%% Load Data
mld=nc_varget('micom_mxld_ltmmean_jan.nc','mxld');
% lat=nc_varget('mld_DReqDTm02.nc','lat');
% lon=nc_varget('mld_DReqDTm02.nc','lon');
load grid.mat plat plon ;
% [lon lat]=meshgrid(lon,lat);

mld(find(mld<20))=NaN;   %get rid of the missing value.
mld(end+1,:)=mld(1,:);
plat(end+1,:)=plat(1,:);
plon(end+1,:)=plon(1,:);
lat=plat; lon=plon;
clear plat plon;
%% Compute ***

% var=squeeze(mld(7,:,:));  %plot these value
var=mld;
clear mld;
%% Plot Figures
axesm 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,var);shading interp;
% [C Hm_ctour]=contourm(lat,lon,squeeze(mld(3,:,:)));
% set(Hm_ctour,'LineColor','k','LineStyle','-','LineWidth',0.5,...
%    'LevelListMode','auto','LevelList',[0:100:400],'ShowText','on',...
%    'TextStep',5,'TextList',[0:100:400]);
caxis([0 400]);
load Odv;
colormap(cmap);
axis tight
set(gcf,'Position',[0 400 1024 768]);
h_cb=colorbar('location','southoutside');
pos=get(h_cb,'position');
pos(2)=pos(2)*0.85;
pos(4)=pos(4)/2; % half height of original size.
set(h_cb,'position',pos)

textm(-74,5,['max  =',int2str(max(max(var))),' m']);
textm(-80,5,['min   =',int2str(min(min(var))),'  m']);
textm(-86,5,['mean=',int2str(mean(mean(var(find(~isnan(var)))))),'  m']);
xlabel('','fontsize',12,'fontweight','bold');
ylabel('','fontsize',12,'fontweight','bold');
title(['MICOM Mixed Layer Depth (MLD) Longterm Monthly Mean @ Jan',...
    ' (unit:meter)'],'fontsize',12,'fontweight','bold');

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

%% Save the Figures and Data

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