Fr,
            c,
            t_start=tmin,
            run_nb=run_nb,
            n_colors=len(df),
        )


if __name__ == "__main__":
    sns.set_palette("cubehelix", 3)
    matplotlib_rc(11)
    path_fig = exit_if_figure_exists(__file__)
    set_figsize(7, 3)
    fig, ax = pl.subplots(1, 2, sharex=True, sharey=True)

    df_w = load_df("df_w")
    df_3840 = df_w[df_w["$n$"] == 3840]
    df_7680 = df_w[df_w["$n$"] == 7680]

    sns.set_palette("cubehelix", 5)
    plot_df(df_3840, fig, ax[0])
    sns.set_palette("cubehelix", 3)
    plot_df(df_7680, fig, ax[1])

    for ax1 in ax:
        ax1.set_ylim(1e-2, 1e2)
        ax1.set_xlim(2e-1, 5e2)

    ax[1].set_ylabel(None)
    fig.tight_layout()
from paths import shortname_from_path

df = pd.DataFrame({"path": paths})
with warnings.catch_warnings():
    warnings.filterwarnings("ignore", category=optimize.OptimizeWarning)
    params = df.path.apply(init_df)
df_params = pd.DataFrame(list(params))
df = df.join(df_params)
df = df.sort_values(["c", "$n$"])
short = df["path"].apply(str).apply(shortname_from_path)
df.set_index(short, inplace=True)
df.head()

# ## Load shock separation estimates from cache

df_shocks = load_df("shock_sep_laplacian_nupt1_by_counting_mean")
df_shocks

#  _df = df[(df["$n$"] == 960) | (df["$n$"] == 2880)]
_df = df
try:
    _df["d"] = df_shocks["mean"].values
except ValueError:
    breakpoint()
    raise
df = _df

fig, ax = plt.subplots(1, 2, figsize=(10, 3), dpi=150)

colors = [
    mpl.colors.to_hex(c) for c in sns.color_palette("cubehelix", len(df))
Example #3
0
import numpy as np
from peak_detection import run
from paths import paths_lap, load_df

df = load_df("df_lap")
df = df[np.logical_and(
    df["$c$"] > 10, np.logical_not((df["$n$"] == 960) | (df["$n$"] == 2880)))]
print(df)
# FIXME: t=12,21
for t in range(22, 26):
    print("Time:", t)
    run(
        nh_min=0,
        df=df,
        save_as=f"dataframes/shock_sep_laplacian_nupt1_by_counting_t{t}.csv",
        dict_paths=paths_lap,
        t_approx=t,
    )
import matplotlib.pyplot as plt
from base import matplotlib_rc
from paths import load_df, exit_if_figure_exists
from base_fig_energy import plot_energy

matplotlib_rc(fontsize=10)
path_fig = exit_if_figure_exists(__file__)
df_w = load_df("df_lap")
fig, ax = plt.subplots(1, 2, figsize=(6.5, 3))
plot_energy(df_w,
            fig,
            ax,
            N=[960, 1920, 2880, 3840, 7680],
            C=[10, 20, 40, 100, 200])
fig.tight_layout()
fig.savefig(path_fig)
fig.savefig(path_fig.replace(".png", ".pdf"))
Example #5
0
        result = f"{short_name},{path},{mean},{std}\n"
        f.write(result)
    return mean, std


def run(
    nh_min,
    nh_max=10_000,
    df=None,
    save_as="dataframes/shock_sep.csv",
    dict_paths=paths_sim,
    t_approx=None,
    overwrite=False,
):
    if df is None:
        df = load_df()
    df = df[(df["$n$"] > nh_min) & (df["$n$"] < nh_max)]
    for i in range(len(df)):
        short = df.iloc[i]["short name"]
        print(dict_paths[short])

    if os.path.exists(save_as) and overwrite:
        os.remove(save_as)

    return (df["short name"].apply(
        avg_shock_seperation_from_shortname,
        dict_paths=dict_paths,
        save_as=save_as,
        t_approx=t_approx,
    ).apply(pd.Series))