Hi Lion,
I am grateful for your help. I have SEG-Y files, each having 144 traces corresponding to three components at 48 geophones. After converting the individual trace into miniseed file, I also want to put header information (station, channel, network, sampling rate, npts, etc) in the miniseed file. I wrote the following command that loop through station, channel, and network name corresponding to 144 traces, fill header attributes and write 144 miniseed files.
###To create an array of stations
St = []
for i in range (1, 145):
if i <=9:
St.append(‘ST0’+ str(i))
elif i <=48:
St.append(‘ST’+ str(i))
elif i <=57:
St.append(‘ST0’+ str(i-48))
elif i <=96:
St.append(‘ST’+ str(i-48))
elif i <=105:
St.append(‘ST0’+ str(i-96))
elif i <=144:
St.append(‘ST’+ str(i-96))
###To create an array for channel
C = []
Channel
for i in range (1, 49):
C.append(‘BHZ’)
for i in range (49, 97):
C.append(‘BHN’)
for i in range (97, 145):
C.append(‘BHE’)
###To create an array of network
N = []
for i in range (1, 145):
N.append(‘TX’)
from obspy.segy.segy import readSEGY
from obspy.segy.core import readSEGY
from obspy import Stream, Trace
filename = ‘1.0.0.sgy’
st2 = readSEGY(filename) #reading SEG-Y file
i=0
for tr in st2:
stats = {‘network’: N[i], ‘station’: St[i], ‘location’: ‘’,‘channel’: C[i], ‘npts’: 30000,
‘sampling_rate’: 1000, ‘mseed’: {‘dataquality’: ‘D’}} ###filling header attributes
i = i+1
tr = Stream([Trace(data=tr, header=stats)]) ##This is problematic part
tr.stats.segy.trace_header = stats
tr.write(str(i)+’.MSEED’,format=‘MSEED’)
But I am not able to successfully write the headers to the miniseed file. With this code, I get a value error “ValueError: Trace.data must be a NumPy array”
I would be extremely grateful for any suggestion on how to modify the last loop of the code that is being used to write miniseed file with header information.
Best regards
Abhash Kumar