def test_integration_correction_no_ref_pulse(example_event): telid = list(example_event.r0.tel)[0] delattr(example_event, "mc") calibrator = CameraCalibrator() calibrator._calibrate_dl0(example_event, telid) correction = calibrator._get_correction(example_event, telid) assert (correction == 1).all()
def test_integration_correction_no_ref_pulse(example_event): telid = list(example_event.r0.tel)[0] delattr(example_event, 'mc') calibrator = CameraCalibrator() calibrator._calibrate_dl0(example_event, telid) correction = calibrator._get_correction(example_event, telid) assert correction[0] == 1
def test_check_r1_empty(example_event): calibrator = CameraCalibrator() telid = list(example_event.r0.tel)[0] waveform = example_event.r1.tel[telid].waveform.copy() with pytest.warns(UserWarning): example_event.r1.tel[telid].waveform = None calibrator._calibrate_dl0(example_event, telid) assert example_event.dl0.tel[telid].waveform == None assert calibrator._check_r1_empty(None) is True assert calibrator._check_r1_empty(waveform) is False
def test_check_dl0_empty(example_event): calibrator = CameraCalibrator() telid = list(example_event.r0.tel)[0] calibrator._calibrate_dl0(example_event, telid) waveform = example_event.dl0.tel[telid].waveform.copy() with pytest.warns(UserWarning): example_event.dl0.tel[telid].waveform = None calibrator._calibrate_dl1(example_event, telid) assert example_event.dl1.tel[telid].image is None assert calibrator._check_dl0_empty(None) is True assert calibrator._check_dl0_empty(waveform) is False calibrator = CameraCalibrator() event = DataContainer() event.dl1.tel[telid].image = np.full(2048, 2) with pytest.warns(UserWarning): calibrator(event) assert (event.dl1.tel[telid].image == 2).all()
def test_check_r1_empty(example_event): calibrator = CameraCalibrator() telid = list(example_event.r0.tel)[0] waveform = example_event.r1.tel[telid].waveform.copy() with pytest.warns(UserWarning): example_event.r1.tel[telid].waveform = None calibrator._calibrate_dl0(example_event, telid) assert example_event.dl0.tel[telid].waveform is None assert calibrator._check_r1_empty(None) is True assert calibrator._check_r1_empty(waveform) is False calibrator = CameraCalibrator(image_extractor=FullWaveformSum()) event = DataContainer() event.dl0.tel[telid].waveform = np.full((2048, 128), 2) with pytest.warns(UserWarning): calibrator(event) assert (event.dl0.tel[telid].waveform == 2).all() assert (event.dl1.tel[telid].image == 2 * 128).all()
def test_select_gain(): n_channels = 2 n_pixels = 2048 n_samples = 128 telid = 0 calibrator = CameraCalibrator() event = DataContainer() event.r1.tel[telid].waveform = np.ones((n_channels, n_pixels, n_samples)) calibrator._calibrate_dl0(event, telid) assert event.dl0.tel[telid].waveform.shape == (n_pixels, n_samples) event = DataContainer() event.r1.tel[telid].waveform = np.ones((n_pixels, n_samples)) with pytest.raises(ValueError): calibrator._calibrate_dl0(event, telid) event = DataContainer() event.r1.tel[telid].waveform = np.ones((n_pixels, n_samples)) event.r1.tel[telid].selected_gain_channel = np.zeros(n_pixels) calibrator._calibrate_dl0(event, telid) assert event.dl0.tel[telid].waveform.shape == (n_pixels, n_samples)