python - How to Estimate a bandwidth of a Signal in Python
问题描述
Required Bandwidth to Calculate
How is it possible for me to calculate or estimate the bandwidth between the redlines. as well is is possilbe for me to change the actual line colour instead of scatter.
import numpy as np
from pylab import *
from rtlsdr import RtlSdr
from matplotlib import pyplot as plt
from matplotlib.collections import LineCollection
from matplotlib.colors import ListedColormap, BoundaryNorm
# Get a list of detected device serial numbers (str)
serial_numbers = RtlSdr.get_device_serial_addresses()
# Find the device index for a given serial number
device_index = RtlSdr.get_device_index_by_serial('00000001')
sdr = RtlSdr(device_index)
# configure device
sdr.sample_rate = 2.4e6
sdr.center_freq = 95.5e6
sdr.gain = 0
samples = sdr.read_samples(1024*1024)
sdr.close()
# use matplotlib to estimate and plot the PSD
[Pxx, freqs] = psd(samples, NFFT=1024, Fs=sdr.sample_rate/1e6, Fc=sdr.center_freq/1e6)
xlabel('Frequency (MHz)')
ylabel('Relative power (dB)')
show()
y = Pxx
x = freqs
# The x and y data to plot
plt.plot(freqs,Pxx)
y = Pxx
x = freqs
col = np.where(x<1,'k',np.where(y<0.008,'y','r'))
plt.scatter(x,y,c=col,s=5, linewidth=7)
plt.show()
# Find centre freq
max1 = Pxx.max()
print(max1)
max_index= np.argmax(Pxx)
print(max_index)
print(freqs[max_index])
# Estimate Bandwidth
# Filter
# Record the signal
# Compress <<
How is it possible for me to calculate or estimate the bandwidth between the redlines. as well is is possilbe for me to change the actual line colour instead of scatter.
The image above shows exactly what I want to calculate.
解决方案
推荐阅读
- c++ - Palabos - C++ - 信号代码:地址未映射错误
- sql-server - 多对多关系返回空结果
- javascript - 删除选择列表选项,因为它们被选中
- java - Android/Java:如何从另一个子包导入一个子包中的类?
- java - 如何在命令提示符下多次运行 BufferedReader 以输入值?
- c++ - 使用多态方法从非模板基本案例派生模板类?
- c# - 使用 Initialized Factory 和 Inheritence 创建自定义对象
- wordpress - 在木材菜单中使用 ACF 的链接自定义字段
- bash - 为什么这个 kill 在这个 Bash 脚本中不起作用,而只在脚本之外起作用?
- c# - 两次而不是一次获得所需的结果