Пример #1
0
def test_camera_to_altaz():
    pos_x = np.array([0, 0]) * u.m
    pos_y = np.array([0, 0]) * u.m
    focal = 28 * u.m
    pointing_alt = np.array([1.0, 1.0]) * u.rad
    pointing_az = np.array([0.2, 0.5]) * u.rad
    sky_coords = utils.camera_to_altaz(pos_x, pos_y, focal, pointing_alt,
                                       pointing_az)
    np.testing.assert_allclose(sky_coords.alt, pointing_alt, rtol=1e-4)
    np.testing.assert_allclose(sky_coords.az, pointing_az, rtol=1e-4)

    # Test for real event with a time
    obs_time = Time(['2018-11-01T02:00', '2018-11-01T02:00'])
    sky_coords = utils.camera_to_altaz(pos_x,
                                       pos_y,
                                       focal,
                                       pointing_alt,
                                       pointing_az,
                                       obstime=obs_time)
    np.testing.assert_allclose(sky_coords.alt, pointing_alt, rtol=1e-4)
    np.testing.assert_allclose(sky_coords.az, pointing_az, rtol=1e-4)
Пример #2
0
def test_change_frame_camera_sky():
    from lstchain.reco.utils import sky_to_camera, camera_to_altaz
    import astropy.units as u
    x = np.random.rand(1) * u.m
    y = np.random.rand(1) * u.m
    focal_length = 5 * u.m
    pointing_alt = np.pi / 3. * u.rad
    pointing_az = 0. * u.rad

    sky_pos = camera_to_altaz(x, y, focal_length, pointing_alt, pointing_az)
    cam_pos = sky_to_camera(sky_pos.alt, sky_pos.az, focal_length,
                            pointing_alt, pointing_az)
    np.testing.assert_almost_equal([x, y], [cam_pos.x, cam_pos.y], decimal=4)
Пример #3
0
def set_expected_pos_to_reco_altaz(data):
    """
    Set expected source positions to reconstructed alt, az positions for
    source-dependent analysis.
    This is just a trick to easily extract ON/OFF events in gammapy analysis.
    """
    # set expected source positions as reco positions
    time = data['dragon_time']
    obstime = Time(time, scale='utc', format='unix')
    expected_src_x = data['expected_src_x'] * u.m
    expected_src_y = data['expected_src_y'] * u.m
    focal = 28 * u.m
    pointing_alt = data['pointing_alt']
    pointing_az = data['pointing_az']
    expected_src_altaz = camera_to_altaz(expected_src_x,
                                         expected_src_y,
                                         focal,
                                         pointing_alt,
                                         pointing_az,
                                         obstime=obstime)
    data["reco_alt"] = expected_src_altaz.alt
    data["reco_az"] = expected_src_altaz.az