Have you ever seen upper air sounding data that looks like this...I'm trying to write a Python script to decode this kind of stuff. I'm not sure what to make of this or how the best way to decode it is.
There are some hints here: http://www.ofcm.gov/fmh3/pdf/13-app-e.pdf
and here: http://www.meteor.iastate.edu/classes/mt311/extras/Codul-TEMP.pdf
and here: http://www.rwic.und.edu/metresources/raob.html
USUS41 KWBC 191400
IIAA USBOI02 69144 99441 71160 15645 09333
99910 12464 00000 00144 ///// ///// 92796 ///// ///// 85536
18876 01008 70162 10476 34521 50588 07170 33030 40756 20769
33043
88999
77999
31313 40708 81429=
NNNN
UMUS41 KWBC 191400
IIBB USBOI02 69148 99441 71160 15645 09333
00910 12464 11870 18073 22813 18477 33808 18278 44727 10874
55694 10476 66590 00468 77501 06969 88387 22969
21212 11910 00000 22840 01010 33795 05010 44712 36019 55712
36019 66641 31518 77449 34038 88387 33041
31313 40708 81429
41414 /////
21212 11910 00000 22840 01010 33795 05010 44712 36019 55712
36019 66641 31518 77449 34038 88387 33041=
NNNN
This page demonstrates Python tips and tricks that I use in my everyday programming as an atmospheric science graduate student.
-Brian Blaylock
Showing posts with label Sounding. Show all posts
Showing posts with label Sounding. Show all posts
Monday, August 29, 2016
Wednesday, June 29, 2016
Plot a psudo-sounding with MesoWest Data
In the Salt Lake City area there are many weather stations at elevations higher than the valley floor. Farnsworth Peak is such a weather station at almost 700 hPa. I wondered what it would look like to plot station weather data on a skew-t graph, and see how it compares to rawinsonde balloons.
Here I use the MesoWest API and the Wyoming Sounding data to plot these graphs. I use the SkewT 1.1.0 module for Python to create the SkewT graph. The balloon observations are in green and the real observations are plotted in blue with the station id next to the point. A red line is drawn to create the "psudo-sounding" from the temperature observations at the different elevations. It doesn't match up exactly, except, for FWP, which seems to be an accurate representation of the temperatures of the atmosphere at that elevation.
Here I use the MesoWest API and the Wyoming Sounding data to plot these graphs. I use the SkewT 1.1.0 module for Python to create the SkewT graph. The balloon observations are in green and the real observations are plotted in blue with the station id next to the point. A red line is drawn to create the "psudo-sounding" from the temperature observations at the different elevations. It doesn't match up exactly, except, for FWP, which seems to be an accurate representation of the temperatures of the atmosphere at that elevation.
See more of the code on GitHub: https://github.com/blaylockbk/pyBKB and https://github.com/blaylockbk/Ute_other/blob/master/MesoWest_psudo_sounding.py
## Brian Blaylock
## 27 June 2016
# A lot of the stations in Utah are at elevations.
# I want to plot station data on a skew-t graph to get a
# psudo vertical profile for any time of day.
import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime, timedelta
import sys
sys.path.append('B:\pyBKB') #for running on PC (B:\ is my network drive)
from BB_MesoWest import MesoWest_stations_radius as MW
from skewt_900_700 import SkewT #this version plots between 900-700 hPa
import wyoming_sounding
##############################
request_time = datetime(2016,6,29,12,0)
##############################
MWdatetime = request_time.strftime('%Y%m%d%H%M')
a = MW.get_mesowest_radius_winds(MWdatetime,'10')
p = a['PRESS']>0 #pressure is in these indexes
pres = a['PRESS'][p]/100
temp = a['TEMP'][p]
hght = a['ELEVATION'][p]
dwpt = a['TEMP'][p]*np.nan #don't get the dewpoint now
wd = a['WIND_DIR'][p]
ws = a['WIND_SPEED'][p]
stns = a['STNID'][p]
# sort all that data based on pressure
from operator import itemgetter
pres,temp,hght,dwpt,wd,ws,stns = zip(*sorted(zip(pres,temp,hght,dwpt,wd,ws,stns),key=itemgetter(0)))
data = {'drct':wd,
'dwpt':dwpt, #don't plot dwpt right now
'hght':hght,
'pres':pres,
'sknt':ws,
'temp':temp}
S=SkewT.Sounding(soundingdata=data)
S.plot_skewt(title='psudo sounding\n'+MWdatetime,color='r',lw=.8,parcel_type=None,
pmin=700.,pmax=900.)
for i in range(0,len(stns)):
if temp[i]>0: #wont accept nan values
print temp[i],pres[i],stns[i]
S.plot_point(temp[i],pres[i])
S.plot_text(temp[i],pres[i],str(stns[i]))
# Add real sounding to plot
# If request_time is in the afternoon, then request the evening sounding
if request_time.hour > 18:
# Get the evening sounding (00 UTC) for the next day
next_day = request_time + timedelta(days=1)
request_sounding = datetime(next_day.year,next_day.month,next_day.day,0)
elif request_time.hour < 6:
# Get the evening sounding (00 UTC) for the same
request_sounding = datetime(request_time.year,request_time.month,request_time.day,0)
else:
# Get the morning sounding (12 UTC) for the same day
request_sounding = datetime(request_time.year,request_time.month,request_time.day,12)
print "SLC sounding for", request_sounding
a = wyoming_sounding.get_sounding(request_sounding)
balloon = {'drct':a['wdir'],
#'dwpt':a['dwpt'],
'hght':a['height'],
'pres':a['press'],
'sknt':a['wspd'],
'temp':a['temp']}
# Add to plot
T = SkewT.Sounding(soundingdata=balloon)
S.soundingdata=T.soundingdata
S.add_profile(color='g',lw=.9,bloc=1.2)
Monday, July 6, 2015
Plotting Sounding Data from University of Wyoming's Website
Plotting sounding data can be difficult, but it is made easy with this python module: https://pypi.python.org/pypi/SkewT
It requires a .txt file with data in the format of the University of Wyoming sounding data archive (example) or you can create your own dictionary.
Here I grab the sounding data from the University of Wyoming's website and process it with the following steps:
# Brian Blaylock
It requires a .txt file with data in the format of the University of Wyoming sounding data archive (example) or you can create your own dictionary.
Here I grab the sounding data from the University of Wyoming's website and process it with the following steps:
- Use urllib2 to open the url and read the data
- Parse out the html tags using BeautifulSoup
- Separate the text by a new line "\n"
- Write each line of text to a new .txt file reinserting the new line with +"\n" and skipping the first three lines of the file (this puts it in the same format as the University of Wyoming website)
- Draw the Skew-T Plot (NOTE: requires the SkewT package here)
Here is the download function on github.
As always, please share other solutions you may come up with :)
As always, please share other solutions you may come up with :)
# Brian Blaylock
# July 6, 2015
# Download, process, and Plot Sounding Data from University of Wyoming
import urllib2
from bs4 import BeautifulSoup
from skewt import SkewT
stn = '72572' #72572 is ID for SLC
year= '2015'
month = '06'
day = '12'
hour = '12' #either 12 or 00
# 1)
# Wyoming URL to download Sounding from
url = 'http://weather.uwyo.edu/cgi-bin/sounding?region=naconf&TYPE=TEXT%3ALIST&YEAR='+year+'&MONTH='+month+'&FROM='+day+hour+'&TO='+day+hour+'&STNM='+stn
content = urllib2.urlopen(url).read()
# 2)
# Remove the html tags
soup = BeautifulSoup(content)
data_text = soup.get_text()
# 3)
# Split the content by new line.
splitted = data_text.split("\n",data_text.count("\n"))
# 4)
# Write this splitted text to a .txt document
Sounding_filename = str(stn)+'.'+str(year)+str(month)+str(day)+str(hour)+'.txt'
f = open(Sounding_filename,'w')
for line in splitted[4:]:
f.write(line+'\n')
f.close()
# 5)
sounding = SkewT.Sounding(filename=Sounding_filename)
sounding.plot_skewt()
And if you wish to plot more than one sounding on the same plot do this...
S = SkewT.Sounding(filename=Sounding_filename)
T = SkewT.Sounding(filename="72572.2015061212.txt")
S.make_skewt_axes(tmax=55)
S.add_profile(color='r',linewidth=5,bloc=0)
S.soundingdata=T.soundingdata
S. add_profile(color="b",bloc=1)
# Download, process, and Plot Sounding Data from University of Wyoming
import urllib2
from bs4 import BeautifulSoup
from skewt import SkewT
stn = '72572' #72572 is ID for SLC
year= '2015'
month = '06'
day = '12'
hour = '12' #either 12 or 00
# 1)
# Wyoming URL to download Sounding from
url = 'http://weather.uwyo.edu/cgi-bin/sounding?region=naconf&TYPE=TEXT%3ALIST&YEAR='+year+'&MONTH='+month+'&FROM='+day+hour+'&TO='+day+hour+'&STNM='+stn
content = urllib2.urlopen(url).read()
# 2)
# Remove the html tags
soup = BeautifulSoup(content)
data_text = soup.get_text()
# 3)
# Split the content by new line.
splitted = data_text.split("\n",data_text.count("\n"))
# 4)
# Write this splitted text to a .txt document
Sounding_filename = str(stn)+'.'+str(year)+str(month)+str(day)+str(hour)+'.txt'
f = open(Sounding_filename,'w')
for line in splitted[4:]:
f.write(line+'\n')
f.close()
# 5)
sounding = SkewT.Sounding(filename=Sounding_filename)
sounding.plot_skewt()
And if you wish to plot more than one sounding on the same plot do this...
S = SkewT.Sounding(filename=Sounding_filename)
T = SkewT.Sounding(filename="72572.2015061212.txt")
S.make_skewt_axes(tmax=55)
S.add_profile(color='r',linewidth=5,bloc=0)
S.soundingdata=T.soundingdata
S. add_profile(color="b",bloc=1)
Subscribe to:
Posts (Atom)

