doc
This commit is contained in:
commit
82eff06057
141 changed files with 10910 additions and 0 deletions
83
ProminenceFunction.txt
Normal file
83
ProminenceFunction.txt
Normal file
|
@ -0,0 +1,83 @@
|
|||
def Prominence_from_fft(lambdas, intensities, refractive_index, num_half_space=None, plot=True):
|
||||
if num_half_space is None:
|
||||
num_half_space = len(lambdas)
|
||||
|
||||
# # # 1. Spectre original
|
||||
# if plot:
|
||||
# plt.figure(figsize=(10, 6), dpi=150)
|
||||
# plt.plot(1/lambdas, intensities, label='Spectre original')
|
||||
# plt.xlabel('1/Longueur d\'onde (nm-1)')
|
||||
# plt.ylabel('Intensité')
|
||||
# plt.legend()
|
||||
# plt.show()
|
||||
|
||||
|
||||
# 2. Conversion lambda → k = n(λ) / λ
|
||||
k_vals = refractive_index / lambdas
|
||||
f_interp = interp1d(k_vals, intensities, kind='linear', fill_value="extrapolate")
|
||||
|
||||
# 3. Axe k uniforme + interpolation
|
||||
k_linspace = np.linspace(k_vals[0], k_vals[-1], 2 * num_half_space)
|
||||
intensities_k = f_interp(k_linspace)
|
||||
|
||||
# 4. FFT
|
||||
delta_k = (k_vals[-1] - k_vals[0]) / (2 * num_half_space)
|
||||
fft_vals = fft(intensities_k)
|
||||
freqs = fftfreq(2 * num_half_space, delta_k)
|
||||
|
||||
# 5. Pic FFT
|
||||
freqs_pos = freqs[freqs > 0]
|
||||
abs_fft_pos = np.abs(fft_vals[freqs > 0])
|
||||
idx_max = np.argmax(abs_fft_pos)
|
||||
F_max = freqs_pos[idx_max]
|
||||
|
||||
if plot:
|
||||
plt.figure(figsize=(10, 6), dpi=150)
|
||||
plt.plot(freqs_pos, abs_fft_pos, label='|FFT|')
|
||||
plt.axvline(F_max, color='r', linestyle='--', label='Pic principal')
|
||||
plt.xlabel('Distance optique [nm]')
|
||||
plt.ylabel(r'FFT($I^*$)')
|
||||
plt.xscale('log')
|
||||
plt.yscale('log')
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
# 6. Filtrage (garde hautes fréquences)
|
||||
cutoff_HF = 2*F_max
|
||||
|
||||
mask_HF = np.abs(freqs) >= cutoff_HF
|
||||
fft_filtered_HF = np.zeros_like(fft_vals, dtype=complex)
|
||||
fft_filtered_HF[mask_HF] = fft_vals[mask_HF]
|
||||
|
||||
# 7. Filtrage (garde basses fréquences)
|
||||
cutoff_BF = 10*F_max
|
||||
mask_BF = np.abs(freqs) <= cutoff_BF
|
||||
fft_filtered_BF = np.zeros_like(fft_vals, dtype=complex)
|
||||
fft_filtered_BF[mask_BF] = fft_vals[mask_BF]
|
||||
|
||||
|
||||
# 8. Reconstruction
|
||||
signal_filtered_HF = np.real(ifft(fft_filtered_HF))
|
||||
signal_filtered_BF = np.real(ifft(fft_filtered_BF))
|
||||
lambda_reconstructed = np.interp(k_linspace, k_vals[::-1], lambdas[::-1])
|
||||
|
||||
# Masque dans la plage [550, 700] nm
|
||||
mask_Cam_Sensitivity = (lambda_reconstructed >= 550) & (lambda_reconstructed <= 700)
|
||||
|
||||
# 9. Affichage reconstruction
|
||||
if plot:
|
||||
plt.figure(figsize=(10, 6), dpi=150)
|
||||
plt.plot(lambda_reconstructed, intensities_k, '--', label='Original interpolé')
|
||||
plt.plot(lambda_reconstructed, signal_filtered_HF,'--',color='gray')
|
||||
|
||||
plt.plot(lambda_reconstructed[mask_Cam_Sensitivity], signal_filtered_HF[mask_Cam_Sensitivity],color='orange', label='Spectre filtré HF')
|
||||
plt.plot(lambda_reconstructed, signal_filtered_BF, label='Spectre filtré BF')
|
||||
|
||||
plt.xlabel('Longueur d\'onde (nm)')
|
||||
plt.ylabel('Intensité')
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
max_amplitude = np.max(np.abs(signal_filtered_HF[mask_Cam_Sensitivity]))
|
||||
|
||||
return max_amplitude,signal_filtered_BF,lambda_reconstructed
|
Loading…
Add table
Add a link
Reference in a new issue