c
c
      subroutine EFtoAB ( C, E, sigE, F, sigF, covEF, A, sigA, D, sigD )
c
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c
c  Subroutine for converting the coefficients of the expression
c
c               E*sin( twopi*C*t ) + F*cos( twopi*C*t ) ,
c
c  for any frequency C, to the amplitude and phase in the equivalent expression
c
c                     A*sin[ twopi*( C*t + D ) ] ,
c
c  and the uncertainties in E and F into uncertainties in A and D.
c
c-------------------------------------------------------------------------------
c
c  INPUT
c  -----
c  C     = frequency (in inverse time unit)
c  E     = coefficient of sine   term = A*cos( twopi*D )
c  sigE  = standard deviation of E
c  F     = coefficient of cosine term = A*sin( twopi*D )
c  sigF  = standard deviation of F
c  covEF = covariance between E and F
c
c  OUTPUT
c  ------
c  A     = the desired amplitude
c  sigA  = standard deviation of A
c  D     = the desired phase (in time units)
c  sigD  = standard deviation of D
c
c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c
      twopi = 2.0 * ACOS( -1.0 )
c
      A = SQRT( E**2 + F**2 )
c
      sigA = SQRT( (E*sigE)**2 + (F*sigF)**2 + 2.0*E*F*covEF ) / A
c
      D = ATAN2( F, E )
c                       --- The phase in radians
c
      sigD = SQRT( (E*sigE)**2 + (F*sigF)**2 - 2.0*E*F*covEF ) / A**2
c
      if ( C .ne. 0.0 ) then
c
             D    = D / ( twopi*C )
c                                   --- The phase in time units
c
             sigD = sigD / ( twopi*C )
c
      end if

c
      return
c
      end

