load swfl_coast.mat;
lon_coast=lon;
lat_coast=lat;



cd ../OUTDRY8FebSW
fn='calus2008_flt.nc'


%open float file, get coordinates of trajectories
% nc=netcdf(fn);
% x=nc{'x'}(2:end,:);  %last index for for the number of floats released
% y=nc{'y'}(2:end,:);
% close(nc);

x_=nc_varget(fn,'lon');
x=x_(2:end,:);

y_=nc_varget(fn,'lat');
y=y_(2:end,:);

z_=nc_varget(fn,'depth');
z=z_(2:end,:);

dstart=nc_varget(fn,'dstart');
ocean_time=nc_varget(fn,'ocean_time');
ocean_time=ocean_time(2:end);

cd ../analout


save floatdat_dry8SW x y z ocean_time lat_coast lon_coast


%load floatdat_3

% %check initial depths,  many NaNs at beginning, values start at t=25
% 
% figure;
% 
% for t=1:length(ocean_time),
% plot(z(t,:),'r.')
% title(['Depths at time ' num2str(t)])
% pause
% end



% %plot initial positions
% figure;
% plot(lon_coast, lat_coast)
% dasp(26)
% pause %for zoom
% hold on
% 
% plot(x(25,1:697),y(25,1:697),'r.')
% title('Initial Float Positions, 1st 25 steps NaN, 1st 100 locs=0')


if 0,  %plots

jd=datenum(1968,5,24)+ocean_time./(3600.*24);


%plot artificial reef floats
figure;


plot(lon_coast, lat_coast)
dasp(26)
pause %for zoom

xlimp=get(gca,'xlim');
ylimp=get(gca,'ylim');
%hold on
ind=1:657; %calus
%ind=658:897; %reef floats

for t=25:length(ocean_time)-2,
    if t<=30,
        
    plot(lon_coast, lat_coast,'k-',x(t,ind),y(t,ind),'r.')%,x(t,50),y(t,50),'b.')
    %set(gca,'xtick',xtickp,'ytick',ytickp)
    title(datestr(jd(t)))
    axis([xlimp ylimp])
    dasp(26)
    else,
        plot(lon_coast, lat_coast,'k-',x(t,ind),y(t,ind),'r.',...
            x(t-5:t-1,ind),y(t-5:t-1,ind),'b.')%,x(t,50),y(t,50),'b.')
        %set(gca,'xtick',xtickp,'ytick',ytickp)
        axis([xlimp ylimp])
        dasp(26)
        title(datestr(jd(t)))
    end
    pause(0.1)
end


%plot Calusa floats
figure;


plot(lon_coast, lat_coast)
dasp(26)
pause %for zoom

xlimp=get(gca,'xlim');
ylimp=get(gca,'ylim');
%hold on

for t=25:length(ocean_time)-2,
    if t<=30,
        
    plot(lon_coast, lat_coast,'k-',x(t,1:654),y(t,1:654),'r.')%,x(t,50),y(t,50),'b.')
    %set(gca,'xtick',xtickp,'ytick',ytickp)
    title(datestr(jd(t)))
    axis([xlimp ylimp])
    dasp(26)
    else,
        plot(lon_coast, lat_coast,'k-',x(t-5:t-1,1:654),y(t-5:t-1,1:654),'b.',...
            x(t,1:654),y(t,1:654),'r.')%,x(t,50),y(t,50),'b.')
        %set(gca,'xtick',xtickp,'ytick',ytickp)
        axis([xlimp ylimp])
        dasp(26)
        title(datestr(jd(t)))
    end
    pause(0.1)
end

end  %end plots
