I have a query about a code that I am running on a archivo.mseed
:
code:
from obspy import read
st=read('weather.mseed')
tr=st[0]
print (tr.stats)
st.plot()
This calls a archivo.mseed
and plots it, the problem is that the file weather.mseed
is a file that transforms from .txt to .mseed with a code that you found in the obspy documentation: link in this case the link code transforms a text string. I transformed a archivo.txt
. for the code of the link "anything_to_miniseed.html" it does not work either and it gives me the same 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: [
Note : Perhaps the txt
file when passed to .mseed
does not have the same format as a true .mseed
? because when executing these exercises delivered in the documentation of obspy
if you show me the image and the wave of the earthquake.
Code with which I transform the .txt to .mseed:
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())
If I take the line where it says weather ="".join(str(x) for x in lista)
, the following error is displayed:
Traceback (most recent call last):
File "convertirArray.py", line 14, in <module>
data = np.fromstring(lista, dtype='|S1')
TypeError: fromstring() argument 1 must be string or read-only buffer, not list