The EDEX modelsounding plugin creates 64-level vertical profiles from GFS and ETA (NAM) model runs. As of AWIPS release 16.1.5, the available locations are limited to stations around OAX (Omaha) due to localization (16.2.2 will allow requests for all stations).
from awips.dataaccess import DataAccessLayer
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")
request = DataAccessLayer.newDataRequest()
request.setDatatype("modelsounding")
request.addIdentifier("reportType", "ETA")
request.setParameters("pressure","temperature","specHum","uComp","vComp")
availableLocs = DataAccessLayer.getAvailableLocationNames(request)
availableLocs.sort()
for loc in availableLocs: print loc
CHE CRL EAX HSI KDSM KFOE KFRM KFSD KGRI KLNK KMCI KMCW KMHE KMHK KMKC KOFK KOMA KRSL KSLN KSTJ KSUX KTOP KYKN OAX P#8 P#9 P#A P#G P#I RDD WSC
request.setLocationNames("WSC")
cycles = DataAccessLayer.getAvailableTimes(request, True)
print "using ", str(cycles[-1]) # 0 for FIRST time, -1 for LAST
using 2016-07-15 00:00:00
allTimes = DataAccessLayer.getAvailableTimes(request)
# Build one complete model run
fcstRun = []
for time in allTimes:
if str(time)[:19] == str(cycles[-1]):
fcstRun.append(time)
#for time in fcstRun: print time
response = DataAccessLayer.getGeometryData(request,times=[fcstRun[0]])
print "parms = " + str(response[0].getParameters())
print "site = " + response[0].getLocationName()
print "datetime = " + str(response[0].getDataTime())
print "geom = " + str(response[0].getGeometry())
print ""
print fcstRun[0]
tmp,prs,sh,uc,vc = [],[],[],[],[]
for ob in response:
tmp.append(float(ob.getString("temperature")))
prs.append(float(ob.getString("pressure")))
sh.append(float(ob.getString("specHum")))
uc.append(float(ob.getString("uComp")))
vc.append(float(ob.getString("vComp")))
parms = ['pressure', 'uComp', 'temperature', 'specHum', 'vComp'] site = WSC datetime = 1970-01-17 23:55:40.800000 (0) geom = POINT (-93.55999755859375 44.13999938964844) 2016-07-15 00:00:00 (0)
import matplotlib.tri as mtri
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from math import exp, log
import numpy as np
from metpy.calc import get_wind_components, lcl, dry_lapse, parcel_profile, dewpoint
from metpy.calc import get_wind_speed,get_wind_dir, thermo, vapor_pressure
from metpy.plots import SkewT, Hodograph
from metpy.units import units, concatenate
pres = np.array(prs)
# we can use units.* here...
t = (np.array(tmp)-273.16) * units.degC
p = np.array(pres)/100 * units.mbar
s = np.array(sh)
u,v = np.array(uc)*1.94384,np.array(vc)*1.94384 # m/s to knots
spd = get_wind_speed(u, v) * units.knots
dir = get_wind_dir(u, v) * units.deg
Because the modelsounding plugin does not return dewpoint values, we must calculate the profile ourselves. Here are three examples of dewpoint calculated from specific humidity, including a manual calculation following NCEP AWIPS/NSHARP.
rmix = (s/(1-s)) *1000 * units('g/kg')
e = vapor_pressure(p, rmix)
td = dewpoint(e)
td2 = dewpoint(vapor_pressure(p, s))
based on GEMPAK/NSHARP, from https://github.com/Unidata/awips2-ncep/blob/unidata_16.2.2/edex/gov.noaa.nws.ncep.edex.plugin.soundingrequest/src/gov/noaa/nws/ncep/edex/plugin/soundingrequest/handler/MergeSounding.java#L1783
# new arrays
ntmp,nprs,nsh = np.array(tmp)-273.16,np.array(prs),np.array(sh)
# where p=pressure(pa), T=temp(C), T0=reference temp(273.16)
rh = 0.263*nprs*nsh / (np.exp(17.67*ntmp/(ntmp+273.16-29.65)))
vaps = 6.112 * np.exp((17.67 * ntmp) / (ntmp + 243.5))
vapr = rh * vaps / 100
dwpc = np.array(243.5 * (np.log(6.112) - np.log(vapr)) / (np.log(vapr) - np.log(6.112) - 17.67)) * units.degC
/awips2/python/lib/python2.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: divide by zero encountered in log /awips2/python/lib/python2.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in divide
print min(td), max(td)
print min(td2), max(td2)
print min(dwpc), max(dwpc)
-92.478017542 degC 13.9116676363 degC -92.4780705498 degC 13.7561341768 degC -92.4797373828 degC 14.0048053654 degC
%matplotlib inline
plt.rcParams['figure.figsize'] = (12, 14)
# Create a skewT plot
skew = SkewT()
# Plot the data
skew.plot(p, t, 'r')
skew.plot(p, td, 'g')
skew.plot(p, td2, 'y')
skew.plot(p, dwpc, 'b')
skew.plot_barbs(p, u, v)
skew.ax.set_ylim(1000, 100)
skew.ax.set_xlim(-40, 60)
# Calculate LCL height and plot as black dot
l = lcl(p[0], t[0], td[0])
lcl_temp = dry_lapse(concatenate((p[0], l)), t[0])[-1].to('degC')
skew.plot(l, lcl_temp, 'ko', markerfacecolor='black')
# An example of a slanted line at constant T -- in this case the 0 isotherm
l = skew.ax.axvline(0, color='c', linestyle='--', linewidth=2)
# Draw hodograph
ax_hod = inset_axes(skew.ax, '40%', '40%', loc=3)
h = Hodograph(ax_hod, component_range=80.)
h.add_grid(increment=20)
h.plot_colormapped(u, v, spd)
# Show the plot
plt.show()
# manually inspect the three calculated dewpoint profiles
for i in range(0,len(p)):
print p[i], td[i], td2[i], dwpc[i]
972.6 millibar 13.9116676363 degC 13.7561341768 degC 14.0048053654 degC 968.1 millibar 13.795309995 degC 13.6403678572 degC 13.8880708933 degC 963.5 millibar 13.7070447902 degC 13.5523590688 degC 13.7996354037 degC 958.9 millibar 13.6034524052 degC 13.4491913275 degC 13.6957654641 degC 954.2 millibar 13.5430001542 degC 13.3886616121 degC 13.6353487333 degC 949.4 millibar 13.4955511833 degC 13.3409697537 degC 13.5880407718 degC 944.6 millibar 13.4327262238 degC 13.2780704887 degC 13.5252528231 degC 939.6 millibar 13.3214175505 degC 13.1671951789 degC 13.4136681067 degC 934.5 millibar 13.1780826854 degC 13.0246305994 degC 13.2698459052 degC 929.1 millibar 12.9840646965 degC 12.8318898986 degC 13.0750280636 degC 923.7 millibar 12.7587117079 degC 12.6081461774 degC 12.8486706315 degC 917.9 millibar 12.5100387601 degC 12.3612538202 degC 12.5988843283 degC 911.9 millibar 12.2408903895 degC 12.094052447 degC 12.3285202779 degC 905.6 millibar 11.8707829848 degC 11.7268890509 degC 11.956583349 degC 898.9 millibar 11.5848832854 degC 11.4429383778 degC 11.6694675004 degC 891.7 millibar 10.7024681841 degC 10.5684121493 degC 10.782184737 degC 883.7 millibar 10.3675094536 degC 10.2355668766 degC 10.4459068236 degC 874.4 millibar 9.57881581015 degC 9.4530891449 degC 9.65338390277 degC 863.7 millibar 9.06297448338 degC 8.9405219329 degC 9.13551253922 degC 851.4 millibar 8.52959620858 degC 8.41026712977 degC 8.6001943448 degC 837.3 millibar 7.8463517454 degC 7.73112740211 degC 7.91440526624 degC 821.3 millibar 7.05865450398 degC 6.94802011914 degC 7.12386015443 degC 803.3 millibar 6.13786844357 degC 6.0324581565 degC 6.19983982692 degC 783.1 millibar 4.96638946899 degC 4.86761101024 degC 5.02427139898 degC 760.7 millibar 3.49028027301 degC 3.39965174803 degC 3.54314509801 degC 736.3 millibar 2.01375469655 degC 1.93042025112 degC 2.06212831003 degC 710.0 millibar -0.0814385343568 degC -0.154522524712 degC -0.039357011505 degC 682.1 millibar -3.3723881986 degC -3.43052326592 degC -3.33943614929 degC 653.2 millibar -7.36829567182 degC -7.41166867572 degC -7.34434733517 degC 623.5 millibar -13.9853134577 degC -14.0107174126 degC -13.9722607858 degC 593.2 millibar -27.435498651 degC -27.4428708731 degC -27.4332329337 degC 562.4 millibar -28.0124591985 degC -28.0197921015 degC -28.0102992759 degC 531.4 millibar -21.9801025193 degC -21.9942242484 degC -21.9740756264 degC 500.3 millibar -20.9592100388 degC -20.9757571349 degC -20.951921361 degC 469.1 millibar -24.7329831608 degC -24.7452030637 degC -24.7284099272 degC 438.1 millibar -26.2142515313 degC -26.2255402965 degC -26.2103242606 degC 407.3 millibar -28.0020354968 degC -28.0121700893 degC -27.9988837034 degC 376.9 millibar -32.7137422477 degC -32.7204493669 degC -32.712754352 degC 346.8 millibar -37.2686443182 degC -37.2730902274 degC -37.2691563363 degC 317.4 millibar -40.851081496 degC -40.8543253515 degC -40.8524421238 degC 289.3 millibar -46.189552697 degC -46.1914523695 degC -46.1918308 degC 263.1 millibar -51.9389914221 degC -51.9400147149 degC -51.9418882721 degC 239.4 millibar -63.7858391889 degC -63.7860643717 degC -63.7889037616 degC 218.0 millibar nan degC nan degC nan degC 198.7 millibar nan degC nan degC nan degC 181.3 millibar nan degC nan degC nan degC 165.6 millibar nan degC nan degC nan degC 151.1 millibar nan degC nan degC nan degC 137.3 millibar nan degC nan degC nan degC 124.0 millibar nan degC nan degC nan degC 111.3 millibar nan degC nan degC nan degC 98.9 millibar nan degC nan degC nan degC 86.9 millibar nan degC nan degC nan degC 75.1 millibar -79.2738862478 degC -79.27394893 degC -79.2769313644 degC 63.6 millibar -80.3091524605 degC -80.3092143549 degC -80.3120880214 degC 52.3 millibar -81.5110089092 degC -81.5110698952 degC -81.5138426851 degC 41.0 millibar -82.9820927066 degC -82.98215259 degC -82.9847684189 degC 29.8 millibar -84.8703007167 degC -84.8703591996 degC -84.872780293 degC 18.7 millibar -87.5495154933 degC -87.5495720173 degC -87.5517264671 degC 7.6 millibar -92.478017542 degC -92.4780705498 degC -92.4797373828 degC