Beispiel #1
0
def get_Om_from_abs_angles(abs_angles, m):
    angles_vector = vector_from_matrix(abs_angles)
    Om = np.zeros((m, m))
    for i in range(m):
        for j in range(m):
            Om[i, j] = np.cos(angles_vector[i] - angles_vector[j])
    return Om
Beispiel #2
0
def get_noisy_points(points_original, noise):
    from pylocus.plots_cti import plot_matrix
    from pylocus.basics_angles import from_0_to_2pi
    points_noisy = points_original.copy()
    points_noisy.add_noise(noise)
    abs_angles_vector = vector_from_matrix(points_noisy.abs_angles)
    #diff_angles = points_noisy.abs_angles - points_original.abs_angles
    #diff_dm = (points_noisy.dm - points_original.dm).reshape((1,-1))
    #diff = from_0_to_2pi(diff)
    #plot_matrix(diff_angles, 'diff abs angles')
    #print('diff dm:',diff_dm)
    return points_noisy.Om, points_noisy.dm, abs_angles_vector
Beispiel #3
0
def get_noisy_absolute(abs_angles_original, dm_original, rho, sigmad,
                       gaussian):
    m = len(dm_original)
    if gaussian:
        errors = np.triu(np.random.normal(0, rho, abs_angles_original.shape))
    else:
        from tikhonov import tikhonov_scipy
        tik_sc = tikhonov_scipy(rho)
        errors = np.triu(tik_sc.rvs(size=abs_angles_original.shape))
    abs_angles_noisy = abs_angles_original + errors + errors.T
    np.fill_diagonal(abs_angles_noisy, 0.0)
    abs_angles_vector = vector_from_matrix(abs_angles_noisy)

    if gaussian:
        # create Om with same variance as absolute angles.
        errors = np.triu(
            np.random.normal(0, rho / 2.0, abs_angles_original.shape))
        abs_angles_noisy = abs_angles_original + errors + errors.T
    Om = get_Om_from_abs_angles(abs_angles_noisy, m)
    dm = (np.sqrt(dm_original) + np.random.normal(0, sigmad, m))**2
    return Om, dm, abs_angles_vector
Beispiel #4
0
def dm_from_edm(edm):
    from pylocus.basics import vector_from_matrix
    dm = vector_from_matrix(edm)
    dm = np.extract(dm > 0, dm)
    return np.power(dm, 0.5)