def calc_random_source(pointing_zd, pointing_az, wobble_distance): phi = np.random.uniform(0, 2 * np.pi, len(pointing_zd)) r = wobble_distance / camera_distance_mm_to_deg(1) x = r * np.cos(phi) y = r * np.sin(phi) zd, az = camera_to_horizontal(x, y, pointing_zd, pointing_az) return zd, az
def test_there_and_back_again_horizontal(): from fact.coordinates import camera_to_horizontal, horizontal_to_camera df = pd.DataFrame({ 'az_tracking': [0, 90, 270], 'zd_tracking': [0, 10, 20], 'timestamp': pd.date_range('2017-10-01 22:00Z', periods=3, freq='10min'), 'x': [-100, 0, 150], 'y': [0, 100, 0], }) zd, az = camera_to_horizontal(df.x, df.y, df.zd_tracking, df.az_tracking) x, y = horizontal_to_camera(zd, az, df.zd_tracking, df.az_tracking) assert np.allclose(x, df.x) assert np.allclose(y, df.y)
def calc_source_features_common( prediction_x, prediction_y, source_zd, source_az, pointing_position_zd, pointing_position_az, ): result = {} k_zd, k_az = "zd_prediction", "az_prediction" result[k_zd], result[k_az] = camera_to_horizontal( prediction_x, prediction_y, pointing_position_zd, pointing_position_az, ) result["theta_deg"] = calc_theta_camera( prediction_x, prediction_y, source_zd=source_zd, source_az=source_az, zd_pointing=pointing_position_zd, az_pointing=pointing_position_az, ) theta_offs = calc_theta_offs_camera( prediction_x, prediction_y, source_zd=source_zd, source_az=source_az, zd_pointing=pointing_position_zd, az_pointing=pointing_position_az, n_off=5, ) for i, theta_off in enumerate(theta_offs, start=1): result["theta_deg_off_{}".format(i)] = theta_off return result