I have a data set where pairs of numbers are represented by 32 bits, each number is represented as two 8 unsigned integers.
I'm trying to get the first real part in one array and the complex part in a second array. I'm then trying to square each part, add them up and take the square root of the sum. (aka taking the magnitude). When I try squaring the elements of each arrays using numpy.square I get not only negative but also inaccurate values. Any idea what's going on/what's wrong?
import matplotlib.pyplot as plt
import numpy as np
import scipy.signal as signal
data = np.fromfile(r'C:\Users\Miaou\Desktop\RAW_DATA_000066_000008.bin', dtype="int16")
print(data)
Is = data[0::2]
Qs = data[1::2]
Is_square = np.square(Is, dtype='int16')
Qs_square = np.square(Qs, dtype='int16')
print('Is',Is)
print('Qs',Qs)
print('Is square',Is_square)
print('Qs square',Qs_square)
Output: Is [ 335 -720 8294 ... -3377 3878 6759]
Qs [-2735 4047 1274 ... -279 1319 4918]
Is square [-18847 -5888 -22364 ... 865 31140 5489]
Qs square [ 9121 -5791 -15324 ... 12305 -29711 3940]