% @(#)interptsa.hlq	19.1 (ESO-IPG) 02/25/03 13:32:44
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
%.COPYRIGHT (c) 1992 European Southern Observatory & Copernicus Astron. Center%.IDENT     interptsa.hlq
%.AUTHOR    Alex Schwarzenberg-Czerny, ESO & Copernicus Astronomical Center 
%.KEYWORD   MIDAS, help files, INTERPOLATE/TSA
%.LANGUAGE  LATEX
%.PURPOSE   Interpolate an unevensampled series using its covariance function
%.VERSION   0.0               June 1992
%.RETURNS   None  
%.ENVIRON   TSA context
%-----------------------------------------------------------------------------
\se
SECTION./TSA
\es\co
INTERPOLATE/TSA                             15-SEPT-1992 A. Schwarzenberg-Czerny
\oc\su
INTERPOLATE/TSA intab outtab func parm
	Interpolate an unevenly sampled series using its covariance function
\us\pu
Purpose:
          Interpolate an unevenly sampled series using its analytic covariance 
          function. The algorithm is described in Ap.J. 385, 404.
          Individual measurements must be given with their variances.
          This command requires as input the autocovariance function 
          of observations in analytical form. Note that this method (not the code) 
          is not yet finally tested, thus use it with care. 
\up\sy
Syntax:
          INTERPOLATE/TSA intab outtab func parm
\ys\pa
          intab = name of the table containing observations with their
                  variances. The table must contain columns :TIME :VALUE :VAR
                  in DOUBLE PRECISION. For numerical reasons it is advisable to
                  subtract mean from :VALUE.
\ap\pa
          oname = same for the output time series. The corresponding
                  table must exist and contain columns :TIME :VALUE :VAR.
                  Only the values in :TIME are used for input.
\ap\pa
          func =  code for analytical form of the autocorrelation
                  function of the observations. The user may choose
                  to use one of the predefined formulae (LIN,... IPO) 
                  suppling just parameters or to specify USR and supply
                  his/her own code for the function TSAINTUSR.
                  The options are
\\{\tt
                  LIN     ACF(x) = A + B*x              (default)
\\
                  POL     ACF(x) = A + B*x + Cx**2 +.... (up to 12 coeff)
\\
                  POW     ACF(x) = A + B*x**C
\\
	          EXP     ACF(x) = A + B*exp(C*x)
\\
	          LOG     ACF(x) = A + B*LOG(C*x)
\\
                  IPO     ACF(x) = A + B/(x-x0) + C/(x-x0)**2 + ...
\\
                  where A=PARM(1), B=PARM(2),  ...., 
\\
                  except for IPO where x0=PARM(1), A=PARM(2),...
\\
                  USR     ACF(x)  = user defined function TSADELUSR
\\}
                  The head of the user supplied function must be the following:
\\{\tt
                  DOUBLE PRECISION FUNCTION TSAINTUSR(TLAG,PARM)
\\
                  DOUBLE PRECISION TLAG,PARM(12)
\\
                  .........................
\\}
                  The computed value of TSAINTUSR must depend only
                  on ABS(TLAG) and (optionally) on PARM(1), PARM(2),.....

\ap\pa
          parm  = parameters for the function used
                  1) from command line: a,b,c,d,....(max.12)
                  2) from keyword: "K(iname)", e.g. KINPUTR
                  Default values are 0,1,0,0,... 
\ap\sa
See also:
          DELAY/TSA, COVAR/TSA, SHOW/TSA
\as\no
Note:
          The analytical form of the ACF function can be created using
          the output of COVAR/TSA and the MIDAS FIT package. 
\on\exs
Examples:
\ex
          INTERPOLATE/TSA DATA1 DATA2 EXP 0,1,-0.25
\xe\ex
          INTERPOLATE/TSA DATA1 DATA2 USR KINPUTR
          We should get the same results as before assuming that the 
          parameters 0,1,-0.25 are saved in keyword INPUTR defining the user 
          function:
\\{\tt
          DOUBLE PRECISION FUNCTION TSAINTUSR(TLAG,PARM)
\\
          DOUBLE PRECISION TLAG,PARM(12)
\\
          TSAINTUSR=PARM(1)+PARM(2)*EXP(ABS(TLAG)*PARM(3))
\\
          END
\\}
\xe\sxe
