Ejemplo n.º 1
0
def overlay_contour_plot(prefix,
                         q1,
                         q2,
                         lead_q1_q2_trials_dyn,
                         follows_q1_q2_trials_nrmse,
                         xlabel,
                         ylabel,
                         logx=False,
                         logy=False,
                         logz=False,
                         levels="auto",
                         levels2="auto"):
    """
    """

    # Lead contour
    X, Y = np.meshgrid(q1, q2)
    Z = np.zeros((len(q2), len(q1)))
    for i, listQ2_listTrials_nrmse in enumerate(lead_q1_q2_trials_dyn):
        for j, listTrials_nrmse in enumerate(listQ2_listTrials_nrmse):
            Z[j, i] = np.mean(listTrials_nrmse)

    plt.clf()
    # fig, ax = plt.subplots()
    # ax.ticklabel_format(useOffset=False,style='plain')
    if levels is "auto":
        plt.contourf(X, Y, Z, cmap=cm.magma)
    else:
        plt.contourf(X, Y, Z, cmap=cm.magma, levels=levels)
    # cbar = plt.colorbar()
    # cbar.set_label('${NRMSE}$')

    color_list = ['r', 'b', 'g']
    for l, follow in enumerate(follows_q1_q2_trials_nrmse):
        Z = np.zeros((len(q2), len(q1)))
        for i, listQ2_listTrials_nrmse in enumerate(follow):
            for j, listTrials_nrmse in enumerate(listQ2_listTrials_nrmse):
                Z[j, i] = np.mean(listTrials_nrmse)

        if levels2 is "auto":
            CS = plt.contour(X, Y, Z, colors=color_list[l])
        else:
            CS = plt.contour(X, Y, Z, colors=color_list[l], levels=levels2)
        plt.clabel(CS, fontsize=10, inline=1)

    plt.xlabel(xlabel, fontsize=30)
    plt.ylabel(ylabel, fontsize=30)
    if logx:
        plt.xscale('log')
    if logy:
        plt.yscale('log')
    if logz:
        plt.zscale('log')

    plt.tight_layout()
    plt.savefig(prefix + '_q1_q2_nrmse_contour.png')
    plt.clf()
    plt.close()
def plot_dynrange_contour(prefix,
                          Q1,
                          Q2,
                          Aq1_Aq2_Asample_Arates_p,
                          Aq1_Aq2_Asample_Arates_F,
                          xlabel,
                          ylabel,
                          logx=False,
                          logy=False,
                          logz=False,
                          levels=None):
    """
    plot the dynamic rage averaged over a number of sample graphs versus two variables
    """

    X, Y = np.meshgrid(Q1, Q2)
    Z = np.zeros((len(Q2), len(Q1)))
    for i in range(Aq1_Aq2_Asample_Arates_p.shape[0]):
        for j in range(Aq1_Aq2_Asample_Arates_p.shape[1]):
            dynranges = []
            for k in range(Aq1_Aq2_Asample_Arates_p.shape[2]):
                dynrange, _, _ = calc_dynamical_range(
                    Aq1_Aq2_Asample_Arates_p[i, j, k],
                    Aq1_Aq2_Asample_Arates_F[i, j, k])
                dynranges.append(dynrange)

            Z[j, i] = np.mean(dynranges)

    plt.clf()
    if levels == None:
        plt.contourf(X, Y, Z, cmap=cm.magma)
    else:
        plt.contourf(X, Y, Z, cmap=cm.magma, levels=levels)
    cbar = plt.colorbar()
    cbar.set_label('$\Delta$')
    plt.xlabel(xlabel, fontsize=30)
    plt.ylabel(ylabel, fontsize=30)
    if logx:
        plt.xscale('log')
    if logy:
        plt.yscale('log')
    if logz:
        plt.zscale('log')

    plt.tight_layout()
    plt.savefig(prefix + '_q1_q2_delta_contour.png')
    plt.clf()
    plt.close()
Ejemplo n.º 3
0
def performance_contour_plot(prefix,
                             q1,
                             q2,
                             listQ1_listQ2_listTrials_nrmse,
                             xlabel,
                             ylabel,
                             zlabel,
                             logx=False,
                             logy=False,
                             logz=False,
                             levels="auto"):

    X, Y = np.meshgrid(q1, q2)
    Z = np.zeros((len(q2), len(q1)))
    for i, listQ2_listTrials_nrmse in enumerate(
            listQ1_listQ2_listTrials_nrmse):
        for j, listTrials_nrmse in enumerate(listQ2_listTrials_nrmse):
            # print listTrials_nrmse, X[j,i], Y[j,i])
            Z[j, i] = np.mean(listTrials_nrmse)

    plt.clf()
    # fig, ax = plt.subplots()
    # ax.ticklabel_format(useOffset=False,style='plain')
    if levels is "auto":
        plt.contourf(X, Y, Z, cmap=cm.magma)
    else:
        plt.contourf(X, Y, Z, cmap=cm.magma, levels=levels)
    cbar = plt.colorbar()
    cbar.set_label(zlabel)  #"${NRMSE}$"
    plt.xlabel(xlabel, fontsize=30)
    plt.ylabel(ylabel, fontsize=30)
    if logx:
        plt.xscale('log')
    if logy:
        plt.yscale('log')
    if logz:
        plt.zscale('log')

    plt.tight_layout()
    plt.savefig(prefix + '_q1_q2_mc_contour.png')
    plt.clf()
    plt.close()
Ejemplo n.º 4
0
def contour_plot(prefix,
                 q1,
                 q2,
                 listQ1_listQ2_listTrials_val,
                 xlabel,
                 ylabel,
                 logx=False,
                 logy=False,
                 logz=False,
                 levels=None,
                 zlabel=None):

    X, Y = np.meshgrid(q1, q2)
    Z = np.zeros((len(q2), len(q1)))
    for i, listQ2_listTrials_val in enumerate(listQ1_listQ2_listTrials_val):
        for j, listTrials_val in enumerate(listQ2_listTrials_val):
            Z[j, i] = np.mean(listTrials_val)

    plt.clf()
    # fig, ax = plt.subplots()
    # ax.ticklabel_format(useOffset=False,style='plain')
    if levels == None:
        plt.contourf(X, Y, Z, cmap=cm.magma)
    else:
        plt.contourf(X, Y, Z, cmap=cm.magma, levels=levels)
    cbar = plt.colorbar()
    if zlabel:
        cbar.set_label(zlabel)
    plt.xlabel(xlabel, fontsize=30)
    plt.ylabel(ylabel, fontsize=30)
    if logx:
        plt.xscale('log')
    if logy:
        plt.yscale('log')
    if logz:
        plt.zscale('log')

    plt.tight_layout()
    plt.savefig(prefix + '_q1_q2_contour.png')
    plt.clf()
    plt.close()
def plot_performance_contour(prefix,
                             q1,
                             q2,
                             listQ1_listQ2_listTrials_mc,
                             xlabel,
                             ylabel,
                             logx=False,
                             logy=False,
                             logz=False,
                             levels=None):

    X, Y = np.meshgrid(q1, q2)
    Z = np.zeros((len(q2), len(q1)))
    for i, listQ2_listTrials_mc in enumerate(listQ1_listQ2_listTrials_mc):
        for j, listTrials_mc in enumerate(listQ2_listTrials_mc):
            Z[j, i] = np.mean(
                listTrials_mc)  # Take average over all signal inputs

    plt.clf()
    if levels == None:
        plt.contourf(X, Y, Z, cmap=cm.magma)
    else:
        plt.contourf(X, Y, Z, cmap=cm.magma, levels=levels)
    cbar = plt.colorbar()
    cbar.set_label('${MC}$')
    plt.xlabel(xlabel, fontsize=30)
    plt.ylabel(ylabel, fontsize=30)
    if logx:
        plt.xscale('log')
    if logy:
        plt.yscale('log')
    if logz:
        plt.zscale('log')

    plt.tight_layout()
    plt.savefig(prefix + '_q1_q2_mc_contour.png')
    plt.clf()
    plt.close()