let's get the Springfest sounding loaded and separated into individual variable arrays import numpy as np import matplotlib.pyplot as plt %matplotlib inline filename = '/scratch/scholar/m/mebaldwi/EAPS431/20160416_1642Z_Purdue_Oval.txt' data = np.genfromtxt(filename, delimiter=',',skip_header=3) lat=data[:,0] lon=data[:,1] time=data[:,2] height_m=data[:,3] press_mb=data[:,4] temp_C=data[:,5] mix_ratio_gkg=data[:,6] wind_spd_ms=data[:,7] wind_dir_deg=data[:,8] temp_K=temp_C+273.15 height_msl=height_m+190. print 'temp at 5000m = ',np.interp(5000.,height_msl,temp_K) numpy interp documentation https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.interp.html code to set up standard atmosphere temperature profile z=np.arange(0,20500,500) print z
std_atm=np.zeros(41) To=288.15 lapserate=6.5 std_atm[0:23]=To-lapserate*z[0:23]/1000. std_atm[23:42]=216.85 print std_atm code to plot a dashed line, control the axes, labels, tick marks fig, ax = plt.subplots() ax.plot(temp_K,height_msl,'b--',linewidth=2) ax.set_xlabel('temp K') ax.set_ylabel('height MSL m') ax.set_xlim(200, 300) ax.set_ylim(0, 20000) ax.set_xticks(np.arange(200,301,10)) ax.set_yticks(np.arange(0,20001,5000)) code to plot a series of dashed lines to show lines of constant temperature T = np.arange(200, 400, 10) z = np.arange(0, 20000, 500) T_2D, Z_2D = np.meshgrid(T, z) fig, ax = plt.subplots() ax.plot(temp_K,height_msl,'b',linewidth=2) ax.set_xlabel('temp K') ax.set_ylabel('height MSL m') ax.set_xlim(250, 300) ax.set_ylim(0, 5000) ax.set_xticks(np.arange(250,301,10)) ax.set_yticks(np.arange(0,5001,1000)) ax.plot(T_2D,Z_2D,'m--') copy and paste, hit shift-enter to execute this code |