%----------------------------------------------------------
  function [Ha,Za]=dipole(x,Im,Ie,m,z);
% Computes total field anomaly due to a uniformly magnetized 
% sphere (dipole) along a transect directly over the dipole.
% Inputs are:
% x=vector of positions over the dipole (x=0) from S (x<0) to N (x>0)
% Im= inclination of magnetization
% Ie= inclination of the Earth's field
% m= magnetic dipole moment
% z= depth of dipole center
% Outputs are:
% Ha, Za=horizontal and vertical components of the total field
%        anomaly along the positions x
%----------------------------------------------------------
C=1e-7 ;		%henry/m or N/A^2
C=C.*1e9;               %nT

thet_minus_I=atan(z./x);

r=sqrt(x.^2+z.^2);

thet=thet_minus_I+Im;

Br=2.*C.*m.*cos(thet)./(r.^3);
Bt=C.*m.*sin(thet)./(r.^3);

Ha=Br.*cos(thet_minus_I)-Bt.*sin(thet_minus_I);
Za=-(Br.*sin(thet_minus_I)+Bt.*cos(thet_minus_I));


return;
