Exemplo n.º 1
0
    def save_step_chart(self):
        if self.record_step_chart:
            plt.figure(figsize=(20, 12))

            plt.subplot(511)
            plt.title(r"State (0:state$x$, 1:state$y$)")
            plt.ylim(-0.15, 1.15)
            plt.step(self.steps, self.states, color="#0E7AC4")

            plt.subplot(512)
            plt.title(r"$R_x^W$")
            plt.ylim(-0.05, 1.05)
            plt.step(self.steps, self.rxw_history, color="#0E7AC4")

            plt.subplot(513)
            plt.title(r"$R_y$")
            plt.ylim(-0.05, 1.05)
            plt.step(self.steps, self.ry_history, color="#0E7AC4")

            plt.subplot(514)
            plt.title(r"$K$")
            plt_line(plt, self.random_choices, color='green')
            plt.step(self.steps, self.k_history, color="#0E7AC4")

            plt.subplot(515)
            plt.title(r"Turnover angle $A$")
            plt_line(plt, self.turnover_times)
            plt.scatter(self.turnover_times, self.turnover_angles, color="#0E7AC4", s=3)

            plt.tight_layout()
            save_and_close_plt(plt, 'walking')
        else:
            raise Exception('Walking chart is not recorded.')
Exemplo n.º 2
0
    def save_interval_angle_dist(self):
        """
        Plot 2D probability distribution P(tau,a)
        """

        plt.figure(figsize=(3, 4))

        xmin = min(self.calced_log_turnover_intervals.get())
        xmax = max(self.calced_log_turnover_intervals.get())
        ymin = min(self.calced_log_turnover_angles.get())
        ymax = max(self.calced_log_turnover_angles.get())

        xx = np.linspace(-1, 6, 32)
        yy = np.linspace(-2, 3, 32)
        X, Y = np.meshgrid(xx, yy)
        positions = np.vstack([X.ravel(), Y.ravel()])
        values = np.vstack([self.calced_log_turnover_intervals.get(), self.calced_log_turnover_angles.get()])
        kernel = gaussian_kde(values)
        Z = np.reshape(kernel(positions), X.shape)
        plt.imshow(np.rot90(Z.T), cmap=plt.cm.gist_earth_r, extent=[-1, 6, -2, 3], aspect=2)

        plt.xlabel(r'$\log_{10}(\tau)$')
        plt.ylabel(r'$\log_{10}(A)$')

        plt.plot(self.calced_log_turnover_intervals.get(), self.calced_log_turnover_angles.get(), 'k.', markersize=5, c='#FF0000')
        save_and_close_plt(plt, 'interval_angle_dist')
def main():

    parser = argparse.ArgumentParser(description='Plot 3D scatter graphs of human turnover simulations from csv.')
    parser.add_argument('file', type=str,
                       help='csv file inputted')

    args = parser.parse_args()

    df = pd.read_csv(args.file)

    fig = plt.figure()
    ax = Axes3D(fig)

    ax.set_xlabel(r"$\alpha_S$")
    ax.set_ylabel(r"$\alpha_L$")
    ax.set_zlabel(r"Skewness of $\log_{10}\tau$")

    ax.set_xlim(0.45, 0.8)
    ax.set_ylim(0.45, 0.8)
    ax.set_zlim(2.3, -2.3)

    d_wake = df[df.stage == 'wake']
    d_sleep_disturb = df[(df.stage == 'sleep') & (df.alpha_l > 0.55)]
    d_sleep_undisturb = df[(df.stage == 'sleep') & (df.alpha_l <= 0.55)]


    ax.scatter3D(d_sleep_disturb['alpha_s'], d_sleep_disturb['alpha_l'], d_sleep_disturb['skew'], "o", color="#00FF00", s=2)
    ax.scatter3D(d_sleep_undisturb['alpha_s'], d_sleep_undisturb['alpha_l'], d_sleep_undisturb['skew'], "o", color="#0000FF", s=2)
    ax.scatter3D(d_wake['alpha_s'], d_wake['alpha_l'], d_wake['skew'], "o", color="gold", s=2)

    save_and_close_plt(plt, '3dscat')
Exemplo n.º 4
0
    def save_fluctuation(self):
        """
        Plot F(n) and alpha(n)
        """
        plt.figure(figsize=(3, 4))

        plt.xscale('log')
        plt.yscale('log')
        plt.ylim(0.005, 100)
        plt.scatter(self.calced_fn_series.get()[0], self.calced_fn_series.get()[1], s=100, c='#999999')
        plt.xlabel(r'$n$')
        plt.ylabel(r'$F(n)$')
        ax = plt.twinx()
        ax.set_ylim(0, 1)
        ax.set_ylabel(r'$\alpha(n)$')
        ax.scatter(self.calced_alpha_series.get()[0], self.calced_alpha_series.get()[1], s=100, c='white')
        save_and_close_plt(plt, 'fn_and_alpha')
def main():

    parser = argparse.ArgumentParser(
        description=
        'Plot 3D scatter graphs of human turnover simulations from csv.')
    parser.add_argument('file', type=str, help='csv file inputted')

    args = parser.parse_args()

    df = pd.read_csv(args.file)

    fig = plt.figure()
    ax = Axes3D(fig)

    ax.set_xlabel(r"$\alpha_S$")
    ax.set_ylabel(r"$\alpha_L$")
    ax.set_zlabel(r"Skewness of $\log_{10}\tau$")

    ax.set_xlim(0.45, 0.8)
    ax.set_ylim(0.45, 0.8)
    ax.set_zlim(2.3, -2.3)

    d_wake = df[df.stage == 'wake']
    d_sleep_disturb = df[(df.stage == 'sleep') & (df.alpha_l > 0.55)]
    d_sleep_undisturb = df[(df.stage == 'sleep') & (df.alpha_l <= 0.55)]

    ax.scatter3D(d_sleep_disturb['alpha_s'],
                 d_sleep_disturb['alpha_l'],
                 d_sleep_disturb['skew'],
                 "o",
                 color="#00FF00",
                 s=2)
    ax.scatter3D(d_sleep_undisturb['alpha_s'],
                 d_sleep_undisturb['alpha_l'],
                 d_sleep_undisturb['skew'],
                 "o",
                 color="#0000FF",
                 s=2)
    ax.scatter3D(d_wake['alpha_s'],
                 d_wake['alpha_l'],
                 d_wake['skew'],
                 "o",
                 color="gold",
                 s=2)

    save_and_close_plt(plt, '3dscat')
Exemplo n.º 6
0
    def save_interval_ccdf(self):
        """
        Plot complementary cumulative distribution function P(x>=tau)
        """
        plt.figure(figsize=(3, 4))

        plt.xlabel(r'$\tau (s)$')
        plt.ylabel(r'$P(x\geq\tau)$')

        slis = sorted(self.calced_log_turnover_intervals.get())
        l = len(slis)
        i = 0
        y = []
        for x in slis:
            y.append(1.0 * (l - i) / l)
            i += 1

        plt.scatter(slis, y, s=100, c='white')
        save_and_close_plt(plt, 'interval_ccdf')