

% Calculate the land mask
varpth=['/d6/haibo/lme/cam5/BLMTRC5CN/ALLFORCEINGS/010'];
xlat=ncread([varpth '/TREFHT/b.e11.BLMTRC5CN.f19_g16.010.cam.h0.TREFHT.085001-184912.nc'],'lat');
xlon=ncread([varpth '/TREFHT/b.e11.BLMTRC5CN.f19_g16.010.cam.h0.TREFHT.085001-184912.nc'],'lon');
sftlf=permute(ncread([varpth '/QSOIL/b.e11.BLMTRC5CN.f19_g16.010.clm2.h0.QSOIL.085001-184912.nc'],'landmask'),[2 1]);
sftlf(sftlf==0)=NaN;

clat=xlat;clon=xlon;


% Load masks
load argentina_mask.mat
load chile_mask.mat


s=load('coast');mlat=s.lat;mlon=s.long;

figure
%h=axesm('MapProjection','eqdcylin','MapLatLimit',[-60 15],'MapLonLimit',[270 330]);
h=axesm('MapProjection','eqdcylin','MapLatLimit',[-60 15],'MapLonLimit',[270 330],...
'grid','on','MLineLocation',[clon(1:72) (clon(73:end)-360)],'PLineLocation',clat,'GLineStyle','-');
pcolorm(xlat,xlon,sftlf)
hold on
pcolorm(xlat,xlon,chl*0)
pcolorm(xlat,xlon,argntn*0.5)
caxis([0 1])
plotm(mlat,mlon,'color',[0 0 0])
set(gca,'FontSize',14)
%colorbar
tightmap
print(['/home/nsteiger/Dropbox/sa-phyda/masks_chile_argentina'],'-dpng','-r300')


