Event source time is changed when added to the data

I took a look at the repository on git and found nothing about this problem. I make a loop to add header data to the bag data, but the time of origin of the event is very high, does anyone know what it can be? @jkmacc-LANL

Hi @LessandroValente,

can you describe your problem in a bit more detail/context and with a small reproducible example? Right now I don’t know what this is about.

Cheers!

Okay, I’m sending you a picture of the script. In it I prepare my data to fill the header and find the arrival of the P wave. However, when placing the event time in the sac.o, which is given in seconds, this value is unpredictable. The events take place in the year 2011, but it is given in the year 2052, I don’t know what may be happening.

Here is the ending, where I just add the header parameters.

You are assigning the timestamp of the absolute event time t0 to the .o header of sac. The timestamp is the number of seconds since 1970. In SAC it should instead be the difference to the reference time of the file in seconds. That time is mostly likely just the start time of the trace.

Thus 2011 + (2011 - 1970) = 2052 which explains the time you are seeing. Just assign arrivalP to .o and it should be fine. But best check the the reference time again and also consider using the lower level SacTrace object for full control over the SAC files if you need it: https://docs.obspy.org/master/packages/autogen/obspy.io.sac.sactrace.html#module-obspy.io.sac.sactrace

Bored, it makes sense, but the arrivalP I already add in sac.a, which is the time of arrival of the P, no problem?

Yea you are right - that was a mistake on my side. Assign t0 - st[0].stats.starttime.timestamp to .o so the origin time is also correct with respect to the reference time (assuming that is the start of the trace). And .a has to to be the arrival time with respect to the reference time and not with respect to the event time - so make sure to do the correct calculation there.

Okay, it helped my friend a lot, thanks !!!

Hi @LionKrischer , I was trying to do what you had suggested, however, as I carry a large amount of data, this becomes impracticable due to the capacity of my notebook, with that, I try to load the data with a window close to the first arrivals of P, thus , the timestamp would not fit. So, I took a look at reftime, but I couldn’t understand how I can use it, could you help me in this case? I thank you in any way.