Mac OSX - Eclipse - PyDev troubles

Hi there!!
I’m having a little bit of troubles trying to run a basic (1 line!!) scrips with obspy in the cited environment.

My interpreter is Python 2.7

Here’s the script:

import obspy
st = obspy.read('http://examples.obspy.org/RJOB_061005_072159.ehz.new’)
print st

And here are the errors I get:

Traceback (most recent call last):
File “/Users/andreabono/Eclipse Projects/pippo/package1/prova.py”, line 7, in
import obspy
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/init.py”, line 38, in
version = _getVersionString(abbrev=10)
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/core/util/version.py”, line 147, in get_git_version
release_version = read_release_version()
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/core/util/version.py”, line 133, in read_release_version
with io.open(VERSION_FILE, “rt”) as fh:
LookupError: unknown encoding:

I’m working with Mac OS X Yosemite and installed Python and obspy through MacPorts.
Can anyone help?

Andrea

Hi Andrea

Actually it would be enough with the line:
import obspy
to raise the exception

This is most likely the same error as reported by Pascal Audet begining of this month (see the mailing list archive thread “Error Upgrading to Obspy 0.10.2_2 from 0.9.2_0”, for more info) and the dev-team is most likely working on a solution to it.

For now a workaround may be to edit line 133 in
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/core/util/version.py
to read:
������� with io.open(VERSION_FILE, “rt”, encoding=“UTF-8”) as fh:
(or whatever encoding is appropriate for your system)

regP

Hi Andrea,

I will look at this as soon I am back in the institute.
This problem seems to be specific to Yosemite, where encoding is not set to a reasonable default. I was not able to reproduce it and got not enough info to understand the original cause.
~petr

That’s great!!
It working now!!

Thanks a lot!!
Andrea

Dear all,

I would like to mark phase arrivals in a waveform plot using ObsPy. My approach so far is to create a Figure instance, plot the waveforms to this Figure using the ObsPy plot function and then add lines to mark the arrivals. It looks something like this:

import matplotlib.pyplot as plt
data = read(Stream with several Traces)
fig = plt.figure()
data.plot(fig=fig)
plt.axvline(x, stuff)

However, this way the line is plotted only on top of the very last Trace, not all of them. I guess it is because I am not plotting to the correct subplot?

Is it possible to plot something on top of any of the Traces in the Stream? Alternatively: Do you maybe know a better way to do what I have in mind? I wanted to make use of the convenient .plot() function, but maybe for this type of task it is not the best idea after all?

Thanks a lot and best regards,

Florian

pyplot convenience routines usually plot in the currently active axes,
which happens to be the last axes in the stream plot figure.
You can use `fig.axes` (which is a list of axes) to access all of them,
and directly issue the plot commands to the respective axes e.g.:

for ax in fig.axes:
    ax.axhline(...)

best,
T

Hi,
  I had the same problem using and IDE wherelocale.getprefferedencoding() returns an empty string. I reported it to python.org, and it was confirmed. However, I don't see anyone pressing to fix it.
  The bug report is here http://bugs.python.org/issue25359
  Another work around is by setting one of these env vars: 'LANGUAGE', 'LC_ALL', 'LC_CTYPE', and 'LANG'
Cheers,
  Lloyd