smousavi05 / EQTransformer

EQTransformer, a python package for earthquake signal detection and phase picking using AI.
https://rebrand.ly/EQT-documentations
MIT License
311 stars 150 forks source link

Wrong phase outputs in case of multiple phase detections #145

Open alirezaniki opened 1 year ago

alirezaniki commented 1 year ago

Dear @smousavi05 I am having a problem with EQT outputs (output CSV file). The problem arises when there are two S or P detections with different probabilities in a 1-minute trace and EQT (seems like) outputs the first one regardless of their probabilities. The attached figure is an example:

NZ02_ZU_BH_2000-01-01T05:46:00 000000Z

and here is the output:

NZ02_ZU_BH_2000-01-01T05:46:00.000000Z, ,NZ02,BH,25.0,26.0,-27.0,2000-01-01 05:46:07.110000,2000-01-01 05:46:24.620000,0.92,,2000-01-01 05:46:07.420000,0.86,,6.7,2000-01-01 05:46:20.490000,0.22,,1.0

Do you have any suggestions on this? Thanks in advance

alirezaniki commented 1 year ago

It seems EQT prioritizes the closest detected S phase to the P phase regardless of probabilities, causing the above issue. replacing the below line of Eqt_utils.py (1949): candidate_Ss = {list(candidate_Ss.keys())[0] : candidate_Ss[list(candidate_Ss.keys())[0]]} with the following line: candidate_Ss = {max(candidate_Ss, key=candidate_Ss.get): max(candidate_Ss.values())}

prioritizes the probabilities over P-S distances and solves the issue.

smousavi05 commented 1 year ago

@alirezaniki thanks for the update. Yes, this sounds like a good fix.