Reading a Seismogram

Hello,

I am having trouble simply reading a seismogram using the following code:

from obspy.core import read
st = read(pathname)
print(st)

However, after attempting to print ‘st’, the following error message occurs:

File “C:\Python27\lib\site-packages\obspy\core\stream.py”, line 253, in read
raise IOError(2, “No such file or directory”, pathname)
IOError: [Errno 2] No such file or directory: ‘C:\Users\Edge 14 User\Desktop\x813-06-23-1959-35S.OV____078’

So it seems that there is an error with obspy attempting to locate the waveform file. I double-checked the file pathname multiple times, so I don’t think there is a problem with the pathname. Could there be a problem with where the obspy package is located in the Python27 directory? Currently, the pathname for the obspy folder is: C:\Python27\Lib\site-packages.

Has anyone else run into this similar issue?

Thank you fr your help,

Greg Brenn

Hi Brenn,

the most important information is missing - how is pathname generated? Is it a string or do you get it via e.g. the glob module?

So the issue is that the last '\' is not properly escaped, so it should be

'C:\\Users\\Edge 14 User\\Desktop\\x813-06-23-1959-35S.OV____078'

instead of

'C:\\Users\\Edge 14 User\\Desktop\x813-06-23-1959-35S.OV____078'

Cheers,
Robert

My guess this

Hi Greg,

It seems the path name is missing a \ after Desktop. Python on Windows needs \ to mean a . Have you tried

‘C:\Users\Edge 14 User\Desktop\x813-06-23-1959-35S.OV____078’

or
r’C:\Users\Edge 14 User\Desktop\x813-06-23-1959-35S.OV____078’

?

Using the r in the beginning of the string makes it a raw string.

Cheers,

Leonardo Uieda