Coverage for hiperta_stream/tests/test_T_REC_040_dl2_to_dl3.py: 100%
14 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-07-16 10:16 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-07-16 10:16 +0000
1import inspect
2import subprocess
3from pathlib import Path
4import numpy as np
5from astropy.io import fits
8def compare_fits(file1_pathname, file2_pathname):
10 # fitsdiff uses np.allclose internally, with rtol of 0.0 (ie not diff allowed)
11 # we relax to numpy's allclose default value of rtol to allow for small changes
12 # due to numerical computations
13 rtol = inspect.signature(np.allclose).parameters["rtol"].default
14 assert fits.FITSDiff(file1_pathname, file2_pathname, rtol=rtol).identical
17def test_T_REC_040_dl2_to_dl3(request):
19 current_dir = Path(request.fspath).resolve().parent
20 (current_dir / "dl3").mkdir(exist_ok=True)
21 subprocess.run(
22 [
23 "lstchain_dl2_to_dl3",
24 "-f",
25 current_dir / "resources/dl2_LST_Run06892_gammaness_cut_70_sample_500.h5",
26 "-o",
27 current_dir / "dl3",
28 "--config",
29 current_dir / "resources/lstchain_configuration.json",
30 "--add-irf",
31 "False"
32 ]
33 )
35 assert (current_dir / "dl3/dl3_LST_Run06892_gammaness_cut_70_sample_500.fits").exists()
37 compare_fits(
38 str(current_dir / "resources/dl3_LST_Run06892_gammaness_cut_70_sample_500.fits"),
39 str(current_dir / "dl3/dl3_LST_Run06892_gammaness_cut_70_sample_500.fits")
40 )