Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moralejo committed May 9, 2023
1 parent ce63080 commit 285768e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lstchain/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def observed_dl1_files(temp_dir_observed_files, run_summary_path):
dl1_output_path1 = temp_dir_observed_files / "dl1_LST-1.Run02008.0000.h5"
muons_file1 = temp_dir_observed_files / "muons_LST-1.Run02008.0000.fits"
datacheck_file1 = temp_dir_observed_files / "datacheck_dl1_LST-1.Run02008.0000.h5"
dvr_file1 = temp_dir_observed_files / "DVR_settings_LST-1.Run02008.h5"
pixmasks_file1 = temp_dir_observed_files / "Pixel_selection_LST-1.Run02008.0000.h5"

# Second set of files
dl1_output_path2 = temp_dir_observed_files / "dl1_LST-1.Run02008.0100.h5"
Expand Down Expand Up @@ -147,6 +149,24 @@ def observed_dl1_files(temp_dir_observed_files, run_summary_path):
dl1_output_path1
)

run_program(
"lstchain_dvr_pixselector",
"--dl1-files",
dl1_output_path1,
"--output-dir",
temp_dir_observed_files
)

run_program(
"lstchain_dvr_pixselector",
"--dl1-files",
dl1_output_path1,
"--output-dir",
temp_dir_observed_files,
"--action",
"create_pixel_masks"
)

run_program(
"lstchain_data_r0_to_dl1",
"-f",
Expand Down Expand Up @@ -180,6 +200,8 @@ def observed_dl1_files(temp_dir_observed_files, run_summary_path):
'dl1_file1': dl1_output_path1,
'muons1': muons_file1,
'datacheck1': datacheck_file1,
'dvr_file1': dvr_file1,
'pixmasks_file1': pixmasks_file1,
'dl1_file2': dl1_output_path2,
'muons2': muons_file2,
'datacheck2': datacheck_file2
Expand Down
12 changes: 12 additions & 0 deletions lstchain/scripts/tests/test_lstchain_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ def test_observed_dl1_validity(observed_dl1_files):
)
np.testing.assert_allclose(dl1_df["dragon_time"], dl1_df["trigger_time"])

@pytest.mark.private_data
def test_dvr_file_validity(observed_dl1_files):
dvr_file = pd.read_hdf(observed_dl1_files["dvr_file1"], key="run_summary")
assert "mean_pixel_survival_fraction" in dvr_file.columns
assert dvr_file['number_of_events'].iloc[0] == 200
assert dvr_file['mean_pixel_survival_fraction'].iloc[0] < 0.1

@pytest.mark.private_data
def test_pixmasks_file_validity(observed_dl1_files):
pixmasks_file = tables.open_file(observed_dl1_files["pixmasks_file1"])
pixmasks = pixmasks_file.root.selected_pixels_masks.col('pixmask')
assert pixmasks.sum() < 0.1 * len(pixmasks.flatten())

@pytest.mark.private_data
@pytest.fixture(scope="session")
Expand Down

0 comments on commit 285768e

Please sign in to comment.