Results 1 to 4 of 4

Thread: questions about cross correlation using CCF

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    2

    questions about cross correlation using CCF

    I am performing cross-correlations between two signals.
    To check the routine, I started by using two identical (duplicated) signals.
    From this I would expect a correlation of 1 at zero lag (a result that I obtained in other programs).
    However, in the CCF routine, I only had a value of 0.87 at zero phase lag.
    Can any one help me understand why?
    When I graph the output of the routine (variable cc), there is not a distinct peak at 0 but rather a more distributed peak.
    Is it possible that there's some filter on the output (although I see nothing in the documentation that would suggest that)?

    Thank you for any help.

  2. #2
    Senior Member mecej4's Avatar
    Join Date
    Dec 2009
    Posts
    133
    Did you note the requirements that MAXLAG >= 1 and that CC should be of length 2*MAXLAG+1?

    I tried the manual example, modifying the first call to CALL CCF (X, X,...), and I obtained the expected result:

    Variance of series X = 1.1469

    Lag CCV CC SECC

    -1 1.09243 0.95247 0.01879
    0 1.14694 1.00000 0.00000
    1 1.09243 0.95247 0.01879

    Note that for Lag = 0 the CCV value agrees with the variance.

    If you still need more help, please post the relevant parts of your code.

  3. #3
    Junior Member
    Join Date
    Oct 2019
    Posts
    2
    THank you for the reply.
    I thought that I had also used the format from the documentation.
    Here are the essential parts of the code.

    INTEGER IPRINT, MAXLAG, NOBS
    PARAMETER (IPRINT=3, MAXLAG=650, NOBS=1300)
    !
    INTEGER IMEAN, ISEOPT, NCOL, NROW
    Integer IReadData, Length, IWr_CC, LagTime
    REAL CC(-MAXLAG:MAXLAG), CCV(-MAXLAG:MAXLAG), DumyLag(NObs),
    & RDATA(296,2), SECC(-MAXLAG:MAXLAG), X(NOBS), XMEAN,
    & XVAR, Y(NOBS), YMEAN, YVAR, ACX (maxlag+1), ACY (Maxlag+1)
    Real Maxcc, Oldmaxcc
    !
    OPEN (unit=16,FILE=CCFileName,STATUS='OLD', ACCESS='SEQUENTIAL')

    Do IReaddata = 1, NOBS
    Read(16, *) X(Ireaddata), Y(IReadData)
    X(IReadData) = Y(IReadData)
    End Do


    CALL CCF (X, Y, MAXLAG, CC)

    Return
    End

  4. #4
    Senior Member mecej4's Avatar
    Join Date
    Dec 2009
    Posts
    133
    Well, if that is the "essential part", it is wrong.

    Do you want to call the generic name CCF, or the specific name CCF?

    I think that you want the former; unfortunately, unless you include an interface, the compiler will use the implicit F77 interface when it generates the call, and that will be wrong on many counts. For one, the F77 routine CCF() has NOBS as its first argument, which you are not supplying; secondly, the number of arguments for it is fourteen, not the four that you pass; etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •