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.
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’)
It is always possible to save the data as miniSEED but use a different encoding. For example, you could use a 64-bit float encoding. This will produce a larger file but will avoid issues with forcing data to be integers.
Hi Ringler_Adam,
Thank you for your reply.
I need to have them on integers to be able to read these files with SEISAN software for seismic analysis. I think that converting them to another float encoding does not help me, unfortunately.
Cheers, Marianna.
If SEISAN can’t handle miniSEED float encodings, then how about reading original data in SEISAN and decimating there? Pretty much any processing done on data will force you into float and then forcing back to integer you introduce arbitrary artifacts you certainly don’t want to have. You could jump through some hoops like multiply by some large number to make the loss of precision less impactful, but that means quite some data management burden and anyway, it will always be distorted data.
This sets up the files to be written continuously and saved exactly where you would like to find it later with the naming convention of your preference.