Giter Site home page Giter Site logo

obspy / obspy Goto Github PK

View Code? Open in Web Editor NEW
1.1K 111.0 530.0 103.93 MB

ObsPy: A Python Toolbox for seismology/seismological observatories.

Home Page: https://www.obspy.org

License: Other

Shell 3.21% CSS 0.01% Python 74.97% HTML 0.03% TeX 0.40% AGS Script 0.16% C 11.65% Makefile 0.41% QML 0.17% Fortran 0.02% Batchfile 0.06% SaltStack 0.02% XSLT 4.11% Roff 3.28% MAXScript 0.01% Dockerfile 0.42% Jinja 0.01% JavaScript 0.03% SCSS 0.02% Euphoria 1.02%
seismology python observatories science earthquakes data-center waveforms signal-processing web-services lgplv3

obspy's Introduction

ObsPy: A Python Toolbox for seismology/seismological observatories.

NumFOCUS affiliated project

Github Action Status Coverage Status Supported Python versions

License LGPLv3

PyPI Version DOI Conda

Discourse status Gitter Announcements Mailing List

Mastodon Follow

ObsPy is an open-source project dedicated to provide a Python framework for processing seismological data. It provides parsers for common file formats, clients to access data centers and seismological signal processing routines which allow the manipulation of seismological time series (see Beyreuther et al. 2010, Megies et al. 2011, Krischer et al. 2015).

The goal of the ObsPy project is to facilitate rapid application development for seismology.

ObsPy is licensed under the GNU Lesser General Public License (LGPL) v3.0.

A one-hour introduction to ObsPy is available at YouTube.

Installation

Installation instructions can be found in the wiki.

Getting started

Read about how to get started in the wiki and in our Tutorial section in the documentation.

ObsPy Tutorial notebooks -- and much more on specific seismology topics -- can also be found on Seismo-Live, both as a static preview and as interactively runnable version.

Link to Seismo-Live

from obspy import read
st = read()  # load example seismogram
st.filter(type='highpass', freq=3.0)
st = st.select(component='Z')
st.plot()

Example waveform Plot

Documentation and Changelog

The detailed changelog is available here, our docs can be found at docs.obspy.org.

Contributing

Please see details on how to contribute to the project here.

References

Impact

obspy's People

Contributors

3rdcycle avatar aringler-usgs avatar barsch avatar bmorg avatar brtle avatar calum-chamberlain avatar celsoreyes avatar claudiodsf avatar d-chambers avatar dependabot[bot] avatar filefolder avatar flixha avatar heavelock avatar jkmacc-lanl avatar johnrudge avatar jollyfant avatar krischer avatar markcwill avatar martinvandriel avatar mbyt avatar megies avatar mmesch avatar nick-falco avatar paitor avatar qulogic avatar rothenhouser avatar thefroid avatar thomaslecocq avatar trichter avatar waynecrawford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

obspy's Issues

Waveform conversion problems

test.py:
{{{
from obspy.core import read
import sys

st = read("http://examples.obspy.org/gaps.mseed")
tr = st[0]
tr.write("gaps1.asc", format=sys.argv[1])
}}}

Executing tests:
{{{
for FORMAT in MSEED SAC GSE2 SH_ASC Q WAV; do python ./test.py $FORMAT; done

Traceback (most recent call last):
File "./test.py", line 6, in
tr.write("gaps1.asc", format=sys.argv[1])
File "/home/moritz/research/ffb/obspy/obspy.core/trunk/obspy/core/trace.py", line 409, in write
Stream([self]).write(filename, format, *_kwargs)
File "/home/moritz/research/ffb/obspy/obspy.core/trunk/obspy/core/stream.py", line 597, in write
writeFormat(self, filename, *_kwargs)
File "/home/moritz/research/ffb/obspy/obspy.mseed/trunk/obspy/mseed/core.py", line 188, in writeMSEED
raise Exception(msg)
Exception: Unsupported data type int32
Traceback (most recent call last):
File "./test.py", line 6, in
tr.write("gaps1.asc", format=sys.argv[1])
File "/home/moritz/research/ffb/obspy/obspy.core/trunk/obspy/core/trace.py", line 409, in write
Stream([self]).write(filename, format, *_kwargs)
File "/home/moritz/research/ffb/obspy/obspy.core/trunk/obspy/core/stream.py", line 597, in write
writeFormat(self, filename, *_kwargs)
File "/home/moritz/research/ffb/obspy/obspy.sac/trunk/obspy/sac/core.py", line 132, in writeSAC
trace.stats.sac.setdefault('nvhdr', 1)
File "/home/moritz/research/ffb/obspy/obspy.core/trunk/obspy/core/util.py", line 60, in getitem
return super(AttribDict, self).getitem(name)
KeyError: 'sac'
Traceback (most recent call last):
File "./test.py", line 6, in
tr.write("gaps1.asc", format=sys.argv[1])
File "/home/moritz/research/ffb/obspy/obspy.core/trunk/obspy/core/trace.py", line 409, in write
Stream([self]).write(filename, format, *_kwargs)
File "/home/moritz/research/ffb/obspy/obspy.core/trunk/obspy/core/stream.py", line 597, in write
writeFormat(self, filename, *_kwargs)
File "/home/moritz/research/ffb/obspy/obspy.sh/trunk/obspy/sh/core.py", line 202, in writeASC
for key, value in trace.stats.get('sh', []).iteritems():
AttributeError: 'list' object has no attribute 'iteritems'
Traceback (most recent call last):
File "./test.py", line 6, in
tr.write("gaps1.asc", format=sys.argv[1])
File "/home/moritz/research/ffb/obspy/obspy.core/trunk/obspy/core/trace.py", line 409, in write
Stream([self]).write(filename, format, *_kwargs)
File "/home/moritz/research/ffb/obspy/obspy.core/trunk/obspy/core/stream.py", line 597, in write
writeFormat(self, filename, *_kwargs)
File "/home/moritz/research/ffb/obspy/obspy.sh/trunk/obspy/sh/core.py", line 428, in writeQ
for key, value in trace.stats.get('sh', []).iteritems():
AttributeError: 'list' object has no attribute 'iteritems'
}}}

That is we have a major problem converting files. Most of the cases assume format specific attributes. We need test cases like this in our default tests.

spectroGram

Please correct the "spectroGram" spelling, it doesn't follow your naming conventions (and it's just illogical).

test_Backend stand-alone fails

test_Backend does not set the matplotlib backend, but tests for "Agg".upper(). This may not be valid for all matplotlib setups. I just paste the content of my '''~/.matplotlib/matplotlibrc''':

{{{
backend : TkAgg
interactive : True
}}}

In the full testing suite the '''Agg''' backend is set from obspy/imaging/tests/__init__.py, so that this issue will never show up there.

Some obspy.sac tests fail on Linux 32bit

python runtests.py -v sac

/home/krischer/workspace/obspy/obspy/branches/symlink/obspy/core/util.py:278: UserWarning: Unbuilt egg for obspy [unknown version] (/home/k$
mod = require(module)[0]
Doctest: obspy.sac.sacio.ReadSac.GetHvalueFromFile ... ok
Doctest: obspy.sac.sacio.ReadSac.ReadSacFile ... ok
Doctest: obspy.sac.sacio.ReadSac.ReadSacHeader ... ok
Doctest: obspy.sac.sacio.ReadSac.ReadSacXY ... ok
Doctest: obspy.sac.sacio.ReadSac.SetHvalue ... ok
Doctest: obspy.sac.sacio.ReadSac.SetHvalueInFile ... ok
Doctest: obspy.sac.sacio.ReadSac.WriteSacBinary ... ok
Doctest: obspy.sac.sacio.ReadSac.WriteSacHeader ... ok
Doctest: obspy.sac.sacio.ReadSac.WriteSacXY ... ok
Doctest: obspy.sac.sacio.ReadSac.get_date ... ok
Doctest: obspy.sac.sacio.ReadSac.get_dist ... FAIL
Doctest: obspy.sac.sacio.ReadSac.fromarray ... ok
Doctest: obspy.sac.sacio.ReadSac.swap_byte_order ... ok
test_Date (obspy.sac.tests.test_sacio.SacioTestCase) ... ok
test_Write (obspy.sac.tests.test_sacio.SacioTestCase) ... ok
test_getdist (obspy.sac.tests.test_sacio.SacioTestCase) ... FAIL
test_isSAC (obspy.sac.tests.test_sacio.SacioTestCase) ... ok
test_read (obspy.sac.tests.test_sacio.SacioTestCase) ... ok
test_readBigEnd (obspy.sac.tests.test_sacio.SacioTestCase) ... ok
test_readWrite (obspy.sac.tests.test_sacio.SacioTestCase) ... ok
test_readWriteXY (obspy.sac.tests.test_sacio.SacioTestCase) ... ok
test_swapbytes (obspy.sac.tests.test_sacio.SacioTestCase) ... ok
test_readAndWriteViaObspy (obspy.sac.tests.test_core.CoreTestCase) ... ok
test_readHeadViaObspy (obspy.sac.tests.test_core.CoreTestCase) ... ok
test_readViaObspy (obspy.sac.tests.test_core.CoreTestCase) ... ok
test_writeViaObspy (obspy.sac.tests.test_core.CoreTestCase) ... ok

FAIL: Doctest: obspy.sac.sacio.ReadSac.get_dist

Traceback (most recent call last):
File "/usr/lib/python2.5/doctest.py", line 2128, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for obspy.sac.sacio.ReadSac.get_dist
File "/home/krischer/workspace/obspy/obspy/branches/symlink/obspy/sac/sacio.py", line 766, in get_dist


File "/home/krischer/workspace/obspy/obspy/branches/symlink/obspy/sac/sacio.py", line 778, in obspy.sac.sacio.ReadSac.get_dist
Failed example:
round(abs(t.GetHvalue('dist') - 18486532.0),5)
Expected:
0.0
Got:
18468045.466800001

FAIL: test_getdist (obspy.sac.tests.test_sacio.SacioTestCase)

Traceback (most recent call last):
File "/home/krischer/workspace/obspy/obspy/branches/symlink/obspy/sac/tests/test_sacio.py", line 153, in test_getdist
self.assertEqual(t2.GetHvalue('dist'), 18486532.0)
AssertionError: 18486.533 != 18486532.0


Ran 26 tests in 0.651s

FAILED (failures=2)

GSE Integer Problem?

GseParser Output sind Integer, die eigentlich mit e.g. 2.5290e-01 (dem Wert nach der Sampling Frequenz im Header) multipliziert werden sollten.

obspy.Trace.stats Attribut-Dictionary cannot be pickled.

{{{

!python

import obspy, pickle, cPickle
st = obspy.read('test.mseed')

Pickling raises a KeyError.

... pickle.dumps(st[0].stats)
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (171, 0))


KeyError Traceback (most recent call last)

/home/lion/Dokumente/Arbeit/Tests/ in ()

/usr/lib/python2.6/pickle.pyc in dumps(obj, protocol)
1364 def dumps(obj, protocol=None):
1365 file = StringIO()
-> 1366 Pickler(file, protocol).dump(obj)
1367 return file.getvalue()
1368

/usr/lib/python2.6/pickle.pyc in dump(self, obj)
222 if self.proto >= 2:
223 self.write(PROTO + chr(self.proto))
--> 224 self.save(obj)
225 self.write(STOP)
226

/usr/lib/python2.6/pickle.pyc in save(self, obj)
304 reduce = getattr(obj, "reduce_ex", None)
305 if reduce:
--> 306 rv = reduce(self.proto)
307 else:
308 reduce = getattr(obj, "reduce", None)

/usr/lib/python2.6/copy_reg.pyc in _reduce_ex(self, proto)
72 args = (self.class, base, state)
73 try:
---> 74 getstate = self.getstate
75 except AttributeError:
76 if getattr(self, "slots", None):

/home/lion/workspace/obspy/obspy.core/trunk/obspy/core/util.pyc in getitem(self, name)
48
49 def getitem(self, name):
---> 50 return super(AttribDict, self).getitem(name)
51
52 def delitem(self, name):

KeyError: 'getstate'

The same is True when using cPickle.

... cPickle.dumps(st[0].stats)

KeyError Traceback (most recent call last)

/home/lion/Dokumente/Arbeit/Tests/ in ()

/usr/lib/python2.6/copy_reg.pyc in _reduce_ex(self, proto)
72 args = (self.class, base, state)
73 try:
---> 74 getstate = self.getstate
75 except AttributeError:
76 if getattr(self, "slots", None):

/home/lion/workspace/obspy/obspy.core/trunk/obspy/core/util.pyc in getitem(self, name)
48
49 def getitem(self, name):
---> 50 return super(AttribDict, self).getitem(name)
51
52 def delitem(self, name):

KeyError: 'getstate'

}}}

runtests.py relys on all modules

If not all obspy modules are installed (e.g. seisan, wav or sh), runtests.py fails completely:

{{{
$ python runtests.py -v

Traceback (most recent call last):
File "runtests.py", line 88, in
main()
File "runtests.py", line 80, in main
runTests(verbosity, parser.largs)
File "runtests.py", line 59, in runTests
unittest.TextTestRunner(verbosity=verbosity).run(suite(tests))
File "runtests.py", line 47, in suite
suite = unittest.TestLoader().loadTestsFromNames(names)
File "/usr/lib/python2.5/unittest.py", line 565, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python2.5/unittest.py", line 541, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'wav'
}}}

Introduce start, end and length attributes to all waveform importer

We should uniformly support start, end and length attributes at the read methods for each waveform module, e.g.

Reading 200 samples from position 100
{{{

st = read(filename, start=100, length=200)
}}}

Reading 100 samples from position 300
{{{

st = read(filename, start=300, end=400)
}}}

Reading 400 samples from given start time
{{{

start = UTCDateTime(2009,1,1)
st = read(filename, start=start, length=400)
}}}

Reading all samples until given end time
{{{

end = UTCDateTime(2009,1,1)
st = read(filename, end=end)
}}}

There two possibilities to suport this feature:
(1) '''native''' - the import module itself supports this feature by skipping (seek) to the relevant file position and reading only the relevant part.

(2) '''via global read() method''' - if the latter is not possible, than the read method itself could cut/trim the stream to the relevant part

Notes:

  • Feature (1) could be announced to the global read() method via the plugin architecture.
  • obspy.mseed and obspy.sh.asc partly support this features already.

readMSTracesViaRecords is not thread safe.

The method of readMSTracesViaRecords is currently not thread safe.

See test_readMSTracesViaRecords_thread_safety in the [http://svn.geophysik.uni-muenchen.de/trac/obspy/browser/obspy.mseed/trunk/obspy/mseed/tests/test_libmseed.py libmseed test suite]. It actually quits Python with some memory error after some complaining. The same test passes when using readMSTraces.

This is due to ms_readmsr in the libmseed not being thread safe. The solution probably would be/was to use ms_readmsr_r which in turn was responsible for the memory leaks of obspy.mseed ...

import obspy; st = obspy.read(file) does still not work

{{{

!bash

como:T6$ svn update ~/local/src/obspy/
At revision 830.
como:T6$ python -c "import obspy; st = obspy.read('GR.FUR..BHN.D.2008.133'); print st"
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute 'read'
}}}

Calibration factor support

The traces do not support a calibation factor. This makes any amplitude related calculation impossible.

Built-in trace plotting doesn't work

I assume that's related to my rather old matplotlib installation (same procedure as last year):

{{{

In [11]: st.plot(outfile="/tmp/x.png")

<type 'exceptions.AttributeError'> Traceback (most recent call last)

/misc/b311/walther/IT/SHX/shx/src/SeismicHandler/3rdparty/obspy/core/ in ()

/home/walther/shx-src/SeismicHandler/3rdparty/obspy/core/stream.py in plot(self, _args, *_kwargs)
456 raise
457 waveform = WaveformPlotting(stream=self, _args, *_kwargs)
--> 458 waveform.plotWaveform()
459
460 def pop(self, index= -1):

/home/walther/shx-src/SeismicHandler/3rdparty/obspy/imaging/waveform.py in plotWaveform(self, _args, *_kwargs)
136 plt.ioff()
137 # Setup the figure.
--> 138 self.__setupFigure()
139 # Determine kind of plot and do the actual plotting.
140 if self.type == 'normal':

/home/walther/shx-src/SeismicHandler/3rdparty/obspy/imaging/waveform.py in __setupFigure(self)
660 pattern = '%Y-%m-%dT%H:%M:%SZ'
661 suptitle = '%s - %s' % (self.starttime.strftime(pattern),
662 self.endtime.strftime(pattern))
--> 663 plt.suptitle(suptitle, x=0.02, y=0.96, fontsize='small',
664 horizontalalignment='left')

<type 'exceptions.AttributeError'>: 'module' object has no attribute 'suptitle'
}}}

I'm using the latest obspy sources (rev 960).

fissures test fails

the obspy.fissures test gets stuck and if I try initialise a client-instance I get the following error:

In [7]: import obspy.fissures as fs

In [8]: a = fs.Client()

TRANSIENT Traceback (most recent call last)

/home/behrya/dev/obspy/obspy/branches/symlink/obspy/ in ()

/home/behrya/dev/obspy/obspy/branches/symlink/obspy/fissures/client.py in init(self, network_dc, seismogram_dc)
86 #
87 # Resolve naming service
---> 88 self.rootContext = self.obj._narrow(NamingContext)
89 #
90 # network cosnaming

/usr/local/lib/python2.5/site-packages/omniORB/CORBA.pyc in _narrow(self, dest)
1 # Small hack to make omniORB.CORBA appear as CORBA
2
3 import sys, omniORB.CORBA
4 sys.modules["CORBA"] = omniORB.CORBA

TRANSIENT: CORBA.TRANSIENT(omniORB.TRANSIENT_ConnectFailed, CORBA.COMPLETED_NO)

I guess I'm having some firewall issues but I couldn't figure out what I have to change to make it work. Any suggestions?

test_Waveform fails in complete test run, but passes when called stand-alone

When running '''python testing.py -v''' inside obspy/core the test '''test_Waveform''' throws an exception:

{{{

ERROR: test_Waveform (obspy.imaging.tests.test_spectrogram.SpectrogramTestCase)

Traceback (most recent call last):
File "/home/walther/shx-src/SeismicHandler/3rdparty/obspy/imaging/tests/test_spectrogram.py", line 40, in test_Waveform
log=True, outfile=outfile)
File "/home/walther/shx-src/SeismicHandler/3rdparty/obspy/imaging/spectrogram.py", line 117, in spectrogram
plt.savefig(outfile)
File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line 269, in savefig
return fig.savefig(_args, *_kwargs)
File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line 782, in savefig
self.canvas.print_figure(_args, *_kwargs)
File "/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py", line 1201, in print_figure
self.figure.canvas.draw()
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py", line 358, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line 624, in draw
for a in self.axes: a.draw(renderer)
File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 1345, in draw
a.draw(renderer)
File "/usr/lib/python2.5/site-packages/matplotlib/patches.py", line 223, in draw
tverts = self.get_transform().seq_xy_tups(verts)
ValueError: Cannot take log of nonpositive value
}}}

This test case completes without hassle if started independently:

{{{
.../obspy/imaging/tests$ python test_spectrogram.py -v
test_Waveform (main.SpectrogramTestCase) ... ok


Ran 1 test in 0.794s

OK
}}}

Since the random numbers used for this test are in fact identical I'm a bit stunned by this issue.

Use of matplotlib

You set options for matplotlib using

{{{
matplotlib.use('Agg', warn=False)
}}}

The argument "warn" is not supported in older versions of matplotlib (e.g. shipped with Ubuntu 8.04 (which is an LTS version supported until 2013)):

{{{
In [1]: import matplotlib

In [2]: matplotlib.version
Out[2]: '0.91.2'

In [3]: matplotlib.use("Agg", warn=False)

<type 'exceptions.TypeError'> Traceback (most recent call last)

/home/walther/ in ()

<type 'exceptions.TypeError'>: use() got an unexpected keyword argument 'warn'
}}}

Creating SEED RESP files from parsed XML-SEED file fails

See commit [740] obspy.xseed/tests/test_parser.py

In short -> Blockettes contain Strings from parsed XML - therefore checks like "self.number_of_zeros > 0" won't work

we need to convert the values to the correct data type using the information given within each single field ...

Bug in obspy.mseed.write(.., encoding=0) for small ASCII strings

Working ...
{{{
from obspy.core import read, Trace, Stream, UTCDateTime
import numpy as np

data = np.fromstring("very big string with at least 17 chars", dtype='|S1')
tr = Trace(data=data)
tr.write("muh.mseed", format='MSEED', encoding=0, reclen=256)
}}}

Won't work:
{{{
data = np.fromstring("small string", dtype='|S1')
tr = Trace(data=data)
tr.write("muh.mseed", format='MSEED', encoding=0, reclen=256)
}}}

AttributeError: Attribute "endtime" in Stats object is read only!

There seem to be some problems plotting special mseed files. For the following one, it does not work any more.
For others it still works. Doing the following

{{{

!python

import obspy.core

st = obspy.core.read("ArclinkRequest_398382")
st.plot()
}}}

results in Error message:

{{{
Traceback (most recent call last):
File "error.py", line 4, in
st.plot()
File "/home/beyreuth/research/ffb/obspy/obspy.core/trunk/obspy/core/stream.py", line 331, in plot
waveform.plotWaveform()
File "/home/beyreuth/research/ffb/obspy/obspy.imaging/trunk/obspy/imaging/waveform.py", line 141, in plotWaveform
self.plot(_args, *_kwargs)
File "/home/beyreuth/research/ffb/obspy/obspy.imaging/trunk/obspy/imaging/waveform.py", line 212, in plot
self.*plotStraight(stream_new[_i], _args, _kwargs)
File "/home/beyreuth/research/ffb/obspy/obspy.imaging/trunk/obspy/imaging/waveform.py", line 318, in __plotStraight
trace.stats.endtime = self.endtime
File "/home/beyreuth/research/ffb/obspy/obspy.core/trunk/obspy/core/trace.py", line 32, in __setitem

raise AttributeError(msg)
AttributeError: Attribute "endtime" in Stats object is read only!
}}}

GSE2 test suite fails on windows

{{{

FAIL: test_readAndWriteViaObspy (obspy.gse2.tests.test_core.CoreTestCase)

Traceback (most recent call last):
File "C:\Users\Robert\Workspace\obspy\obspy.gse2\trunk\obspy\gse2\tests\test_core.py", line 67, in test_readAndWriteViaObspy
self.assertEqual(tr3.stats.gse2.get('calib'), tr.stats.gse2.get('calib'))
AssertionError: 5.9600000381469727 != 0.59600001573562622
}}}

Bug is still related to the exponential format!

Temporary GSE file looks like that:
{{{
WID2 2004/06/09 20:05:59.850 RNON Z RNON CM6 12000 200.000000 5.9600e-001 1.000 0.0 -1.0
WID2 2004/06/09 20:05:59.850 RNON Z RNON CM6 12000 200.000000 5.9600e-01 1.000 0.0 -1.0
DAT2
JTVCkPGGHUSl9UMUOl762kKUTUIl3MHUSHl0VPkGl3UF-ULl0AUMlAUMULl5FV+ONFkHV+8l4UL3kSUT
}}}

python setup.py build_ext does not move/install libraries from build to obspy/gse2/lib directory

Here an example:

{{{
como:trunk$ svn info
Path: .
URL: https://[email protected]/svn/obspy/obspy.gse2/trunk
Repository Root: https://[email protected]/svn/obspy
Repository UUID: 4d6d3c52-f836-0410-912b-bd33546c67dc
Revision: 828
Node Kind: directory
Schedule: normal
Last Changed Author: barsch
Last Changed Rev: 825
Last Changed Date: 2009-12-10 06:37:46 +0100 (Thu, 10 Dec 2009)

como:trunk$ pwd
/home/beyreuth/local/src/obspy/obspy.gse2/trunk
como:trunk$ python setup.py build_ext
running build_ext
building 'gse_functions' extension
creating build
creating build/temp.linux-i686-2.5
creating build/temp.linux-i686-2.5/obspy
creating build/temp.linux-i686-2.5/obspy/gse2
creating build/temp.linux-i686-2.5/obspy/gse2/src
creating build/temp.linux-i686-2.5/obspy/gse2/src/GSE_UTI
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c obspy/gse2/src/GSE_UTI/buf.c -o build/temp.linux-i686-2.5/obspy/gse2/src/GSE_UTI/buf.o
In file included from obspy/gse2/src/GSE_UTI/buf.c:25:
obspy/gse2/src/GSE_UTI/buf.h:1: warning: function declaration isn’t a prototype
obspy/gse2/src/GSE_UTI/buf.h:4: warning: function declaration isn’t a prototype
In file included from obspy/gse2/src/GSE_UTI/buf.c:26:
obspy/gse2/src/GSE_UTI/buf_intern.h:10: warning: function declaration isn’t a prototype
obspy/gse2/src/GSE_UTI/buf.c:42: warning: function declaration isn’t a prototype
obspy/gse2/src/GSE_UTI/buf.c:142: warning: function declaration isn’t a prototype
obspy/gse2/src/GSE_UTI/buf.c:168: warning: function declaration isn’t a prototype
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c obspy/gse2/src/GSE_UTI/gse_functions.c -o build/temp.linux-i686-2.5/obspy/gse2/src/GSE_UTI/gse_functions.o
In file included from obspy/gse2/src/GSE_UTI/gse_functions.c:7:
obspy/gse2/src/GSE_UTI/buf.h:1: warning: function declaration isn’t a prototype
obspy/gse2/src/GSE_UTI/buf.h:4: warning: function declaration isn’t a prototype
obspy/gse2/src/GSE_UTI/gse_functions.c: In function ‘decomp_6b’:
obspy/gse2/src/GSE_UTI/gse_functions.c:215: warning: implicit declaration of function ‘isspace’
creating build/lib.linux-i686-2.5
creating build/lib.linux-i686-2.5/obspy
creating build/lib.linux-i686-2.5/obspy/gse2
creating build/lib.linux-i686-2.5/obspy/gse2/lib
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-i686-2.5/obspy/gse2/src/GSE_UTI/buf.o build/temp.linux-i686-2.5/obspy/gse2/src/GSE_UTI/gse_functions.o -o build/lib.linux-i686-2.5/obspy/gse2/lib/gse_functions.so
como:trunk$ find ./ -name "gse_functions.so" -ls
15571547 24 -rwxr-x--- 1 beyreuth users 24420 Sep 15 13:27 ./obspy/gse2/lib/gse_functions.so
5026973 24 -rwxr-x--- 1 beyreuth users 20877 Dec 10 10:48 ./build/lib.linux-i686-2.5/obspy/gse2/lib/gse_functions.so
}}}

That is ./obspy/gse2/lib/gse_functions.so is not updated.

Seisan test files needed

We need additional test files for full coverage of the seisan waveform format - especially files written on a 64 bit architecture under little and big endian. Extracted data in ASCII format + meta data would also help a lot to write comparing tests.

If you can provide us with some data - please append your files. Thanks!

Strange problem with Trace.stats

Hi,

mir ist ein komisches Problem aufgefallen beim Ändern der stats Attribute
des obspy.Stream Objekts. Ich weiß nicht woran es liegt und es tritt auch
nicht immer auf, aber im hier angeführten Fall ist es reproduzierbar.
{{{

import obspy
st = obspy.read('test.mseed')
st += st
print st
2 Trace(s) in Stream:
NL.HGN.00.BHZ | 2003-05-29T02:13:22.043400 -- 2003-05-29T02:18:20.693400 |
40.000000 Hz, 11947 samples
NL.HGN.00.BHZ | 2003-05-29T02:13:22.043400 -- 2003-05-29T02:18:20.693400 |
40.000000 Hz, 11947 samples

Ändern der stats attribute auf zwei verschieden Arten.

st[0].stats.station = 'AAA'
st[1].stats['station'] = 'BBB'
print st
2 Trace(s) in Stream:
NL.AAA.00.BHZ | 2003-05-29T02:13:22.043400 -- 2003-05-29T02:18:20.693400 |
40.000000 Hz, 11947 samples
NL.BBB.00.BHZ | 2003-05-29T02:13:22.043400 -- 2003-05-29T02:18:20.693400 |
40.000000 Hz, 11947 samples
st[0].stats.station
'AAA'
st[0].stats['station']
'AAA'
}}}

Soweit alles gut, nun das Problem:

{{{

st[1].stats['station']
'BBB'
st[1].stats.station
'HGN'
}}}

Tritt bei einem einzelnen Trace nicht auf und hier auch nur beim zweiten
Trace. Den ersten Trace kann man per Dictionary ändern.

Finde ich ein bisschen komisch und unverhersehbar. Irgendwelche Ideen?

Three obspy.mseed.core tests are failing - can't delete file, cause it's used by another process

Failing on three different boxes - 2x Win XP, 1x Vista

{{{

.......EEE

ERROR: test_writeAndReadDifferentEncodings (main.CoreTestCase)

Traceback (most recent call last):
File "C:\Dokumente und Einstellungen\Robert\workspace\obspy\obspy.mseed\trunk\obspy\mseed\tests\test_core.py", line 258, in test_writeAndReadDifferentEncodings
os.remove(tempfile)
WindowsError: [Error 32] Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird: 'temp1.mseed'

ERROR: test_writeAndReadDifferentRecordLengths (main.CoreTestCase)

Traceback (most recent call last):
File "C:\Dokumente und Einstellungen\Robert\workspace\obspy\obspy.mseed\trunk\obspy\mseed\tests\test_core.py", line 186, in test_writeAndReadDifferentRecordLengths
os.remove(tempfile)
WindowsError: [Error 32] Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird: 'temp1.mseed'

ERROR: test_writeIntegersViaObsPy (main.CoreTestCase)

Traceback (most recent call last):
File "C:\Dokumente und Einstellungen\Robert\workspace\obspy\obspy.mseed\trunk\obspy\mseed\tests\test_core.py", line 111, in test_writeIntegersViaObsPy
os.remove(tempfile)
WindowsError: [Error 32] Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird: 'temp1.mseed'


Ran 10 tests in 0.453s

FAILED (errors=3)

}}}

mseed/tests/test_plotting.py

Plotting test of mseed shold be migrated to obspy.imaging?

python2.5 obspy/mseed/tests/test_plotting.py
EE
======================================================================
ERROR: test_LibMSEEDPlot (__main__.LibMSEEDPlottingTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "mseed/tests/test_plotting.py", line 39, in test_LibMSEEDPlot
    minmaxlist = mseed._getMinMaxList(mseed_file, 777)
AttributeError: 'libmseed' object has no attribute '_getMinMaxList'

======================================================================
ERROR: test_PlotOutputFormats (__main__.LibMSEEDPlottingTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "mseed/tests/test_plotting.py", line 107, in test_PlotOutputFormats
    minmaxlist = mseed._getMinMaxList(mseed_file, 50)
AttributeError: 'libmseed' object has no attribute '_getMinMaxList'

----------------------------------------------------------------------
Ran 2 tests in 0.001s

Two tests additional fail for "python -O testing.py"

A test run in optimized mode
{{{
python -O testing.py
}}}

produces on my machine the following errors:

{{{
...

ERROR: test_arrayNotNumpy (obspy.gse2.tests.test_libgse2.LibGSE2TestCase)

Traceback (most recent call last):
File "c:\users\robert\workspace\obspy\obspy.gse2\trunk\obspy\gse2\tests\test_libgse2.py", line 133, in test_arrayNotNumpy
testfile)
File "C:\Programme\Python26\lib\unittest.py", line 336, in failUnlessRaises
callableObj(_args, *_kwargs)
File "c:\users\robert\workspace\obspy\obspy.gse2\trunk\obspy\gse2\libgse2.py", line 268, in write
if data.max() > 2 ** 26:
AttributeError: 'list' object has no attribute 'max'

ERROR: test_trigger3 (obspy.trigger.tests.test_trigger.TriggerTestCase)

Traceback (most recent call last):
File "c:\users\robert\workspace\obspy\obspy.trigger\trunk\obspy\trigger\tests\test_trigger.py", line 48, in test_trigger3
self.assertRaises(AssertionError, recStalta, [1], 5, 10)
File "C:\Programme\Python26\lib\unittest.py", line 336, in failUnlessRaises
callableObj(_args, *_kwargs)
File "c:\users\robert\workspace\obspy\obspy.trigger\trunk\obspy\trigger\trigger.py", line 75, in recStalta
charfct = C.pointer(lib.recstalta(a.ctypes.data_as(C.c_void_p),
AttributeError: 'list' object has no attribute 'ctypes'


Ran 109 tests in 13.119s
}}}

My guess: they are somehow related to type checkings and/or internal conversion from numpy array to list ...

Force types in stats

I think it would be useful to force the types in the stats attribute dictionary. I noticed by accident that it is e.g. possible to assign an integer value to stats.sampling_rate or a float value to stats.npts.

This breaks some calculations that rely on fixed types in stats.

mseed test test_unpackSteim2 fails

{{{

ERROR: test_unpackSteim2 (obspy.mseed.tests.test_libmseed.LibMSEEDTestCase)

Traceback (most recent call last):
File "/home/walther/shx-src/SeismicHandler/3rdparty/obspy/mseed/tests/test_libmseed.py", line 631, in test_unpackSteim2
data_record = mseed.readMSTracesViaRecords(steim2_file)[0][1]
File "/home/walther/shx-src/SeismicHandler/3rdparty/obspy/mseed/libmseed.py", line 149, in readMSTracesViaRecords
raise_flag=True)
File "/home/walther/shx-src/SeismicHandler/3rdparty/obspy/mseed/libmseed.py", line 1055, in read
raise Exception("Error in ms_readmsr_r")
Exception: Error in ms_readmsr_r
}}}

Tested using bundled library as well as self-compiled from revision 993 on Linux 32-bit.

Improve encoding handling for obspy.mseed

(1) obspy.mseed should automatically choose the right output format - in this case float32
{{{

!python

import asc
a=asc.readASC("tests/data/TEST_090101_0101.ASC")
a[0].data.dtype
dtype('float32')
a.write("test.mseed", format="MSEED")
Exception: Data must be of type numpy.ndarray dtype int32
}}}

(2) Possible encoding options are not human readable nor really meaningful. This should be 'STEIM1', 'STEIM2', 'FLOAT' etc. or the integer values if someone is really deep into SEED.
{{{

!python

import asc
a=asc.readASC("tests/data/TEST_090101_0101.ASC")
a[0].data.dtype
dtype('float32')
a.write("test.mseed", format="MSEED", encoding="unknown")
ValueError: Invalid encoding f. Valid encodings: [0, 3, 4, 5, 10, 11, -1]
}}}

python xseed/tests/__init__.py fails on python 2.5

Cannot verify xseed tests on python2.5, warnings.catch_warnings are not existent.

python xseed/tests/init.py

................E.....

ERROR: test_missingRequiredDateTimes (obspy.xseed.tests.test_parser.ParserTestCase)

Traceback (most recent call last):
File "/home/moritz/research/ffb/obspy/obspy/branches/symlink/obspy/xseed/tests/test_parser.py", line 327, in test_missingRequiredDateTimes
with warnings.catch_warnings(record=True):
AttributeError: 'module' object has no attribute 'catch_warnings'


Ran 22 tests in 8.859s

FAILED (errors=1)

Stream.merge(): shape mismatch: objects cannot be broadcast to a single shape

Test file may be found in the BW archive.

{{{
In [1]: from obspy.core import read

In [2]: st=read("BW.ZUGS..EHE.D.2010.007")

In [3]: print st
------> print(st)
4 Trace(s) in Stream:
BW.ZUGS..EHE | 2010-01-06T23:59:59.975000Z - 2010-01-07T07:41:01.650000Z | 200.0 Hz, 5532336 samples
BW.ZUGS..EHE | 2010-01-07T07:41:02.660000Z - 2010-01-07T08:01:45.865000Z | 200.0 Hz, 248642 samples
BW.ZUGS..EHE | 2010-01-07T08:01:44.870000Z - 2010-01-07T20:03:42.545000Z | 200.0 Hz, 8663536 samples
BW.ZUGS..EHE | 2010-01-07T20:03:42.535000Z - 2010-01-08T00:00:00.480000Z | 200.0 Hz, 2835590 samples

In [4]: st.merge()

ValueError Traceback (most recent call last)

C:\Users\barsch\Workspace\seishub\trunk\data\new34\2010\BW\ZUGS\EHE.D in ()

c:\users\barsch\workspace\obspy\obspy.core\trunk\obspy\core\stream.pyc in merge(self)
700 # Update the old trace with the interpolation.

701                     cur_trace[-1][left_delta:] = \

--> 702 (cur_trace[-1][left_delta:] + trace[:right_delta]) / 2
703 # Append the rest of the trace.

704                     cur_trace.append(trace[right_delta:])

ValueError: shape mismatch: objects cannot be broadcast to a single shape
}}}

cannot read mini-SEED trace from a full seed file

I have a seed-file that I can read with the xseed.Parser
but I can't read the trace the way Moritz showed it in one
of the example lists. The Error I get is:

In [13]: from obspy.core import read
In [14]: st = read('rf1S1_BHZ.seed')
Error: Cannot detect record length at byte offset 28672: rf1S1_BHZ.seed

It could be a big-endian file. Is that supported in the mseed-module?

Cheers,
Yannik

Waveform plotting of short seismograms

Currently waveform plotting is intended to be used with large amounts of data points (at least 10000 data points). It works with smaller data sets too but results will look strange and confusing as can be seen in the attached picture. A new method for plotting these small sets and a switch in the plotting function that decides which method will be used for plotting the seismograms need to be implemented.
This is probably not trivial as the new method needs to account for any possible gaps and overlaps present in the seismograms.

[[Image(SmallDataSet.png, border=1)]]

SH_ASC writing fails

{{{
from obspy.core import read
st = read("http://examples.obspy.org/gaps.mseed")
tr = st[0]
tr.write("gaps1.asc", format="SH_ASC")

Traceback (most recent call last):
File "test.py", line 4, in
st.write("gaps1.asc", format="SH_ASC")
File "/home/moritz/research/ffb/obspy/obspy.core/trunk/obspy/core/stream.py", line 597, in write
writeFormat(self, filename, **kwargs)
File "/home/moritz/research/ffb/obspy/obspy.sh/trunk/obspy/sh/core.py", line 202, in writeASC
for key, value in trace.stats.get('sh', []).iteritems():
AttributeError: 'list' object has no attribute 'iteritems'
}}}

Failing test for obspy.signal.trigger ('EPU4' != 'IPU0')

failing on three different boxes: 2x WinXP, 1x Vista

{{{

.F....

FAIL: test_pkBaer (main.TriggerTestCase)

Traceback (most recent call last):
File "C:\Dokumente und Einstellungen\Robert\workspace\obspy\obspy.signal\trunk\obspy\signal\tests\test_trigger.py", line 73, in test_pkBaer
self.assertEquals(pfm, 'IPU0')
AssertionError: 'EPU4' != 'IPU0'


Ran 6 tests in 2.922s

FAILED (failures=1)
}}}

obspy.imaging.waveform: ValueError: zero-size array to ufunc.reduce without identity

{{{

import obspy
from obspy.seishub.client import Client
c = Client("http://teide.geophysik.uni-muenchen.de:8080")
start = obspy.UTCDateTime(2008,1,1,12,00,00)
end = start + 10
st = c.waveform.getWaveform("BW", "MANZ", "", "_", start, end)
Enter username for SeisHub at teide.geophysik.uni-muenchen.de:8080: admin
Enter password for admin in SeisHub at teide.geophysik.uni-muenchen.de:8080:
st.plot()
Traceback (most recent call last):
File "", line 1, in
File "c:\users\robert\workspace\obspy\obspy.core\trunk\obspy\core\stream.py", line 306, in plot
waveform.plotWaveform(self, *_kwargs)
File "c:\users\robert\workspace\obspy\obspy.imaging\trunk\obspy\imaging\waveform.py", line 119, in plotWaveform
endtime=endtime)
File "c:\users\robert\workspace\obspy\obspy.imaging\trunk\obspy\imaging\waveform.py", line 379, in _getMinMaxList
maxlist.append(_i.data[int(start) : int(end)].max())
ValueError: zero-size array to ufunc.reduce without identity
}}}

ArcLink fails to get PAZ from arclink node erde

{{{
python arclink/tests/test_client.py ClientTestCase.test_getPAZ2

E

ERROR: test_getPAZ2 (main.ClientTestCase)

Traceback (most recent call last):
File "arclink/tests/test_client.py", line 231, in test_getPAZ2
paz = client.getPAZ('BW', 'MANZ', '', 'EHZ', t, t+1)
File "/home/moritz/research/ffb/obspy/obspy/branches/symlink/obspy/arclink/client.py", line 273, in getPAZ
xml_doc = objectify.fromstring(xml_doc, self.inventory_parser)
File "lxml.objectify.pyx", line 1820, in lxml.objectify.fromstring (src/lxml/lxml.objectify.c:16186)
File "lxml.etree.pyx", line 2433, in lxml.etree.fromstring (src/lxml/lxml.etree.c:21907)
File "parser.pxi", line 1511, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:60613)
File "parser.pxi", line 1390, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:59530)
File "parser.pxi", line 932, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:56815)
File "parser.pxi", line 538, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:53512)
File "parser.pxi", line 624, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:54372)
File "parser.pxi", line 564, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:53770)
XMLSyntaxError: Element '{http://geofon.gfz-potsdam.de/ns/inventory/0.2/}station': The attribute 'archive_net' is required but missing.


Ran 1 test in 0.685s

FAILED (errors=1)
}}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.