예제 #1
0
def make_plot(in_filename, out_filename, time, title):
    ncf = scipy.io.netcdf.netcdf_file(in_filename, 'r')
    particles = partmc.aero_particle_array_t(ncf)
    env_state = partmc.env_state_t(ncf)
    ncf.close()

    age = abs(particles.least_create_times / 3600. - time)
    dry_diameters = particles.dry_diameters()
    s_crit = (particles.critical_rel_humids(env_state) - 1) * 100

    x_axis = partmc.log_grid(min=1e-8, max=1e-6, n_bin=140)
    y_axis = partmc.linear_grid(min=0, max=48, n_bin=96)

    vals2d = partmc.multival_2d(dry_diameters, age, s_crit, x_axis, y_axis)

    plt.clf()
    plt.pcolor(x_axis.edges(),
               y_axis.edges(),
               vals2d.transpose(),
               norm=matplotlib.colors.LogNorm(),
               linewidths=0.1)
    a = plt.gca()
    a.set_xscale("log")
    a.set_yscale("linear")
    plt.axis([x_axis.min, x_axis.max, y_axis.min, y_axis.max])
    plt.xlabel("dry diameter (m)")
    plt.ylabel("age (h)")
    cbar = plt.colorbar()
    cbar.set_label("S_crit (%)")
    plt.title(title)
    fig = plt.gcf()
    fig.savefig(out_filename)
예제 #2
0
def get_plot_data_bc(filename, value_min=None, value_max=None):
    ncf = scipy.io.netcdf.netcdf_file(filename, 'r')
    particles = partmc.aero_particle_array_t(ncf)
    env_state = partmc.env_state_t(ncf)
    ncf.close()

    diameters = particles.dry_diameters() * 1e6
    comp_frac = particles.masses(include = ["BC"]) \
                / particles.masses(exclude = ["H2O"]) * 100
    # hack to avoid landing just around the integer boundaries
    comp_frac *= (1.0 + 1e-12)
    h2o = particles.masses(include=["H2O"])

    x_axis = partmc.log_grid(min=diameter_axis_min,
                             max=diameter_axis_max,
                             n_bin=num_diameter_bins * 2)
    y_axis = partmc.linear_grid(min=bc_axis_min,
                                max=bc_axis_max,
                                n_bin=num_bc_bins * 2)

    value = partmc.multival_2d(diameters, comp_frac, h2o, x_axis, y_axis)
    if value_max == None:
        value_max = value.max()
    if value_min == None:
        maxed_value = np.where(value > 0.0, value, value_max)
        value_min = maxed_value.min()
    #if value_max > 0.0:
    #    value = (log(value) - log(value_min)) \
    #            / (log(value_max) - log(value_min))
    #value = value.clip(0.0, 1.0)

    return (value, x_axis.edges(), y_axis.edges(), env_state, value_min,
            value_max)
예제 #3
0
def make_plot(in_filename,out_filename):
    ncf = scipy.io.netcdf.netcdf_file(in_filename, 'r')
    particles = partmc.aero_particle_array_t(ncf)
    env_state = partmc.env_state_t(ncf)
    ncf.close()

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

    so4 = particles.masses(include = ["SO4"])
    inorg = particles.masses(include = ["SO4", "NO3", "NH4"])
    inorg_frac = inorg / dry_mass 

    kappas = particles.kappas()
 
    wet_diameters = particles.diameters()
    dry_diameters = particles.dry_diameters() * 1e6

    x_axis = partmc.log_grid(min=1e-2,max=1e0,n_bin=90)
    y_axis = partmc.linear_grid(min=0,max=0.8,n_bin=40)

    vals = partmc.multival_2d(dry_diameters, bc_frac, kappas, x_axis, y_axis, rand_arrange=False)

    vals_pos = np.ma.masked_less_equal(vals, 0)
    vals_zero = np.ma.masked_not_equal(vals, 0)
    
    plt.clf()
    if vals_zero.count() > 0:
       plt.pcolor(x_axis.edges(), y_axis.edges(), vals_zero.transpose(), cmap=matplotlib.cm.gray, linewidths = 0.1)
    
    if vals_pos.count() > 0:
       plt.pcolor(x_axis.edges(), y_axis.edges(), vals_pos.transpose(), linewidths = 0.1)

    title = partmc.time_of_day_string(env_state)
    a = plt.gca()
    a.set_xscale("log")
    a.set_yscale("linear")
    plt.axis([x_axis.min, x_axis.max, y_axis.min, y_axis.max])
    plt.xlabel("dry diameter (\mu m)")
    plt.ylabel("BC dry mass fraction")
    cbar = plt.colorbar()
    plt.clim(0, 0.6)
    cbar.set_label("kappa")
    plt.title(title)
    fig = plt.gcf()
    fig.savefig(out_filename)
예제 #4
0
def get_plot_data(filename, value_min=None, value_max=None):
    ncf = scipy.io.netcdf.netcdf_file(filename, 'r')
    particles = partmc.aero_particle_array_t(ncf)
    env_state = partmc.env_state_t(ncf)
    ncf.close()

    diameters = particles.dry_diameters() * 1e6
    comp_frac = particles.masses(include = ["BC"]) \
                / particles.masses(exclude = ["H2O"]) * 100
    # hack to avoid landing just around the integer boundaries
    comp_frac *= (1.0 + 1e-12)
    h2o = particles.masses(include=["H2O"]) * 1e18  # kg to fg

    x_axis = partmc.log_grid(min=diameter_axis_min,
                             max=diameter_axis_max,
                             n_bin=num_diameter_bins * 2)
    y_axis = partmc.linear_grid(min=bc_axis_min,
                                max=bc_axis_max,
                                n_bin=num_bc_bins * 2)

    value = partmc.multival_2d(diameters, comp_frac, h2o, x_axis, y_axis)

    return (value, x_axis.edges(), y_axis.edges(), env_state)