예제 #1
0
ax1.set_yticks(labels)
ax1.set_yticklabels(labels)
ax1.set_ybound((400, 1000))
xlims = convertTempToSkew([-10, 30], 1.e3, skew)
ax1.set_xbound((xlims[0], xlims[1]))
ax1.set_title('littlerock sounding, %s' %var_names[3])
fig1.canvas.draw()

#get user inputed coords to draw moist adiabat
#ginput(1) returns a list with a tuple containing the coords
coords = plt.ginput(1)[0]
thePress = coords[1]
theTemp = convertSkewToTemp(coords[0], thePress, skew)
thetaeVal = thetaes(theTemp + c.Tc, thePress*100)
#pressVals in Pa, tempVals in K
pressVals, tempVals = calcAdiabat(thePress*100, thetaeVal, 400*100)
xtemp = convertTempToSkew(tempVals - c.Tc, pressVals*1e-2, skew)
#plot the adiabat
plt.semilogy(xtemp, pressVals*1e-2, 'r', linewidth=3)

#press must have unique values
newPress = nudgePress(press)
#interpolators return temp. in deg C given pressure in hPa
#newPress must be in increasing order
#env. temp. interpolator
interpTenv = lambda pVals: np.interp(pVals, newPress[::-1], temp[::-1])
#dew point temp. interpolator
interpTdenv = lambda pVals: np.interp(pVals, newPress[::-1], dewpt[::-1])
#test the interpolator
trytemp = interpTenv(pressVals*1e-2)
tryxtemp = convertTempToSkew(trytemp, pressVals*1e-2, skew)
예제 #2
0
plt.xlabel('temperature (deg C)')
plt.show()

plt.figure(2)
skew, ax2 = convecSkew(2)
xtemp=convertTempToSkew(temp,press,skew)
xdew=convertTempToSkew(dewpoint,press,skew)
plt.semilogy(xtemp,press,'g-',linewidth=4)
plt.semilogy(xdew,press,'b-',linewidth=4)

#use 900 hPa sounding level for adiabat
#array.argmin() finds the index of the min. value of array 
p900_level = np.abs(900 - press).argmin()

thetaeVal=thetaep(dewpoint[p900_level] + c.Tc,temp[p900_level] + c.Tc,press[p900_level]*100.)
pressVals,tempVals =calcAdiabat(press[p900_level]*100.,thetaeVal,200.e2)
xTemp=convertTempToSkew(tempVals - c.Tc,pressVals*1.e-2,skew)
p900_adiabat = plt.semilogy(xTemp,pressVals*1.e-2,'r-',linewidth=4)
xleft=convertTempToSkew(-20,1.e3,skew)
xright=convertTempToSkew(25.,1.e3,skew)

#
#interpolator fails if two pressure values are the same
#
newPress = nudge(press)
#independent variable used to interpolate must be in increasing order 
#pVals must be in hPa
interpTenv = lambda pVals: np.interp(pVals, newPress[::-1], temp[::-1])
interpTdenv = lambda pVals: np.interp(pVals, newPress[::-1], dewpoint[::-1])
interpDirec = lambda pVals: np.interp(pVals, newPress[::-1], direct[::-1])
interpSpeed = lambda pVals: np.interp(pVals, newPress[::-1], speed[::-1])