# sac B and E values

**URL:** <https://discourse.obspy.org/t/sac-b-and-e-values/609>\
**Category:** Users Mailing List Archive\
**Tags:** archive\
**Created:** [March 1, 2017, 8:22pm UTC](https://discourse.obspy.org/t/sac-b-and-e-values/609 "2017-03-01T20:22:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![A11](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/a/b77776/32.png) [@A11](https://discourse.obspy.org/u/A11)\
**Post date:** [March 1, 2017, 8:22pm UTC](https://discourse.obspy.org/t/sac-b-and-e-values/609/1 "2017-03-01T20:22:01Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![LionKrischer](https://discourse.obspy.org/user_avatar/discourse.obspy.org/lionkrischer/32/219_2.png) [@LionKrischer](https://discourse.obspy.org/u/LionKrischer)\
**Post date:** [March 2, 2017, 1:22pm UTC](https://discourse.obspy.org/t/sac-b-and-e-values/609/2 "2017-03-02T13:22:05Z")

</div>

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
