I'm trying to calculate the SNR of a satellite signal using GRC, but all of the 4 offered estimators either have a lot of -NaN values or are ~35dB throughout the entire recording. (I just connected the file source to the MPSK SNR estimator probe and redirected the messages to message debug.)
I've tried the examples adapted to my input and M2M4 estimator spits out somewhat expected values (so I've been told by others in the company).
The code:
from sys import argv
from scipy import fromfile, absolute, array_split, mean, sqrt, log10, ceil, linspace, complex64
from matplotlib import pyplot as plt
def snr_est_m2m4(signal):
M2 = mean(absolute(signal)**2)
M4 = mean(absolute(signal)**4)
snr_rat = sqrt(2*M2*M2 - M4) / (M2 - sqrt(2*M2*M2 - M4))
return 10.0*log10(snr_rat)
def chunkify(lst, chunk_size):
return [lst[i * chunk_size : (i+1) * chunk_size] for i in range(int(ceil(len(lst)/chunk_size)))]
def main():
if len(argv) != 2:
return
bits = fromfile(argv[1], dtype=complex64)
m2m4_axis = [absolute(snr_est_m2m4(s)) for s in array_split(bits, 100000)]
f1 = plt.figure(1)
s1 = f1.add_subplot(1,1,1)
chunk_size = 100
smooth_m2m4 = [mean(c) for c in chunkify(m2m4_axis, chunk_size)]
s1.plot(linspace(0, 1000, len(smooth_m2m4)), smooth_m2m4, 'b-', label='m2m4')
s1.grid(True)
s1.set_xlabel('time')
s1.set_ylabel('snr')
s1.legend()
print("Done!")
plt.show()
if __name__ == "__main__":
main()
I know the recording is valid since the GRC chain we currently have implemented gives out an image of the Earth. I've tried the estimators on a different signal but yet again, the values didn't make sense; the SNR was higher when there was no signal.
What do the parameters alpha
and Samples between SNR messages
in GRC represent? Why don't the estimators in GRC work as expected? What is the suggested way of calculating SNR?
I'm at a loss here, please send help.