clear all;close all;clc;
% currdir=pwd;
% simdir='d:\Coupling\test_local';

addpath D:\OpenEarthTools\trunk\matlab\
oetsettings('quiet');
wlsettings

xb = xb_getdimensions('d:\Coupling\refrun_metduin\');

x=load('d:\Coupling\refrun_metduin\x.grd'); % vergelijking, interpolatie depXB met base330.dep
y=load('d:\Coupling\refrun_metduin\y.grd');
drawgrid(x,y)

xbo = xb_read_output('d:\Coupling\refrun_metduin\','vars',{'zs','zb','u','v','H'});
zb = xb_get(xbo,'zb');
figure; pcolor(xb.xc,xb.yc,squeeze(zb(1,:,:)')); shading flat;

zb = xb_read_dat('d:\Coupling\refrun_metduin\zb.dat');
zb1 = zb.data(1,2);
zb2 = squeeze(zb1.value(1,:,:)); %weer inlezen op een tijdstap (de laatste van XB sim)
zb2 = zb2';
% figure(5);pcolor(x,y,zb2);axis equal; shading flat;
figure(1);pcolor(xb.x,xb.y,zb2);axis equal; shading flat;

zs = xb_read_dat('d:\Coupling\refrun_metduin\zs.dat');
zs1 = zs.data(1,2);
zs2 = squeeze(zs1.value(50,:,:));
zs2 = zs2';

u = xb_read_dat('d:\Coupling\refrun_metduin\u.dat');
u1 = u.data(1,2);
u2 = squeeze(u1.value(50,:,:));
u2 = u2';

v = xb_read_dat('d:\Coupling\refrun_metduin\v.dat');
v1 = v.data(1,2);
v2 = squeeze(v1.value(50,:,:));
v2 = v2';

figure
subplot(2,2,1)
pcolor(xb.x,xb.y,zb2);shading flat;axis equal; 
subplot(2,2,2)
pcolor(xb.x,xb.y,zs2);shading flat;axis equal;
subplot(2,2,3)
pcolor(xb.x,xb.y,u2);shading flat;axis equal;
subplot(2,2,4)
pcolor(xb.x,xb.y,v2);shading flat;axis equal;

zbcross = xb_read_dat('d:\Coupling\refrun_metduin\zb.dat');
zbcross1 = zbcross.data(1,2);
zbcross2 = squeeze(zbcross1.value(1,:,:)); %weer inlezen op een tijdstap (de laatste van XB sim)
zbcross2 = zbcross2';

delta=zb2-zbcross2;

figure;pcolor(xb.x,xb.y,delta);shading flat;axis equal;

figure;plot(zb2(10:end,200)); hold on
plot(zbcross2(10:end,200),':r')
figure; plot(zb2(1:end,190)-zbcross2(1:end,190));
