Thread: Correlation (CORRELATE) v SPE Correlation (COR)

Started: 2017-11-15 18:54:26
Last activity: 2017-11-19 02:00:34
Topics: SAC Help
Richard Godfrey
2017-11-15 18:54:26
Hi, SAC users:

I have been trying to calculate the cross-correlation function between two signals (both of contains 240000 data points). For this I'm using the function CORRELATION with these parameters: NUMBER 30 LENGTH 62 TYPE HANNING. When I execute this command this message shows up: "Segmentation fault (core dumped)". So I made some tests with other parameters and I found out that this command executes well if I'm using 5 windows.

Then I tried with the autocorrelation function for one of the signals. The exact situation described before happened. But when I used the correlation function of the SPE subprocess with the parameters: NUMBER 30 LENGTH 62 TYPE HANNING, it actually worked.

I noticed that one of the differences between both functions is that CORRELATE results are defined in a time interval from -T to T, while in COR the time interval begins in 0.

So I have the next questions:
1) What's the difference between the functions CORRELATE and COR (SPE Subprocess)?
2) Does the number of windows depend of amount of data points?
3) If I want to calculate the cross-spectrum between two signals I can use first CORRELATE then FFT? Because the PSD only allows you to estime the power densitiy spectrum of one signal and it doesn't give you the phase of the spectrum.

Regards,

Richard Godfrey
  • Brian Savage
    2017-11-17 18:30:57
    Richard,

    Thank for reporting this. There is a bug in the CORRELATE command when a window length is specified. Your large number of data points is not the issue as I can recreate the behavior with signals of 10 points or so.

    The issue does not occur with the default CORRELATE settings (a single cross correlation window).

    I am looking into your questions and hopefully will have answers soon.

    Brian

    On Nov 15, 2017, at 1:55 PM, Richard Godfrey <richardgm94<at>gmail.com> wrote:

    Hi, SAC users:

    I have been trying to calculate the cross-correlation function between two signals (both of contains 240000 data points). For this I'm using the function CORRELATION with these parameters: NUMBER 30 LENGTH 62 TYPE HANNING. When I execute this command this message shows up: "Segmentation fault (core dumped)". So I made some tests with other parameters and I found out that this command executes well if I'm using 5 windows.

    Then I tried with the autocorrelation function for one of the signals. The exact situation described before happened. But when I used the correlation function of the SPE subprocess with the parameters: NUMBER 30 LENGTH 62 TYPE HANNING, it actually worked.

    I noticed that one of the differences between both functions is that CORRELATE results are defined in a time interval from -T to T, while in COR the time interval begins in 0.

    So I have the next questions:
    1) What's the difference between the functions CORRELATE and COR (SPE Subprocess)?
    2) Does the number of windows depend of amount of data points?
    3) If I want to calculate the cross-spectrum between two signals I can use first CORRELATE then FFT? Because the PSD only allows you to estime the power densitiy spectrum of one signal and it doesn't give you the phase of the spectrum.

    Regards,

    Richard Godfrey

    ----------------------
    SAC Help
    Topic home: http://ds.iris.edu/message-center/topic/sac-help/ | Unsubscribe: sac-help-unsubscribe<at>lists.ds.iris.edu

    Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
    Update subscription preferences at http://ds.iris.edu/account/profile/


  • George Helffrich
    2017-11-19 02:00:34
    Dear Richard -

    The essential difference between the CORRELATE command and SPE’s COR command is that the SPE version is a prelude to estimating the power spectrum of the signal. Some of the estimation procedures (MLM, MEM) are not FFT-based (though they use the FFT as a fast convolution method to implement the estimation procedures). Hence COR only needs the autocorrelation, and due to its symmetry around zero lag, only one side of it. That is why the results for CORRELATE and COR have different lag ranges.

    If you do not give both NUMBER and LENGTH, the number of windows varies according to your LENGTH. Combinations of NUMBER and LENGTH can lead to window overlap depending on the number of points in your data.

    In principle, CORRELATE should allow you to calculate the cross-spectrum, since it is defined as the FT of the cross-correlation. (If your time series is real, then the cross-correlation also will be.) I’ve never had a need to use SAC for this, but it should serve.

    Chapter 9 of the SAC book covers the use of the SPE subprocess.

    On 16 Nov 2017, at 03:55, Richard Godfrey <richardgm94<at>gmail.com> wrote:

    Hi, SAC users:

    I have been trying to calculate the cross-correlation function between two signals (both of contains 240000 data points). For this I'm using the function CORRELATION with these parameters: NUMBER 30 LENGTH 62 TYPE HANNING. When I execute this command this message shows up: "Segmentation fault (core dumped)". So I made some tests with other parameters and I found out that this command executes well if I'm using 5 windows.

    Then I tried with the autocorrelation function for one of the signals. The exact situation described before happened. But when I used the correlation function of the SPE subprocess with the parameters: NUMBER 30 LENGTH 62 TYPE HANNING, it actually worked.

    I noticed that one of the differences between both functions is that CORRELATE results are defined in a time interval from -T to T, while in COR the time interval begins in 0.

    So I have the next questions:
    1) What's the difference between the functions CORRELATE and COR (SPE Subprocess)?
    2) Does the number of windows depend of amount of data points?
    3) If I want to calculate the cross-spectrum between two signals I can use first CORRELATE then FFT? Because the PSD only allows you to estime the power densitiy spectrum of one signal and it doesn't give you the phase of the spectrum.

    Regards,

    Richard Godfrey

    ----------------------
    SAC Help
    Topic home: http://ds.iris.edu/message-center/topic/sac-help/ | Unsubscribe: sac-help-unsubscribe<at>lists.ds.iris.edu

    Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
    Update subscription preferences at http://ds.iris.edu/account/profile/



    George Helffrich
    george<at>elsi.jp


04:46:01 v.22510d55