Error in plot stream

Hi all

I have fedora 12 with python 2.6 and obspy 0.9.2

I have a new problem with plotting a stream waves.

I have declared a list variable with [], a dictionary variable with {} and then I have filled the dictionary with this line code:

     event=[]

               evt={}
               evt['text']=EventID # Event identifier
               evt['time']=UTCDateTime(TimeArr) # UTC time of P wave of station
               event.append(evt) # append dictionary evt in event list
               print event

        # trackWave is trace of stations wave loaded from archive to made a dayplot

        trackWave.plot(type='dayplot', outfile=PictureWave,size=(1024, 800),starttime=UTCDateTime(TimeYesterday),interval=30, events=event)

When I print the event variable, the output is:

[{'text': 'OSB2014tqmo', 'time': UTCDateTime(2014, 10, 7, 14, 1, 13, 849900)}, {'text': 'OSB2014trrp', 'time': UTCDateTime(2014, 10, 8, 5, 42, 40, 599900)}, {'text': 'OSB2014trsk', 'time': UTCDateTime(2014, 10, 8, 6, 7, 17, 970000)}]

I think this is correct, but the program get the error:

Traceback (most recent call last):
   File "/home/lenet/seiscomp3/bin/scwave", line 284, in <module>
     trackWave.plot(type='dayplot', outfile=PictureWave,size=(1024, 800),starttime=UTCDateTime(TimeYesterday),interval=30, events=event)
   File "/usr/lib/python2.6/site-packages/obspy-0.9.2-py2.6-linux-i686.egg/obspy/core/stream.py", line 1058, in plot
     return waveform.plotWaveform(*args, **kwargs)
   File "/usr/lib/python2.6/site-packages/obspy-0.9.2-py2.6-linux-i686.egg/obspy/imaging/waveform.py", line 251, in plotWaveform
     self.plotDay(*args, **kwargs)
   File "/usr/lib/python2.6/site-packages/obspy-0.9.2-py2.6-linux-i686.egg/obspy/core/util/decorator.py", line 73, in echo_func
     return func(*args, **kwargs)
   File "/usr/lib/python2.6/site-packages/obspy-0.9.2-py2.6-linux-i686.egg/obspy/imaging/waveform.py", line 467, in plotDay
     self._plotEvent(event)
   File "/usr/lib/python2.6/site-packages/obspy-0.9.2-py2.6-linux-i686.egg/obspy/imaging/waveform.py", line 575, in _plotEvent
     for pick in event.picks:
AttributeError: 'dict' object has no attribute 'picks'
Exception TypeError: "'NoneType' object is not callable" in <bound method WaveformPlotting.__del__ of <obspy.imaging.waveform.WaveformPlotting object at 0xb31a0ac>> ignored

Can anyone help me?

Regards,

Sergio

Hi Sergio,

this is a bug in 0.9.2 and is fixed in master (see
https://github.com/obspy/obspy/commit/aa0eaed2307a2d12bb4a555ed2fb3ea84a2570a8).

One fast solution for you would be to simply edit your file
/usr/lib/python2.6/site-packages/obspy-0.9.2-py2.6-linux-i686.egg/obspy/imaging/waveform.py
at line 575 with the same change as done in the above commit..

The other quick solution I can think of is to make your event
dictionaries into AttribDicts and then add some empty picks attribute to
trick the buggy code by presenting it the attribute it is (but shouldn't
be) looking for.. e.g.

from obspy.core.util import AttribDict
evt = AttribDict()
evt['text']=EventID
evt['time']=UTCDateTime(TimeArr)
evt['picks']=[]

best,
Tobias

Hi Tobias

Thanks for the fast reply.

I have made the changes in waveform.py and now.... IT WORKS WELL!!!

Many thanks for the suggestion.

Cheers,

Sergio