


TIDE_ELL calculates tidal ellipse parameters from TIDE_FIT output.
TIDE_ELL(ucoef,periods) computes the tidal ellipse parameters from the
TIDE_FIT output "ucoef" for the components specified in "periods",i.e.,
[ucoef,unew]=tide_fit(jd,uv,periods,goplot)
ell=tide_ell(ucoef,periods)
where
ell(:,1) = constitutent period(s)in hr.
ell(:,2) = umaj = major axis.
ell(:,3) = umin = minor axis, where the sign indicates the
rotation of the ellipse. A positive sign
of umin indicates counterclockwise rotation.
ell(:,4) = inc = counterclockwise inclination from
positive x axis (degrees). The inclination
will always be in the upper half plane [0:pi].
ell(:,5) = phase = phase relative to t=0 (degrees).

0001 function ell=tide_ell(ucoef,periods) 0002 % TIDE_ELL calculates tidal ellipse parameters from TIDE_FIT output. 0003 % TIDE_ELL(ucoef,periods) computes the tidal ellipse parameters from the 0004 % TIDE_FIT output "ucoef" for the components specified in "periods",i.e., 0005 % 0006 % [ucoef,unew]=tide_fit(jd,uv,periods,goplot) 0007 % ell=tide_ell(ucoef,periods) 0008 % 0009 % where 0010 % ell(:,1) = constitutent period(s)in hr. 0011 % ell(:,2) = umaj = major axis. 0012 % ell(:,3) = umin = minor axis, where the sign indicates the 0013 % rotation of the ellipse. A positive sign 0014 % of umin indicates counterclockwise rotation. 0015 % ell(:,4) = inc = counterclockwise inclination from 0016 % positive x axis (degrees). The inclination 0017 % will always be in the upper half plane [0:pi]. 0018 % ell(:,5) = phase = phase relative to t=0 (degrees). 0019 0020 % Uses notation of M.G.G FOREMAN'S (1978) least squares harmonic 0021 % analysis. Adapted from R. Signell's TIDE_ELL. 0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0023 % 5/20/98: 0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0025 0026 % convert input into format for tide_ell 0027 periods=periods(:); 0028 NC=length(periods); 0029 0030 cx=zeros(NC,1); 0031 sx=cx;cy=cx;sy=cx; 0032 0033 for nc=1:NC 0034 cx(nc)=ucoef(2*(nc-1)+2,1); 0035 sx(nc)=ucoef(2*(nc-1)+3,1); 0036 cy(nc)=ucoef(2*(nc-1)+2,2); 0037 sy(nc)=ucoef(2*(nc-1)+3,2); 0038 end 0039 0040 % begin tide_ell 0041 [imax,jmax]=size(cx); 0042 if imax>jmax 0043 cx=cx'; sx=sx'; cy=cy'; sy=sy'; 0044 end 0045 0046 template=ones(size(cx))*NaN; 0047 umaj=template;umin=template;inc=template;phase=template; 0048 ell=zeros(length(cx),4); 0049 0050 ind=find(~isnan(cx)); 0051 cx=cx(ind);sx=sx(ind);cy=cy(ind);sy=sy(ind); 0052 0053 p=(cx+sy)/2+i*(cy-sx)/2; 0054 m=(cx-sy)/2+i*(cy+sx)/2; 0055 0056 ap=abs(p); 0057 epsp=angle(p); 0058 0059 am=abs(m); 0060 epsm=angle(m); 0061 0062 umaj(ind)=ap+am; 0063 umin(ind)=ap-am; 0064 0065 ieps=find((epsp+epsm)<0); % choose inc to range from [0:pi] 0066 0067 if length(ieps)>1 0068 epsp(ieps)=epsp(ieps)+2*pi*ones(size(ieps)); 0069 else 0070 epsp(ieps)=epsp(ieps)+2*pi; 0071 end 0072 inc(ind)=.5*(epsp+epsm)*180/pi; 0073 phase(ind)=-.5*(epsp-epsm)*180/pi; 0074 ipha=find(phase<0); 0075 phase(ipha)=phase(ipha)+360; 0076 ell=[umaj(:) umin(:) inc(:) phase(:)]; 0077 0078 ell=[periods ell];