def plot_f_R_g_R_g_ln_R_lognorm(mu_log, sigma_log, DNC, LWC_tot, R, m, xlim_m,
                                xlim_R, figsize, figname):

    #    f_m0 = compute_f_m0(m, DNC, LWC)
    f_R0 = compute_f_R_lognormal_multi_modal(R, mu_log, sigma_log, DNC)
    #    f_m0 =
    g_R0 = f_R0 * m
    g_ln_R = g_R0 * R
    #
    #    DNC_tot = DNC.sum()

    f_R_max = f_R0.max()
    g_R_max = g_R0.max()
    g_lnR_max = g_ln_R.max()

    #    scale_f = 1E-9
    #    scale_gR = 1E9

    fig, ax = plt.subplots(figsize=(cm2inch(figsize)), tight_layout=True)

    #    ax.plot(m, f_m0 * scale_f)
    #    ax.plot(R, f_R0 / DNC_tot, c = "k")
    #    ax.plot(R, g_R0 / LWC_tot, "--", c = "0.3")
    ax.plot(R, f_R0 / f_R_max, c="k", label="$f_R$")
    ax.plot(R, g_R0 / g_R_max, "--", c="0.3", label="$g_R$")
    #    ax.plot(m, g_ln_R)
    #    ax.set_xticks(np.arange(-10,41,10))
    ax.set_xlim(xlim_m)
    #    ax.set_ylim((1E-6,1E12))
    #    ax.set_ylim((3,1E2))
    #    ax.set_xlabel("$T$ (K)")
    #    ax.set_xscale("log")
    #    ax.set_yscale("log")
    #    ax.set_xlabel("Droplet mass (kg)")
    #    ax.set_ylabel("$f_m$ ($\mathrm{kg^{-1}\,m^{-3}}$)")
    ax.set_ylabel("Distributions (relative units)")

    #    ax_ = ax.twiny()
    ax_ = ax
    #    ax2 = ax_.twiny()
    #    ax_.plot(R, g_ln_R / LWC_tot, ":", c = "0.3")
    ax_.plot(R, g_ln_R / g_lnR_max, ":", c="0.3", label="$g_{\ln R}$")
    #    ax_.plot(R, g_ln_R*scale_gR)
    ax_.set_xscale("log")
    ax_.set_yscale("log")
    ax_.set_xlim(xlim_R)
    ax_.set_xlabel(r"Droplet radius ($\si{\micro\meter}$)")
    ax_.legend()
    #    ax_ = ax.twinx()
    #    ax2 = ax_.twiny()
    #    ax2.plot(R, g_ln_R*scale_gR)
    #    ax2.set_xscale("log")
    #    ax2.set_yscale("log")
    #    ax.grid(which = "both", linestyle="--", linewidth=0.5, c = "0.5", zorder = 0)
    fig.savefig(
        figname,
        #                bbox_inches = 0,
        bbox_inches='tight',
        pad_inches=0.065)
def plot_f_m_g_m_g_ln_R(DNC, LWC, m, R, xlim_m, xlim_R, figsize, figname):

    f_m0 = compute_f_m0(m, DNC, LWC)
    g_m0 = f_m0 * m
    g_ln_R = 3. * f_m0 * m * m

    f_m_max = f_m0.max()
    g_m_max = g_m0.max()
    g_R_max = g_ln_R.max()

    scale_f = 1E-9
    scale_gR = 1E9

    fig, ax = plt.subplots(figsize=(cm2inch(figsize)), tight_layout=True)

    #    ax.plot(m, f_m0 * scale_f)
    #    ax.plot(m, f_m0 / DNC, c = "k")
    #    ax.plot(m, g_m0 / LWC, "--", c = "0.3")
    ax.plot(m, f_m0 / f_m_max, c="k", label="$f_m$")
    ax.plot(m, g_m0 / g_m_max, "--", c="0.3", label="$g_m$")
    #    ax.plot(m, g_ln_R)
    #    ax.set_xticks(np.arange(-10,41,10))
    ax.set_xlim(xlim_m)
    #    ax.set_ylim((1E-6,1E12))
    #    ax.set_ylim((3,1E2))
    #    ax.set_xlabel("$T$ (K)")
    ax.set_xscale("log")
    ax.set_yscale("log")
    ax.set_xlabel("Droplet mass (kg)")
    #    ax.set_ylabel("$f_m$ ($\mathrm{kg^{-1}\,m^{-3}}$)")
    ax.set_ylabel("Distributions (relative units)")
    ax_ = ax.twiny()
    #    ax2 = ax_.twiny()
    #    ax_.plot(R, g_ln_R / LWC, ":", c = "0.3")
    ax_.plot(R, g_ln_R / g_R_max, ":", c="0.3", label="$g_{\ln R}$")
    #    ax_.plot(R, g_ln_R*scale_gR)
    ax_.set_xscale("log")
    ax_.set_xlim(xlim_R)
    ax_.set_xlabel(r"Droplet radius ($\si{\micro\meter}$)")

    lines, labels = ax.get_legend_handles_labels()
    lines2, labels2 = ax_.get_legend_handles_labels()
    ax.legend(lines + lines2, labels + labels2, loc="lower center")
    #    ax.legend()
    #    ax_ = ax.twinx()
    #    ax2 = ax_.twiny()
    #    ax2.plot(R, g_ln_R*scale_gR)
    #    ax2.set_xscale("log")
    #    ax2.set_yscale("log")
    #    ax.grid(which = "both", linestyle="--", linewidth=0.5, c = "0.5", zorder = 0)
    fig.savefig(
        figname,
        #                bbox_inches = 0,
        bbox_inches='tight',
        pad_inches=0.065)
Beispiel #3
0
def plot_phase_diagram(T_vl, e_vl, T_vi, e_vi, T_sl, e_sl, figname, figsize):

    fig, ax = plt.subplots(figsize=(cm2inch(figsize)), tight_layout=True)

    T_shift = -273.15
    ax.plot(T_vl + T_shift, e_vl, c="k")
    ax.plot(T_vi + T_shift, e_vi, "--", c="k")
    ax.plot(T_sl + T_shift, e_sl, "-.", c="k")
    #    ax.annotate("triple point", (T_vi[-1] + T_shift, e_vi[-1]-0.5),
    ##                ha='left',
    #                ha='center',
    #                va='top',
    #                xycoords='data',
    #                arrowprops=dict(facecolor='black',
    #                                width = 0.5,
    #                                headwidth = 2,
    #                                shrink=0.05
    #                                ),
    #                textcoords='data',
    #                xytext=(T_vi[-1] + T_shift, 2)
    #                )
    ax.annotate("vapor", (20, 6), ha='center')
    ax.annotate("solid", (-5, 15), ha='center')
    ax.annotate("liquid", (12, 30), ha='center')
    ax.annotate(r"$e_s(T)$", (22, 16), ha='center')
    #    ax.annotate("vapor")
    ax.set_yscale("log")
    ax.set_xticks(np.arange(-10, 41, 10))
    ax.set_xlim((-10, 40))
    ax.set_ylim((3, 1E2))
    #    ax.set_xlabel("$T$ (K)")
    ax.set_xlabel("$T$ (°C)")
    ax.set_ylabel("$p$ (hPa)")
    #    ax.grid(which = "both", linestyle="--", linewidth=0.5, c = "0.5", zorder = 0)
    fig.savefig(
        figname,
        #                bbox_inches = 0,
        bbox_inches='tight',
        pad_inches=0.065)
Beispiel #4
0
kernel_list = ['Hall_Bott', 'Ecol_const', 'Long_Bott']

#%% SET SIMULATION PARAS
# choose simulation series (index of the lists/tuples above)
SIM_N = 2

no_sims = 50
t_grid = 0
t_start = 7200
t_end = 10800
dt = 1.  # advection time step (seconds)
# 'with_collisions', 'wo_collisions' or 'spin_up'
# simulation_mode = 'with_collisions'

#%% SET PLOTTING PARAMETERS
figsize_scalar_fields = cm2inch(13.7, 22.)
figsize_spectra = cm2inch(13.3, 20.)
figsize_tg_cells = cm2inch(6.6, 7)

### GRID FRAMES
show_target_cells = True

### SPECTRA
# if set to "None" the values are loaded from stored files
no_rows = None
no_cols = None

# if set to "None" the values are loaded from stored files
no_bins_R_p = None
no_bins_R_s = None
Beispiel #5
0
def plot_rho_T_p_init(centers, corners, no_cells, density, temperature,
                      pressure, potential_temperature, saturation,
                      mixing_ratio_water_liquid, mixing_ratio_water_vapor,
                      no_ticks, figsize, figname):

    rho0 = density[0, 0]
    T0 = temperature[0, 0]
    p0 = pressure[0, 0]
    Theta0 = potential_temperature[0, 0]
    r_v0 = np.average(mixing_ratio_water_vapor[:, 0])
    r_l0 = np.average(mixing_ratio_water_liquid[:, -1])
    #    S0 = np.average( saturation[:,0] )
    S0 = 1.

    #    r_l0 = r_l[0,0]
    #    S0 = r_l[0,0]

    rho = density[0, :]
    T = temperature[0, :]
    p = pressure[0, :]
    Theta = potential_temperature[0, :]
    r_v = np.average(mixing_ratio_water_vapor, axis=0)
    r_l = np.average(mixing_ratio_water_liquid, axis=0)
    S = np.average(saturation, axis=0)

    data0 = np.array((rho0, r_v0, T0, p0, Theta0))
    data = np.array((rho, r_v, T, p, Theta))

    names = [r"$\rho_\mathrm{dry}$", r"$r_v$", r"$T$", r"$p$", r"$\Theta$"]
    ls = ["-", "--", ":", "-.", (0, (3, 1, 1, 1, 1, 1))]

    z = centers[1][0, :]

    fig, ax = plt.subplots(figsize=(cm2inch(figsize)), tight_layout=True)
    #    ax.plot(rho,z, c = "0.0")
    #    ax.plot(p,z, c = "0.2", linestyle = "dashed")
    #    ax.plot(T,z, c = "0.4", linestyle = "dashdot")

    for n in range(len(data0)):
        #        ax.plot(data[n]/data0[n], z, label = "$r$")
        ax.plot(data[n] / data0[n], z, label=names[n], c="k", linestyle=ls[n])

#    ax.set_xlabel("Hallo")

    ax2 = ax.twiny()
    ax2.plot(r_l / r_l0, z, label="$r_l$", c="0.6")
    ax2.plot(S, z, label="$S$", c="0.6", linestyle="dashdot")
    #    ax.set_xticks(np.linspace(corners[0][0,0], corners[0][-1,0], no_ticks[0]) )
    ax.set_yticks(np.linspace(corners[1][0, 0], corners[1][0, -1],
                              no_ticks[1]))
    #    ax.set_xticks(corners[0][::tick_every_x,0])
    #    ax.set_yticks(corners[1][0,::tick_every_y])
    #    ax.set_xticks(corners[0][:,0], minor = True)
    #    ax.set_yticks(corners[1][0,:], minor = True)

    ax.set_xlim(0.82, 1.03)
    ax.set_ylim(corners[1][0, 0], corners[1][0, -1])

    ax.set_xlabel(r'$\rho_\mathrm{dry}$, $r_v$, $T$, $p$, $\Theta$' +
                  ' (relative values)')
    #    ax.set_xlabel('Atmospheric state variables (-)')
    #    ax.set_xlabel("$r$ (-)")
    #    ax.set_xlabel('$S$ (m)')
    #    ax.set_ylabel('Hallo (m)')
    ax.set_ylabel('$z$ (m)')
    ax.grid(linestyle="dashed", c="0.6")
    ax.legend(loc='lower left', bbox_to_anchor=(0.06, -0.01))

    ax2.set_xlabel("$S$ (-) and $r_l/r_{l,\mathrm{max}}$ (-)")
    ax2.tick_params(axis='x', colors='0.5')
    ax2.legend(loc='lower left', bbox_to_anchor=(0.34, -0.01))
    #    ax2.legend()

    for n, d_ in enumerate(data0):
        print(names[n], f"{d_:.4e}")
    print(f"{r_l0*1000:.4}")

    #    fig.tight_layout()
    fig.savefig(
        figname,
        #                bbox_inches = 0,
        bbox_inches='tight',
        pad_inches=0.05)
Beispiel #6
0
def plot_velocity_field_centered(velocity, corners, centers, shifts, no_cells,
                                 no_arrows, no_ticks, figsize, figname,
                                 ARROW_SCALE, ARROW_WIDTH):
    centered_u_field = ( velocity[0][0:-1,0:-1]\
                         + velocity[0][1:,0:-1] ) * 0.5
    centered_w_field = ( velocity[1][0:-1,0:-1]\
                         + velocity[1][0:-1,1:] ) * 0.5

    #    no_cells = np.array((len(centered_u_field), len(centered_w_field)))

    if no_ticks[0] < no_cells[0]:
        # take no_major_xticks - 1 to get the right spacing
        # in dimension of full cells widths
        tick_every_x = no_cells[0] // (no_ticks[0] - 1)
    else:
        tick_every_x = 1

    if no_ticks[1] < no_cells[1]:
        tick_every_y = no_cells[1] // (no_ticks[1] - 1)
    else:
        tick_every_y = 1

    if no_arrows[0] < no_cells[0]:
        arrow_every_x = no_cells[0] // (no_arrows[0] - 1)
    else:
        arrow_every_x = 1

    if no_arrows[1] < no_cells[1]:
        arrow_every_y = no_cells[1] // (no_arrows[1] - 1)
    else:
        arrow_every_y = 1

    fig, ax = plt.subplots(figsize=(cm2inch(figsize)), tight_layout=True)

    sx = shifts[0]
    sy = shifts[1]

    ax.quiver(centers[0][sx::arrow_every_x, sy::arrow_every_y],
              centers[1][sx::arrow_every_x, sy::arrow_every_y],
              centered_u_field[sx::arrow_every_x, sy::arrow_every_y],
              centered_w_field[sx::arrow_every_x, sy::arrow_every_y],
              pivot='mid',
              width=ARROW_WIDTH,
              scale=ARROW_SCALE,
              zorder=3)
    #    ax.axis('equal',"box")
    ax.set_aspect('equal')
    #    ax.set_aspect('equal', 'box')
    ax.set_xticks(np.linspace(corners[0][0, 0], corners[0][-1, 0],
                              no_ticks[0]))
    ax.set_yticks(np.linspace(corners[1][0, 0], corners[1][0, -1],
                              no_ticks[1]))
    #    ax.set_xticks(corners[0][::tick_every_x,0])
    #    ax.set_yticks(corners[1][0,::tick_every_y])
    #    ax.set_xticks(corners[0][:,0], minor = True)
    #    ax.set_yticks(corners[1][0,:], minor = True)
    ax.set_xlim(corners[0][0, 0], corners[0][-1, 0])
    ax.set_ylim(corners[1][0, 0], corners[1][0, -1])

    ax.grid(linestyle="dashed")

    ax.set_xlabel('$x$ (m)')
    ax.set_ylabel('$z$ (m)')
    #    ax2 = ax.twiny()
    #    ax2.set_xlabel("$S$ (-) and $r_l/r_{l,\mathrm{max}}$ (-)", color="white")
    #    fig.tight_layout()
    #    plt.gca().set_axis_off()
    #    plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
    #                hspace = 0, wspace = 0)
    #    plt.margins(0,0)
    #    plt.gca().xaxis.set_major_locator(plt.NullLocator())
    #    plt.gca().yaxis.set_major_locator(plt.NullLocator())
    fig.savefig(
        figname,
        #                bbox_inches = 0,
        bbox_inches='tight',
        pad_inches=0.065)
#x1 = np.hstack( ( np.array( (35) ), x1 ) )

x1b = np.array((35,35))
fit1b = np.array((1.,1.08))

x2 = np.linspace(80,100,10)
fit2 = fit_exp1(x2,*p1)
#fit2 = np.hstack( ( np.array( () ) , fit_exp1(x2,*p1) ) )

#%%

#S = np.arange()

# figsize in cm (x,y)
fig_size = (7.5,6.0)
fig, ax = plt.subplots(figsize=cm2inch(fig_size))

ax.plot(data1[0],data1[1],c="k")
ax.plot(x1, fit1,":",c="k")
ax.plot(x1b, fit1b,":",c="k")
ax.plot(x2, fit2,c="k")
#ax.plot(x1, fit1,":",c="0.6")
#ax.plot(x1, fit1,"..",c="k")
#ax.plot(data2[0],data2[1],c="k")
#ax.plot(data_deli[0],data_deli[1],c="0.6")
ax.plot(data_crys1[0],data_crys1[1],"--",c="k")
ax.plot(data_crys2[0],data_crys2[1],"--",c="k")
#ax.plot(data_crys[0],data_crys[1],c="0.4")

ax.set_xlim((0.0,100.0))
ax.set_ylim((0.91,1.56))
Beispiel #8
0
TTFS = 10
LFS = 10
TKFS = 8

# LINEWIDTH, MARKERSIZE
LW = 1.2
MS = 2

# raster resolution for e.g. .png
DPI = 600

mpl.rcParams.update(generate_rcParams_dict(LW, MS, TTFS, LFS, TKFS, DPI))

if act_plot_moments_kappa_var_paper:
    figsize = cm2inch(7., 12.0)
    ref_data_path = "collision/ref_data/" \
                    + f"{kernel_name}/"
    moments_ref = np.loadtxt(ref_data_path + "Wang_2007_moments.txt")
    times_ref = np.loadtxt(ref_data_path + "Wang_2007_times.txt")

    data_dir = simdata_path + result_path_add
    figname = fig_path \
            + f"{kernel_name}_moments_vs_time_" \
            + f"kappa_{kappa_list[0]}_{kappa_list[-1]}.pdf"
    boxm.plot_moments_vs_time_kappa_var_paper(kappa_list, eta, dt, no_sims,
                                              no_bins, kernel_name, gen_method,
                                              dist, start_seed, moments_ref,
                                              times_ref, data_dir, figsize,
                                              figname, TTFS, LFS, TKFS)