SeismicSource / sourcespec

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

Autoset Mw inversion limits #22

Closed claudiodsf closed 1 year ago

claudiodsf commented 1 year ago

Hi @krisvanneste,

I just pushed a commit (a15d171) with a new approach for autosetting Mw limits, between 90% of the minimum of the spectral plateau and 110% of its maximum.

In my tests, this works very well and removes the need for the Mw_0_variability parameter.

However, I just tested it with noise weighting. I would be very glad if you could test it in your case, with frequency weighting.

Thanks!

krisvanneste commented 1 year ago

Claudio, I will try to test it before the end of the week. Is that OK with you? Kris

claudiodsf commented 1 year ago

Sure, no rush!

claudiodsf commented 1 year ago

I also changed the clipping detection algorithm, see d1dbb0f.

krisvanneste commented 1 year ago

I compared the new approach for autosetting the Mw limits with the previous one using the Mw_0_variability parameter on my example with short/missing noise windows, requiring frequency weighting. In this particular case, I obtain better results with the new approach:

However, I'm not sure this example is representative. I should do more testing, but unfortunately I'm still struggling to check the instrument responses for our older data.

The change you made looks simple, but there are 2 fundamental differences with the previous approach:

Below I include the plots and logs obtained with the 2 approaches.

Fitted spectra (old approach): 1306 ssp 00

Fitted spectra (new approach): 1306 ssp 00

Log (old approach): 1306.ssp.log

Log (new approach): 1306.ssp.log

krisvanneste commented 1 year ago

Concerning the frequency weighting, in another program I use inverse frequency weighting. This is something I read in a paper by Kaneko & Shearer (2014) (https://academic.oup.com/gji/article/197/2/1002/617325):

We weight the fit inversely with frequency so that all parts of the spectrum seen in a log–log plot contribute equally (this generally improves the fit to the low-frequency part of the spectrum, which is defined by relatively few points).

If you don't have this paper, I can send it to you.

I was thinking of implementing this in sourcespec as well, but this will thus also require a strategy to determine the initial part of the spectrum (_freq_ranges_for_Mw0_and_tstar0 function)...

But first I will try to test the new clipping detection!

krisvanneste commented 1 year ago

I tested the new clipping detection with some clipped data, but it doesn't seem to be working. Four stations (BEBN, LCH, MEMB and RCHB) have clipped S phases, but no warnings are given. Here is the trace plot: 1306 traces 00 I edited the code to turn on the debug plot for these particular stations: BEBN_clipping LCH_clipping MEMB_clipping RCHB_clipping

RCHB may be more difficult to detect, but the other stations are quite obviously clipped.

What I do like about the new implementation is that the detection is limited to the wave type, which makes it possible to determine Mw from the P-phase when clipping is limited to the S-phase. However, for this to work properly, I think line 87 should be removed, as it redefines the end of the checked interval:

t2 = (trace.stats.arrivals['S'][1] + config.win_length)

I also implemented clip detection in my code, but it tends to overdetect. Robust clip detection is not so easy as it would seem...

claudiodsf commented 1 year ago

Hi Kris, thanks for your testing.

Mw_0_variablity was also in linear space (magnitude space). The old code is this one:

bounds.Mw_min = Mw_0 - config.Mw_0_variability
bounds.Mw_max = Mw_0 + config.Mw_0_variability

While the new one is:

bounds.Mw_min = np.nanmin(ydata[idx0: idx1]) * 0.9
bounds.Mw_max = np.nanmax(ydata[idx0: idx1]) * 1.1

This new code should provide larger bounds, which make it possible to find a better solution. It is particularly evident when using grid search and looking at misfit plots, as in the attached plots.

fr2023kxdoxu misfit_fc-Mw_FR BLAF 00 HHH_broadb--oldcode fr2023kxdoxu misfit_fc-Mw_FR BLAF 00 HHH_broadb--newcode

Concerning the inversion, it is made in logarithmic frequency spacing (see here) and this should mitigate the problem raised by Kaneko & Shearer.

But, of course, any improvement to the weighting strategy is welcome!

claudiodsf commented 1 year ago

Concerning the clipping detection: I guess there is a problem when the histogram peaks are at the edges of the histogram.

I had to smooth the histogram (orange curve) to avoid secondary peaks, but it obviously doesn't work in your case.

Your third case is hard because the clipping is just on one oscillation, but the other two should work. Any idea on how to properly smooth the histogram? I can also try figure out myself, if you send me the traces ;-)

krisvanneste commented 1 year ago

Sorry about the confusion regarding linear/log space. I forgot that you convert the spectra to seismic moment, whereas I was reasoning in amplitude...

krisvanneste commented 1 year ago

I will export the clipped records to miniseed and send them to you.

krisvanneste commented 1 year ago

Here are the miniseed files: clipped_seismograms.zip Do you need other data (stationxml, ...)?

claudiodsf commented 1 year ago

Thanks, I'm fine with miniSEED, since clipping is evaluated on uncorrected data.

claudiodsf commented 1 year ago

I moved the discussion on clipping detection to #23.

Let me know if you want to iterate more on Mw limits, or if you think that it is fine.

krisvanneste commented 1 year ago

I think it is fine as the new code indeed provides larger bounds. The misfit plots you show are interesting. Is there an option in sourcespec to generate them? I suppose the upper plot corresponds to the old code, and the lower one to the new code?

claudiodsf commented 1 year ago

The misfit plots are generated when using "grid search" (GS) for inv_algorithm.

I'm using more and more grid search (even if slower) because misfit plots give a clear view of parameter interdependence.

And, yes, old code on top plot.

krisvanneste commented 1 year ago

Great, I didn't know that. I will try it too!

claudiodsf commented 1 year ago

I think we can considered this as tested. Closing