def calc_sounding_stats(_z, _th, _p, _qv): T = met.T(_th, _p) # T (K) pcl = met.CAPE(_z, _p, T, _qv, 1) # CAPE mupcl = met.CAPE(_z, _p, T, _qv, 2) # MUCAPE mlpcl = met.CAPE(_z, _p, T, _qv, 3) # MLCAPE return (pcl, mupcl, mlpcl)
def plot_sounding(axes, z, th, p, qv, u=None, v=None): """Plot sounding data This plots temperature, dewpoint and wind data on a Skew-T/Log-P plot. This will also plot derived values such as wetbulb temperature and label the surface based LCL, LFC and EL. :parameter z: height values (1D array) :parameter th: potential temperature at z heights (1D array) :parameter p: pressure at z heights (1D array) :parameter qv: water vapor mixing ratio at z heights (1D array) :parameter u: U component of wind at z heights (1D array) :parameter v: V component of wind at z heights (1D array) :paramter axes: The axes instance to draw on """ # calculate Temperature and dewpoint T = met.T(th, p) - met.T00 # T (C) Td = met.Td(p, qv) - met.T00 # Td (C) # calculate wetbulb temperature Twb = np.empty(len(z), np.float32) # Twb (C) for zlvl in range(len(z)): Twb[zlvl] = met.Twb(z, p, th, qv, z[zlvl]) # Get surface parcel CAPE and temperature / height profiles pcl = met.CAPE(z, p, T + met.T00, qv, 1) # CAPE T_parcel = pcl['t_p'] - met.T00 # parcel T (C) T_vparcel = pcl['tv_p'] - met.T00 # parcel Tv (C) T_venv = met.T(pcl['thv_env'], pcl['pp']) - met.T00 # Env Tv (C) # plot Temperature, dewpoint, wetbulb and lifted surface parcel profiles on skew axes axes.semilogy(T + skew(p), p, basey=math.e, color=linecolor_T, linewidth=linewidth_T) axes.semilogy(Td + skew(p), p, basey=math.e, color=linecolor_Td, linewidth=linewidth_Td) axes.semilogy(T_parcel + skew(pcl['pp']), pcl['pp'], basey=math.e, color=linecolor_Parcel_T, linewidth=linewidth_Parcel_T) axes.semilogy(Twb + skew(p), p, basey=math.e, color=linecolor_Twb, linewidth=linewidth_Twb) # plot virtual temperature of environment and lifted parcel axes.semilogy(T_venv + skew(pcl['pp']), pcl['pp'], basey=math.e, color=linecolor_Tve, linewidth=linewidth_Tve, linestyle=linestyle_Tve) axes.semilogy(T_vparcel + skew(pcl['pp']), pcl['pp'], basey=math.e, color=linecolor_Tvp, linewidth=linewidth_Tvp, linestyle=linestyle_Tvp) # Add labels for levels based on surface parcel #debug print(pcl['lfcprs'], pcl['lclprs'], pcl['elprs'], pcl['ptops']) if (pcl['lfcprs'] > 0): label_m(Tmax - .5, pcl['lfcprs'], '--LFC', axes) if (pcl['lclprs'] > 0): label_m(Tmax - .5, pcl['lclprs'], '--LCL', axes) if (pcl['elprs'] > 0): label_m(Tmax - .5, pcl['elprs'], '--EL', axes) if (pcl['ptops'] > 0): label_m(Tmax - .5, pcl['ptops'], '--TOPS', axes) # plot labels for std heights for plvl in plevs_std: zlvl = pymeteo.interp.interp_height(z, p, plvl) label_m(Tmin - .5, plvl, str(int(zlvl)), axes) # plot wind barbs on left side of plot. move this? right side? if (u is not None and v is not None): #draw_wind_line(axes) for i in np.arange(0, len(z), 2): if (p[i] > pt_plot): plt.barbs(Tmin + 4, p[i], u[i], v[i], length=5, linewidth=.5)
a=pot zdat=h/1000 axs[0].plot(a,zdat,c='r') axs[0].set_title('Th') a=qv axs[1].plot(a,zdat,c='g') axs[1].set_title('qv') a=rh axs[2].plot(a,zdat,c='b') axs[2].set_title('Rh') plt.savefig(dirpic+"sounding_t_th_qc_profs.png",dpi=300) plt.close() #### fout=dirpic+'Sounding_t_lnp.png' skewtpy.myplot_chenjh('ICASE', zdat, pot, pres*100, qv*1e-3, u, v, fout,title='Sounding') cape=met.CAPE(zdat,pres*100,t+273.15,qv*1e-3,1) print cape[] fpath='/Volumes/MacHD/Work/Papers/ICMW2020/Data/'+'input_sounding_bk' onedim=readAscii(fpath,0) pres=[] pot=[] qv=[] z=[] u=[] v=[] pres.append(onedim[0]) pot.append(onedim[1]) qv.append(onedim[2]) z.append(0) u.append(0) v.append(0)