예제 #1
0
def test_at_least_one_event_found():
    for path in test_paths:
        one_found = False
        for event in SimTelFile(path):
            one_found = True
            break
        assert one_found, path
예제 #2
0
def test_show_we_get_a_dict_with_hower_and_event():
    for path in test_paths:
        for event in SimTelFile(path):
            assert 'mc_shower' in event
            assert 'telescope_events' in event
            assert 'mc_event' in event
            break
예제 #3
0
def test_skip_calibration_events():
    with SimTelFile(calib_path, skip_calibration=True) as f:
        i = 0
        for event in f:
            if event['type'] == 'calibration':
                i += 1
        assert i == 0
예제 #4
0
def test_iterate_complete_file_zst():
    importorskip('zstandard')
    expected = 30
    try:
        for counter, event in enumerate(SimTelFile(prod4_zst_path)):
            pass
    except (EOFError, IndexError):  # truncated files might raise these...
        pass
    assert counter == expected
예제 #5
0
def test_iterate_mc_events():
    expected = 200
    try:
        with SimTelFile(prod4_path) as f:
            for counter, event in enumerate(f.iter_mc_events(), start=1):
                pass
    except (EOFError, IndexError):  # truncated files might raise these...
        pass
    assert counter == expected
예제 #6
0
def test_show_event_is_not_empty_and_has_some_members_for_sure():
    for path in test_paths:
        for event in SimTelFile(path):
            assert event['mc_shower'].keys() == {
                'shower',
                'primary_id',
                'energy',
                'azimuth',
                'altitude',
                'depth_start',
                'h_first_int',
                'xmax',
                'hmax',
                'emax',
                'cmax',
                'n_profiles',
                'profiles'
            }

            assert event.keys() == {
                'type',
                'event_id',
                'mc_shower',
                'mc_event',
                'telescope_events',
                'trigger_information',
                'tracking_positions',
                'photoelectron_sums',
                'photoelectrons',
                'camera_monitorings',
                'laser_calibrations',
            }

            telescope_events = event['telescope_events']

            assert telescope_events  # never empty!

            for telescope_event in telescope_events.values():
                expected_keys = {
                    'header',
                    'pixel_timing',
                    'pixel_lists',
                }
                allowed_keys = {
                    'image_parameters',
                    'adc_sums',
                    'adc_samples'
                }

                found_keys = set(telescope_event.keys())
                assert expected_keys.issubset(found_keys)

                extra_keys = found_keys.difference(expected_keys)
                assert extra_keys.issubset(allowed_keys)
                assert 'adc_sums' in found_keys or 'adc_samples' in found_keys

            break
예제 #7
0
def test_calibration_events():
    with SimTelFile(calib_path) as f:
        i = 0
        for event in f:
            assert event['type'] == 'calibration'

            for t in event['telescope_events'].keys():
                assert t in event['laser_calibrations']
                assert t in event['camera_monitorings']
            i += 1
        assert i >= 1
예제 #8
0
def test_iterate_complete_file():
    expected_counter_values = {
        prod2_path: 8,
        prod3_path: 5,
        prod4_path: 30,
    }
    for path, expected in expected_counter_values.items():
        try:
            for counter, event in enumerate(SimTelFile(path)):
                pass
        except (EOFError, IndexError):  # truncated files might raise these...
            pass
        assert counter == expected
예제 #9
0
def test_allowed_tels():
    allowed_telescopes = {1, 2, 3, 4}
    n_read = 0
    with SimTelFile(prod2_path, allowed_telescopes=allowed_telescopes) as f:
        try:
            for i, event in enumerate(f):
                print(i)
                telescopes = set(event['telescope_events'].keys())
                assert allowed_telescopes.issuperset(telescopes)
                assert telescopes.issubset(allowed_telescopes)
                n_read += 1
        except EOFError:
            pass

    assert n_read == 3
예제 #10
0
def test_can_open():
    for path in test_paths:
        assert SimTelFile(path)
예제 #11
0
def test_frankenstein():
    with SimTelFile(frankenstein_path) as f:
        assert len(f.telescope_descriptions) == f.n_telescopes
예제 #12
0
def test_pixel_trigger_times():
    # astri files must have trigger times
    with SimTelFile(prod4_astri_path) as f:
        for counter, event in enumerate(f, start=1):
            for telescope_event in event['telescope_events'].values():
                assert 'pixel_trigger_times' in telescope_event
예제 #13
0
def test_iterate_mc_events():
    expected = 200
    with SimTelFile(prod4_path) as f:
        for counter, event in enumerate(f.iter_mc_events(), start=1):
            pass
    assert counter == expected
예제 #14
0
            else:
                pix_rotation = 30 * u.deg

    return CameraGeometry(
        cam_id='CAM-{}'.format(telescope_id),
        pix_id=np.arange(cam_data['n_pixels']),
        pix_x=cam_data['pixel_x'] * u.m,
        pix_y=cam_data['pixel_y'] * u.m,
        pix_area=cam_data['pixel_area'] * u.m**2,
        pix_type=pix_type,
        cam_rotation=cam_data['cam_rot'] * u.rad,
        pix_rotation=pix_rotation,
    )


with SimTelFile(args.inputfile) as f:
    for array_event in f:
        print('Event:', array_event['event_id'])
        for telescope_id, event in array_event['telescope_events'].items():
            print('Telescope:', telescope_id)

            data = event.get('adc_samples')
            if data is None:
                data = event['adc_sums'][:, :, np.newaxis]

            image = data[0].sum(axis=1)

            cam = build_cam_geom(f, telescope_id)

            plt.figure()
            disp = CameraDisplay(cam)
예제 #15
0
def test_new_prod4():
    with SimTelFile('tests/resources/prod4_pixelsettings_v3.gz') as f:
        i = 0
        for e in f:
            i += 1
        assert i == 10