Exemple #1
0
def main():
    args = get_args(__file__)

    labels = [
        'N/A', 'Id. Física', 'Id. Historiográfica', 'Desconocido', 'Perdido'
    ]
    colornames = ['light grey', 'medium green', 'denim blue', 'pale red']

    df = pd.DataFrame(read_table(args.table))
    df['ident'] = df.apply(categorize, axis=1)
    data = df\
        .drop_duplicates(['bid', 'lid'], keep='first')\
        .pivot(index='bid', columns='lid', values='ident')\
        .fillna(0)

    #colors = sns.color_palette('hls', len(data))
    #colors = sns.color_palette('husl', len(data))
    #colors = sns.light_palette('red', len(data))
    colors = sns.xkcd_palette(colornames)

    f, ax = plt.subplots()

    sns.heatmap(data,
                ax=ax,
                square=True,
                linewidth=0.5,
                cmap=ListedColormap(colors),
                cbar=False)

    set_axis(ax, data, as_letters(set(df.year.values)), 'Libros')
    legend(f, ax, labels, colors)
    plotting(plt, args)
Exemple #2
0
def plot(args):
    df = pd.DataFrame(read_table(args.table))
    configurer = configs[args.color_by]
    data, labels, colors = configurer(df, args.color_by)

    f, ax = plt.subplots()

    fig = sns.heatmap(
        data,
        ax=ax,
        #square=True,
        linewidth=0.5,
        cmap=ListedColormap(colors),
        cbar=False)

    set_axis(ax, data, as_letters(set(df.year.values)), ylabel='Posición')
    legend(f, ax, labels, colors)

    if args.annotated and args.color_by in ['bid', 'year']:
        df_by_bid = df.drop_duplicates('bid').set_index('bid')
        texts = [
            fig.text(
                15,
                bid,
                df.loc[bid, 'short'],
                fontsize=8,
            ) for bid, row in data.iterrows()
        ]

    plotting(plt, args)
Exemple #3
0
def run_experiment(board, next, win, gmme, gabe):
    b = [0 for x in range(9)]
    common.set_board(b, board)
    common.print_board(b)
    common.variables.explored = 0
    wmm = student_code.minmax_tictactoe(b, next)
    mme = common.variables.explored
    common.variables.explored = 0
    wabp = student_code.abprun_tictactoe(b, next)
    abpe = common.variables.explored

    print(common.legend(next) + " moves Result :")
    res1 = "- MIN-MAX: " + common.legend(wmm) + " wins "
    if (wmm != win):
        res1 += "(" + bcolors.RED + "Fail" + bcolors.NORMAL + ")"
    else:
        res1 += "(" + bcolors.GREEN + "Pass" + bcolors.NORMAL + ")"

    res1 += " boards explored " + str(mme)

    if (mme != gmme):
        res1 += "(" + bcolors.RED + "Fail" + bcolors.NORMAL + ")"
    else:
        res1 += "(" + bcolors.GREEN + "Pass" + bcolors.NORMAL + ")"

    print(res1)

    res1 = "- ALPHA-BETA: " + common.legend(wabp) + " wins "
    if (wabp != win):
        res1 += "(" + bcolors.RED + "Fail" + bcolors.NORMAL + ")"
    else:
        res1 += "(" + bcolors.GREEN + "Pass" + bcolors.NORMAL + ")"

    res1 += " boards explored " + str(abpe)

    if (abpe != gabe):
        res1 += "(" + bcolors.RED + "Fail" + bcolors.NORMAL + ")"
    else:
        res1 += "(" + bcolors.GREEN + "Pass" + bcolors.NORMAL + ")"

    print(res1)
    print("")
    print("")
    return wmm == win and mme <= gmme and wabp == win and abpe <= gabe
Exemple #4
0
def simFilters():
    df = loadCSV('VS-filtering-34.csv', (
    'AbsAlt', 'TerAlt', 'Alt', 'AltAhead', 'Err', 'VSP', 'VSF', 'MinVSF', 'aV', 'rV', 'dV', 'mdTWR', 'mTWR', 'hV'))
    df = df[df.Alt > 3].reset_index()
    addL(df)
    L = df.L
    a = df.TerAlt
    aa = df.AltAhead
    #     t1 = 20
    T = np.arange(0, df.shape[0] * dt, dt)
    #     er = np.sin(T*0.5)+np.random.normal(size=len(L))/10.0
    ewa = vFilter(aa, EWA, ratio=0.1)
    ewa2 = vFilter(aa, EWA2, ratio=0.9)
    ax = plt.subplot()
    ax1 = ax.twinx()
    ax.plot(T, a, label='Alt')
    ax1.plot(T, -aa, label='Rad')
    ax1.plot(T, -ewa, label='EWA')
    ax1.plot(T, -ewa2, label='EWA2')
    #     ax1.plot(L, g2, label='Gauss2')
    legend()
    plt.show()
Exemple #5
0
def sim_Rotation():
    def _plot(r, c, n, X, Y, aa, ylab):
        plt.subplot(r, c, n)
        plt.plot(X, Y, label=("V: AA=%.1f" % aa))
        plt.xlabel("time (s)")
        plt.ylabel(ylab)

    MaxAngularA = np.arange(0.5, 30, 5);
    start_error = 0.8 * np.pi
    end_time = 10.0

    def test(c, n, pid):
        p = pid.kp;
        d = pid.kd
        for aa in MaxAngularA:
            A = [start_error]
            V = [0.0]
            S = [0.0]
            T = [0.0]

            def plot(c, n, Y, ylab):
                _plot(3, c, n, T, Y, aa, ylab)

            pid.kp = p / aa
            pid.kd = d / aa
            while T[-1] < end_time:
                S.append(pid.update(A[-1]))
                V.append(V[-1] - S[-1] * aa * dt)
                A.append(A[-1] + V[-1] * dt)
                T.append(T[-1] + dt)
            plot(c, n, np.fromiter(A, float) / np.pi * 180.0, 'Angle')
            plot(c, c + n, V, 'Angular velocity')
            plot(c, c * 2 + n, S, 'Steering')

    test(2, 1, PID(6.0, 0, 10.0, -1, 1))
    test(2, 2, PID(4.0, 0, 6.0, -1, 1))
    legend()
    plt.show()
Exemple #6
0
def main():
    args = get_args(__file__)

    names = ['NA', 'LAT', 'ROM', 'FRAN']
    labels = ['N/A', 'Latín', 'Romance', 'Francés']
    colornames = ['light grey', 'pale red', 'medium green', 'denim blue']

    df = pd.DataFrame(read_table(args.table))
    data = categorical_by(df, 'lang', names)
    colors = sns.xkcd_palette(colornames)

    f, ax = plt.subplots()

    sns.heatmap(data,
                ax=ax,
                square=True,
                linewidth=0.5,
                cmap=ListedColormap(colors),
                cbar=False)

    set_axis(ax, data, as_letters(set(df.year.values)), 'Libros')
    legend(f, ax, labels, colors)
    plotting(plt, args)
Exemple #7
0
def main():
    args = get_args(__file__)

    names = ['NA', 'REL', 'CRONIC', 'ANTI']
    labels = ['N/A', 'Religioso', 'Crónicas y Leyes', 'Historia Antigua']
    colornames = ['light grey', 'pale red', 'medium green', 'denim blue']

    df = pd.DataFrame(read_table(args.table))
    #df = pd.read_csv(args.table)
    data = categorical_by(df, 'topic', names)
    colors = sns.xkcd_palette(colornames)

    f, ax = plt.subplots()

    sns.heatmap(data,
                ax=ax,
                square=True,
                linewidth=0.5,
                cmap=ListedColormap(colors),
                cbar=False)

    set_axis(ax, data, as_letters(df.year.values), ylabel='Posición')
    legend(f, ax, labels, colors)
    plotting(plt, args)