list other sac headers

Hi Users,

How to list event-related information from sac headers? Specifically
'evla', 'evlo', 'evdp'.
I read this is done with some structure "convert_dict", any suggestions welcome.

Also, ideally this can be done with the read command without having to
re-read files (eg. SacIO,

Some beginner code below.


Hi Rodrigo,

When you read a SAC file the Trace object has a dictionary called 'sac'.

st = read('demo.sac')
print st[0].stats.sac

This only allows you to list them and any changes to it will be lost when writing the file to disk.


Actually, changes in the SAC specific header variables do get written to
file (of course only when writing to SAC format):

st = read("/path/to/test.sac")
print st[0].stats.sac["evla"]
st[0].stats.sac["evla"] = 11
st.write("tmp.sac", "SAC")
st = read("tmp.sac")
print st[0].stats.sac["evla"]

You need to be careful with fields that can interfere with the basic
Trace.stats header fields (like all the timing related fields), though.
Refer to this older mail for more information:


P.S.: Maybe we should consider the possibility to make readEvents()
parse event information contained in SAC files into the ObsPy event

Tobias is right, sorry for the mis-information.


This works, thanks.