Beispiel #1
0
def make_plot(dir_name, in_filename, out_filename):
    ncf = scipy.io.netcdf.netcdf_file(dir_name + in_filename, 'r')
    particles = partmc.aero_particle_array_t(ncf)
    ncf.close()

    bc = particles.masses(include=["BC"])
    dry_mass = particles.masses(exclude=["H2O"])
    bc_frac = bc / dry_mass

    dry_diameters = particles.dry_diameters() * 1e6

    x_axis = partmc.log_grid(min=1e-3, max=1e1, n_bin=100)
    y_axis = partmc.linear_grid(min=0, max=0.8, n_bin=40)

    hist2d = partmc.histogram_2d(dry_diameters,
                                 bc_frac,
                                 x_axis,
                                 y_axis,
                                 weights=1 / particles.comp_vols)

    hist2d = hist2d * 1e-6
    print hist2d[36, :]
    (figure, axes_array,
     cbar_axes_array) = mpl_helper.make_fig_array(1,
                                                  1,
                                                  figure_width=5,
                                                  top_margin=0.5,
                                                  bottom_margin=0.45,
                                                  left_margin=0.65,
                                                  right_margin=1,
                                                  vert_sep=0.3,
                                                  horiz_sep=0.3,
                                                  colorbar="shared",
                                                  colorbar_location="right")

    axes = axes_array[0][0]
    cbar_axes = cbar_axes_array[0]
    p = axes.pcolor(x_axis.edges(),
                    y_axis.edges(),
                    hist2d.transpose(),
                    norm=matplotlib.colors.LogNorm(vmin=1e3, vmax=1e5),
                    linewidths=0.1)
    axes.set_xscale("log")
    axes.set_yscale("linear")
    axes.set_ylabel(r"BC mass fraction $w_{\rm BC}$")
    axes.set_xlabel(r"dry diameter $D$/ $\rm \mu m$")
    axes.set_ylim(0, 0.8)
    axes.set_xlim(5e-3, 1e0)
    axes.grid(True)
    cbar = figure.colorbar(p,
                           cax=cbar_axes,
                           format=matplotlib.ticker.LogFormatterMathtext(),
                           orientation='vertical')
    cbar_axes.xaxis.set_label_position('top')
    cbar.set_label(r"number conc. $n(D,w_{\rm BC})$ / $\rm cm^{-3}$")

    mpl_helper.remove_fig_array_axes(axes_array)
    figure.savefig(out_filename)
def make_plot(dir_name,in_filename,out_filename):
    ncf = scipy.io.netcdf.netcdf_file(dir_name+in_filename, 'r')
    
    particles = partmc.aero_particle_array_t(ncf)
    env_state = partmc.env_state_t(ncf)
    ncf.close()

    dry_diameters = particles.dry_diameters() * 1e6

    s_crit = (particles.critical_rel_humids(env_state) - 1)*100
    
    x_axis = partmc.log_grid(min=1e-3,max=1e1,n_bin=100)
    y_axis = partmc.log_grid(min=1e-3,max=1e2,n_bin=50)

    hist2d = partmc.histogram_2d(dry_diameters, s_crit, x_axis, y_axis, weights = particles.num_concs)

    hist2d = hist2d * 1e-6

    (figure, axes_array, cbar_axes_array) = mpl_helper.make_fig_array(1,1, figure_width=5,
									  top_margin=0.5, bottom_margin=0.45,
									  left_margin=0.65, right_margin=1,
									  vert_sep=0.3, horiz_sep=0.3,
									  colorbar="shared", colorbar_location="right")

    axes = axes_array[0][0]
    cbar_axes = cbar_axes_array[0]
    p = axes.pcolor(x_axis.edges(), y_axis.edges(), hist2d.transpose(), 
		    norm = matplotlib.colors.LogNorm(vmin=1e3, vmax=1e5), linewidths = 0.1)
    axes.set_xscale("log")
    axes.set_yscale("log")
    axes.set_ylabel(r"crit. supersat. $S_{\rm c}$")
    axes.set_xlabel(r"dry diameter $D$/ $\rm \mu m$")
    axes.set_ylim(1e-3,10)
    axes.set_xlim(5e-3, 1e0)
    axes.grid(True)
    cbar = figure.colorbar(p, cax=cbar_axes, format=matplotlib.ticker.LogFormatterMathtext(),
			   orientation='vertical')
    cbar_axes.xaxis.set_label_position('top')
    cbar.set_label(r"number conc. $n(D,S_{\rm c})$ / $\rm cm^{-3}$")
    
    mpl_helper.remove_fig_array_axes(axes_array)
    figure.savefig(out_filename)
    plt.close()
Beispiel #3
0
num_avg_overall = np.zeros([config.i_loop_max])
mass_avg_overall = np.zeros([config.i_loop_max])

f1 = "data/ensemble_norm_num_brownian_60s.txt" 
f2 = "data/ensemble_norm_mass_brownian_60s.txt" 
#f3 = "data/ensemble_norm_num_brownian_1200s.txt" 
#f4 = "data/ensemble_norm_mass_brownian_1200s.txt" 

num_avg_overall = np.loadtxt(f1) / 1e6
mass_avg_overall = np.loadtxt(f2)*1e9

#num_avg_overall_6s = np.loadtxt(f3) / 1e6
#mass_avg_overall_6s = np.loadtxt(f4)*1e9

(figure, axes_array) = mpl_helper.make_fig_array(1,2, figure_width=config.figure_width_double, 
                                                 left_margin=0.75, horiz_sep=0.6, share_y_axes = False)

axes = axes_array[0][0]

large_time_step = axes.plot(num_avg_overall, 'b-')
axes.set_xscale("log")
axes.set_yscale("log")

axes.set_xlim([0, 100])
axes.set_ylim([num_avg_overall.min(), num_avg_overall.max()])
axes.grid(True)
axes.set_xlabel(r"ensemble size")
axes.set_ylabel(r" $\| \langle  n_{\rm p}(24\, {\rm h}) - n_{\rm sect}(24 \, {\rm h}) \rangle \|_2$")
#axes.legend((large_time_step, small_time_step), (r"60 s", r"1200 s"))

axes = axes_array[0][1]
Beispiel #4
0
                                     particle_set[id].emit_time) / 3600.
    else:
        time_for_aging[i_counter] = -1
    i_counter = i_counter + 1

emit_morning = (emit_time < 6.)
emit_afternoon = ((emit_time > 6.) & (emit_time < 12.))
emit_night = (emit_time > 12)

# Scatter plot, colored by diameter at time of aging
(figure, axes_array,
 cbar_axes_array) = mpl_helper.make_fig_array(3,
                                              1,
                                              top_margin=1,
                                              bottom_margin=0.45,
                                              left_margin=1.07,
                                              right_margin=0.65,
                                              vert_sep=0.3,
                                              horiz_sep=0.3,
                                              colorbar="shared",
                                              colorbar_location="top")
axes = axes_array[2][0]
cbar_axes = cbar_axes_array[0]
p = axes.scatter(emit_diam[emit_morning],
                 time_for_aging[emit_morning],
                 c=aging_no3_fraction[emit_morning],
                 norm=matplotlib.colors.Normalize(vmin=0, vmax=1),
                 s=2,
                 linewidths=0)
axes.set_xscale("log")
axes.set_yscale("linear")
axes.set_xlim(1e-9, 1e-6)
y_array_scrit = np.loadtxt("data/2d_scrit_compo_12_y_values_corrected2.txt")

num_bc = np.loadtxt("data/2d_bc_compo_12_average_num_corrected2.txt") / 1e6
num_scrit = np.loadtxt(
    "data/2d_scrit_compo_12_average_num_corrected2.txt") / 1e6

mass_bc = np.loadtxt("data/2d_bc_compo_12_average_mass_corrected2.txt") * 1e9
mass_scrit = np.loadtxt(
    "data/2d_scrit_compo_12_average_mass_corrected2.txt") * 1e9

(figure, axes_array, cbar_axes_array) = mpl_helper.make_fig_array(
    2,
    2,
    figure_width=config.figure_width_double,
    left_margin=0.7,
    right_margin=0.1,
    top_margin=0.8,
    vert_sep=1.5,
    horiz_sep=0.3,
    colorbar="individual",
    colorbar_location="top")

axes = axes_array[1][0]
cbar_axes = cbar_axes_array[1][0]
p = axes.pcolor(x_array_bc,
                y_array_bc,
                num_bc.transpose(),
                linewidths=0.1,
                norm=matplotlib.colors.LogNorm(vmin=num_bc_min,
                                               vmax=num_bc_max))
axes.set_xscale("log")
Beispiel #6
0
import mpl_helper
import matplotlib
import config

bc_std_overall = np.zeros([21, 4])  # 21 for weighting schemes, 4 for ss-values
ccn_std_overall = np.zeros([21, 4])

i_counter = 0
for counter in ["ss1", "ss2", "ss3", "ss4"]:
    f1 = "data/ccn_std_overall_%s.txt" % counter
    f2 = "data/bc_std_overall_%s.txt" % counter
    ccn_std_overall[:, i_counter] = np.loadtxt(f1)
    bc_std_overall[:, i_counter] = np.loadtxt(f2)
    i_counter += 1

(figure, axes_array) = mpl_helper.make_fig_array(
    1, 2, figure_width=config.figure_width_double, vert_sep=0.2, axis_ratio=1)
axes = axes_array[0][0]
axes.set_xscale("log")
axes.set_yscale("log")
axes.set_ylim(1e-3, 1)
axes.set_xlabel(
    r"avg. CCN coeff. var. $\overline{{\rm CV}(N_{\rm CCN}(S_{\rm env}))}$")
axes.set_ylabel(
    r"avg. scav. BC mass coeff. var. $\overline{{\rm CV}(M_{\rm CCN}^{\rm BC}(S_{\rm env}))}$"
)
axes.grid()
axes.plot(ccn_std_overall[0:6, 2], bc_std_overall[0:6, 2], 'r-x')
axes.plot(ccn_std_overall[6:12, 2], bc_std_overall[6:12, 2], 'g-x')
axes.plot(ccn_std_overall[12:18, 2], bc_std_overall[12:18, 2], 'b-x')
axes.plot(ccn_std_overall[18, 2], bc_std_overall[18, 2], 'ro')
axes.plot(ccn_std_overall[19, 2], bc_std_overall[19, 2], 'go')
num_std3 = np.loadtxt("data/1d_10K_wei-4_12_e_bars_num.txt") / 1e6

mass_avg1 = np.loadtxt("data/1d_10K_wei+1_12_hist_array_gav_mass.txt") * 1e9
mass_avg2 = np.loadtxt("data/1d_10K_wei-1_12_hist_array_gav_mass.txt") * 1e9
mass_avg3 = np.loadtxt("data/1d_10K_wei-4_12_hist_array_gav_mass.txt") * 1e9

mass_std1 = np.loadtxt("data/1d_10K_wei+1_12_e_bars_mass.txt") * 1e9
mass_std2 = np.loadtxt("data/1d_10K_wei-1_12_e_bars_mass.txt") * 1e9
mass_std3 = np.loadtxt("data/1d_10K_wei-4_12_e_bars_mass.txt") * 1e9

(figure, axes_array) = mpl_helper.make_fig_array(
    3,
    2,
    figure_width=config.figure_width_double,
    top_margin=0.41,
    bottom_margin=0.45,
    left_margin=1.07,
    right_margin=0.65,
    horiz_sep=0.3,
    vert_sep=0.3,
    share_y_axes=False)

axes = axes_array[2][0]
axes.errorbar(x_array, num_avg1, num_std1, fmt='b-')
axes.set_xscale("log")
axes.set_yscale("log")
axes.set_ylabel(r"number conc. $n(D_{\rm dry})$ / $\rm cm^{-3}$")
axes.set_ylim(1e-3, 1e5)
axes.grid(True)
axes.text(-0.3,
          0.5,
Beispiel #8
0
l2 = axes.plot(wet_diameter_inertial * 1e6, equilibrium_rhs_inertial_grid_080)
l3 = axes.plot(wet_diameter_inertial * 1e6, equilibrium_rhs_inertial_grid_100)
l4 = axes.plot(wet_diameter_inertial * 1e6, equilibrium_rhs_inertial_grid_130)
l5 = axes.plot(wet_diameter_inertial * 1e6, equilibrium_rhs_inertial_grid_150)
axes.grid(True)
axes.set_xscale("log")
axes.set_xlabel(r"diameter / $\rm \mu m$")
axes.set_ylabel(r"rh")
axes.set_xlim(1, 100)
axes.set_ylim(1, 1.003)
axes.legend((l1, l2, l3, l4, l5),
            ("env rh", "eq rh 080", "eq rh 100", "eq rh 130", "eq rh 150"),
            loc='center left')
figure.savefig("figs/rh_versus_d_inertial.pdf")

(figure, axes_array) = mpl_helper.make_fig_array(2, 1, share_x_axes=True)
axes = axes_array[0][0]
l1 = axes.plot(seconds, diam_not_activate * 1e6)
l2 = axes.plot(seconds, d_c_not_activate * 1e6)
axes.grid(True)
axes.set_xlabel(r"time / s")
axes.set_ylabel(r"diameter / $\rm \mu m$")
axes.legend((l1, l2), ("wet diameter", "critical diameter"),
            loc='center right')

axes = axes_array[1][0]
l1 = axes.plot(seconds, rh)
l2 = axes.plot(seconds, rh_c_not_activate)
l3 = axes.plot(seconds, rh_eq_not_activate)
axes.grid(True)
axes.set_ylim(1, 1.005)
x_array_bc = np.loadtxt("data/2d_bc_10K_wei-1_12_x_values.txt") * 1e6
y_array_bc = np.loadtxt("data/2d_bc_10K_wei-1_12_y_values.txt") * 100

x_array_scrit = np.loadtxt("data/2d_scrit_10K_wei-1_12_x_values.txt") * 1e6
y_array_scrit = np.loadtxt("data/2d_scrit_10K_wei-1_12_y_values.txt")

num_bc_std = np.loadtxt("data/2d_bc_10K_wei-1_12_hist_std_norm_num.txt")
num_scrit_std = np.loadtxt("data/2d_scrit_10K_wei-1_12_hist_std_norm_num.txt")

num_bc_std = np.ma.masked_invalid(num_bc_std)
num_scrit_std = np.ma.masked_invalid(num_scrit_std)

(figure, axes_array, cbar_axes_array) \
    = mpl_helper.make_fig_array(1,2, figure_width=config.figure_width_double,
                                left_margin=0.5,right_margin=0.2,top_margin=0.8,
                                vert_sep=0.2, horiz_sep=0.7,
                                colorbar="individual", colorbar_location="top", share_y_axes=False)

print "check"
print num_bc_std.max(), num_bc_std.min()
print num_scrit_std.max(), num_scrit_std.min()

axes = axes_array[0][0]
cbar_axes = cbar_axes_array[0][0]
p = axes.pcolor(x_array_bc,
                y_array_bc,
                num_bc_std.transpose(),
                norm=matplotlib.colors.LogNorm(vmin=5e-2, vmax=10),
                linewidths=0.1)
axes.set_xscale("log")
axes.set_yscale("linear")