function [r,theta,w1,w2]=bcomcor(cdf1,u1s,v1s,cdf2,u2s,v2s,start,stop);
%function [r,theta,w1,w2]=bcomcor(cdf1,u1,v1,cdf2,u2,v2);
% or
%function [r,theta]=bcomcor(cdf1,u1,v1,cdf2,u2,v2,start_time,stop_time);
%complex correlations for data in cdf files
% example: [a]=bcorr('data1.cdf','east','north','data2.cdf','east','north');
%
% theta positive means that w2 is theta degrees to the right of w1
%
if nargin==6,
  [icyc1,ncyc1,icyc2,ncyc2]=like_cyc(cdf1,cdf2);
else
  [icyc1,ncyc1]=mctime(cdf1,start,stop);
  [icyc2,ncyc2]=mctime(cdf2,start,stop);
end
u1=mcvgt(cdf1,u1s,icyc1,ncyc1);
v1=mcvgt(cdf1,v1s,icyc1,ncyc1);
u2=mcvgt(cdf2,u2s,icyc2,ncyc2);
v2=mcvgt(cdf2,v2s,icyc2,ncyc2);
u1=plfilt(u1);
v1=plfilt(v1);
%princax1=princax([u1 v1])
u2=plfilt(u2);
v2=plfilt(v2);
%princax2=princax([u2 v2])
w1=u1(:)+i*v1(:);
w2=u2(:)+i*v2(:);
a=corrcoef([w1 w2]);
r=abs(a(2,1));
theta=angle(a(2,1))*180/pi;
