

REstarA = [2400 0 -1800];
Bo = 1000;
%t = 1020.1;
X0 = 15;
C_soliton = 1.2649110640673518
mid_str = 'shoal_RE';


for k=1:3,
    REstar = REstarA(k);
    prefix = sprintf('/home/kghanson/basilisk/shoaling/runs/test_2022_11_09/%s%d_BO%d/shoal_dump',mid_str,REstar,Bo);
    
    for index=1:560,
    [~,t]=return_basilisk_time(index);

    [Xs,Ys,R] = read_processed_surface_extract(9,REstar,Bo,t);
 

    Xsoliton = X0 + (t-1001.0)*C_soliton;
    xmin = Xsoliton-6;
    xmax = Xsoliton+8;

    ii = find (Xs>=xmin  & Xs<=xmax);

    Xq = Xs(ii);
    Yq = Ys(ii);


    Xmid = 0.5*(Xq(1:end-1)+Xq(2:end));
    Ymid = 0.5*(Yq(1:end-1)+Yq(2:end));

    dYq = diff(Yq);
    dXq = diff(Xq);

    Delta = sqrt( dYq.^2 + dXq.^2);

    hist(Delta,20);

    theta = atan2( diff(Yq), diff(Xq));

    nd = length(theta);

    del = 0.01;

    for i=1:nd,
      G = [ cos(theta(i))  -sin(theta(i));  sin(theta(i)) cos(theta(i))];
      T = G * [0 del]';
      Xpq(i) = T(1) + Xmid(i);
      Ypq(i) = T(2) + Ymid(i);    
    end;


    Tpq = [Xpq' Ypq'];
    sfile = sprintf('%s/surf_dyn_%.3f.txt',prefix,t);
    disp(sfile)
    save(sfile,'Tpq','-ascii')

  end;
end;
