Ejemplo n.º 1
0
    dataset_angle[cal_index] = pd.DataFrame(dataset_angle[cal_index], columns=['Angle'])

    # filter angles out of range
    valid_angle = (cfg.min_angle <= dataset_angle[cal_index]['Angle']) & \
                  (cfg.max_angle >= dataset_angle[cal_index]['Angle'])

    test_data[cal_index] = test_data[cal_index].loc[valid_angle]
    dataset_angle[cal_index] = dataset_angle[cal_index].loc[valid_angle]

    dataset_angle[cal_index] = np.array(dataset_angle[cal_index]).ravel()

    """
    create trainset
    """
    ant_pat = fn_exp.find_pattern(test_data[cal_index], dataset_angle[cal_index])
    train = np.repeat(ant_pat, cfg_exp.cal_rep, axis=0)
    noise = np.random.normal(0, cfg_exp.cal_noise, train.shape)
    train += noise

    train_max = np.max(train[:, :-1], axis=1).reshape((train.shape[0], 1))

    train -= train_max

    # train angles
    ant_angles = [cfg.min_angle]
    while ant_angles[-1] < cfg.max_angle:
        ant_angles.append(ant_angles[-1] + 2.5)
    ant_angles = np.array(ant_angles)
    ant_angles = np.repeat(ant_angles, cfg_exp.cal_rep)
Ejemplo n.º 2
0
    rfc[cal_index].fit(arranged_data[cal_index], dataset_angle[cal_index])

    # # plot test prediction(angle) - for checking
    # x = range(dataset_angle[cal_index].shape[0])
    #
    # # creating predicted test set angles
    # test_prediction = rfc[cal_index].predict(arranged_data[cal_index]).tolist()
    # plt.plot(x, dataset_angle[cal_index], 'ro', x, test_prediction, 'go')
    # plt.show()

    """
    Plot antennas' graph
    """
    # Find parameters SD (from not arranged data)
    sd_ant = fn_exp.cal_sd(dataseta_for_sd, dataset_angle[cal_index])
    ant_pat = fn_exp.find_pattern(arranged_data[cal_index], dataset_angle[cal_index])

    ant_angles = [cfg.min_angle]
    while ant_angles[-1] < cfg.max_angle:
        ant_angles.append(ant_angles[-1] + 2.5)
    ant_angles = np.array(ant_angles)

    # # plotting
    # plt.figure(1)
    # plt.subplot(211)
    # plt.plot(ant_angles, ant_pat[:, 0], 'r', ant_angles, ant_pat[:, 0] + sd_ant[:, 0], 'r--',
    #          ant_angles, ant_pat[:, 0] - sd_ant[:, 0], 'r--',
    #          ant_angles, ant_pat[:, 1], 'g', ant_angles, ant_pat[:, 1] + sd_ant[:, 1], 'g--',
    #          ant_angles, ant_pat[:, 1] - sd_ant[:, 1], 'g--',
    #          ant_angles, ant_pat[:, 2], 'b', ant_angles, ant_pat[:, 2] + sd_ant[:, 2], 'b--',
    #          ant_angles, ant_pat[:, 2] - sd_ant[:, 2], 'b--',