field header lcalda

Good afternoon, I am trying to set field header “lcalda” , using this function: “something.SetHvalue(‘lcalda’, “TRUE”)”, but I am getting next error:

Traceback (most recent call last):
File “head_edi.py”, line 41, in
sac.SetHvalue(‘lcalda’, “TRUE”) #calcula distancia estacion evento.
File “/Applications/ObsPy.app/Contents/MacOS/lib/python2.7/site-packages/obspy/sac/sacio.py”, line 461, in SetHvalue
self.hi[index] = int(value)
ValueError: invalid literal for int() with base 10: ‘TRUE’

can somebody help me about it?

Thank you so much,

Juan Carlos.

Hi Juan Carlos,

In your Snippet the second argument should be a boolean or an integer, and you gave the string ‘TRUE’, it should be:

sac.SetHvalue(‘lcalda’, True)
or

sac.SetHvalue(‘lcalda’, 1)

Cheers,

Juan

Hi Juan Carlos,

I don't know if there is a special reason why you use SacIO class,
anyway, SAC header fields can also be modified simply in
Trace.stats.sac. E.g.:

st = read("/path/to/test.sac")
st[0].stats.sac['lcalda'] = 0
st.write("/tmp/modified.sac", "SAC")

best,
Tobias