Skip to content
Snippets Groups Projects
save_figure2.py 3.53 KiB
Newer Older
import numpy as np
import matplotlib.pyplot as plt

from util import save_fig, Fh_limit, R2_limit

from util_dataframe import df, df_proj

plt.rcParams["text.usetex"] = True

fig, axes = plt.subplots(
    ncols=2, nrows=1, figsize=(10, 1.2 * 3 * 4.5 / 4), constrained_layout=True
)

ax0 = axes[0]
ax1 = axes[1]

ax0.scatter(
    df["Fh"],
    df["R2"],
    c=df["I_velocity"],
    cmap="inferno",
    edgecolors="k",
    marker="o",
    vmin=0.0,
    vmax=1.0,
    s=50 * df["I_dissipation"],
)
cs = ax1.scatter(
    df_proj["Fh"],
    df_proj["R2"],
    c=df_proj["I_velocity"] * 2 / 3,  # 2/3 because of projection
    cmap="inferno",
    edgecolors="k",
    marker="o",
    vmin=0.0,
    vmax=1.0,
    s=50 * df_proj["I_dissipation"],
)


for ax in axes:
    ax.set_xlim([1e-3, 20])
    ax.set_xscale("log")
    ax.set_ylim([1e-1, 1e5])
    ax.set_yscale("log")

    ax.set_xlabel(r"$F_h$", fontsize=20)
    ax.set_ylabel(r"$\mathcal{R}$", fontsize=20)

    ax.set_xticks([1e-3, 1e-2, 1e-1, 1e0, 1e1])
    ax.set_xticklabels(
        [r"$10^{-3}$", r"$10^{-2}$", r"$10^{-1}$", r"$10^{0}$", r"$10^{1}$"],
        fontsize=14,
    )
    ax.set_yticks([1e-1, 1e-0, 1e1, 1e2, 1e3, 1e4, 1e5])
    ax.set_yticklabels(
        [
            r"$10^{-1}$",
            r"$10^{0}$",
            r"$10^{1}$",
            r"$10^{2}$",
            r"$10^{3}$",
            r"$10^{4}$",
            r"$10^{5}$",
        ],
        fontsize=14,
    )
    ax.axvline(1.0, linestyle=":")
    ax.axvline(Fh_limit, linestyle=":")
    Fh_min, Fh_max = ax.get_xlim()
    ax.plot([Fh_min, Fh_limit], [R2_limit, R2_limit], linestyle=":")

"""
# Emphasizing the points (N,Rb) = (40,20)
df_L = df[df["N"]==40]
df_L = df_L[df_L["Rb"]==20]
df_L_proj = df_proj[df_proj["N"]==40]
df_L_proj = df_L_proj[df_L_proj["Rb"]==20]
ax0.scatter(df_L["Fh"], df_L["R2"], edgecolors="r", facecolors='none', s=60, marker="s", linewidths=2)
ax1.scatter(df_L_proj["Fh"], df_L_proj["R2"], edgecolors="r", facecolors='none', s=60, marker="s", linewidths=2)
"""

# ax0.text(2e-3, 1e3, r"Strongly", fontsize=14, alpha=0.5)
ax0.text(2e-3, 3e2, r"LAST", fontsize=14, alpha=0.5)

ax0.text(1.5e-1, 1e4, r"Weakly", fontsize=14, alpha=0.5)
ax0.text(1.5e-1, 3e3, r"stratified", fontsize=14, alpha=0.5)

ax0.text(1.2e0, 1e1, r"Unstratified", fontsize=14, alpha=0.5)
# ax0.text(2e0, 3e0, r"", fontsize=14, alpha=0.5)

ax0.text(2e-3, 1e0, r"Viscosity", fontsize=14, alpha=0.5)
ax0.text(2e-3, 3e-1, r"affected", fontsize=14, alpha=0.5)

ax1.set_ylabel(None)
ax1.set_yticks([])
ax0.set_title(r"Standard Navier-Stokes" + "\n" + r"$\rm (a)$", fontsize=20)
ax1.set_title(r"Without vortical modes" + "\n" + r"$\rm (b)$", fontsize=20)

fig.tight_layout()
fig.subplots_adjust(right=0.85, wspace=0.1)

ax_legend = fig.add_axes([0.1, 0.65, 0.12, 0.16])
ax_legend.set_xticklabels([])
ax_legend.set_xticks([])
ax_legend.set_yticklabels([])
ax_legend.set_yticks([])
isotropy_diss = np.array([0.1, 0.5, 0.9])
heights = np.array([0.2, 0.5, 0.8])
ax_legend.scatter([0.15, 0.15, 0.15], heights, s=50 * isotropy_diss, marker="o")
ax_legend.set_xlim([0, 1])
ax_legend.set_ylim([0, 1])

for h, i in zip(heights, isotropy_diss):
    ax_legend.text(0.28, h - 0.06, r"$I_{\rm diss} = " + f"{i}$", fontsize=14)


cbar_ax = fig.add_axes([0.88, 0.17, 0.02, 0.65])
cbar = fig.colorbar(cs, cax=cbar_ax, orientation="vertical")
cbar.ax.set_ylabel(r"$I_{\rm kin}$", fontsize=20)
cbar.ax.set_yticks([0, 0.2, 0.4, 0.6, 0.8, 1])
cbar.ax.set_yticklabels(
    [r"$0$", r"$0.2$", r"$0.4$", r"$0.6$", r"$0.8$", r"$1$"], fontsize=14
)


save_fig(fig, "figure2.png")

if __name__ == "__main__":
    plt.show()