function oaciplot

FN='mb1';

run /home/ruoying/Software/opnml_matlab5/startup
fg=['../mesh/' FN];
g=loadgrid(fg)
e=g.e';

for k=1:2

 if k==1
  dpost=read_s3r('../output/Tanalysis.s3r');
  dpost_v=read_s3r('../output/Tvariance.s3r');
  fg=['../obs/' FN '.T.s3r'];
  dprior=read_s3r(fg);
  sca=[2 10]; anm=[0 2];
 elseif k==2
  dpost=read_s3r('../output/Sanalysis.s3r');
  dpost_v=read_s3r('../output/Svariance.s3r');
  sg=['../obs/' FN '.S.s3r'];
  dprior=read_s3r(sg);
  sca=[28 35]; anm=[0 5];
 end

 tpost=dpost(21:21:end,3);
 tprior=dprior(21:21:end,3);
 tpost_v=dpost_v(21:21:end,3);

 figure

 subplot(2,3,1);
 patch(g.x(e),g.y(e),tprior(e));
 set(gca,'xtick',[],'ytick',[]);
 shading interp;caxis(sca);
 title('Prior','fontsize',12,'fontweight','bold')
 if k==1, ylabel('surface temperature','fontsize',12,'fontweight','bold'); end
 if k==2, ylabel('surface salinity','fontsize',12,'fontweight','bold'); end

 subplot(2,3,2);
 patch(g.x(e),g.y(e),tpost(e));
 set(gca,'xtick',[],'ytick',[]);
 shading interp;caxis(sca);
 title('Posterior','fontsize',12,'fontweight','bold')

 subplot(2,3,3);
 patch(g.x(e),g.y(e),tpost_v(e));
 set(gca,'xtick',[],'ytick',[]);
 shading interp;caxis(anm);
 title('Posterior standard error','fontsize',12,'fontweight','bold');


 tpost=dpost(1:21:end,3);
 tprior=dprior(1:21:end,3);
 tpost_v=dpost_v(1:21:end,3);

 subplot(2,3,4);
 patch(g.x(e),g.y(e),tprior(e));
 set(gca,'xtick',[],'ytick',[]);
 shading interp;caxis(sca);colorbar 'h'
 if k==1, ylabel('bottom temperature','fontsize',12,'fontweight','bold');end
 if k==2, ylabel('bottom salinity','fontsize',12,'fontweight','bold'); end

 subplot(2,3,5);
 patch(g.x(e),g.y(e),tpost(e));
 set(gca,'xtick',[],'ytick',[]);
 shading interp;caxis(sca);colorbar 'h'

 subplot(2,3,6);
 patch(g.x(e),g.y(e),tpost_v(e));
 set(gca,'xtick',[],'ytick',[]);
 shading interp;caxis(anm);colorbar 'h'
end

 %figure;
 %%j=3089
 %%j=2104;
 %j=1941
 %l=(j-1)*21+1
 %tpost=dpost(l:l+20,3);
 %tpost_v=1.96*sqrt(dpost_v(l:l+20,3));
 %tprior=dprior(l:l+20,3);
 %z=dpost(l:l+20,2);
 %plot(tpost,z,'rx-',tprior,z,'bo-',tpost-tpost_v,z,'k-.',tpost+tpost_v,z,'k-.');
 %legend('posterior','prior')
 %xlabel('T (deg c)');ylabel('z (m)')



