Trimming traces with different start times

Hello everyone,

I have traces with start times differing in microseconds with the same onsets calculated by rfstats(). When I cut around the onsets, start times do not align which is problematic for the RF calculation. Not sure why this happens as I am cutting around the same point for all traces. What am I missing? Could it be related to the number of samples?

I’ve seen suggestions of using interpolation method, but not quite sure how to use it (and I would prefer not to alter the signal). I was wondering if there is another solution to this problem?

print(st)

print("\nOld Starttime:")
for tr in st:    
    print(tr.id, tr.stats.starttime)

print("\nOnset:")
for tr in st:
    print(tr.id, tr.stats.onset)
    tr.trim(tr.stats.onset-10,tr.stats.onset+30)

print("\nNew Starttime:")
for tr in st:    
    print(tr.id, tr.stats.starttime)

print("\n",st)

3 Trace(s) in Stream:
HP.SERG…HHE | -62.4s - 179.1s onset:2011-09-27T06:16:11.306401Z | 100.0 Hz, 24149 samples | mag:3.7 dist:0.1 baz:160.9 slow:8.62
HP.SERG…HHN | -62.4s - 179.0s onset:2011-09-27T06:16:11.306401Z | 100.0 Hz, 24145 samples | mag:3.7 dist:0.1 baz:160.9 slow:8.62
HP.SERG…HHZ | -64.7s - 179.6s onset:2011-09-27T06:16:11.306401Z | 100.0 Hz, 24437 samples | mag:3.7 dist:0.1 baz:160.9 slow:8.62

Old Starttime:
HP.SERG…HHE 2011-09-27T06:15:08.912700Z
HP.SERG…HHN 2011-09-27T06:15:08.880700Z
HP.SERG…HHZ 2011-09-27T06:15:06.564500Z

Onset:
HP.SERG…HHE 2011-09-27T06:16:11.306401Z
HP.SERG…HHN 2011-09-27T06:16:11.306401Z
HP.SERG…HHZ 2011-09-27T06:16:11.306401Z

New Starttime:
HP.SERG…HHE 2011-09-27T06:16:01.302700Z
HP.SERG…HHN 2011-09-27T06:16:01.310700Z
HP.SERG…HHZ 2011-09-27T06:16:01.304500Z

3 Trace(s) in Stream:
HP.SERG…HHE | -10.0s - 30.0s onset:2011-09-27T06:16:11.306401Z | 100.0 Hz, 4001 samples | mag:3.7 dist:0.1 baz:160.9 slow:8.62
HP.SERG…HHN | -10.0s - 30.0s onset:2011-09-27T06:16:11.306401Z | 100.0 Hz, 4001 samples | mag:3.7 dist:0.1 baz:160.9 slow:8.62
HP.SERG…HHZ | -10.0s - 30.0s onset:2011-09-27T06:16:11.306401Z | 100.0 Hz, 4001 samples | mag:3.7 dist:0.1 baz:160.9 slow:8.62

Hi!

Everything looks fine with your code and data.
After trimming the starttimes only differ up to 0.01s, which is your sampling time interval. If you trim at exactly the time of one sample of a trace, you can reduce the maximal difference to 0.005s, but honestly, it is not worth the effort. The 0.01s time difference will not distort the receiver functions in any meaningful way.