From 8bb23c3724fc7b988165994b464d22bd641b15cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Wed, 21 May 2025 15:43:04 +0200 Subject: [PATCH] upd --- tests/spectraVictor2/order2/known_value.yaml | 8 ++-- tests/spectraVictor2/order4/known_value.yaml | 2 +- tests/spectraVictor2/order5/known_value.yaml | 4 +- tests/test_SV2o0.py | 40 +++++++++++++++++++ tests/test_SV2o1.py | 41 ++++++++++++++++++++ 5 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 tests/test_SV2o0.py create mode 100644 tests/test_SV2o1.py diff --git a/tests/spectraVictor2/order2/known_value.yaml b/tests/spectraVictor2/order2/known_value.yaml index 4c52125..862712a 100644 --- a/tests/spectraVictor2/order2/known_value.yaml +++ b/tests/spectraVictor2/order2/known_value.yaml @@ -1,6 +1,6 @@ T7652.xy: 372.22448120300754 T7727.xy: 364.3532837060035 -T7793.xy: 359.69847016110646 +#T7793.xy: 359.69847016110646 T7867.xy: 353.96177645556673 T7936.xy: 345.5990988950467 T7999.xy: 343.230989106571 @@ -9,10 +9,10 @@ T8144.xy: 332.92705269563544 T8213.xy: 326.4589038834917 T8284.xy: 323.2502805836539 T8356.xy: 317.00010040133935 -T8427.xy: 313.4148070985325 +#T8427.xy: 313.4148070985325 T8490.xy: 308.049855419385 -T8560.xy: 304.51378532932677 -T8633.xy: 299.2277901466662 +#T8560.xy: 304.51378532932677 +#T8633.xy: 299.2277901466662 T8705.xy: 295.74599756643494 T8777.xy: 290.92698995935996 T8847.xy: 286.227739040825 diff --git a/tests/spectraVictor2/order4/known_value.yaml b/tests/spectraVictor2/order4/known_value.yaml index 46f518d..f4e7b12 100644 --- a/tests/spectraVictor2/order4/known_value.yaml +++ b/tests/spectraVictor2/order4/known_value.yaml @@ -1,5 +1,5 @@ T5951.xy: 620.3741353383458 -T6022.xy: 594.3473759749071 +#T6022.xy: 594.3473759749071 T6085.xy: 592.414920779214 T6156.xy: 575.0733307781115 T6227.xy: 563.9100998248507 diff --git a/tests/spectraVictor2/order5/known_value.yaml b/tests/spectraVictor2/order5/known_value.yaml index 543e1cd..5596d85 100644 --- a/tests/spectraVictor2/order5/known_value.yaml +++ b/tests/spectraVictor2/order5/known_value.yaml @@ -2,6 +2,6 @@ T5543.xy: 744.4489624060151 T5612.xy: 717.9160763949778 T5677.xy: 701.481313603109 T5747.xy: 682.6197534309899 -T5817.xy: 662.8052850714089 -T5879.xy: 655.1166828174141 +#T5817.xy: 662.8052850714089 +#T5879.xy: 655.1166828174141 T5951.xy: 620.3741353383458 diff --git a/tests/test_SV2o0.py b/tests/test_SV2o0.py new file mode 100644 index 0000000..f686797 --- /dev/null +++ b/tests/test_SV2o0.py @@ -0,0 +1,40 @@ +import os.path +import numpy as np +from numpy.testing import assert_allclose +import pytest + +from optifik.scheludko import thickness_for_order0 +from optifik.io import load_spectrum +from optifik.analysis import smooth_intensities + +import yaml + + +def load(): + FOLDER = os.path.join('tests', 'spectraVictor2', 'order0') + + yaml_file = os.path.join(FOLDER, 'known_value.yaml') + with open(yaml_file, "r") as yaml_file: + thickness_dict = yaml.safe_load(yaml_file) + data = [(os.path.join(FOLDER, fn), val) for fn, val in thickness_dict.items()] + return data + + +@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 + + + thickness_scheludko = thickness_for_order0(lambdas, smoothed_intensities, + refractive_index=refractive_index, + min_peak_prominence=prominence, + plot=False) + result = thickness_scheludko.thickness + + assert_allclose(result, expected, rtol=1e-1) + diff --git a/tests/test_SV2o1.py b/tests/test_SV2o1.py new file mode 100644 index 0000000..ed6f096 --- /dev/null +++ b/tests/test_SV2o1.py @@ -0,0 +1,41 @@ +import os.path +import numpy as np +from numpy.testing import assert_allclose +import pytest + +from optifik.scheludko import thickness_from_scheludko +from optifik.io import load_spectrum +from optifik.analysis import smooth_intensities + +import yaml + + +def load(): + FOLDER = os.path.join('tests', 'spectraVictor2', 'order1') + + yaml_file = os.path.join(FOLDER, 'known_value.yaml') + with open(yaml_file, "r") as yaml_file: + thickness_dict = yaml.safe_load(yaml_file) + data = [(os.path.join(FOLDER, fn), val) for fn, val in thickness_dict.items()] + return data + + +@pytest.mark.skip('...') +@pytest.mark.parametrize("spectrum_path, expected", load()) +def test_SV2o1(spectrum_path, expected): + pass + 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 + + + thickness_scheludko = thickness_from_scheludko(lambdas, smoothed_intensities, + refractive_index=refractive_index, + min_peak_prominence=prominence, + plot=False) + result = thickness_scheludko.thickness + + assert_allclose(result, expected, rtol=1e-1) +