% function R = read_surface_extract(day,REstar,Bo,time)
%
%  reads in the raw surface extract file for a particular simulation and time

function R = read_surface_extract(day,REstar,Bo,time)

if day==18,  %day = 9;   
    dirstart = 'RE';   %
elseif day==9 || day==31,
    dirstart = 'shoal_RE';
else
    disp('*** Bad day to read_surface_extract() ***')
    R=[];
    return
end;

if time<1000,
    time = time+1001;
end;

if (time<1000 | time>1030)
    disp('*** Bad time to read_surface_extract() ***')
    R = [];
    return
end;
prefix=sprintf('/home/kghanson/basilisk/shoaling/runs/test_2022_11_%02d/%s%d_BO%d/shoal_dump',day,dirstart,REstar,Bo);

results_file = sprintf('%s/results%.3f_0.dat',prefix,time);

R = load( results_file);

return
%R2 = load( results_file2);

figure(1),clf
plot(R1(:,3),R1(:,4),'k.',R2(:,3),R2(:,4),'r.')
%scatter(R1(:,3),R1(:,4),[],R1(:,8),'.')
grid
%hold on
%scatter(R2(:,3),R2(:,4),[],R2(:,8),'o')
%colorbar('vert')
axis([39 43  -0.2 0.8])
xlabel('x/h')
ylabel('z/h')
stitle = sprintf('REstar = (%d, %d) (black,red): Bo=%d: moment of impact: t1=%.3f, t2=%.3f',REstar1,REstar2,Bo1,tbreak1-1000,tbreak2-1000);
title(stitle)
%title(sprintf('ind = %d,  file = %s',ind,DD(ind).name))
%pause(0.02)


% DD = dir( sprintf('%s/*.dat',prefix));
% 
% 
% for ind=350:450,
% R = load( sprintf('%s/%s',DD(ind).folder,DD(ind).name));
% 
% scatter(R(:,3),R(:,4),[],R(:,8),'.')
% grid
% colorbar('vert')
% axis([0 60 -0.2 0.8])
% title(sprintf('ind = %d,  file = %s',ind,DD(ind).name))
% pause(0.02)
% end;
