lab8 plots

copy and paste this block of code into an empty jupyter cell. modify the first line to read in a different sounding file for analysis. the remainder of the code will calculate a variety of characteristics based on surface, mixed-layer, and most-unstable parcels, plotting a skew-T and hodograph. repeat this process for different input soundings.

filename = '/scratch/scholar/mebaldwi/EAPS431/dsm.txt'
# the filename will also be used as a title for the plot

# read data in from text file using BUFKIT format, put variables into individual numpy arrays

data = np.genfromtxt(filename)
height_MSL_m=data[:,8]
press_mb=data[:,0]
temp_C=data[:,1]
td_C=data[:,3]
wind_spd_kt=data[:,6]
wind_dir_deg=data[:,5]

# create a sharppy profile
#prof = profile.create_profile(profile='default', pres=press_mb, hght=height_MSL_m, tmpc=temp_C, \
#                                    dwpc=td_C, wspd=wind_spd_kt, wdir=wind_dir_deg, missing=-9999, strictQC=True)


# Create a new figure. The dimensions here give a good aspect ratio
fig = plt.figure(figsize=(6.5875, 6.2125))
ax = fig.add_subplot(111, projection='skewx')
ax.grid(True)

pmax = 1000
pmin = 10
dp = -10
presvals = np.arange(int(pmax), int(pmin)+dp, dp)

# plot the moist-adiabats
#for t in np.arange(-10,45,5):
#    tw = []
#    for p in presvals:
#        tw.append(thermo.wetlift(1000., t, p))
#    ax.semilogy(tw, presvals, 'k-', alpha=.2)

def thetas(theta, presvals):
    return ((theta + 273.15) / (np.power((1000. / presvals),0.286))) - 273.15

# plot the dry adiabats
for t in np.arange(-50,110,10):
    ax.semilogy(thetas(t, presvals), presvals, 'r-', alpha=.2)

# plot the title
plt.title(filename, fontsize=12, loc='left')

# Plot the data using normal plotting functions, in this case using
# log scaling in Y, as dicatated by the typical meteorological plot
ax.semilogy(temp_C, press_mb, 'r', lw=2) # Plot the temperature profile
ax.semilogy(td_C, press_mb, 'g', lw=2) # plot the dewpoint profile


# Disables the log-formatting that comes with semilogy
# set tick marks and labels
ax.yaxis.set_major_formatter(plt.ScalarFormatter())
ax.set_yticks(np.linspace(100,1000,10))
ax.set_ylim(1050,100)
ax.xaxis.set_major_locator(plt.MultipleLocator(10))
ax.set_xlim(-50,50)

# make a new figure and plot the approximate wetbulb temperatures
fig, ax2 = plt.subplots(1,1)
ax2.set_xlabel('wetbulb temp C')
ax2.set_ylabel('height AGL m')
ax2.set_title(filename)
ax2.set_xlim(-30, 10)
ax2.set_ylim(0, 5000)
ax2.plot(2.*temp_C/3.+td_C/3.,height_MSL_m-height_MSL_m[0],color='c',linewidth=2)
ax2.grid(True)
Comments