
Python Obspy error .plot()
Publicado por rodrigo (1 intervención) el 16/04/2018 17:51:00
Tengo una consulta sobre un codigo que estoy ejectuando sobre un archivo.mseed:
codigo:
Esto llama a un archivo.mseed y lo plotea, el problema es que el archivo weather.mseed es un archivo que transforme de .txt a .mseed con un codigo que encontre en la documentacion de obspy: http://docs.obspy.org/tutorial/code_snippets/anything_to_miniseed.html en este caso el código del enlace transforma una cadena de texto. Yo transforme un archivo.txt. para el código del enlace"anything_to_miniseed.html" tampoco me funciona y me entrega el mismo error:
File "leermseed.py", line 10, in <module>
st.plot()
File "/usr/local/lib/python2.7/dist-packages/obspy/core/stream.py", line 1146, in plot
return waveform.plot_waveform(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/obspy/imaging/waveform.py", line 278, in plot_waveform
self.plot(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/obspy/imaging/waveform.py", line 398, in plot
self.__plot_straight(stream_new[_i], ax, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/obspy/imaging/waveform.py", line 702, in __plot_straight
trace.data = np.require(trace.data, np.float64) * trace.stats.calib
File "/home/pi/.local/lib/python2.7/site-packages/numpy/core/numeric.py", line 690, in require
return asanyarray(a, dtype=dtype)
File "/home/pi/.local/lib/python2.7/site-packages/numpy/core/numeric.py", line 544, in asanyarray
return array(a, dtype, copy=False, order=order, subok=True)
ValueError: could not convert string to float: [
Nota: Quizás el archivo txt al pasarlo a .mseed no tiene el mismo formato que un verdadero .mseed? porque al ejecutar estos ejercicios entregados en la documentación de obspy si me muestra la imagen y la onda del sismo.
http://docs.obspy.org/tutorial/code_snippets/reading_seismograms.html
Codigo con el que transformo el .txt a .mseed :
ALGUIEN TIENE ALGUNA IDEA DEL PORQUE ME TIRA EL ERROR AL PLOTEAR EL ARCHIVO .mseed
codigo:
1
2
3
4
5
from obspy import read
st=read('weather.mseed')
tr=st[0]
print (tr.stats)
st.plot()
Esto llama a un archivo.mseed y lo plotea, el problema es que el archivo weather.mseed es un archivo que transforme de .txt a .mseed con un codigo que encontre en la documentacion de obspy: http://docs.obspy.org/tutorial/code_snippets/anything_to_miniseed.html en este caso el código del enlace transforma una cadena de texto. Yo transforme un archivo.txt. para el código del enlace"anything_to_miniseed.html" tampoco me funciona y me entrega el mismo error:
File "leermseed.py", line 10, in <module>
st.plot()
File "/usr/local/lib/python2.7/dist-packages/obspy/core/stream.py", line 1146, in plot
return waveform.plot_waveform(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/obspy/imaging/waveform.py", line 278, in plot_waveform
self.plot(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/obspy/imaging/waveform.py", line 398, in plot
self.__plot_straight(stream_new[_i], ax, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/obspy/imaging/waveform.py", line 702, in __plot_straight
trace.data = np.require(trace.data, np.float64) * trace.stats.calib
File "/home/pi/.local/lib/python2.7/site-packages/numpy/core/numeric.py", line 690, in require
return asanyarray(a, dtype=dtype)
File "/home/pi/.local/lib/python2.7/site-packages/numpy/core/numeric.py", line 544, in asanyarray
return array(a, dtype, copy=False, order=order, subok=True)
ValueError: could not convert string to float: [
Nota: Quizás el archivo txt al pasarlo a .mseed no tiene el mismo formato que un verdadero .mseed? porque al ejecutar estos ejercicios entregados en la documentación de obspy si me muestra la imagen y la onda del sismo.
http://docs.obspy.org/tutorial/code_snippets/reading_seismograms.html
Codigo con el que transformo el .txt a .mseed :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from __future__ import print_function
import pandas as pd
import numpy as np
from obspy import UTCDateTime, read, Trace, Stream
salida = []
with open('/home/pi/Desktop/lecturas4.txt', 'r') as f:
lista = [linea.split() for linea in f]
weather ="".join(str(x) for x in lista)
data = np.fromstring(weather, dtype='|S1')
stats = {'network': 'BW', 'station': 'RJOB', 'location': '',
'channel': 'WLZ', 'npts': len(data), 'sampling_rate': 0.1,
'mseed': {'dataquality': 'D'}}
stats['starttime'] = UTCDateTime()
st = Stream([Trace(data=data, header=stats)])
st.write("weather.mseed", format='MSEED', encoding=0, reclen=256)
st1 = read("weather.mseed")
print(st1[0].data.tostring())
ALGUIEN TIENE ALGUNA IDEA DEL PORQUE ME TIRA EL ERROR AL PLOTEAR EL ARCHIVO .mseed
Valora esta pregunta


0