I'm trying to calculate the impulse response of a signal. Here is the code:
def impulse_response(self):
# Inverse filter:
T = self.recorded_data.shape[0] / self.samplerate
t = np.arange(0, T*self.samplerate - 1) / self.samplerate
R = np.log(20/20000)
k = np.exp(t*R/T).astype(np.float32)
f = self.recorded_data[::-1] / k # Gives an MemoryError
# Impulse response:
return sig.fftconvolve(self.recorded_data, f, mode="same")
The division when calculating the filter f gives an MemoryError.
self.recorded_data is a sine sweep of 15 sec and with a samplingrate of 44100Hz its 2822400 Bytes large. k is 2822396 Bytes large(both arrays are 32 bit floats). I didn't think these arrays would be a problem to divide as they aren't that large. Is there a problem with how the dividing is done? Maybe theres an more effective way to do it? Or should I use another datatype?
The array sizes I found by using https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.ndarray.nbytes.html
I get the same error when dividing NumPY arrays in my transfer_function() function, so I guess its the same problem.
I got the code from https://dsp.stackexchange.com/questions/41696/calculating-the-inverse-filter-for-the-exponential-sine-sweep-method
By the way, my computer has 8GB of RAM.
Thanks for any answers!
kandself.recorded_data? - Daniel