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,
http://docs.obspy.org/packages/autogen/obspy.sac.sacio.SacIO.GetHvalue.html#obspy.sac.sacio.SacIO.GetHvalue)

Some beginner code below.

Thanks,
rodrigo

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.

Cheers,
Yannik

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:
http://lists.swapbytes.de/archives/obspy-users/2013-September/000978.html

best,
Tobias

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

Tobias is right, sorry for the mis-information.

Cheers,
Yannik

This works, thanks.