function [uvbb vv]=cut_back_obs(outfile1,outfile2,ufile,obsfile,timecut,nlon,nlat)


cutat=timecut;

%if you want to cut the background
uvb=load(ufile);

uvbb=uvb(1:(cutat+0)*nlon*nlat,:);

dlmwrite(outfile1,uvbb,'\t');


robs=load(obsfile);

Nf=length(unique(robs(:,2)));

vv=[];
for k=0:Nf-1
    II=find(robs(:,2)==k);
    oob=robs(II,:);
    ooob=oob(1:cutat,:);
    vv=[vv;ooob];
end

dlmwrite(outfile2,vv,'\t');



end