Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppressed self-detection correlations if resampled samples do not align #547

Open
calum-chamberlain opened this issue Jul 28, 2023 · 0 comments

Comments

@calum-chamberlain
Copy link
Member

Describe the bug
We enforce the same processing (filters, resampling, fft-shape etc), which ensures that templates and continuous data are processed the same, however when resampling, if the data that the template is cut from and the continuous data used for self-detection start one sample apart (for resampling by half), then the correlations are suppressed because the same samples of data are not retained in the resampling.

This is obvious when considering self-detections: in a recent example, self-detections (which should have an average cross-correlation of 1.0) fall as low as an average of 0.8. I suspect this issue is less pronounced for lower frequency data (I was filtering 2--20 Hz), but this is annoying.

I'm not entirely sure what to do about this. We should provide self-detections with unity correlations, which requires that the sample locations are the same...

To Reproduce
Using the tribe linked here:

from obspy import UTCDateTime
from obspy.clients.fdsn import Client
from eqcorrscan import Tribe

import logging

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s\t%(processName)s\t%(name)s\t%(levelname)s\t%(message)s",
)

tribe = Tribe().read("test_self_det_tribe.tgz")

party, st = tribe.client_detect(
   client=Client("GEONET"),
   starttime=UTCDateTime(2020, 10, 10, 14),
   endtime=UTCDateTime(2020, 10, 11, 12),
   threshold=9,
   threshold_type="MAD",
   trig_int=2,
   return_stream=True,
)

The returned party contains two detections, with the zeroth a self detection:

 print(f"{party[0][0].detect_val / party[0][0].no_chans:.4f}")

>>> 1.0000

In contrast, if we start the detection one-sample further on in time:

party, st = tribe.client_detect(
   client=Client("GEONET"),
   starttime=UTCDateTime(2020, 10, 10, 14) + 0.01,
   endtime=UTCDateTime(2020, 10, 11, 12),
   threshold=9,
   threshold_type="MAD",
   trig_int=2,
   return_stream=True,
)

We get a party of three detections, with the zeroth as the same self-detection, but with a suppressed average correlation value:

print(f"{party[0][0].detect_val / party[0][0].no_chans:.4f}")

>>> 0.8101

If we move one more sample on, we get the same result as the first go.

Suggestions welcome

Note that the correlations are correct, as is the resampling and processing, it is just that if we sample different samples then we don't get the same correlation values. The times of the resulting self detections are accurate as well (as in the suppressed one is not the same time as the correct self-detection because the samples are different).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant