def supersaturation(T, p, rv): r_vs = common.r_vs(T, p) ss = 100. * (rv / r_vs - 1) return ss
for i in np.arange(nx): for j in np.arange(ny): if clb_idx[i, j] > 0: clb_rv[i, j] = rv[i, j, clb_idx[i, j]] clb_th[i, j] = th[i, j, clb_idx[i, j]] # model a parcel to get an adiabatic rl for i in np.arange(nx): for j in np.arange(ny): parcel_rv = clb_rv[i, j] parcel_th = clb_th[i, j] parcel_rl = 0 for k in np.arange(nz): parcel_T = parcel_th * lcmn.exner(p_e.astype(float)[k]) delta_rv = parcel_rv - lcmn.r_vs(parcel_T, p_e.astype(float)[k]) if delta_rv <= 0: delta_rv = 0 parcel_rv -= delta_rv parcel_th += delta_rv * evap_lat / lcmn.c_pd / lcmn.exner( p_e.astype(float)[k]) parcel_rl += delta_rv adia_rl[i, j, k] = parcel_rl #adia_rl = np.where(adia_rl > 0., adia_rl, 0) #print adia_rl # translate rl to AF #AF = np.where(adia_rl > 0., rl / adia_rl, 0) #AF = np.where(adia_rl > 1e-5, rl / adia_rl, 0)