PlotSet('traps_clust', '/Volumes/Backup/bannock_data/Model2D_dim=2,seed=1,dt=0.1,L=2.5e+03,dx=40.3,c_D=1e+03,c_sink=0.01,c_source=1,v_0=20,p_0=1,D_rot=0.2,origin_flag=0,rho_0=0.001,chi=all,onesided_flag=1,force_mu=0,vicsek_R=0,walls=Traps_dim=2,L=2.5e+03,dx=40.3,n=5,d=40.3,w=282,s=80.6/Model2D_dim=2,seed=1,dt=0.1,L=2.5e+03,dx=40.3,c_D=1e+03,c_sink=0.01,c_source=1,v_0=20,p_0=1,D_rot=0.2,origin_flag=0,rho_0=0.001,chi=686,onesided_flag=1,force_mu=0,vicsek_R=0,walls=Traps_dim=2,L=2.5e+03,dx=40.3,n=5,d=40.3,w=282,s=80.6', False),
    PlotSet('traps_multi_clust', '/Volumes/Backup/bannock_data/Model2D_dim=2,seed=1,dt=0.1,L=2.5e+03,dx=40.3,c_D=1e+03,c_sink=0.01,c_source=1,v_0=20,p_0=1,D_rot=0.2,origin_flag=0,rho_0=0.001,chi=all,onesided_flag=1,force_mu=0,vicsek_R=0,walls=Traps_dim=2,L=2.5e+03,dx=40.3,n=5,d=40.3,w=282,s=80.6/Model2D_dim=2,seed=1,dt=0.1,L=2.5e+03,dx=40.3,c_D=1e+03,c_sink=0.01,c_source=1,v_0=20,p_0=1,D_rot=0.2,origin_flag=0,rho_0=0.001,chi=1.6e+03,onesided_flag=1,force_mu=0,vicsek_R=0,walls=Traps_dim=2,L=2.5e+03,dx=40.3,n=5,d=40.3,w=282,s=80.6', False),
    PlotSet('maze_noclust', '/Volumes/Backup/bannock_data/Model2D_dim=2,seed=1,dt=0.1,L=2.5e+03,dx=40.3,c_D=1e+03,c_sink=0.01,c_source=1,v_0=20,p_0=1,D_rot=0.2,origin_flag=0,rho_0=0.001,chi=all,onesided_flag=1,force_mu=0,vicsek_R=0,walls=Maze_dim=2,L=2.5e+03,dx=40.3,d=40,seed=1/Model2D_dim=2,seed=1,dt=0.1,L=2.5e+03,dx=40.3,c_D=1e+03,c_sink=0.01,c_source=1,v_0=20,p_0=1,D_rot=0.2,origin_flag=0,rho_0=0.001,chi=0,onesided_flag=1,force_mu=0,vicsek_R=0,walls=Maze_dim=2,L=2.5e+03,dx=40.3,d=40,seed=1', False),
    PlotSet('maze_clust', '/Volumes/Backup/bannock_data/Model2D_dim=2,seed=1,dt=0.1,L=2.5e+03,dx=40.3,c_D=1e+03,c_sink=0.01,c_source=1,v_0=20,p_0=1,D_rot=0.2,origin_flag=0,rho_0=0.001,chi=all,onesided_flag=1,force_mu=0,vicsek_R=0,walls=Maze_dim=2,L=2.5e+03,dx=40.3,d=40,seed=1/Model2D_dim=2,seed=1,dt=0.1,L=2.5e+03,dx=40.3,c_D=1e+03,c_sink=0.01,c_source=1,v_0=20,p_0=1,D_rot=0.2,origin_flag=0,rho_0=0.001,chi=800,onesided_flag=1,force_mu=0,vicsek_R=0,walls=Maze_dim=2,L=2.5e+03,dx=40.3,d=40,seed=1', False),
]

for plot_set in plot_sets:
    model = output_utils.get_recent_model(plot_set.dirname_path)

    fig = plt.figure(figsize=(12, 12 * ejm_rcparams.golden_ratio))

    ax = fig.add_subplot(111)
    ejm_rcparams.prettify_axes(ax)

    D_rho = cutils.get_D_rho(model.v_0, model.p_0, model.dim)
    L_red = cutils.get_reduced_length(delta=model.c_sink, D_rho=D_rho,
                                      x=model.L)

    if plot_set.centre_flag:
        # Centre particles in the axes.
        r_com = get_r_com(model.r)
        r = model.r - r_com
        i_com = np.round(r_com / model.dx).astype(np.int)
        c = center_image(model.c.a, i_com)
    else:
        r = model.r
        c = model.c.a
    mask = np.logical_not(model.walls.a)
    c = ma.array(c, mask=np.logical_not(mask), fill_value=0)

    r_red = cutils.get_reduced_length(delta=model.c_sink, D_rho=D_rho, x=r)
for plot_set in plot_sets:
    fnames = output_utils.get_filenames(plot_set.dirname_path)
    ms = [output_utils.filename_to_model(fname) for fname in fnames]
    ms_steady = [m for m in ms if m.t > t_steady]

    m_0 = ms_steady[-1]

    rhos = [get_rho(m, bins) for m in ms_steady]
    rho = np.mean(rhos, axis=0)
    rho_err = sem(rhos, axis=0)
    rho_red = cutils.get_reduced_rho(m_0.rho_0, rho)
    rho_red_err = cutils.get_reduced_rho(m_0.rho_0, rho_err)

    x = np.linspace(-m_0.L / 2.0, m_0.L / 2.0, rho.shape[0])
    D_rho = cutils.get_D_rho(m_0.v_0, m_0.p_0, m_0.dim)
    x_red = cutils.get_reduced_length(m_0.c_sink, D_rho, x)

    ax.errorbar(x_red, rho_red, rho_red_err, label=plot_set.label,
                c=plot_set.color)

ax.legend(loc='upper left', fontsize=26)
ax.set_xlabel(r'$\tilde{x}$', fontsize=35)
ax.set_ylabel(r'$\tilde{\rho}$', fontsize=35)
ax.tick_params(axis='both', labelsize=26, pad=10.0)
ax.set_xlim(x_red.min(), x_red.max())
ax.set_ylim(0.0, None)

if save_flag:
    plt.savefig('plots/snapshot_1d.pdf', bbox_inches='tight')
else:
    plt.show()