コード例 #1
0
ファイル: test_optics.py プロジェクト: ParsonsRD/ctapipe
def test_guess_optics():
    od = OpticsDescription.guess(28.0 * u.m)
    od.info()

    assert od.tel_type == 'LST'
    assert od.tel_subtype == ''
    assert od.mirror_type == 'DC'

    with pytest.raises(KeyError):
        OpticsDescription.guess(0 * u.m)  # unknown tel
コード例 #2
0
def test_guess_optics():

    od = OpticsDescription.guess(28.0 * u.m)

    assert od.tel_type == 'LST'
    assert od.tel_subtype == ''
    assert od.mirror_type == 'DC'

    with pytest.raises(KeyError):
        od2 = OpticsDescription.guess(0 * u.m)
コード例 #3
0
ファイル: test_optics.py プロジェクト: dipierr/ctapipe
def test_guess_optics():
    from ctapipe.instrument import guess_telescope
    answer = guess_telescope(1855, 28.0 * u.m)

    od = OpticsDescription.from_name(answer.name)

    assert od.equivalent_focal_length.to_value(u.m) == 28
    assert od.num_mirrors == 1
コード例 #4
0
ファイル: test_optics.py プロジェクト: ParsonsRD/ctapipe
def test_construct_optics():
    with pytest.raises(ValueError):
        OpticsDescription(mirror_type="DC",
                          tel_type="bad",  # bad value
                          tel_subtype="1M",
                          equivalent_focal_length=10 * u.m)

    with pytest.raises(ValueError):
        OpticsDescription(mirror_type="bad",  # bad value
                          tel_type="MST",
                          tel_subtype="1M",
                          equivalent_focal_length=10 * u.m)

    with pytest.raises(u.UnitsError):
        OpticsDescription.guess(28.0 * u.kg)  # bad unit

    with pytest.raises(TypeError):
        OpticsDescription.guess(28.0)  # not a unit quantity
コード例 #5
0
ファイル: test_optics.py プロジェクト: watsonjj/ctapipe
def test_construct_optics():
    """create an OpticsDescription and make sure it
    fails if units are missing"""
    OpticsDescription(
        name="test",
        num_mirrors=1,
        num_mirror_tiles=100,
        mirror_area=u.Quantity(550, u.m**2),
        equivalent_focal_length=u.Quantity(10, u.m),
    )

    with pytest.raises(TypeError):
        OpticsDescription(
            name="test",
            num_mirrors=1,
            num_mirror_tiles=100,
            mirror_area=550,
            equivalent_focal_length=10,
        )
コード例 #6
0
ファイル: test_optics.py プロジェクト: watsonjj/ctapipe
def test_guess_optics():
    """ make sure we can guess an optics type from metadata"""
    from ctapipe.instrument import guess_telescope

    answer = guess_telescope(1855, 28.0 * u.m)

    od = OpticsDescription.from_name(answer.name)

    assert od.equivalent_focal_length.to_value(u.m) == 28
    assert od.num_mirrors == 1
コード例 #7
0
def test_construct_optics():

    with pytest.raises(ValueError):
        od = OpticsDescription(
            mirror_type="DC",
            tel_type="bad",  # bad value
            tel_subtype="1M",
            equivalent_focal_length=10 * u.m)

    with pytest.raises(ValueError):
        od = OpticsDescription(
            mirror_type="bad",  # bad value
            tel_type="MST",
            tel_subtype="1M",
            equivalent_focal_length=10 * u.m)

    with pytest.raises(u.UnitsError):
        od = OpticsDescription.guess(28.0 * u.kg)  # bad unit

    with pytest.raises(TypeError):
        od = OpticsDescription.guess(28.0)  # not a unit quantity
コード例 #8
0
def test_hash():

    types = ["LST", "MST", "SST"]
    names = ["LST", "MST", "SST-1M"]
    cameras = ["LSTCam", "FlashCam", "DigiCam"]

    telescopes = []
    for name, type, camera in zip(names, types, cameras):
        for i in range(3):

            telescopes.append(
                TelescopeDescription(name=name,
                                     tel_type=type,
                                     optics=OpticsDescription.from_name(name),
                                     camera=CameraGeometry.from_name(camera)))

    assert len(telescopes) == 9
    assert len(set(telescopes)) == 3
コード例 #9
0
def test_hash():
    from ctapipe.instrument.telescope import TelescopeDescription
    from ctapipe.instrument.optics import OpticsDescription
    from ctapipe.instrument.camera import CameraGeometry

    types = ['LST', 'MST', 'SST']
    names = ['LST', 'MST', 'SST-1M']
    cameras = ['LSTCam', 'FlashCam', 'DigiCam']

    telescopes = []
    for name, type, camera in zip(names, types, cameras):
        for i in range(3):

            telescopes.append(
                TelescopeDescription(name=name,
                                     type=type,
                                     optics=OpticsDescription.from_name(name),
                                     camera=CameraGeometry.from_name(camera)))

    assert len(telescopes) == 9
    assert len(set(telescopes)) == 3
コード例 #10
0
ファイル: test_optics.py プロジェクト: watsonjj/ctapipe
def test_optics_from_dump_instrument():
    # test with file written by dump-instrument

    svc_path_before = os.getenv("CTAPIPE_SVC_PATH")
    cwd = os.getcwd()

    with tempfile.TemporaryDirectory() as tmp_dir:
        os.chdir(tmp_dir)
        os.environ["CTAPIPE_SVC_PATH"] = tmp_dir

        infile = get_dataset_path("gamma_test_large.simtel.gz")
        run_tool(DumpInstrumentTool(), [f"--input={infile}", "--format=ecsv"])

        lst = OpticsDescription.from_name("LST_LST_LSTCam",
                                          "MonteCarloArray.optics")
        assert lst.num_mirrors == 1
        assert lst.equivalent_focal_length.to_value(u.m) == 28
        assert lst.num_mirror_tiles == 198

    os.chdir(cwd)
    if svc_path_before is None:
        del os.environ["CTAPIPE_SVC_PATH"]
    else:
        os.environ["CTAPIPE_SVC_PATH"] = svc_path_before
コード例 #11
0
ファイル: test_optics.py プロジェクト: watsonjj/ctapipe
def test_optics_from_name_user_supplied_table():
    table = get_table_dataset("optics", role="")
    optics = OpticsDescription.from_name("SST-GCT", optics_table=table)
    assert optics.name == "SST-GCT"
    assert optics.mirror_area > 1.0 * u.m**2
コード例 #12
0
ファイル: test_optics.py プロジェクト: watsonjj/ctapipe
def test_optics_from_name(optics_name):
    """ try constructing all by name """
    optics = OpticsDescription.from_name(optics_name)
    assert optics.equivalent_focal_length > 0
    # make sure the string rep gives back the name:
    assert str(optics) == optics_name
コード例 #13
0
ファイル: test_optics.py プロジェクト: watsonjj/ctapipe
        mirror_area=u.Quantity(550, u.m**2),
        equivalent_focal_length=u.Quantity(10, u.m),
    )

    with pytest.raises(TypeError):
        OpticsDescription(
            name="test",
            num_mirrors=1,
            num_mirror_tiles=100,
            mirror_area=550,
            equivalent_focal_length=10,
        )


@pytest.mark.parametrize("optics_name",
                         OpticsDescription.get_known_optics_names())
def test_optics_from_name(optics_name):
    """ try constructing all by name """
    optics = OpticsDescription.from_name(optics_name)
    assert optics.equivalent_focal_length > 0
    # make sure the string rep gives back the name:
    assert str(optics) == optics_name


def test_optics_from_name_user_supplied_table():
    table = get_table_dataset("optics", role="")
    optics = OpticsDescription.from_name("SST-GCT", optics_table=table)
    assert optics.name == "SST-GCT"
    assert optics.mirror_area > 1.0 * u.m**2

コード例 #14
0
ファイル: test_telescope.py プロジェクト: xuzno-h/ctapipe
    telescopes = []
    for name, type, camera in zip(names, types, cameras):
        for i in range(3):

            telescopes.append(
                TelescopeDescription(
                    name=name,
                    tel_type=type,
                    optics=OpticsDescription.from_name(name),
                    camera=CameraDescription.from_name(camera),
                ))

    assert len(telescopes) == 9
    assert len(set(telescopes)) == 3


OPTICS_NAMES = OpticsDescription.get_known_optics_names()
CAMERA_NAMES = CameraDescription.get_known_camera_names()


@pytest.mark.parametrize("camera_name", CAMERA_NAMES)
@pytest.mark.parametrize("optics_name", OPTICS_NAMES)
def test_telescope_from_name(optics_name, camera_name):
    """ Check we can construct all telescopes from their names """
    tel = TelescopeDescription.from_name(optics_name, camera_name)
    assert optics_name in str(tel)
    assert camera_name in str(tel)
    assert tel.camera.geometry.pix_x.shape[0] > 0
    assert tel.optics.equivalent_focal_length.to("m") > 0
    assert tel.type in ["MST", "SST", "LST", "UNKNOWN"]