This commit is contained in:
François Boulogne 2025-05-27 16:01:50 +02:00
parent 8bb23c3724
commit d321fce459
9 changed files with 371 additions and 261 deletions

View file

@ -1,12 +1,13 @@
import os.path
import numpy as np
from numpy.testing import assert_allclose
from numpy.testing import assert_allclose, assert_equal
import pytest
from optifik.minmax import thickness_from_minmax
from optifik.io import load_spectrum
from optifik.analysis import smooth_intensities
from optifik.analysis import finds_peak
from optifik.fft import Prominence_from_fft
import yaml
@ -26,13 +27,27 @@ def test_minmax(spectrum_path, expected):
lambdas, raw_intensities = load_spectrum(spectrum_path, lambda_min=450)
smoothed_intensities = smooth_intensities(raw_intensities)
assert_equal(len(lambdas), len(smoothed_intensities))
indice = 1.324188 + 3102.060378 / (lambdas**2)
prominence = 0.02
#prominence, s, w = Prominence_from_fft(lambdas, smoothed_intensities, indice)
#prominence *= 10
thickness_minmax = thickness_from_minmax(lambdas,
smoothed_intensities,
refractive_index=indice,
min_peak_prominence=prominence)
#prominence, s, w = Prominence_from_fft(lambdas, smoothed_intensities, indice)
#print(f'Prom: {prominence}')
#indice = 1.324188 + 3102.060378 / (w**2)
#thickness_minmax = thickness_from_minmax(w,
# s,
# refractive_index=indice,
# min_peak_prominence=prominence)
result = thickness_minmax.thickness
assert_allclose(result, expected, rtol=1e-1)

View file

@ -8,7 +8,7 @@ from optifik.minmax import thickness_from_minmax
from optifik.scheludko import thickness_from_scheludko
from optifik.scheludko import thickness_for_order0
from optifik.analysis import smooth_intensities
from optifik.analysis import Prominence_from_fft
from optifik.fft import Prominence_from_fft
from optifik.io import load_spectrum
@ -39,10 +39,10 @@ def test_minmax_ransac():
smoothed_intensities = smooth_intensities(raw_intensities)
indice = 1.324188 + 3102.060378 / (lambdas**2)
prominence = Prominence_from_fft(lambdas=lambdas,
intensities=smoothed_intensities,
refractive_index=indice,
plot=False)
prominence, signal, wavelength = Prominence_from_fft(lambdas,
smoothed_intensities,
refractive_index=indice,
plot=False)
thickness_minmax = thickness_from_minmax(lambdas,
@ -66,7 +66,10 @@ def test_scheludko_4peaks():
smoothed_intensities = smooth_intensities(raw_intensities)
indice = 1.324188 + 3102.060378 / (lambdas**2)
prominence = Prominence_from_fft(lambdas=lambdas, intensities=smoothed_intensities, refractive_index=indice, plot=False)
prominence, signal, wavelength = Prominence_from_fft(lambdas,
smoothed_intensities,
refractive_index=indice,
plot=False)
result = thickness_from_scheludko(lambdas, smoothed_intensities,