Hi,
I have an issue in decimating mseed while converting them from .wav file.
In short, after running the decimation function “stream.decimate” with the “no_filter=False”, the numbers from integers are transformed in floats and I cannot then write my mseed in STEIM2 encoding.
I read here: STEIM2 stream encoding · Issue #296 · obspy/obspy · GitHub
That changes in the original files -running a filter for instance- “may change the data type”.
Well, in my case, applying the filter to avoid aliasing is important and thus to have “no_filter=False”. If I write “True” the data type remains integer but it is not what I want.
I thought to change the datatype again at the stream level after the decimation with this: stream[0].data = stream[0].data.astype(np.int32)
QUESTIONS:
- is the above line correct?
- is there another way to have int numbers after data decimation? I also tried “trace.decimate” and I got the same issue.
Any help will be VERY MUCH appreciated!
Best, Marianna.
##########################################
A simplified version of my script:
#Read .wav
samplerate,data=wavfile.read(filename)
#Data conversion from floats to integers
data=np.asarray(data* 2**23, dtype=np.int32)
#Stream
stream=Stream(Trace(data=data,header=stats))
#Decimation
stream.decimate(4,strict_length=False,no_filter=False)
#Data conversion again to integers
stream[0].data = stream[0].data.astype(np.int32)
#Write mseed
stream.write(outdir+filename[-34:-4]+“.mseed”,format=‘MSEED’)