Coverage for hiperta_stream/config/tests/test_stream_configuration.py: 90%

30 statements  

« prev     ^ index     » next       coverage.py v7.4.3, created at 2024-07-16 10:16 +0000

1import pytest 

2import tables 

3import pkg_resources 

4import numpy as np 

5from pathlib import Path 

6 

7configuration_keys = [ 

8 "threshold_bad_adc", 

9 "threshold_bad_ped", 

10 "integration_type", 

11 "nb_slice_before_peak", 

12 "nb_slice_window", 

13 "nb_first_slice_to_reject", 

14 "nb_last_slice_to_reject", 

15 "hillas_threshold_signal_tel", 

16 "hillas_threshold_signal_tel_max", 

17 "cleaning_type", 

18 "hillas_threshold_center", 

19 "hillas_threshold_neighbours", 

20 "min_number_neighbour_pixels", 

21 "keep_isolated_pixel", 

22 "wavelet_threshold", 

23 "min_selected_pixel", 

24 "zfits_offset", 

25 "nb_event_average_ped", 

26 "nb_event_per_hdf5", 

27 "keep_rejected_event", 

28 "is_stream_read_zfit", 

29 "is_stream_real_data", 

30 "obs_id", 

31 "run_id", 

32 "tel_id", 

33 "debug_performance", 

34 "common_abs_path", 

35 "base_prefix", 

36 "exchange_dir", 

37 "confighdf5", 

38 "tmp_prefix", 

39 "tmp_dl1_file", 

40 "tmp_dl1_reorganise", 

41 "tmp_dl2_dir", 

42 "tmp_dl2_file", 

43 "tmp_dl3_dir", 

44 "path_dq_dir", 

45 "dq_dl1", 

46 "model_path", 

47 "lstchain_config_file", 

48 "lstchain_dl2_dl3_config", 

49 "reservation_name", 

50 "host_config", 

51 "job", 

52] 

53 

54 

55@pytest.fixture() 

56def create_tmp_dir(tmp_path): 

57 test_dir = tmp_path 

58 test_dir.mkdir(exist_ok=True) 

59 return test_dir 

60 

61 

62def test_default_hdf5_configuration(): 

63 base_config = pkg_resources.resource_filename("hiperta_stream", "dataset/default_configuration.h5") 

64 assert Path(base_config).is_file() 

65 h5 = tables.open_file(base_config, "r") 

66 assert isinstance(h5.root.configuration, tables.group.Group) 

67 assert isinstance(h5.root.configuration.instrument, tables.group.Group) 

68 assert isinstance(h5.root.configuration.instrument.subarray, tables.group.Group) 

69 assert isinstance(h5.root.configuration.instrument.subarray.layout, tables.table.Table) 

70 assert isinstance(h5.root.configuration.instrument.telescope, tables.group.Group) 

71 assert isinstance(h5.root.configuration.instrument.telescope.optics, tables.table.Table) 

72 assert isinstance(h5.root.configuration.instrument.telescope.camera, tables.group.Group) 

73 assert isinstance(h5.root.configuration.instrument.telescope.camera.geometry_LSTCam, tables.table.Table) 

74 assert isinstance(h5.root.configuration.instrument.telescope.camera.readout_LSTCam, tables.table.Table) 

75 assert isinstance(h5.root.configuration.instrument.telescope.camera.pixel_order, tables.group.Group) 

76 

77 

78def test_default_pixel_order(): 

79 file_pix_order = pkg_resources.resource_filename( 

80 "hiperta_stream", "dataset/LST-1.1.Run00442.0000_pixel_order_bin.npy" 

81 ) 

82 pix_order = np.fromfile(file_pix_order) 

83 assert type(pix_order) is np.ndarray 

84 assert len(pix_order) == 463