emolch/pyrocko — pull request #12 by HerrMuellerluedenscheid (2013-10-25 13:35:44+00:00)
Title: new traces from scratch did not have self.file

Hi,

this snippet:

import numpy as np
from pyrocko import trace, pile

ydata = np.array([1,2,3,4,5,51,2,3,2,2])
tt = trace.Trace(station='test', ydata=ydata)
tp = pile.Pile()
tp.add(tt)
print tp.all()

caused the following exception:

Traceback (most recent call last):
File "test_kann_weg.py", line 8, in
print tp.all()
File "/home/zmaw/u254061/.local/lib/python2.6/site-packages/pyrocko/pile.py", line 1028, in all
for traces in self.chopper( *args, **kwargs ):
File "/home/zmaw/u254061/.local/lib/python2.6/site-packages/pyrocko/pile.py", line 995, in chopper
chopped, used_files = self.chop(wmin-tpad, wmax+tpad, group_selector, trace_selector, snap, include_last, load_data)
File "/home/zmaw/u254061/.local/lib/python2.6/site-packages/pyrocko/pile.py", line 901, in chop
if tr.file not in used_files:
AttributeError: 'Trace' object has no attribute 'file'

The two extra lines should avoid this.