Change of the program,
I whant to convert older Suds data into mseed and I read and convert windows number in linux number.
After that I fill data with this code:
if Component == 'V':
Component = 'Z'
Rate = descriptTrace.Rate
if Rate >=1000 and Rate < 5000:
BandCode = 'F'
elif Rate >=250 and Rate < 1000:
BandCode = 'C'
elif Rate >=80 and Rate < 250:
BandCode = 'H'
elif Rate >=10 and Rate < 80:
BandCode = 'S'
elif Rate >1:
BandCode = 'L'
elif Rate >.1:
BandCode = 'V'
elif Rate >.01:
BandCode = 'U'
IntCode = 'L'
New_tr = obspy.Trace(data = np.array(values), header = {
"network": Net,
"station": Station,
"location": "",
"channel": BandCode+IntCode+Component,
"starttime" : datetime(Anno, Mese, Giorno, Ore, Minuti, Secondi),
"sampling_rate": Rate,
"npts": len(values)})
st = obspy.Stream(traces=[New_tr])
where “values” are sequential data.
and then I create path and file name and I try to save it with this command
DOY = datetime_obj.strftime('%j').zfill(3)
fileoutname = Archive + slash + str(Anno) + slash + str(Net) + slash + Station
if not os.path.isdir(fileoutname + slash + BandCode + IntCode + Component + '.D'):
os.makedirs(fileoutname + slash + BandCode + IntCode + Component + '.D')
fileout = fileoutname + slash + BandCode + IntCode + Component + '.D' + slash + Net + '.' + Station + '.' + BandCode + IntCode + Component + '.D.' + DOY
if not os.path.isfile(fileout):
st.write(fileout, format = 'MSEED', reclen = 512)
Else, if file exists I do this other command
else:
existingt = obspy.read(fileout)
for trace in st:
if packet_exists(existingt,trace) == False:
existingt.append(trace)
with open(logFile,'at') as log:
for esistente in existingt:
log.write(str(fileout))
log.write(str(esistente))
log.write(str(trace))
existingt.sort(['starttime'])
When I read in the log file I receive again the error of the class of numpy
home/User/var/lib/archive/1991/OB/SERR/HLZ.D/OB.SERR.HLZ.D.292OB.SERR..HLZ | 1991-10-19T23:46:26.000000Z - 1991-10-19T23:47:11.992000Z | 125.0 Hz, 5750 samples/home/User/var/lib/archive/1991/OB/SERR/HLZ.D/OB.SERR.HLZ.D.292OB.SERR..HLZ | 1991-10-19T22:32:18.000000Z - 1991-10-19T22:33:55.992000Z | 125.0 Hz, 12250 samplesOB.SERR..HLZ | 1991-10-19T22:32:18.000000Z - 1991-10-19T22:33:55.992000Z | 125.0 Hz, 12250 samples-----------------------------------------------------------------------------------------
tipo dei dati specificati in descriptTrace.datatype = i
/home/User/var/lib/archive/1991/OB/SERR/HLZ.D/OB.SERR.HLZ.D.292
Traceback (most recent call last):
File "/home/User/Binawin_8.1.1.py/suds.py", line 1411, in converti
existingt.write(fileout, format = 'MSEED', reclen = 512)
File "/home/User/anaconda3/lib/python3.11/site-packages/obspy/core/stream.py", line 1458, in write
write_format(self, filename, **kwargs)
File "/home/User/anaconda3/lib/python3.11/site-packages/obspy/io/mseed/core.py", line 843, in _write_mseed
mst = MST(trace, data, dataquality=trace_attr['dataquality'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/User/anaconda3/lib/python3.11/site-packages/obspy/io/mseed/core.py", line 969, in __init__
sampletype = SAMPLETYPE[data.dtype.type]
~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: <class 'numpy.int64'>
OB.SERR..HLZ | 1991-10-19T22:32:18.000000Z - 1991-10-19T22:33:55.992000Z | 125.0 Hz, 12250 samples
Where I make mistake(s)?
Greetings again and thanks for your patience
Sergio