eqcorrscan / EQcorrscan

Earthquake detection and analysis in Python.
https://eqcorrscan.readthedocs.io/en/latest/
Other
167 stars 86 forks source link

Should the self-detection time of a template be independent of other templates in the tribe? #438

Closed flixha closed 3 years ago

flixha commented 3 years ago

I ran some tests to let an event template detect itself in continuous data. But depending on the station choice and what other templates were in the tribe that I used, I got different detection times (11 s apart). I tried to debug this and believe I have an idea of what's happening. I'm wondering whether this is the expected behaviour or not. If it's not expected, it would be nice if you have some feedback for how to solve it.

Issue description:

Analysis / Consequences:

So as I understand, the difference in detection time is because in case 2 with only one template for detection, there are no NaN-channels in the template. Hence the earliest trace in the template starts at 18:14:53.0 and that is then the detection time. If I try to use the detection from case 2 in lag_calc, I get the wrong picks. So I would say that also in case 2, we should get 18:14:42 as detection time, because the detection time should not change because there are other templates in the tribe or not.

Possible solution:

As a possible solution, one could do a check at the end of the template-preparation in eqcorrscan.utils.preprocessing._prep_data_for_correlation that does as follows:

calum-chamberlain commented 3 years ago

Morning @flixha - I think your conclusion is probably right - that this is due to the earliest trace being thrown out completely in one case, and being converted to NaN in the other due to poor data quality in the continuous data. Having a different result depending on what templates are used is certainly not what we want, nor is getting the wrong pick times from lag_calc! Thanks for spotting this!

Your solution is certainly workable, but adds quite a lot of computational overhead and so probably isn't the most desirable way to fix this long-term, but if it helps you get your case up and running then go for it on your local code.

I think this should be fixed fairly urgently as it is something that I think would not be obvious and could be very frustrating for many people. @flixha would you be able to start a PR with a test-case that demonstrates this, e.g. a test that runs the single template and two template tribes and checks that they have the same detection times (this test should fail), then we can work on a solution in that PR.

flixha commented 3 years ago

Hi @calum-chamberlain, thanks for your quick reply! I will create and upload the test case soon (guess on Monday), and yes I can start the PR for that where we can work on the fix. I also thought that the NaN-trace is not optimal from the overhead-point. But it seems to me right now that we would otherwise need to provide extra metadata with the detections to make them comparable, which would change a lot more in terms of class properties and detection file contents..

calum-chamberlain commented 3 years ago

Thanks, and yes, it may be the simplest way. Maybe we will end up going with that to get it fixed with an eye to a better solution later.

CJ Chamberlain, out of office


From: FelixHa notifications@github.com Sent: Saturday, February 13, 2021 9:51:40 AM To: eqcorrscan/EQcorrscan EQcorrscan@noreply.github.com Cc: Calum Chamberlain calum.chamberlain@vuw.ac.nz; Mention mention@noreply.github.com Subject: Re: [eqcorrscan/EQcorrscan] Should the self-detection time of a template be independent of other templates in the tribe? (#438)

Hi @calum-chamberlainhttps://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcalum-chamberlain&data=04%7C01%7Ccalum.chamberlain%40vuw.ac.nz%7C0c83cf68d28946fe92c308d8cf9800c8%7Ccfe63e236951427e8683bb84dcf1d20c%7C0%7C0%7C637487599098293688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=X8j%2FPGxNhumXGFwRZYtLsaPL5ckWSeyBTdhqs%2B6dQ6Y%3D&reserved=0, thanks for your quick reply! I will create and upload the test case soon (guess on Monday), and yes I can start the PR for that where we can work on the fix. I also thought that the NaN-trace is not optimal from the overhead-point. But it seems to me right now that we would otherwise need to provide extra metadata with the detections to make them comparable, which would change a lot more in terms of class properties and detection file contents..

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feqcorrscan%2FEQcorrscan%2Fissues%2F438%23issuecomment-778448042&data=04%7C01%7Ccalum.chamberlain%40vuw.ac.nz%7C0c83cf68d28946fe92c308d8cf9800c8%7Ccfe63e236951427e8683bb84dcf1d20c%7C0%7C0%7C637487599098303688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=DCk3R4FSVzFgexcQ3nLC1JtIlA4lQStwF5NTZwaiQj0%3D&reserved=0, or unsubscribehttps://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACTIM445GI5OTACMY7FL3HDS6WIFZANCNFSM4XQ5L4VQ&data=04%7C01%7Ccalum.chamberlain%40vuw.ac.nz%7C0c83cf68d28946fe92c308d8cf9800c8%7Ccfe63e236951427e8683bb84dcf1d20c%7C0%7C0%7C637487599098303688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=IF0n5bICaFg5rGskkp5hVD6BrTLFN88yONOjgT%2FxzkE%3D&reserved=0.