function project_obs(dfname,val,trunstart,tvisstart,drnge)

if nargin<3
  trunstart=0;
end
tn=trunstart;

if nargin<4
  tvisstart=trunstart;
end

if nargin<5
  drnge=[0 inf];
end

% open file

fid=fopen(dfname);

% strip .ind echo

for in=1:15
  fgetl(fid);
end

% get number of drifters

ndrft=fscanf(fid,'%f\n',1);

% Trim values to include only those represented by current drifter file

val=val(1:ndrft);
valrange=[-inf 0:10]*max(val)/10;
if valrange>10
  valrange=ceil(valrange);
end

% DJM clrs=cmap4(1,length(valrange)-1);
clrs=jet(length(valrange)-1)*.99+.01;

% Strip another useless line

fgetl(fid);

% get and plot initial positions

drstart=fscanf(fid,'%f',[5 ndrft])';
ind_drnge=find(drstart(:,5)>=drnge(1)&drstart(:,5)<=drnge(2));
drstart=drstart(ind_drnge,:);
val=val(ind_drnge);

[drstart(:,2),drstart(:,1)]=xy2ll(drstart(:,1:2)*[1;i]);

m=loadgrid('bank150');
[m.y,m.x]=xy2ll(m.x,m.y);
clf

hc=lcontour(m,m.z,[60 100]);
set(hc,'linewidth',1,'color','k');
hc=lcontour(m,m.z,[40 80]);
set(hc,'color',[1 1 1]*.5);
hc=plotbnd(m);
set(hc,'linewidth',2);

axis tight;
grid on
set(gca,'DataAspectRatio',[1 cos(42*pi/180) 1],...
	'ytick',[40:.25:42.5],...
	'xtick',[-69:.25:-66],...
	'yticklabel',...
	str2mat(['40' setstr(176)],'15''','30''','45''',...
		['41' setstr(176)],'15''','30''','45''',...
		['42' setstr(176)],'15''','30'''),...
	'xticklabel',...
	str2mat(['69' setstr(176)],...
		'45''','30''','15''',['68' setstr(176)],...
		'45''','30''','15''',['67' setstr(176)],...
		'45''','30''','15''',['66' setstr(176)]),...
	'box','on',...
	'fontname','times');
xlabel(['longitude (',setstr(176),'W)']);
ylabel(['latitude (',setstr(176),'N)']);
hold on;
plot(drstart(:,1),drstart(:,2),'.',...
	 'color',[1 1 1]*0.8);
hst=plot(drstart(:,1),drstart(:,2),'.',...
	 'color',[1 1 1]*0.5);
axis([-67.9  -67.35   40.95   41.3])

for in=1:length(valrange)-1
  for jn=1:5
    h(in,jn)=plot(nan,nan,'.',...
	       'color',clrs(in,:).^(1/jn));
  end
end
opos=drstart;
drawnow;

% CREATE COLORBAR

ah=gca;
set(ah,'position',get(ah,'position').*[1 1 0.85 1]);
ap=get(ah,'position');
hcb=axes('position',[ap(1)+1.04*ap(3) ap(2) ap(3)*.1 ap(4)]);

xcb=1:2;
ycb=[1:length(valrange)];
[xcbg,ycbg]=meshgrid(xcb,ycb);

[outlines,hsbar]=contourf(xcb,ycb,ycbg,[1:length(valrange)]);

set(hcb,'ticklength',[0 0],...
        'XTick',[],...
        'yTick',1:length(valrange),...
        'yticklabel',valrange,...
        'YAxisLocation','right',...
        'color',get(ah,'color'),...
	'fontname','times',...
	'Tag','colorbar')
for in=hsbar
  set(in,'edgecolor','k')
end
axes(ah);

% Strip 5 more useless lines

for in=1:6
fgetl(fid);
end

tstp=fscanf(fid,'%f',[1 3])*[0;1;0]/86400;
if exist('tvisstart')==1
  in1=(tvisstart-trunstart)/tstp;
  tn=tvisstart;
else
  in1=1;
end

disp('Reading path file; this may take several minutes.')
all_pos=fscanf(fid,'%f',[4*ndrft inf])';

opos=reshape(all_pos(in1,:),[4 ndrft])';
[opos(:,2),opos(:,1)]=xy2ll(opos(:,1:2)*[1;i]);
opos=opos(ind_drnge,:);

age=zeros(length(val),1);
pos=opos;

for in=in1:size(all_pos,1)
  tn=tn+tstp;

  pos=reshape(all_pos(in,:),[4 ndrft])';
  pos=pos(ind_drnge,:);
  
  [pos(:,2),pos(:,1)]=xy2ll(pos(:,1:2)*[1;i]);
  indd=find(pos(:,1:2)*[1;i]==opos(:,1:2)*[1;i]);
  set(hst,'xdata',pos(indd,1),'ydata',pos(indd,2));
  
  ind=find(pos(:,1:2)*[1;i]~=opos(:,1:2)*[1;i]);
  age(ind)=age(ind)+tstp;
  
  for jn=length(valrange)-1:-1:1
    for kn=1:5
      ind=find( age>(kn-1)/2 &...
		val > valrange(jn) & val < valrange(jn+1) );
      set(h(jn,kn),'xdata',pos(ind,1),'ydata',pos(ind,2));
    end
  end
  
  title([datestr(datenum(1999,1,1)+tn),' GMT'])
  drawnow
  jpegwrite(['movframes/IT',...
	     sprintf('%07i',in),'.jpg'],...
	    [640 480])
  opos=pos;
end