diff options
author | andreas128 <Andreas> | 2017-04-02 10:46:49 +0100 |
---|---|---|
committer | andreas128 <Andreas> | 2017-04-02 10:46:49 +0100 |
commit | 2aa99f6275e2530a8dd4d3be270e9d7a3633cd66 (patch) | |
tree | 9bb6c05b6e17e3c00c4d68660cb47f846c4d66ba /src/dab_tuning_lib.py | |
parent | 3ee39e3ae187e76b252b5758c12bd35e5707e187 (diff) | |
download | ODR-StaticPrecorrection-2aa99f6275e2530a8dd4d3be270e9d7a3633cd66.tar.gz ODR-StaticPrecorrection-2aa99f6275e2530a8dd4d3be270e9d7a3633cd66.tar.bz2 ODR-StaticPrecorrection-2aa99f6275e2530a8dd4d3be270e9d7a3633cd66.zip |
Add two tone and mer measure
Diffstat (limited to 'src/dab_tuning_lib.py')
-rw-r--r-- | src/dab_tuning_lib.py | 67 |
1 files changed, 64 insertions, 3 deletions
diff --git a/src/dab_tuning_lib.py b/src/dab_tuning_lib.py index 8faafef..e5348b0 100644 --- a/src/dab_tuning_lib.py +++ b/src/dab_tuning_lib.py @@ -17,7 +17,6 @@ def calc_signal_sholder_ratio(fft, sampling_rate, debug = False, debug_path="", du.freq_to_fft_sample(-du.c["bw"]/2, fft_size, sampling_rate)) sholder = np.mean(fft[n_sholder[0]:n_sholder[1]]) - score = -sholder if debug == True: print(n_sig, n_sholder, n_noise) @@ -25,7 +24,69 @@ def calc_signal_sholder_ratio(fft, sampling_rate, debug = False, debug_path="", plt.plot((n_sig[0], n_sig[1]), (sig, sig), linewidth=5, color='g') plt.plot((n_noise[0], n_noise[1]), (noise, noise), linewidth=5, color='r') plt.plot((n_sholder[0], n_sholder[1]), (sholder, sholder), linewidth=5, color='y') - plt.savefig(debug_path + "/" + str(score) + suffix + ".png") + if debug_path: plt.savefig(debug_path + "/" + str(loss) + suffix + ".png") + plt.show() plt.clf() - return score + return sholder + +def calc_signal_sholder_peak_ratio(fft, sampling_rate, debug = False, debug_path="", suffix=""): + fft_size = fft.shape[0] + n_sig = (du.freq_to_fft_sample(-du.c["bw"]/2., fft_size, sampling_rate), + du.freq_to_fft_sample( du.c["bw"]/2., fft_size, sampling_rate)) + sig = np.mean(fft[n_sig[0]:n_sig[1]]) + + n_noise = (du.freq_to_fft_sample(-3000000., fft_size, sampling_rate), + du.freq_to_fft_sample(-2500000, fft_size, sampling_rate)) + noise = np.mean(fft[n_noise[0]:n_noise[1]]) + + n_sholder = (du.freq_to_fft_sample(-1500000, fft_size, sampling_rate), + du.freq_to_fft_sample(-du.c["bw"]/2, fft_size, sampling_rate)) + sholder = np.mean(fft[n_sholder[0]:n_sholder[1]]) + + loss = sholder/sig + + + if debug == True: + print(n_sig, n_sholder, n_noise) + plt.plot(fft) + plt.plot((n_sig[0], n_sig[1]), (sig, sig), linewidth=5, color='g') + plt.plot((n_noise[0], n_noise[1]), (noise, noise), linewidth=5, color='r') + plt.plot((n_sholder[0], n_sholder[1]), (sholder, sholder), linewidth=5, color='y') + if debug_path: plt.savefig(debug_path + "/" + str(loss) + suffix + ".png") + plt.show() + plt.clf() + + return loss + +def calc_max_in_freq_range(fft, sampling_rate, f_start, f_end, debug = False, debug_path="", suffix=""): + fft_size = fft.shape[0] + n_sig = (du.freq_to_fft_sample(f_start, fft_size, sampling_rate), + du.freq_to_fft_sample(f_end, fft_size, sampling_rate)) + sig = np.max(fft[n_sig[0]:n_sig[1]]) + + if debug == True: + print(n_sig) + plt.plot(fft) + plt.plot((n_sig[0], n_sig[1]), (sig, sig), linewidth=5, color='g') + if debug_path: plt.savefig(debug_path + "/" + str(loss) + suffix + ".png") + plt.show() + plt.clf() + + return sig + +def calc_mean_in_freq_range(fft, sampling_rate, f_start, f_end, debug = False, debug_path="", suffix=""): + fft_size = fft.shape[0] + n_sig = (du.freq_to_fft_sample(f_start, fft_size, sampling_rate), + du.freq_to_fft_sample(f_end, fft_size, sampling_rate)) + sig = np.mean(fft[n_sig[0]:n_sig[1]]) + + if debug == True: + print(n_sig) + plt.plot(fft) + plt.plot((n_sig[0], n_sig[1]), (sig, sig), linewidth=5, color='g') + if debug_path: plt.savefig(debug_path + "/" + str(loss) + suffix + ".png") + plt.show() + plt.clf() + + return sig |