def compute_act_fraction(S, T, aer_meta, aerosol_rs): kappa = aer_meta.kappa r_drys = aer_meta.r_drys Nis = aer_meta.Nis r_crits, s_crits = zip(*[kohler_crit(T, r_dry, kappa) for r_dry in r_drys]) s_crits = numpy.array(s_crits) r_crits = numpy.array(r_crits) #big_s = S_max >= s_crits big_s = S >= s_crits rstep = aerosol_rs active_radii = (rstep > r_crits) N_tot = numpy.sum(Nis) Neq = numpy.sum(Nis[big_s])/N_tot Nkn = numpy.sum(Nis[active_radii])/N_tot Nunact = numpy.sum(Nis[(rstep < r_crits)])/N_tot return Neq, Nkn, Nunact
print " ... activation", ## Compute Activation stats for species in aer_species: aerosol = aerosols2[species] aer_meta = aer_dict[species] Nis = aer_meta.Nis Neq = [] Nkn = [] Nunact = [] S_max = S0 for S, T, i in zip(parcel.S, parcel['T'], xrange(len(parcel.S))): r_crits, s_crits = zip(*[kohler_crit(T, r_dry, aer_meta.kappa) for r_dry in aer_meta.r_drys]) s_crits = np.array(s_crits) r_crits = np.array(r_crits) if S > S_max: S_max = S big_s = S_max >= s_crits Neq.append(np.sum(Nis[big_s])) rstep = np.array(aerosol.ix[i]) #active_radii = (S > s_crits) | (rstep > r_crits) active_radii = (rstep > r_crits) #sar = np.min(active_radii) if len(active_radii) > 0 else 1e99 if len(active_radii) > 0: Nkn.append(np.sum(Nis[active_radii])) Nunact.append(np.sum(Nis[(rstep < r_crits)])) else:
## for species in aer_species: if species == 'sulf': continue aerosol = aerosols2[species] aer_meta = aer_dict[species] Nis = aer_meta.Nis Neq = [] Nkn = [] Nunact = [] S_max = S0 for S, T, i in zip(parcel.S, parcel['T'], xrange(len(parcel.S))): r_crits, s_crits = zip(*[kohler_crit(T, r_dry, aer_meta.kappa) for r_dry in aer_meta.r_drys]) s_crits = np.array(s_crits) r_crits = np.array(r_crits) if S > S_max: S_max = S big_s = S_max >= s_crits Neq.append(np.sum(Nis[big_s])) rstep = np.array(aerosol.ix[i]) #active_radii = (S > s_crits) | (rstep > r_crits) active_radii = (rstep > r_crits) #sar = np.min(active_radii) if len(active_radii) > 0 else 1e99 if len(active_radii) > 0: Nkn.append(np.sum(Nis[active_radii])) Nunact.append(np.sum(Nis[(rstep < r_crits)])) else:
aero_subset = {} for key in aerosols: aerosol = aerosols[key] subset = aerosol.ix[aerosol.index % 1 == 0] aero_subset[key] = subset aerosols = pandas.Panel(aero_subset) S_max = np.max(parcel.S) S_max_ind = np.argmax(parcel.S) aerosol = initial_aerosol[0] T = parcel['T'].ix[S_max_ind] rs = aerosols[aerosol.species].ix[S_max_ind] r_drys = aerosol.r_drys r_crits, s_crits = zip(*[kohler_crit(T, r_dry, aerosol.epsilon, aerosol.rho_p, aerosol.Ms, aerosol.nu) for r_dry in aerosol.r_drys]) r_crits, s_crits = np.array(r_crits), np.array(s_crits) Nis = aerosol.Nis Neq = np.sum(Nis[S_max > s_crits]) colors = 'bgrcmyk' figure(1, figsize=(10, 15)) clf() subplot(311) p = parcel.S.plot(logx=False) max_idx = np.argmax(parcel.S) max_z = parcel.index[max_idx] vlines([max_z], ylim()[0], ylim()[1], color='k', linestyle='dashed') ylabel("Supersaturation (%)")