This commit is contained in:
François Boulogne 2025-06-11 08:36:35 +02:00
parent 1800675fd3
commit 3e5d232e36
50 changed files with 4194 additions and 105 deletions

View file

@ -7,7 +7,6 @@ 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
@ -32,22 +31,11 @@ def test_minmax(spectrum_path, expected):
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

@ -20,21 +20,20 @@ def load():
return data
@pytest.mark.skip('...')
#@pytest.mark.skip('...')
@pytest.mark.parametrize("spectrum_path, expected", load())
def test_SV2o0(spectrum_path, expected):
lambdas, raw_intensities = load_spectrum(spectrum_path, lambda_min=450)
smoothed_intensities = smooth_intensities(raw_intensities)
refractive_index = 1.324188 + 3102.060378 / (lambdas**2)
prominence = 0.02
prominence = 0.020
thickness_scheludko = thickness_for_order0(lambdas, smoothed_intensities,
refractive_index=refractive_index,
min_peak_prominence=prominence,
plot=False)
result = thickness_scheludko.thickness
result = thickness_for_order0(lambdas, smoothed_intensities,
refractive_index=refractive_index,
min_peak_prominence=prominence,
plot=False)
assert_allclose(result, expected, rtol=1e-1)
assert_allclose(result.thickness, expected, rtol=1e-1)

View file

@ -28,14 +28,13 @@ def test_SV2o1(spectrum_path, expected):
smoothed_intensities = smooth_intensities(raw_intensities)
refractive_index = 1.324188 + 3102.060378 / (lambdas**2)
prominence = 0.02
prominence = 0.020
thickness_scheludko = thickness_from_scheludko(lambdas, smoothed_intensities,
refractive_index=refractive_index,
min_peak_prominence=prominence,
plot=False)
result = thickness_scheludko.thickness
result = thickness_from_scheludko(lambdas, smoothed_intensities,
refractive_index=refractive_index,
min_peak_prominence=prominence,
plot=False)
assert_allclose(result, expected, rtol=1e-1)
assert_allclose(result.thickness, expected, rtol=1e-1)

View file

@ -8,7 +8,6 @@ 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.fft import Prominence_from_fft
from optifik.io import load_spectrum
@ -39,21 +38,16 @@ def test_minmax_ransac():
smoothed_intensities = smooth_intensities(raw_intensities)
indice = 1.324188 + 3102.060378 / (lambdas**2)
prominence, signal, wavelength = Prominence_from_fft(lambdas,
smoothed_intensities,
refractive_index=indice,
plot=False)
prominence = 0.02
result = thickness_from_minmax(lambdas,
smoothed_intensities,
refractive_index=indice,
min_peak_prominence=prominence,
method='ransac',
plot=False)
thickness_minmax = thickness_from_minmax(lambdas,
smoothed_intensities,
refractive_index=indice,
min_peak_prominence=prominence,
method='ransac',
plot=False)
result = thickness_minmax.thickness
assert_allclose(result, expected, rtol=1e-1)
assert_allclose(result.thickness, expected, rtol=1e-1)
def test_scheludko_4peaks():
@ -66,11 +60,7 @@ def test_scheludko_4peaks():
smoothed_intensities = smooth_intensities(raw_intensities)
indice = 1.324188 + 3102.060378 / (lambdas**2)
prominence, signal, wavelength = Prominence_from_fft(lambdas,
smoothed_intensities,
refractive_index=indice,
plot=False)
prominence = 0.02
result = thickness_from_scheludko(lambdas, smoothed_intensities,
refractive_index=indice,