def plot_rdf(ax, dset_path): dset = dataset.get_dset(dset_path) vp, vp_err = dset.get_vp() if use_latex: label = r'$\phi = \SI{%.2g}{\percent}$' % vp else: label = r'$\phi = %.2g \%$' % vp rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) rhos_norm_err[np.isnan(rhos_norm_err)] = 0.0 ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label)
def plot_rdf(ax, dset_path, theta_max): dset = dataset.get_dset(dset_path, filter_z_flag=False, theta_max=theta_max) vp, vp_err = dset.get_vp() R = dset.R if use_latex: label = r"$\SI{" + "{:.3g}".format(R) + r"}{\um}$, " + r"$\SI{" + "{:.2g}".format(vp) + r"}{\percent}$" else: label = r"$" + "{:.3g}".format(R) + r"\mu m$, $" + "{:.2g}".format(vp) + r"\%$" rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) rhos_norm_err[np.isnan(rhos_norm_err)] = 0.0 ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label)
def plot_rdf(ax, dset_path): dset = dataset.get_dset(dset_path) rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) vp, vp_err = dset.get_vp() R = dset.R if use_latex: label = (r'$\SI{' + '{:.3g}'.format(R) + r'}{\um}$, ' + r'$\SI{' + '{:.2g}'.format(vp) + r'}{\percent}$') else: label = (r'$' + '{:.3g}'.format(R) + r'\mu m$, $' + '{:.2g}'.format(vp) + r'\%$') import numpy as np rhos_norm_err[np.isnan(rhos_norm_err)] = 0.0 ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label)
def plot_rdf(ax, dset_path, theta_max): dset = dataset.get_dset(dset_path, filter_z_flag=False, theta_max=theta_max) vp, vp_err = dset.get_vp() R = dset.R if use_latex: label = (r'$\SI{' + '{:.3g}'.format(R) + r'}{\um}$, ' + r'$\SI{' + '{:.2g}'.format(vp) + r'}{\percent}$') else: label = (r'$' + '{:.3g}'.format(R) + r'\mu m$, $' + '{:.2g}'.format(vp) + r'\%$') rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) rhos_norm_err[np.isnan(rhos_norm_err)] = 0.0 ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label)
def plot_rdf(ax, dset_path, smooth): dset = dataset.get_dset(dset_path) rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) vp, vp_err = dset.get_vp() R = dset.R if use_latex: label = r"$\SI{" + "{:.3g}".format(R) + r"}{\um}$, " + r"$\SI{" + "{:.2g}".format(vp) + r"}{\percent}$" else: label = r"$" + "{:.3g}".format(R) + r"\mu m$, $" + "{:.2g}".format(vp) + r"\%$" if smooth: label += r", Smooth swimming" else: label += r", Wild type" ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label)
def plot_rdf(ax, dset_path, i): dset = dataset.get_dset(dset_path) vp, vp_err = dset.get_vp() R = dset.R R_peak, R_peak_err = dset.get_R_peak(dr=dr, alg=alg) if use_latex: label = (r'$\SI{' + '{:.3g}'.format(R) + r'}{\um}$, ' + r'$\SI{' + '{:.2g}'.format(vp) + r'}{\percent}$') else: label = (r'$' + '{:.3g}'.format(R) + r'\mu m$, $' + '{:.2g}'.format(vp) + r'\%$') rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) rhos_norm_err[np.isnan(rhos_norm_err)] = 0.0 ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label, c=ejm_rcparams.set2[i]) ax.axvline(R_peak / R, c=ejm_rcparams.set2[i], ls='--')
def plot_rdf(ax, dset_path, smooth): dset = dataset.get_dset(dset_path) rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) vp, vp_err = dset.get_vp() R = dset.R if use_latex: label = (r'$\SI{' + '{:.3g}'.format(R) + r'}{\um}$, ' + r'$\SI{' + '{:.2g}'.format(vp) + r'}{\percent}$') else: label = (r'$' + '{:.3g}'.format(R) + r'\mu m$, $' + '{:.2g}'.format(vp) + r'\%$') if smooth: label += r', Smooth swimming' else: label += r', Wild type' ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label)
use_pgf = True n_samples = 1e4 ds = 0.008 ds_exp = 0.008 s_close = 0.2 dr_peak = 0.7 alg = 'mean' ejm_rcparams.set_pretty_plots(use_latex, use_pgf) fig = plt.figure(figsize=(12, 12 * ejm_rcparams.golden_ratio)) ax = fig.add_subplot(111) ejm_rcparams.prettify_axes(ax) dset = dataset.get_dset(paths.correlation_exp_1_dset_path, filter_z_flag=True) R_peak, R_peak_err = dset.get_R_peak(alg=alg, dr=dr_peak) g, ge, s = dset.get_acf(ds_exp, n_samples, R_min=R_peak) close = s < s_close g = g[close] ge = ge[close] s = s[close] ax.errorbar(s, g, yerr=ge, label='Experiment', c=color_exp) dset = dataset.get_dset(paths.correlation_Drc_0_dset_path) R_peak, R_peak_err = dset.get_R_peak(alg=alg, dr=dr_peak) g, ge, s = dset.get_acf(ds, n_samples, R_min=R_peak) close = s < s_close g = g[close] ge = ge[close] s = s[close]
if exp: fname = 'grid_exp' color = color_exp dset_paths = paths.grid_exp_dset_paths else: fname = 'grid_sim' color = color_opt dset_paths = paths.grid_sim_dset_paths fig, axs = plt.subplots(3, 3, sharex=True, sharey=True, figsize=(16, 12)) axs = axs.flatten() ejm_rcparams.prettify_axes(*axs) for i, ax in enumerate(axs): for dset_path in dset_paths: dset = dataset.get_dset(dset_path) rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) vp, vp_err = dset.get_vp() R = dset.R if use_latex: label = (r'$\SI{' + '{:.3g}'.format(R) + r'}{\um}$, ' + r'$\SI{' + '{:.2g}'.format(vp) + r'}{\percent}$') else: label = (r'$' + '{:.3g}'.format(R) + r'\mu m$, $' + '{:.2g}'.format(vp) + r'\%$') ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label, color=color) ax.text(0.07,
if exp: fname = 'grid_exp' color = color_exp dset_paths = paths.grid_exp_dset_paths else: fname = 'grid_sim' color = color_opt dset_paths = paths.grid_sim_dset_paths fig, axs = plt.subplots(3, 3, sharex=True, sharey=True, figsize=(16, 12)) axs = axs.flatten() ejm_rcparams.prettify_axes(*axs) for i, ax in enumerate(axs): for dset_path in dset_paths: dset = dataset.get_dset(dset_path) rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) vp, vp_err = dset.get_vp() R = dset.R if use_latex: label = (r'$\SI{' + '{:.3g}'.format(R) + r'}{\um}$, ' + r'$\SI{' + '{:.2g}'.format(vp) + r'}{\percent}$') else: label = (r'$' + '{:.3g}'.format(R) + r'\mu m$, $' + '{:.2g}'.format(vp) + r'\%$') ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label, color=color) ax.text(0.07, 4.3, label, fontsize=32, horizontalalignment='left', verticalalignment='center')
from utils import scatlyse save_flag = True use_latex = save_flag use_pgf = True ejm_rcparams.set_pretty_plots(use_latex, use_pgf) t_steady = 50.0 dr = 0.7 n_samples = 1e2 alg = 'mean' # Zero d_0 = dataset.get_dset(paths.direct_Drc_0_dset_path) Rps_0 = np.linspace(0.0, d_0.R, n_samples) t_0, r1_0, r2_0 = d_0.get_direct() r_0 = np.array([vector.vector_mag(r1_0), vector.vector_mag(r2_0)]).T ps_0, ps_0_err = unzip([scatlyse(t_0, r_0, Rp, t_steady) for Rp in Rps_0]) ps_0 = np.array(ps_0) ps_0_err = np.array(ps_0_err) R_peak_0 = d_0.get_R_peak(alg=alg, dr=dr)[0] # 10 d_10 = dataset.get_dset(paths.direct_Drc_10_dset_path) Rps_10 = np.linspace(0.0, d_10.R, n_samples) t_10, r1_10, r2_10 = d_10.get_direct() r_10 = np.array([vector.vector_mag(r1_10), vector.vector_mag(r2_10)]).T ps_10, ps_10_err = unzip([scatlyse(t_10, r_10, Rp, t_steady) for Rp in Rps_10]) ps_10 = np.array(ps_10)
fig = plt.figure(figsize=(12, 12 * ejm_rcparams.golden_ratio)) ax = fig.add_subplot(111) ejm_rcparams.prettify_axes(ax) theta_factors = np.arange(1, 7) for theta_factor in theta_factors: force_fullsphere = theta_factor == 1 if theta_factor == 1: theta_max = np.pi / 2.0 else: theta_max = np.pi / theta_factor dset = dataset.get_dset(paths.wholedrop_dset_path, theta_max=theta_max, force_fullsphere=force_fullsphere) rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) label = r'$\theta_\mathrm{max} = \pi' if theta_factor > 1: label += r' / {}'.format(theta_factor) label += r'$' ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label, lw=2) ax.legend(loc='upper left', fontsize=24, ncol=2)
use_latex = save_flag use_pgf = True ejm_rcparams.set_pretty_plots(use_latex, use_pgf) dr = 0.7 fig = plt.figure(figsize=(14, 6)) gridspec = GridSpec(1, 2) ax = fig.add_subplot(111) ejm_rcparams.prettify_axes(ax) dset = dataset.get_dset(paths.alignment_yes_Drc_inf_dset_path) rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) vp, vp_err = dset.get_vp() R = dset.R rhos_norm_err[np.isnan(rhos_norm_err)] = 0.0 ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label='Align') dset = dataset.get_dset(paths.alignment_no_Drc_inf_dset_path) rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) vp, vp_err = dset.get_vp() R = dset.R rhos_norm_err[np.isnan(rhos_norm_err)] = 0.0 ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label='No align') ax.legend(loc='upper left', fontsize=24)
fig = plt.figure(figsize=(12, 12 * ejm_rcparams.golden_ratio)) ax = fig.add_subplot(111) ejm_rcparams.prettify_axes(ax) theta_factors = np.arange(1, 7) for theta_factor in theta_factors: force_fullsphere = theta_factor == 1 if theta_factor == 1: theta_max = np.pi / 2.0 else: theta_max = np.pi / theta_factor dset = dataset.get_dset(paths.wholedrop_dset_path, theta_max=theta_max, force_fullsphere=force_fullsphere) rhos_norm, rhos_norm_err, R_edges_norm = dset.get_rhos_norm(dr) label = r'$\theta_\mathrm{max} = \pi' if theta_factor > 1: label += r' / {}'.format(theta_factor) label += r'$' ax.errorbar(R_edges_norm[:-1], rhos_norm, yerr=rhos_norm_err, label=label, lw=2) ax.legend(loc='upper left', fontsize=24, ncol=2) ax.set_ylim(0.0, 2.0) ax.set_xlim(0.0, 1.05) ax.set_ylabel(r'$\rho(r) / \rho_0$', fontsize=35)