Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sac.evdp error #1345

Closed
FadelI opened this Issue Mar 22, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@FadelI
Copy link

FadelI commented Mar 22, 2016

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

@megies megies added this to the 1.0.1 milestone Mar 22, 2016

@megies megies added the .io.sac label Mar 22, 2016

@jkmacc-LANL

This comment has been minimized.

Copy link
Contributor

jkmacc-LANL commented Mar 22, 2016

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.

@claudiodsf

This comment has been minimized.

Copy link
Member

claudiodsf commented Mar 22, 2016

@jkmacc-LANL This means that setting evdp is not currently unit-tested? Maybe we should test every possible header field. What do you think?

@jkmacc-LANL

This comment has been minimized.

Copy link
Contributor

jkmacc-LANL commented Mar 22, 2016

That's right, most simple properties aren't currently tested. It probably wouldn't be too painful to do so 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.