From 4735301f0d9fe1893e12e867b13dcbaf08e46a0f Mon Sep 17 00:00:00 2001 From: Alexander Steppke Date: Thu, 17 Aug 2023 12:28:57 +0200 Subject: [PATCH] added image calculation tests --- tests/test_analysis.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/test_analysis.py b/tests/test_analysis.py index 1854187..526e936 100644 --- a/tests/test_analysis.py +++ b/tests/test_analysis.py @@ -1,11 +1,32 @@ import pytest import numpy as np +import unittest.mock import cristallina.analysis __author__ = "Alexander Steppke" - + +@unittest.mock.patch("jungfrau_utils.file_adapter.locate_gain_file", lambda path, **kwargs: "tests/data/gains.h5") +@unittest.mock.patch("jungfrau_utils.file_adapter.locate_pedestal_file", lambda path, **kwargs: "tests/data/JF16T03V01.res.h5") +def test_image_calculations(): + res = cristallina.analysis.perform_image_calculations(['/sf/cristallina/applications/cristallina/tests/data/p20841/raw/run0185/data/acq0001.*.h5']) + # these values are only correct when using the specific gain and pedestal files included in the test data + # they do not correspond to the gain and pedestal files used in the actual analysis (otherwise we need to include several here as test data) + intensity = [1712858.6, + 693994.06, + 1766390.0, + 1055504.9, + 1516520.9, + 461969.06, + 3148285.5, + 934917.5, + 1866691.6, + 798191.2, + 2250207.0, + 453842.6] + assert np.allclose(res["JF16T03V01_intensity"], intensity) + def test_minimal_2d_gaussian(): image = np.array([[0,0,0,0,0],