Esempio n. 1
0
        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

Esempio n. 2
0
    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"]