Reputation: 3
# Convert array to float and rescale to voltage.
# Assume 3.3V / 12bits
# (we need calibration data to do a better job on this)
data = data.astype(np.float32) * (3.3 / 2**12)
if downsample > 1: # if downsampling is requested, average N samples together
data = data.reshape(num/downsample,downsample).mean(axis=1)
num = data.shape[0]
return np.linspace(0, (num-1)*1e-6*downsample, num), data, rate
else:
return np.linspace(0, (num-1)*1e-6, num), data, rate`
In this part: data = data.reshape(num/downsample,downsample).mean(axis=1)
, I'm getting this error:
float object cannot be interpreted as an integer
Upvotes: 0
Views: 467
Reputation: 6534
The /
sign in Python3 equates to floating point division or "true" division. So the result will always be a float.
There are two ways you can fix this. However, you should first make sure that your data can be cleanly divided (without a decimal portion) into num*downsample
or this will still cause an error:
data = data.reshape(num//downsample,downsample).mean(axis=1)
or:
data = data.reshape(int(num/downsample),downsample).mean(axis=1)
Both versions get the floored version of the resulting number. So you want to be sure that the number acquired through num/downsample
is something like "x.0" for reshape
to not complain.
Upvotes: 1