如何在直方图中分离噪声和信号

问题描述 投票:0回答:1

我有一个直方图,代表 3000 个信号+噪声的最大幅度,这来自红外探测器。因此,信号是多个光子。我想根据光子数量对直方图进行归一化。因此,如果我采用 0 个光子,我只会得到噪声。但是当我完成所有这些时,我得到了相同的 hstogramme,只是有不同的标准偏差,如果我选择 0 光子,我有一个狄拉克,而不仅仅是我的噪音,所以我有点迷失了我需要的东西(其他历史,新的参数,更多数据???)。

我希望有人可以使用此参数找到解决方案? 也许使用参数:SNR = Mean(Amax)/Std 或 QEFR = SNR/Nbph 或 F= QE/QEFR 其中 QE 是量子效率和 SNR 信号噪声比。

import numpy as np
import matplotlib.pyplot as plt
from scipy.special import gamma
from scipy.signal import convolve

# Quantum Efficiency
QE = 0.72
k1 = 6

# Optical power and number of photons
optical_power_dBm = 77.12
num_photons = 37

# File paths for the files containing the maximum amplitudes
file_amplitude_max_with = r'C:\***\amplitudes_max_signal_bruit_9V_C1.txt'
file_amplitude_max_without = r'C:\***\amplitudes_max_signal_bruit_9V_C1_sans.txt'
# Load maximum amplitudes from files
amplitudes_max_noise_with = np.loadtxt(file_amplitude_max_with)
amplitudes_max_noise_without = np.loadtxt(file_amplitude_max_without)

# Normalize amplitudes to rotate around 1
mean_amplitude_with = np.mean(amplitudes_max_noise_with)
mean_amplitude_without = np.mean(amplitudes_max_noise_without)

# Normalize amplitudes to rotate around 1 photon
normalized_amplitudes_max_noise_with = amplitudes_max_noise_with / (mean_amplitude_with * 37)
normalized_amplitudes_max_noise_without = amplitudes_max_noise_without / (mean_amplitude_without * 37)

normalized_amplitudes_max_noise_with = normalized_amplitudes_max_noise_with * 37
normalized_amplitudes_max_noise_with10 = normalized_amplitudes_max_noise_with * 10
normalized_amplitudes_max_noise_with1 = normalized_amplitudes_max_noise_with * 20

normalized_amplitudes_max_noise_without = normalized_amplitudes_max_noise_without * 37

# Calculate the standard deviations of the normalized amplitudes
STD_noise_with = np.std(normalized_amplitudes_max_noise_with)
STD_noise_with1 = np.std(normalized_amplitudes_max_noise_with1)
STD_noise_with10 = np.std(normalized_amplitudes_max_noise_with10)
STD_noise_without = np.std(normalized_amplitudes_max_noise_without)

# Convert the standard deviations to the number of noise photons
n_photon_noise_with = STD_noise_with * num_photons
n_photon_noise_with1 = STD_noise_with1 * num_photons
n_photon_noise_with10 = STD_noise_with10 * num_photons
n_photon_noise_without = STD_noise_without * num_photons

print('standard deviation with =', STD_noise_with)
print('standard deviation with1 =', STD_noise_with1)
print('standard deviation with10 =', STD_noise_with10)
print('standard deviation without =', STD_noise_without)

print('number of photons without cover', n_photon_noise_with)
print('number of photons without cover', n_photon_noise_with1)
print('number of photons without cover', n_photon_noise_with10)
print('number of photons with cover', n_photon_noise_without)

# Display the results
plt.figure(figsize=(10, 6))
plt.hist(normalized_amplitudes_max_noise_with, bins=37, alpha=0.7, color='lightblue', label='Normalized Maximum Noise Amplitudes (with) 37')
plt.hist(normalized_amplitudes_max_noise_with10, bins=37, alpha=0.7, label='Normalized Maximum Noise Amplitudes (with) 10')
plt.hist(normalized_amplitudes_max_noise_with1, bins=37, alpha=0.7, label='Normalized Maximum Noise Amplitudes (with) 20')
plt.hist(normalized_amplitudes_max_noise_without, bins=37, alpha=0.7, color='red', label='Normalized Maximum Noise Amplitudes (without) 37')
plt.xlabel('Amplitude (Normalized)')
plt.ylabel('Count')
plt.title('Distribution of Normalized Maximum Noise Amplitudes')
plt.legend()
plt.grid()

plt.show()

python signals histogram physics noise
1个回答
0
投票

除以平均振幅并缩放到光子数。计算标准偏差。评估相对于噪声的信号质量。绘制直方图

import numpy as np
import matplotlib.pyplot as plt

QE = 0.72
k1 = 6

optical_power_dBm = 77.12
num_photons = 37

file_amplitude_max_with = r'C:\***\amplitudes_max_signal_bruit_9V_C1.txt'
file_amplitude_max_without = r'C:\***\amplitudes_max_signal_bruit_9V_C1_sans.txt'

amplitudes_max_noise_with = np.loadtxt(file_amplitude_max_with)
amplitudes_max_noise_without = np.loadtxt(file_amplitude_max_without)

mean_amplitude_with = np.mean(amplitudes_max_noise_with)
mean_amplitude_without = np.mean(amplitudes_max_noise_without)

normalized_amplitudes_max_noise_with = amplitudes_max_noise_with / mean_amplitude_with * num_photons
normalized_amplitudes_max_noise_without = amplitudes_max_noise_without / mean_amplitude_without * num_photons

STD_noise_with = np.std(normalized_amplitudes_max_noise_with)
STD_noise_without = np.std(normalized_amplitudes_max_noise_without)

n_photon_noise_with = STD_noise_with
n_photon_noise_without = STD_noise_without

print('Standard deviation (with signal) =', STD_noise_with)
print('Standard deviation (without signal) =', STD_noise_without)
print('Number of photons (noise, with signal) =', n_photon_noise_with)
print('Number of photons (noise, without signal) =', n_photon_noise_without)

plt.figure(figsize=(10, 6))
plt.hist(normalized_amplitudes_max_noise_with, bins=37, alpha=0.7, color='lightblue', label='Normalized Maximum Noise Amplitudes (with signal)')
plt.hist(normalized_amplitudes_max_noise_without, bins=37, alpha=0.7, color='red', label='Normalized Maximum Noise Amplitudes (without signal)')
plt.xlabel('Amplitude (Normalized)')
plt.ylabel('Count')
plt.title('Distribution of Normalized Maximum Noise Amplitudes')
plt.legend()
plt.grid()

plt.show()
© www.soinside.com 2019 - 2024. All rights reserved.