I am trying to add event depth to sac header using:
sac = SACTrace(nzyear=2000, nzjday=1, nzhour=0, nzmin=0, nzsec=0, nzmsec=0,t1=23.5, data=numpy.arange(100))
sac.evdp = 129.97
I receive this error:
Traceback (most recent call last):
File "<ipython-input-10-fc4f09dae8ae>", line 1, in <module>
runfile('/PATH/test.py', wdir='/PATH/WRITESAC')
File "/usr/local/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
execfile(filename, namespace)
File "/usr/local/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
builtins.execfile(filename, *where)
File "/PATH/test.py", line 14, in <module>
sac.evdp = 129.97
File "/usr/local/anaconda/lib/python2.7/site-packages/obspy/io/sac/sactrace.py", line 383, in set_float
self._hf[HD.FLOATHDRS.index(hdr)] = value
ValueError: tuple.index(x): x not in tuple
ObsPy 1.0.0 on Ubuntu 15.1 machine installed using Anaconda
Thank you in advance,
Fadel
There is a typo in the evdp property in SACTrace class. For now, @FadelI , you can change the property in obspy/io/sac/sactrace.py (near line 862) following this diff:
diff --git a/obspy/io/sac/sactrace.py b/obspy/io/sac/sactrace.py
index 26c517c..a5f1a53 100644
--- a/obspy/io/sac/sactrace.py
+++ b/obspy/io/sac/sactrace.py
@@ -859,7 +859,7 @@ class SACTrace(object):
doc=HD.DOC['evla'])
evlo = property(_floatgetter('evlo'), _geosetter('evlo'),
doc=HD.DOC['evlo'])
- evdp = property(_floatgetter('evdp'), _floatsetter('evsp'),
+ evdp = property(_floatgetter('evdp'), _floatsetter('evdp'),
doc=HD.DOC['evdp'])
mag = property(_floatgetter('mag'), _floatsetter('mag'), doc=HD.DOC['mag'])
user0 = property(_floatgetter('user0'), _floatsetter('user0'),
I'll fix it in the maintenance branch for the 1.0.1 release, which should be coming out very soon.
@jkmacc-LANL This means that setting evdp is not currently unit-tested? Maybe we should test every possible header field. What do you think?
That's right, most simple properties aren't currently tested. It probably wouldn't be too painful to do so :smile:
Most helpful comment
@jkmacc-LANL This means that setting
evdpis not currently unit-tested? Maybe we should test every possible header field. What do you think?