Skip to content

Commit

Permalink
Merge pull request #1268 from cta-observatory/test_nsb_waveform
Browse files Browse the repository at this point in the history
Add test for nsb waveform tuning script
  • Loading branch information
moralejo authored Jun 20, 2024
2 parents 89dbc29 + df09417 commit 6ea82fe
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions lstchain/scripts/tests/test_lstchain_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,18 @@


from lstchain.io.config import get_srcdep_config, get_standard_config
from lstchain.io.io import (dl1_images_lstcam_key, dl1_params_lstcam_key,
dl1_params_tel_mon_cal_key,
dl1_params_tel_mon_flat_key,
dl1_params_tel_mon_ped_key, dl2_params_lstcam_key,
get_dataset_keys, get_srcdep_params)
from lstchain.io.io import (
dl1_images_lstcam_key,
dl1_params_lstcam_key,
dl1_params_tel_mon_cal_key,
dl1_params_tel_mon_flat_key,
dl1_params_tel_mon_ped_key,
dl2_params_lstcam_key,
get_dataset_keys,
get_srcdep_params,
get_resource_path
)



def find_entry_points(package_name):
Expand Down Expand Up @@ -198,6 +205,20 @@ def tune_nsb(mc_gamma_testfile, observed_dl1_files):
)


@pytest.mark.private_data
@pytest.fixture(scope="session")
def tune_nsb_waveform(mc_gamma_testfile, observed_dl1_files):
return run_program(
"lstchain_tune_nsb_waveform",
"--config",
"lstchain/data/lstchain_standard_config.json",
"--input-mc",
mc_gamma_testfile,
"--input-data",
observed_dl1_files["dl1_file1"],
)


def test_validity_tune_nsb(tune_nsb):
output_lines = tune_nsb.stdout.splitlines()
for line in output_lines:
Expand All @@ -213,6 +234,22 @@ def test_validity_tune_nsb(tune_nsb):
assert line == ' "extra_noise_in_bright_pixels": 0.0'


def test_validity_tune_nsb_waveform(tune_nsb_waveform):
"""
The resulting nsb_tuning_ratio value of -1 expected in this test is meaningless
because the input data do not allow a full test of the functionality.
This test is only a formal check that the script runs.
"""
output_lines = tune_nsb_waveform.stdout.splitlines()
for line in output_lines:
if '"nsb_tuning"' in line:
assert line == ' "nsb_tuning": true,'
if '"nsb_tuning_ratio"' in line:
assert line == ' "nsb_tuning_ratio": -1.0,'
if '"spe_location"' in line:
assert line == f' "spe_location": "{get_resource_path("data/SinglePhE_ResponseInPhE_expo2Gaus.dat")}"'


def test_lstchain_mc_trainpipe(rf_models):
assert rf_models["energy"].is_file()
assert rf_models["disp_norm"].is_file()
Expand Down

0 comments on commit 6ea82fe

Please sign in to comment.