plotting record sections: type of trace.stats.coordinates


I’m fiddling around with the object in order to plot a seismic section, however reading up on the documentation () I find that I need to set the regP

Hi Peter,

there is a source code link in the example below which should help.



I'm fiddling around with the object in
order to plot a seismic section, however reading up on the


I find that I need to set the |trace.stats.distance or

If "data" is the trace of interest, this should do the job.

data.stats.coordinates = AttribDict(dict(latitude=lat,

Hi Robert

Thanks for the link, I guess that pretty much confirms my guess that trace.stats.distance can simply be set to a float, but does not offer any insight into how to assign a value trace.stats.coordinates. I suspect that it would work to define my own class with the attributes latitude and longitude, and the assign an object of this class to trace.stats.coordinates. However, given that these attributes are expected one of the methods in the Stream class I would suspect that such a coordinate class already exist in obspy.

Thus I guess my question boils down to: is there in obspy a coordinate class with attributes latitude and longitude that is appropriate to use as vale for trace.stats.coordinates or do I need to define such a class myself

regards Peter

Hi Peter,

Not sure if it is the smartest way, but try:

with st your stream with traces:

tr= st[0]
tr.stats[“coordinates”] = {} # add the coordinates to your dictionary, needed for the section plot
tr.stats[“coordinates”][“latitude”] = 0.
tr.stats[“coordinates”][“longitude”] = 27.4

Hi Kasper

Thanks for shipping in, that actually works nicely, thanks.

Hmmm interesting baseclass, AttribDict


Hi Weston

Great, thanks. I guess this is the proper way to what Kasper suggest.


I am trying to install Obspy version 0.10.2 using mac ports with python version 2.7.10 on a Mac OsX 10.10.3. The installation goes without warnings nor errors, but when I run “import obspy” into python I get the following errors:

import obspy
Traceback (most recent call last):
File “”, line 1, in
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/”, line 36, in
from obspy.core.utcdatetime import UTCDateTime # NOQA
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/core/”, line 107, in
from obspy.core.util.attribdict import AttribDict
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/core/util/”, line 27, in
from obspy.core.util.base import (ALL_MODULES, DEFAULT_MODULES,
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/core/util/”, line 27, in
from pkg_resources import iter_entry_points, load_entry_point
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources/”, line 84, in
packaging = pkg_resources._vendor.packaging
AttributeError: ‘module’ object has no attribute ‘_vendor’

I already uninstall and reinstall everything, from the mac ports to the python to obspy, but keep getting the same error. Is there a library I am missing ?
Has anybody had this error before and knows how to overcome it ?

Thank you in advance for your help, regards;

Hi Javier

This MAY be a problem with the version of pkg_resources that are installed on your machine.

A quick search on my own installation locates the file /usr/lib64/python2.7/site-packages/
(and similar in python 3) whereas looking into the most recent version () yields pkg_resources/ as a folder with among other things a subfolder called _vendor/ Thus you probably need to upgrade to the latest version of setuptools (17.0) � (pkg_resources ships with setuptools) regP

Hi Javier,

Sorry for not replying immediately to this request, but I was not able to reproduce this issue immediately, and was pretty busy and traveling a lot in the last period.

I believe the problem is caused by the fact that obspy does not declare any dependency/prequirement on setuptools, and as a consequence MacPorts does neither. It seems however, that it actually (library) depends on this module. So this needs fixing.

As an workaround, please install (or upgrade) the `py27-setuptools` manually.

Sorry for the inconvenience.


for MacPorts this should have be fixed by r137741 (
Please `sync` or `selfupdate`, then `upgrade` to version @0.10.2_2. This should solve any issues. If you still observe any problems, please report back.

I will have a look at ObsPy itself later (If nobody comes earlier).