sac B and E values

Anyone know a quick and dirty way to time shift sac B and E values? I need to take data that currently ranges from 0:T and change the header so that it reflects data ranging from -T/2:+T/2

Unfortunatly,

trace=obspy.read(file)[0]
mid=(trace.stats.sac.e-trace.stats.sac.b)//2
trace.stats.sac.b=-mid
trace.stats.sac.e=mid
trace.write(file,format=“SAC”)

doesnt work, as it looks like trace.write calculates the B and E values??

suggestions? (besides doing it in sac with cuterr and fillz)

thanks!

Hi,

ObsPy has to do some calculations to map its data model to the sac data format. Trace/Stream.write() will create a SAC file consistent with ObsPy’s data model and stats.sac is not necessarily used. While there might be a way to force the .write() method to update B and E as you want it is probably much easier to directly use the SACTrace class (which underpins SAC functionality in ObsPy) for full control over the headers:

Cheers!

Lion