SeismicSource / sourcespec

Earthquake source parameters from P- and S-wave displacement spectra
https://sourcespec.seismicsource.org
Other
49 stars 12 forks source link

Clipping detection #23

Closed claudiodsf closed 1 year ago

claudiodsf commented 1 year ago

Hi @krisvanneste, I moved the discussion on clipping detection here.

Yes, it is hard! So I improved the strategy and added a parameter (commit c71cc5f).

I moved the clipping detector to a standalone module, which can be called from the command line program clipping_detection, in case one wants to do some test (but bear in mind that traces are not cut, when calling from the command line).

Let me know what do you think, as soon as you have time (as usual, no rush!), thanks!

P.S. I tried GitHub Copilot to write the docstring of is_clipped() as well as the main function with argparse: it is pretty impressive!

krisvanneste commented 1 year ago

Claudio,

I will run a test in the coming days! Will have a look at this GitHub Copilot as well.

claudiodsf commented 1 year ago

Thanks!

The only downside of Copilot is that it's 10$/month... (after 60 days trials)

I'm trying and see if my department can pay for it 😉

krisvanneste commented 1 year ago

Oh I see, that could be a bummer...

krisvanneste commented 1 year ago

Claudio,

I tested your new clip detection with my data, with variable success (both false positives and false negatives). In the end I modified the code a bit. I think just testing for the presence of more than 1 peak is too simple. Instead I propose to check for the presence of peaks in the first and last few bins to identify clipping.

I made the following changes:

With these changes, I obtain 3 correct detections (BE.BEBN, BE.MEMB BE.STI, see attached plots), 1 false positive (station BE.STWA) and no false negatives for the P phase on the Z component with my test case, and 4 correct detections (BE.BEBN, BE.LCH, BE.MEMB, BE.RCHB), 1 possible false positive (BE.MEMS, limit case) and no false negatives for the S phase on the N component. In all cases, this is using the lowest sensitivity (which I think should be the default with the current implementation). With higher sensitivities, more false positives are coming up. For the P phase, only 2 stations never trigger a clip detection, and for the S phase only 1.

Debug plots: clipping_detection.zip

Further improvements that could be considered:

I made a new branch and will create a pull request.

claudiodsf commented 1 year ago

Hi Kris, thanks for this work!!!

I'll review it in the following days or next week.

krisvanneste commented 1 year ago

Claudio, no hurry. I'm quite busy as well these days.