function [theta1,maj1,min1,theta2,maj2,min2]=doellipse(cdf1,u1,v1,cdf2,u2,v2) 
%function [theta1,maj1,min1,theta2,maj2,min2]=doellipse(cdf1,u1,v1,cdf2,u2,v2) 
%
% get start and stop times from overlap
%
[start_time,stop_time]=overlap(cdf1,cdf2);
%
%GET DATA FROM CDF FILES
[icyc,ncyc]=mctime(cdf1,start_time,stop_time);
wu=mcvgt(cdf1,u1,icyc,ncyc);
wv=mcvgt(cdf1,v1,icyc,ncyc);
%
[icyc,ncyc]=mctime(cdf2,start_time,stop_time);
u=mcvgt(cdf2,u2,icyc,ncyc);
v=mcvgt(cdf2,v2,icyc,ncyc);
%
% LOWPASS DATA
wu=plfilt(wu);
wv=plfilt(wv);
u=plfilt(u);
v=plfilt(v);
%
% FIND PRICIPAL ELLIPSES
[theta1,maj1,min1]=princax([wu(:) wv(:)]);
[theta2,maj2,min2]=princax([u(:) v(:)]) 
%
% DRAW ELLIPSES
pinc=pi/24;
%ang=-pi:pi/24:pi;
ang= [-pi+pinc -pi-pinc -pi pi pi+pinc pi-pinc NaN 
      -pi/2+pinc -pi/2-pinc -pi/2 pi/2 pi/2+pinc pi/2-pinc];
:pi/24:pi;
 x1=maj1*cos(ang);
 y1=min1*sin(ang);
 x2=maj2*cos(ang);
 y2=min2*sin(ang);
%x1=[-maj1 -maj1 -maj1 maj1 maj1 maj1 NaN -min10kjw1=x1+i*y1;
w1=w1*exp(i*(pi/2-theta1*pi/180));
w2=x2+i*y2;
w2=w2*exp(i*(pi/2-theta2*pi/180));
polar(angle(w1),abs(w1),angle(w2),abs(w2));
grid
  title('Principal current axes');
  text(0.70,0.25,file_lbl(cdf2),'sc');
  text(0.70,0.21,date_lbl(start_time,stop_time),'sc');
  text(0.70,0.17,depth_lbl(cdf2,'east'),'sc');
pause
%if (exist('bin.met')~=2),
%   meta bin
%else
%   meta
%end
