Exemplo n.º 1
0
def test_create_display_without_geometry(example_event, example_subarray):
    """Test we can create a display without giving the geometry to init"""
    from ctapipe.visualization.bokeh import CameraDisplay

    # test we can create it without geometry, and then set all the stuff
    display = CameraDisplay()

    tel_id = next(iter(example_event.r0.tel.keys()))
    display.geometry = example_subarray.tel[tel_id].camera.geometry
    display.image = example_event.dl1.tel[tel_id].image
Exemplo n.º 2
0
def test_camera_image(example_event, example_subarray, tmp_path):
    """Test we set an image"""
    from ctapipe.visualization.bokeh import CameraDisplay

    t = list(example_event.r0.tel.keys())[0]
    geom = example_subarray.tel[t].camera.geometry
    image = np.ones(geom.n_pixels)

    display = CameraDisplay(geom, image)
    assert np.all(display.image == image)

    display.image = np.random.normal(size=geom.n_pixels)
    assert np.all(display.image == image)

    output_path = tmp_path / "test.html"
    output_file(output_path)
    save(display.figure, filename=output_path)
Exemplo n.º 3
0
def test_camera_image(example_event):
    t = list(example_event.r0.tels_with_data)[0]
    geom = example_event.inst.subarray.tel[t].camera
    n_pixels = geom.pix_x.value.size
    image = np.ones(n_pixels)
    colors = intensity_to_hex(image)

    with pytest.raises(ValueError):
        CameraDisplay(None, image)

    c_display = CameraDisplay(geom, image)
    assert (c_display.cdsource.data['image'] == colors).all()
    assert c_display.image_min == 0
    assert c_display.image_max == 2

    image[5] = 5
    colors = intensity_to_hex(image)
    c_display.image = image
    assert (c_display.cdsource.data['image'] == colors).all()
    assert c_display.image_min == image.min()
    assert c_display.image_max == image.max()
Exemplo n.º 4
0
def test_camera_image(example_event, example_subarray):
    from ctapipe.visualization.bokeh import CameraDisplay, intensity_to_hex

    t = list(example_event.r0.tels_with_data)[0]
    geom = example_subarray.tel[t].camera.geometry
    n_pixels = geom.pix_x.value.size
    image = np.ones(n_pixels)
    colors = intensity_to_hex(image)

    with pytest.raises(ValueError):
        CameraDisplay(None, image)

    c_display = CameraDisplay(geom, image)
    assert (c_display.cdsource.data["image"] == colors).all()
    assert c_display.image_min == 0
    assert c_display.image_max == 2

    image[5] = 5
    colors = intensity_to_hex(image)
    c_display.image = image
    assert (c_display.cdsource.data["image"] == colors).all()
    assert c_display.image_min == image.min()
    assert c_display.image_max == image.max()
Exemplo n.º 5
0
def test_camera_image(example_event):
    from ctapipe.visualization.bokeh import CameraDisplay, intensity_to_hex

    t = list(example_event.r0.tels_with_data)[0]
    geom = example_event.inst.subarray.tel[t].camera
    n_pixels = geom.pix_x.value.size
    image = np.ones(n_pixels)
    colors = intensity_to_hex(image)

    with pytest.raises(ValueError):
        CameraDisplay(None, image)

    c_display = CameraDisplay(geom, image)
    assert (c_display.cdsource.data['image'] == colors).all()
    assert c_display.image_min == 0
    assert c_display.image_max == 2

    image[5] = 5
    colors = intensity_to_hex(image)
    c_display.image = image
    assert (c_display.cdsource.data['image'] == colors).all()
    assert c_display.image_min == image.min()
    assert c_display.image_max == image.max()