Пример #1
0
def test_metadata(dl1_file):
    with DL1EventSource(input_url=dl1_file) as source:
        assert source.is_simulation
        assert source.datalevels == (DataLevel.DL1_IMAGES,
                                     DataLevel.DL1_PARAMETERS)
        assert list(source.obs_ids) == [7514]
        assert source.mc_headers[7514].corsika_version == 6990
Пример #2
0
def test_metadata(dl1_file):
    with DL1EventSource(input_url=dl1_file) as source:
        assert source.is_simulation
        assert source.datalevels == (DataLevel.DL1_IMAGES,
                                     DataLevel.DL1_PARAMETERS)
        assert list(source.obs_ids) == [2]
        assert source.simulation_config.corsika_version == 7710
Пример #3
0
def test_allowed_tels(dl1_file):
    allowed_tels = {1, 2}
    with DL1EventSource(input_url=dl1_file,
                        allowed_tels=allowed_tels) as source:
        assert source.allowed_tels == allowed_tels
        for event in source:
            for tel in event.dl1.tel:
                assert tel in allowed_tels
Пример #4
0
def test_max_events(dl1_file):
    max_events = 5
    with DL1EventSource(input_url=dl1_file, max_events=max_events) as source:
        count = 0
        assert source.max_events == max_events  # stop iterating after max_events
        assert len(source) == 20  # total events in file
        for _ in source:
            count += 1
        assert count == max_events
Пример #5
0
def test_max_events(dl1_proton_file):
    max_events = 3
    with DL1EventSource(input_url=dl1_proton_file,
                        max_events=max_events) as source:
        assert source.max_events == max_events  # stop iterating after max_events
        assert len(source) == 4  # total events in file
        for count, _ in enumerate(source, start=1):
            pass
        assert count == max_events
Пример #6
0
def test_allowed_tels(dl1_file):
    allowed_tels = {1, 2}
    with DL1EventSource(input_url=dl1_file,
                        allowed_tels=allowed_tels) as source:
        assert not allowed_tels.symmetric_difference(source.subarray.tel_ids)
        assert source.allowed_tels == allowed_tels
        for event in source:
            assert set(event.trigger.tels_with_trigger).issubset(allowed_tels)
            assert set(event.pointing.tel).issubset(allowed_tels)
            assert set(event.dl1.tel).issubset(allowed_tels)
Пример #7
0
def test_simulation_info(dl1_file):
    with DL1EventSource(input_url=dl1_file) as source:
        for event in source:
            assert np.isfinite(event.simulation.shower.energy)
            # the currently used file does not include true dl1 information
            # this is skipped for that reason
            for tel in event.simulation.tel:
                assert tel in event.simulation.tel
                assert event.simulation.tel[tel].true_image.any()
                assert event.simulation.tel[
                    tel].true_parameters.hillas.x != np.nan
Пример #8
0
def test_pointing(dl1_file):
    with DL1EventSource(input_url=dl1_file) as source:
        for event in source:
            assert np.isclose(event.pointing.array_azimuth.to_value(u.deg), 0)
            assert np.isclose(event.pointing.array_altitude.to_value(u.deg),
                              70)
            assert event.pointing.tel
            for tel in event.pointing.tel:
                assert np.isclose(
                    event.pointing.tel[tel].azimuth.to_value(u.deg), 0)
                assert np.isclose(
                    event.pointing.tel[tel].altitude.to_value(u.deg), 70)
Пример #9
0
def test_dl1_b_only_data(dl1_parameters_file):
    reco_lons = []
    reco_concentrations = []
    with DL1EventSource(input_url=dl1_parameters_file) as source:
        for event in source:
            for tel in event.dl1.tel:
                reco_lons.append(event.simulation.tel[tel].true_parameters.
                                 hillas.fov_lon.value)
                reco_concentrations.append(event.simulation.tel[tel].
                                           true_parameters.concentration.core)
    assert not np.isnan(reco_lons).all()
    assert sum(np.isnan(reco_lons)) == sum(np.isnan(reco_concentrations))
Пример #10
0
def test_simulation_info(dl1_file):
    """
    Test that the simulated event information is plausible.
    In particular this means simulated event information is finite
    for all events and parameters calculated on the true images
    are not all nan with the same number of nans in different columns.
    """
    reco_lons = []
    reco_concentrations = []
    with DL1EventSource(input_url=dl1_file) as source:
        for event in source:
            assert np.isfinite(event.simulation.shower.energy)
            for tel in event.simulation.tel:
                assert tel in event.simulation.tel
                assert event.simulation.tel[tel].true_image is not None
                reco_lons.append(event.simulation.tel[tel].true_parameters.
                                 hillas.fov_lon.value)
                reco_concentrations.append(event.simulation.tel[tel].
                                           true_parameters.concentration.core)
    assert not np.isnan(reco_lons).all()
    assert sum(np.isnan(reco_lons)) == sum(np.isnan(reco_concentrations))
Пример #11
0
def test_dl1_data(dl1_file):
    with DL1EventSource(input_url=dl1_file) as source:
        for event in source:
            for tel in event.dl1.tel:
                assert event.dl1.tel[tel].image.any()
                assert event.dl1.tel[tel].parameters.hillas.x != np.nan
Пример #12
0
def test_subarray(dl1_file):
    with DL1EventSource(input_url=dl1_file) as source:
        assert source.subarray.telescope_types
        assert source.subarray.camera_types
        assert source.subarray.optics_types
Пример #13
0
def test_is_compatible(dl1_file):
    simtel_path = get_dataset_path("gamma_test.simtel.gz")
    assert not DL1EventSource.is_compatible(simtel_path)
    assert DL1EventSource.is_compatible(dl1_file)
    with event_source(input_url=dl1_file) as source:
        assert isinstance(source, DL1EventSource)
Пример #14
0
def test_dl1_a_only_data(dl1_image_file):
    with DL1EventSource(input_url=dl1_image_file) as source:
        for event in source:
            for tel in event.dl1.tel:
                assert event.dl1.tel[tel].image.any()