PWV <- function(sonde=NULL, press, td, temp, minp = 400.)
{
# calculate precipitable water (in mm) up to minp (minimum pressure) using
# dew-point temperature (td) and temperature (temp) (both in deg C)
#
# Grab data from sonde if not null, otherwise use values passed in.
if( !is.null( sonde) ) {
	press <- sonde$press
	td <- sonde$dewpt
	temp <- sonde$temp
	}

  q <- td.to.q(temp, td, press)
  n <- length(press)
  pw <- 0.
  for(k in 2.:n) {
    if(press[k] < minp)
      break
    if(is.na(q[k]) || is.na(q[k - 1.]))
      next
    meanq <- (q[k] + q[k - 1.])/2.
    pw <- pw + (0.1 * meanq * (press[k - 1.] - press[k]))/9.81
  }
  return(pw)
}
"getsonde" <- function(filename, datakey="------", varkey=" Time", unitkey="  sec")
{
#
# The file structure is that there are a bunch of header lines
# followed by some delimiting string that indicates the NEXT line
# is the start of the data ...
#

#
# Copyright 2001,2002 Tim Hoar, Eric Gilleland, and Doug Nychka
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

# must parse the file initially and find:
#   a) the line with the column headers 
#   b) the line with the units for each column
#   c) the line that precedes the data 

	foo    <- scan(filename,what="character",sep="\r",quiet=TRUE)
        nlines <- length(foo)
        inds   <- seq(1:nlines)

#
# Decode the column names / variable fields, whatever
#

	if ( ! is.null(varkey) ) {
	   nameindex <- grep(paste("^",varkey,sep=""),foo)
           if ( length(nameindex) == 0 ){
           stop(paste("(getsonde): Variable-name String <",varkey,"> not found.",sep=""))
           }   
	} else {
           stop("(getsonde): Must be a non-NULL 'varkey'")
	}

        if ( length(nameindex) != 1 ) {
           stop("(getsonde): could not find a unique match for the variable-name string")
        }

	col.names <- tolower(scan(filename, what="", skip=nameindex-1,
                             nlines=1, strip.white=TRUE, quiet=TRUE))

#
# Figure out how many lines to skip and read into a dataframe
#

	if ( ! is.null(datakey) ) {
	   dataindex <- grep(paste("^",datakey,sep=""),foo)
           if ( length(dataindex) == 0 ){
           stop(paste("(getsonde): Data String <",datakey,"> not found.",sep=""))
           }   
	} else {
           stop("(getsonde): Must be a non-NULL 'datakey'")
	}

        if ( length(dataindex) != 1 ) {
           stop("(getsonde): could not find a unique match for the data string")
        }

        dataframe <- read.table(filename,skip=dataindex,col.names=col.names)

	missingones <- (dataframe$press == 9999. | dataframe$rh == 999. | dataframe$dewpt == 999.)

        dataframe[missingones,] <- NA

#
# If there are units, try to decode them
#

	if ( ! is.null(unitkey) ) {
	   unitindex <- grep(paste("^",unitkey,sep=""),foo)
           if ( length(unitindex) == 0 ){
           stop(paste("(getsonde): Unit String <",unitkey,"> not found.",sep=""))
           }   

	   units <- scan(filename, what="", skip=unitindex-1, nlines=1, strip.white=TRUE, quiet=TRUE)
           attr(dataframe,"units") <- units

	}

#
# Store the header information as ancillary data
#

        attr(dataframe,"metadata") <- foo[1:dataindex]

	return(dataframe)
}
plotsonde <- 
function (dataframe, skewT=TRUE, winds=FALSE, site = "", title = "", 
            windplot = NULL, s = 3., col = c(1, 2), ... ){
#
# Copyright 2001,2002 Tim Hoar, Eric Gilleland, and Doug Nychka
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

    msg <- deparse(match.call())

    if( skewT & winds){

       #
       # Plot the SKEW-T, log p diagram and the wind profile.
       #

       # Need some room for both the skewT plot and the wind profile.

       mar.skewt <- c(5.0999999999999996, 1.1000000000000001, 
                      2.1000000000000001, 5.0999999999999996)
       skewt.plt <- skewt.axis(mar = mar.skewt)$plt
       title(title)

       if(is.null(windplot)) {
                windplot <- skewt.plt
                windplot[1] <- 0.8
                windplot[2] <- 0.95

       } else if( (windplot[2] < windplot[1]) | 
                  (windplot[4] < windplot[3]) ) {
                stop("plot region (windplot) too small to add second plot")
       }

       first.par <- par()

       # Draw the SKEW-T, log p diagram
       # Draw background and overlay profiles

       skewt.axis()
       skewt.lines(dataframe$temp,  dataframe$press, col = col[1], ...)
       skewt.lines(dataframe$dewpt, dataframe$press, col = col[2], ...)

       #
       # Draw the windplot in the "space allocated"
       # top and bottom mar the same as skewt
       #
        print( windplot)
        par(new = TRUE, pty = "m", plt = windplot, err = -1.)
        plotwind(dataframe = dataframe, size = s, legend = FALSE)
        par(plt = first.par$plt, mar = first.par$mar, new = FALSE, pty = first.par$
                pty, usr = first.par$usr)
        #       title1 <- paste(site, ": ", month.year, " ", time, sep = "")
        invisible()

    } else if( skewT & !winds) {

       #
       # Draw the SKEW-T, log p diagram
       # Draw background and overlay profiles
       #

       skewt.axis()
       skewt.lines(dataframe$temp,  dataframe$press, col = col[1], ...)
       skewt.lines(dataframe$dewpt, dataframe$press, col = col[2], ...)
       title(title)

    } else if( !skewT & winds) {

       #
       # Draw the Wind profile only
       #
       plotwind(dataframe=dataframe, ...)
       title(title)

    }  # end of if else stmts

    invisible()
}
"plotwind" <-
function(dataframe, size = 5., ylim = c(1050, 100), legend = FALSE)
{
#
# Copyright 2001,2002 Eric Gilleland, and Doug Nychka
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
	y <- dataframe$press
	y <- y[!is.na(y)]
	y <- skewty(y)
	ylim <- skewty(ylim)
	n <- length(y)
	u <- dataframe$uwind
	v <- dataframe$vwind
	theta <- dataframe$dir
	speed <- dataframe$wspd
	speed <- round(speed, digits = 0.)
	speed <- as.integer(speed)
	plot(c(-1.5, 1.5), ylim, axes = FALSE, type = "n", xlab = "", ylab = "")
	if(legend) {
		mtext("full barb = 10 m/s", side = 1, line = 1)
	}
	abline(v=0)
	for(k in 1:length(y)) {
		if(y[k] > ylim[2])
			break
		if(!is.na(speed[k])) {
			if(speed[k] != 999.) {
	station.symbol(0., y[k], speed = speed[k], direction = 
					theta[k], circle=FALSE, cex = size)
			}
		}
	}
}
"satlft" <-
function(thw, p)
{
#
# Copyright 2001,2002 Tim Hoar
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

	cta <- 273.14999999999998
	akap <- 0.28541
	pwrp <- (p/1000.)^akap
	tone <- (thw + cta) * pwrp - cta
	eone <- wobf(tone) - wobf(thw)
	rate <- 1.
	dlt <- 1.
	while(abs(dlt) > 0.10000000000000001) {
		ttwo <- tone - eone * rate
		pt <- (ttwo + cta)/pwrp - cta
		etwo <- pt + wobf(ttwo) - wobf(pt) - thw
		dlt <- etwo * rate
		rate <- (ttwo - tone)/(etwo - eone)
		tone <- ttwo
		eone <- etwo
	}
	ttwo - dlt
}
"skewt.axis" <-
function(BROWN = "brown", GREEN = "green", redo = FALSE, ...)
{
#
# Copyright 2001,2002 Tim Hoar, and Doug Nychka
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
	tmr <- function(w, p)
	{
		#
		# Determine x-coordinate on skew-T, log p diagram given 
		# temperature (C)
		# and y-coordinate from FUNCTION SKEWTY.  X-origin at T=0c.
		#
		#            "algorithms for generating a skew-t, log p
		#            diagram and computing selected meteorological
		#            quantities."
		#            atmospheric sciences laboratory
		#            u.s. army electronics command
		#            white sands missile range, new mexico 88002
		#            33 pages
		#       baker, schlatter  17-may-1982
		#   this function returns the temperature (celsius) on a mixing
		#   ratio line w (g/kg) at pressure p (mb). the formula is 
		#   given in
		#   table 1 on page 7 of stipanuk (1973).
		#
		#   initialize constants
		c1 <- 0.049864645499999999
		c2 <- 2.4082965000000001
		c3 <- 7.0747499999999999
		c4 <- 38.9114
		c5 <- 0.091499999999999998
		c6 <- 1.2035
		x <- log10((w * p)/(622. + w))
		tmrk <- 10^(c1 * x + c2) - c3 + c4 * ((10.^(c5 * x) - c6)^
			2.)
		tmrk - 273.14999999999998
	}
	tda <- function(o, p)
	{
		#       reference stipanuk paper entitled:
		#            "algorithms for generating a skew-t, log p
		#            diagram and computing selected meteorological
		#            quantities."
		#            atmospheric sciences laboratory
		#            u.s. army electronics command
		#            white sands missile range, new mexico 88002
		#            33 pages
		#       baker, schlatter  17-may-1982
		#   this function returns the temperature tda (celsius) 
		#   on a dry adiabat
		#   at pressure p (millibars). the dry adiabat is given by
		#   potential temperature o (celsius). the computation is 
		#   based on
		#   poisson's equation.
		ok <- o + 273.14999999999998
		tdak <- ok * ((p * 0.001)^0.28599999999999998)
		tdak - 273.14999999999998
	}
	#---------------------------------------------------------------------
	#
	# This program generates a skew-T, log p thermodynamic diagram.  This
	# program was derived to reproduce the USAF skew-T, log p diagram
	# (form DOD-WPC 9-16-1  current as of March 1978).
	#
	#---------------------------------------------------------------------
	par(pty = "s", ... )
	# --- Define absoulute x,y max/min bounds corresponding to the outer
	# --- edges of the diagram. These are computed by inverting the 
	# --- appropriate
	# --- pressures and temperatures at the corners of the diagram.
	ymax <- skewty(1050)
	# actually at the bottom ~ -0.935
	ymin <- skewty(100)
	# at the top
	xmin <- skewtx(-33, skewty(1050))
	# was hardcoded to -19.0, is -18.66763
	xmax <- skewtx(50, skewty(1000))
	# was hardcoded to  27.1, is  26.99909
	#---------------------------------------------------------------------
	# --- DRAW OUTLINE OF THE SKEW-T, LOG P DIAGRAM.  
	# --- Proceed in the upper left corner of the diagram and draw 
	# --- counter-clockwise.  The array locations below that are 
	# --- hardcoded refer to points on the background where the
	# --- skew-T diagram deviates from a rectangle, along the right edge.
	#---------------------------------------------------------------------
	kinkx <- skewtx(5, skewty(400))
	# t=5C, p=400 is corner
	xc <- c(xmin, xmin, xmax, xmax, kinkx, kinkx, xmin)
	yc <- c(ymin, ymax, ymax, skewty(625), skewty(400), ymin, ymin)
	plot(xc, yc, type = "l", axes = FALSE, xlab = "", ylab = "", lwd = 
		0.10000000000000001)
	# --- label horizontal axis with degrees F from -20,100 by 20
	ypos <- skewty(1050)
	degc <- ((seq(-20, 100, by = 20) - 32) * 5)/9
	axis(1, at = skewtx(degc, ypos), labels = seq(-20, 100, by = 20), pos
		 = ymax)
	mtext(side = 1, line = 1, "Temperature (F)")
	#---------------------------------------------------------------------
	# --- DRAW HORIZONTAL ISOBARS., LABEL VERTICAL AXIS
	#---------------------------------------------------------------------
	# Declare pressure values and x coordinates of the endpoints of each
	# isobar.  These x,y values are computed from the equations in the
	# transform functions listed at the end of this program.  Refer to
	# a skew-T diagram for reference if necessary.
	pres <- c(1050, 1000, 850, 700, 500, 400, 300, 250, 200, 150, 100)
	NPRES <- length(pres)
	# ISOBARS
	xpl <- rep(xmin, times = NPRES)
	# LEFT EDGE IS STRAIGHT
	xpr <- c(xmax, xmax, xmax, xmax, skewtx(20, skewty(500)), kinkx, kinkx,
		kinkx, kinkx, kinkx, kinkx)
	y <- skewty(pres)
	segments(xpl, y, xpr, y, col = BROWN, lwd = 0.10000000000000001, lty = 
		2)
	ypos <- skewty(pres[2:NPRES])
	axis(2, at = ypos, labels = pres[2:NPRES], pos = xmin)
	mtext(side = 2, line = 1.5, "P (hPa)")
	#---------------------------------------------------------------------
	# --- DRAW DIAGONAL ISOTHERMS.
	#---------------------------------------------------------------------
	temp <- seq(from = -100, to = 50, by = 10)
	# TEMPERATURES
	NTEMP <- length(temp)
	# number of ISOTHERMS
	# Determine pressures where isotherms intersect the
	# edge of the skew-T diagram.
	# ------------------------------------------------------
	# x = 0.54*temp + 0.90692*y		SKEWTX formula
	# y = 132.182 - 44.061 * log10(pres)	SKEWTY formula
	#
	# --- FOR ISOTHERMS TERMINATING ALONG LEFT EDGE, WE KNOW 
	# --- TEMP,X = XMIN, FIND PRES
	lendt <- rep(1050, NTEMP)
	inds <- seq(1, length(temp))[temp < -30]
	exponent <- (132.18199999999999 - (xmin - 0.54000000000000004 * temp[
		inds])/0.90691999999999995)/44.061
	lendt[inds] <- 10^exponent
	# --- FOR ISOTHERMS TERMINATING ALONG TOP, WE KNOW PRESSURE ALREADY
	rendt <- rep(100, NTEMP)
	# FOR ISOTHERMS TERMINATING ALONG MIDDLE EDGE, WE KNOW 
	# --- TEMP,X = KINKX, FIND PRES
	inds <- seq(1, length(temp))[(temp >= -30) & (temp <= 0)]
	exponent <- (132.18199999999999 - (kinkx - 0.54000000000000004 * temp[
		inds])/0.90691999999999995)/44.061
	rendt[inds] <- 10^exponent
	# FOR ISOTHERMS TERMINATING ALONG RIGHT EDGE, WE KNOW 
	# --- TEMP,X = XMAX, FIND PRES
	inds <- seq(1, length(temp))[temp > 30]
	exponent <- (132.18199999999999 - (xmax - 0.54000000000000004 * temp[
		inds])/0.90691999999999995)/44.061
	rendt[inds] <- 10^exponent
	# T = 10, 20, 30 are special cases. don't know the exact x just yet 
	rendt[temp == 10] <- 430
	rendt[temp == 20] <- 500
	rendt[temp == 30] <- 580
	# Declare isotherm values and pressures where isotherms intersect the
	# edge of the skew-T diagram.
	yr <- skewty(rendt)
	# y-coords on right
	xr <- skewtx(temp, yr)
	# x-coords on right
	yl <- skewty(lendt)
	# y-coords on right
	xl <- skewtx(temp, yl)
	# x-coords on right
	segments(xl, yl, xr, yr, col = BROWN, lwd = 0.10000000000000001)
	text(xr[8:NTEMP], yr[8:NTEMP], labels = paste(" ", as.character(temp[
		8:NTEMP])), srt = 45, adj = 0, col = BROWN)
	#---------------------------------------------------------------------
	# --- DRAW SATURATION MIXING RATIO LINES.  
	# --- These lines run between 1050 and 400 mb. The 20 line intersects 
	# --- the sounding below 400 mb, thus a special case is made for it.  
	# --- The lines are dashed.  The temperature where each line crosses 
	# --- 400 mb is computed in order to get x,y locations of the top of
	# --- the lines.
	#---------------------------------------------------------------------
	mixrat <- c(20, 12, 8, 5, 3, 2, 1)
	NMIX <- length(mixrat)
	# --- Compute y coordinate at the top 
	# --- (i.e., right end of slanted line) and
	# --- the bottom of the lines.
	# --- SPECIAL CASE OF MIXING RATIO == 20
	yr <- skewty(440.)
	# y-coord at top (i.e. right)
	tmix <- tmr(mixrat[1], 440.)
	xr <- skewtx(tmix, yr)
	yl <- skewty(1000.)
	# y-coord at bot (i.e. left)
	tmix <- tmr(mixrat[1], 1000.)
	xl <- skewtx(tmix, yl)
	segments(xl, yl, xr, yr, lty = 2, col = GREEN, lwd = 
		0.10000000000000001)
	# dashed line
	# We want to stop the mixing ratio lines at 1000 and plot
	# the mixing ratio values "in-line" with where the line would continue
	yl <- skewty(1025.)
	xl <- skewtx(tmix, yl)
	text(xl, yl, labels = as.character(mixrat[1]), col = GREEN, srt = 55,
		adj = 0.5, cex = 0.75)
	#     --- THE REST OF THE MIXING RATIOS
	yr <- skewty(rep(400., NMIX - 1))
	tmix <- tmr(mixrat[2:NMIX], 400.)
	xr <- skewtx(tmix, yr)
	yl <- skewty(rep(1000., NMIX - 1))
	tmix <- tmr(mixrat[2:NMIX], 1000.)
	xl <- skewtx(tmix, yl)
	segments(xl, yl, xr, yr, lty = 2, col = GREEN, lwd = 
		0.10000000000000001)
	# dashed line
	yl <- skewty(rep(1025., NMIX - 1))
	xl <- skewtx(tmix, yl)
	text(xl, yl, labels = as.character(mixrat[2:NMIX]), col = GREEN, srt = 
		55, adj = 0.5, cex = 0.75)
	#---------------------------------------------------------------------
	# --- DRAW DRY ADIABATS.  
	# --- Iterate in 10 mb increments to compute the x,y points on the
	# ---  curve.
	#---------------------------------------------------------------------
	# Declare adiabat values and pressures where adiabats intersect the
	# edge of the skew-T diagram.  Refer to a skew-T diagram if necessary.
	theta <- seq(from = -30, to = 170, by = 10)
	NTHETA <- length(theta)
	# DRY ADIABATS
	lendth <- rep(100, times = NTHETA)
	lendth[1:8] <- c(880, 670, 512, 388, 292, 220, 163, 119)
	rendth <- rep(1050, times = NTHETA)
	rendth[9:NTHETA] <- c(1003, 852, 728, 618, 395, 334, 286, 245, 210,
		180, 155, 133, 115)
	for(itheta in 1:NTHETA) {
		p <- seq(from = lendth[itheta], to = rendth[itheta], length = 
			200)
		sy <- skewty(p)
		dry <- tda(theta[itheta], p)
		sx <- skewtx(dry, sy)
		lines(sx, sy, lty = 1, col = BROWN)
	}
	#---------------------------------------------------------------------
	# --- DRAW MOIST ADIABATS UP TO ~ 250hPa  
	# Declare moist adiabat values and pressures of the tops of the
	# moist adiabats.  All moist adiabats to be plotted begin at 1050 mb.
	#---------------------------------------------------------------------
	# declare pressure range
	# convert to plotter coords and declare space for x coords
	p <- seq(from = 1050, to = 240, by = -10)
	npts <- length(p)
	sy <- skewty(p)
	sx <- double(length = npts)
	# 
	# Generating the data for the curves can be time-consuming.
	# We generate them once and use them. If, for some reason you
	# need to regenerate the curves, you need to set redo to TRUE
	# 
	if(redo) {
	        pseudo <- c(32, 28, 24, 20, 16, 12, 8)
	        NPSEUDO <- length(pseudo)
		holdx <- matrix(0, nrow = npts, ncol = NPSEUDO)
		holdy <- matrix(0, nrow = npts, ncol = NPSEUDO)
		for(ipseudo in 1:NPSEUDO) {
			for(ilen in 1:npts) {
				# satlft is iterative
				moist <- satlft(pseudo[ipseudo], p[ilen])
				sx[ilen] <- skewtx(moist, sy[ilen])
			}
                        # find the adiabats outside the plot region and
                        # wipe 'em out.
                        inds <- (sx < xmin)
                        sx[inds] <- NA
                        sy[inds] <- NA
			holdx[, ipseudo] <- sx
			holdy[, ipseudo] <- sy
		}
	}
	else {
		holdx <- skewt.data$pseudox
		holdy <- skewt.data$pseudoy
                pseudo <- skewt.data$pseudo
                NPSEUDO <- skewt.data$NPSEUDO
	}
	# 
	# Finally draw the curves. Any curves that extend beyond
        # the left axis are clipped. Those curves only get annotated
        # at the surface.
	# 
	for(ipseudo in 1:NPSEUDO) {
                # plot the curves
		sx <- holdx[, ipseudo]
		sy <- holdy[, ipseudo]
		lines(sx, sy, lty = 1, col = GREEN)
                # annotate the curves -- at the top
		moist <- satlft(pseudo[ipseudo], 230)
		labely <- skewty(230)
		labelx <- skewtx(moist, labely)
                if (labelx > xmin) 
		text(labelx, labely, labels = as.character(pseudo[ipseudo]),
			col = GREEN, adj = 0.5, cex = 0.75)
                # annotate the curves -- at the surface
		moist <- satlft(pseudo[ipseudo], 1100)
		labely <- skewty(1100)
		labelx <- skewtx(moist, labely)
		text(labelx, labely, labels = as.character(pseudo[ipseudo]),
			col = GREEN, adj = 0.5, cex = 0.75)
	}
	# 
        # Most of the time, the only thing that needs to be returned by the 
        # routine is the plot boundaries so we know where to put the wind 
        # plot. However, if you are redrawing the curves, you need to be 
        # able to save the new curve data.
	# 
	invisible(list(pseudox=holdx, pseudoy=holdy, pseudo=pseudo, 
                 NPSEUDO=NPSEUDO, plt=par()$plt))
}
"skewt.data" <-
structure(list(pseudox = structure(c(17.3051433922329, 17.2989428595704, 
17.2932651410438, 17.2880834542373, 17.2833694728839, 17.27909308, 
17.2752220849696, 17.2717218987219, 17.2685551600894, 17.2656813051477, 
17.2630560697911, 17.2606309139155, 17.2601199726826, 17.2588705584636, 
17.2579570357398, 17.2573676515475, 17.2570894675302, 17.2571080336316, 
17.2574069311649, 17.257980763743, 17.2588116279734, 17.2598810751258, 
17.2611698462193, 17.2626566065216, 17.2643176422483, 17.2661264884058, 
17.2680534959655, 17.2700653551824, 17.2721246033246, 17.2741891601946, 
17.2762119540590, 17.2781407240027, 17.2797124880103, 17.2839010078384, 
17.2858278854231, 17.2875337152432, 17.2889536137374, 17.2921990432659, 
17.2962825373800, 17.3007006135903, 17.3054121927579, 17.3103724161692, 
17.3155324364105, 17.3208391558221, 17.3262348826955, 17.3316568668493, 
17.3370366681995, 17.3422993053719, 17.3473621272974, 17.3521333499549, 
17.3565102036191, 17.3579295956207, 17.3604536930190, 17.3620550966234, 
17.3625579390551, 17.3617669764034, 17.3594652072220, 17.3554111502962, 
17.3493357227503, 17.3409386513135, 17.3298843422415, 17.3157971305447, 
17.2982558272625, 17.2767874837796, 17.2508602920805, 17.2198755350518, 
17.1831584860816, 17.1399481277563, 17.0893855147563, 17.0337249925873, 
16.9659888140480, 16.8790156664283, 16.7922115723015, 16.6875392957300, 
16.5674211050648, 16.4298252875925, 16.2724592924504, 16.0927448154399, 
15.8877957490636, 15.6533169503045, 15.3894248308104, 15.0877375091579, 
15.1909191507341, 15.1756646495406, 15.1608984632791, 15.1465783888996, 
15.1326593710743, 15.11909308, 15.1058274263395, 15.0928060026049, 
15.0799674382162, 15.0672446529462, 15.0545639903678, 15.0418442091140, 
15.0316246956967, 15.0199575792791, 15.0084266592549, 14.9970092899004, 
14.9856741837271, 14.9743897022645, 14.9631217360471, 14.9518334868048, 
14.9404851986335, 14.9290338323444, 14.9174326856718, 14.9056309634581, 
14.8935537211630, 14.8811224906170, 14.8683093832441, 14.8573904166947, 
14.8464961064276, 14.8355403010480, 14.8244251203961, 14.8163269666724, 
14.8058789634128, 14.7953037713498, 14.7845345152074, 14.7734994599598, 
14.7621216759159, 14.7503186658088, 14.7380019433749, 14.7250765495594, 
14.7114404889445, 14.6969840655754, 14.6815890944614, 14.6651279631310, 
14.6474625171705, 14.6284427451326, 14.6079052419024, 14.5856714357847, 
14.5615455733313, 14.5353124672213, 14.5067350261884, 14.4755516017815, 
14.4414732041785, 14.4008376352240, 14.3595682907867, 14.3143872139204, 
14.2648981998046, 14.2106671999869, 14.1512183543300, 14.0860296373996, 
14.0145281041074, 13.9398362488374, 13.8530652733609, 13.7577324841896, 
13.6530521249796, 13.5361717404851, 13.4122044511524, 13.2741294353365, 
13.1228578043336, 12.9571672961458, 12.775686025925, 12.5768688509936, 
12.3589788298644, 12.1200781992674, 11.8580329279306, 11.5705335935617, 
11.2551331483113, 10.9114822895579, 10.5357590479412, 10.1261949340361, 
9.6804955285966, 9.19638297076769, 13.0880229537128, 13.0615421561304, 
13.0354771012265, 13.0097621001706, 12.9843263284807, 12.95909308, 
12.9339789050716, 12.9088926119989, 12.8837341065491, 12.8583930389019, 
12.8327964049746, 12.8091386222659, 12.7840408436378, 12.7587980097695, 
12.7333589055291, 12.7076748064522, 12.6830261996590, 12.6592209711919, 
12.6355536918222, 12.6119768683373, 12.5884387309433, 12.5648827125563, 
12.541246885814, 12.5174633762442, 12.4934577766839, 12.4691485948879, 
12.4444467728590, 12.4192553222634, 12.3934691246877, 12.3669749476593, 
12.3426478534008, 12.3153950718135, 12.2872990335027, 12.2582511582012, 
12.2281357796585, 12.1968296145657, 12.1642011716881, 12.1301100916530, 
12.0944064071669, 12.0569297133327, 12.0175082384082, 11.9759578069681, 
11.9320806901175, 11.8856643412120, 11.836480020395, 11.7842813170090, 
11.7288025852325, 11.6697573146728, 11.6068364634235, 11.5397067854227, 
11.4680091857311, 11.3913571353633, 11.3093351702129, 11.2214974852618, 
11.1273666149686, 11.0264321638502, 10.91814951982, 10.8019384511339, 
10.6771814628895, 10.5420045401372, 10.3993608478061, 10.2448552829282, 
10.0789133449388, 9.90069110752482, 9.70928872545332, 9.50374736919887, 
9.28304756604942, 9.04610977147649, 8.7917979587073, 8.51892682615312, 
8.22627287660425, 7.9125891478822, 7.5766228354282, 7.21713453223199, 
6.83564767242616, 6.42725884919475, 5.99236058938253, 5.52991163072513, 
5.03891743604392, 4.51843067907725, 3.96754843088834, 3.38540679379677, 
10.9834286762011, 10.9473815342449, 10.9110314249112, 10.8742760070107, 
10.8370037664101, 10.79909308, 10.7607306214984, 10.7226019999327, 
10.6846237742039, 10.6467024584253, 10.6087338813722, 10.5706025885694, 
10.5321812863893, 10.4965447883931, 10.4588985963292, 10.4211233950226, 
10.3831600037907, 10.3449453631084, 10.3064122133637, 10.2674887537105, 
10.2280982916205, 10.1881588964041, 10.1475830722675, 10.1062774681261, 
10.0641426421020, 10.0210728980662, 9.97695620942346, 9.93167424125133, 
9.88510247565824, 9.83711043665693, 9.78756199995663, 9.73631576007275, 
9.68615045131143, 9.6317082777194, 9.57517534282687, 9.51637631931554, 
9.45512512991982, 9.39122422825892, 9.32446383580123, 9.25462113810175, 
9.18145944566893, 9.104727327215, 9.0241577254556, 8.93946706782088, 
8.85035438617344, 8.7565004606387, 8.6575670027097, 8.55319589175702, 
8.44300847696453, 8.32660495376139, 8.20210722300534, 8.07332531441636, 
7.93669040776117, 7.79006523558106, 7.63581044323856, 7.4724721170371, 
7.29949223720337, 7.11629016362788, 6.92226328948576, 6.71678812727141, 
6.49922195614516, 6.26890516068874, 6.02516437166583, 5.76731647489104, 
5.49467348406401, 5.20654818133938, 4.9022603244647, 4.5811431148963, 
4.24254953339864, 3.88585809432918, 3.51047756049188, 3.11585020539805, 
2.70447875527363, 2.2707123647247, 1.81632541948403, 1.34086951635333, 
0.843916121523552, 0.325052207643314, -0.21612385146258, -0.780005244618362, 
-1.36697755653373, -1.97741649353216, 8.8693198408773, 8.82362060225909, 
8.7778202837706, 8.7318545129958, 8.68564243136579, 8.63909308, 
8.59210501493707, 8.54456600062523, 8.49635278008452, 8.4473309196289, 
8.3973547259304, 8.34626723350831, 8.29717502093355, 8.24508566369272, 
8.19190607248017, 8.13590789945266, 8.07886487223, 8.02101288143116, 
7.96226257825346, 7.90251968473725, 7.84168478320765, 7.77965310870992, 
7.71631435057434, 7.65155246554546, 7.58524550138339, 7.51726542607508, 
7.44747795371448, 7.37574235384074, 7.3019112268378, 7.22583022427214, 
7.14733769025231, 7.06626419855796, 6.98243196096606, 6.89565408539856, 
6.80573366865185, 6.71246271777396, 6.61562090662483, 6.5149741894634, 
6.41027331087583, 6.30125226994055, 6.18762681482522, 6.06909306036851, 
5.94532633381016, 5.815980360912, 5.68068690469817, 5.53905596079303, 
5.39130692049396, 5.23654567807787, 5.07455277730511, 4.90494850891334, 
4.72734317655766, 4.54133809473316, 4.34652679046918, 4.14249642343462, 
3.92882943511941, 3.70510543067685, 3.47090328625409, 3.22580345997613, 
2.96939046654665, 2.70125545471351, 2.42099880536593, 2.12823264813775, 
1.8225831788211, 1.50369265142676, 1.17122091980478, 0.824846416106464, 
0.464266477792906, 0.0891969710428775, -0.300628795139314, -0.705461815413283, 
-1.12553968719240, -1.56108929371912, -2.01232964455361, -2.47947459611463, 
-2.95872612684821, -3.45796943963609, -3.97377226888853, -4.50634809323703, 
-5.05590564375613, -5.62264474479052, -6.20675065628543, -6.80838728764349, 
6.77831772704848, 6.71948788078446, 6.66024960367034, 6.60050919906525, 
6.54016217588293, 6.47909308, 6.41717542011243, 6.35427168908186, 
6.29023348126375, 6.2249017058425, 6.15810689579234, 6.09259502234998, 
6.02413044737311, 5.95428257377271, 5.88295400057493, 5.810041246535, 
5.73543447907136, 5.65901725952678, 5.58066631063983, 5.5002513120674, 
5.41763472952653, 5.33267168260209, 5.24520985550712, 5.15508945410501, 
5.06214321134919, 4.96544321943421, 4.86447279455346, 4.76074565208796, 
4.65409498138669, 4.54434615291771, 4.43131619983376, 4.31484476475966, 
4.19469068292192, 4.07063572609886, 3.94245971418652, 3.80993234989983, 
3.67281307398837, 3.53085107678464, 3.38378550162564, 3.23134587268157, 
3.07325277410780, 2.90921879920850, 2.74088005762418, 2.56501257906871, 
2.38256986542532, 2.19327978408104, 1.99686852200273, 1.79306162179306, 
1.58158509583726, 1.36216660565135, 1.13453668897216, 0.898430012186143, 
0.653586620623024, 0.399753154372238, 0.136683993046701, -0.135857710202, 
-0.418099146605096, -0.710257162212523, -1.01253779831214, -1.32513609343277, 
-1.64823616981836, -1.98201161580829, -2.32662616166401, -2.68223463052745, 
-3.04898412899665, -3.42701542400324, -3.81646443510701, -4.21746375492128, 
-4.6301440962099, -5.05463555349456, -5.49106856128268, -5.93957443207948, 
-6.40028536730572, -6.87333385543792, -7.35885140632547, -7.856966620241, 
-8.3678026546993, -8.8914742285377, -9.42808438413466, -9.97772130258074, 
-10.5404555149944, -11.1163378530414, 4.69967599684703, 4.62557547853907, 
4.55058643310393, 4.47459399843423, 4.39747398229793, 4.31909307999999, 
4.23930918045812, 4.15797175933475, 4.07492235703379, 3.98999513851152, 
3.90301753097215, 3.81687497267339, 3.72710472431085, 3.63536874386069, 
3.54157060244478, 3.44560941169168, 3.34737967576727, 3.24677114889118, 
3.14366869974693, 3.03795218446032, 2.92949633021732, 2.81817063212923, 
2.70383926663402, 2.58636102553892, 2.46558927572689, 2.34137195052574, 
2.21355157970275, 2.08196536591335, 1.94644531610187, 1.80681843671502, 
1.66290700154024, 1.51452890041571, 1.36149807590905, 1.20362505326797, 
1.04071756650901, 0.872581280463646, 0.699020605034008, 0.519839593958682, 
0.334842916236961, 0.146049710655252, -0.0506477422751042, -0.255320558896862, 
-0.466259553862647, -0.683496843759201, -0.907205916279217, -1.13755629651005, 
-1.37471293173180, -1.61883562984477, -1.87007856580488, -2.12858987084959, 
-2.39451131893324, -2.66797812363419, -2.94911885682591, -3.23805549763171, 
-3.5349036166334, -3.83977269605942, -4.15276658182789, -4.47398405800764, 
-4.80351952863908, -5.14146378610905, -5.48790483959868, -5.84292877173785, 
-6.20662058674554, -6.57906500928965, -6.96034719038448, -7.35055327524688, 
-7.74977078860971, -8.15808335523754, -8.57558359150481, -9.00236645792674, 
-9.43852404064522, -9.88414784605981, -10.3393275743270, -10.8041496880084, 
-11.2786958570621, -11.7630413856587, -12.2572537437646, -12.7613913312339, 
-13.2755025876899, -13.7996255211296, -14.3337876563495, -14.8780062972731
), .Dim = c(82, 7)), pseudoy = structure(c(-0.934621706320542, 
-0.751505962843567, -0.566620957734585, -0.379932168001829, -0.191404050236997, 
-0.00100000000000477, 0.191317690837366, 0.385587878912986, 0.58185061649499, 
0.780147201043576, 0.98052022736806, 1.18301364254367, 1.38767280376507, 
1.59454453932747, 1.8036772129403, 2.01512079159389, 2.2289269172185, 
2.44514898239143, 2.66384221037106, 2.88506373975716, 3.10887271410252, 
3.33533037682741, 3.56450017181783, 3.79644785012107, 4.03124158318781, 
4.26895208314798, 4.50965273065185, 4.75341971085473, 5.00033215817528, 
5.25047231051605, 5.5039256736983, 5.76078119693346, 6.0211314602326, 
6.28507287474189, 6.55270589708883, 6.82413525893183, 7.09947021302581, 
7.37882479725053, 7.6623181181989, 7.95007465608973, 8.24222459295915, 
8.53890416629596, 8.84025605052572, 9.14642976901742, 9.4575821395906, 
9.77387775684628, 10.0954895150355, 10.4225991756234, 10.7553979842143, 
11.0940873420798, 11.4388795381941, 11.7899985484402, 12.1476809095196, 
12.5121766761071, 12.8837504709488, 13.2626826389507, 13.6492705178637, 
14.0438298399942, 14.4466962814944, 14.8582271782782, 15.2788034305446, 
15.7088316213421, 16.1487463787078, 16.5990130157781, 17.0601304890717, 
17.5326347220986, 18.0171023498054, 18.5141549494667, 19.0244638358841, 
19.5487555136925, 20.0878178978825, 20.6425074362012, 21.2137572950404, 
21.8025868052466, 22.4101124079681, 23.0375603957970, 23.6862818145741, 
24.3577699810305, 25.0536811873909, 25.7758593150578, 26.5263652779014, 
27.3075124789449, -0.934621706320542, -0.751505962843567, -0.566620957734585, 
-0.379932168001829, -0.191404050236997, -0.00100000000000477, 
0.191317690837366, 0.385587878912986, 0.58185061649499, 0.780147201043576, 
0.98052022736806, 1.18301364254367, 1.38767280376507, 1.59454453932747, 
1.8036772129403, 2.01512079159389, 2.2289269172185, 2.44514898239143, 
2.66384221037106, 2.88506373975716, 3.10887271410252, 3.33533037682741, 
3.56450017181783, 3.79644785012107, 4.03124158318781, 4.26895208314798, 
4.50965273065185, 4.75341971085473, 5.00033215817528, 5.25047231051605, 
5.5039256736983, 5.76078119693346, 6.0211314602326, 6.28507287474189, 
6.55270589708883, 6.82413525893183, 7.09947021302581, 7.37882479725053, 
7.6623181181989, 7.95007465608973, 8.24222459295915, 8.53890416629596, 
8.84025605052572, 9.14642976901742, 9.4575821395906, 9.77387775684628, 
10.0954895150355, 10.4225991756234, 10.7553979842143, 11.0940873420798, 
11.4388795381941, 11.7899985484402, 12.1476809095196, 12.5121766761071, 
12.8837504709488, 13.2626826389507, 13.6492705178637, 14.0438298399942, 
14.4466962814944, 14.8582271782782, 15.2788034305446, 15.7088316213421, 
16.1487463787078, 16.5990130157781, 17.0601304890717, 17.5326347220986, 
18.0171023498054, 18.5141549494667, 19.0244638358841, 19.5487555136925, 
20.0878178978825, 20.6425074362012, 21.2137572950404, 21.8025868052466, 
22.4101124079681, 23.0375603957970, 23.6862818145741, 24.3577699810305, 
25.0536811873909, 25.7758593150578, 26.5263652779014, 27.3075124789449, 
-0.934621706320542, -0.751505962843567, -0.566620957734585, -0.379932168001829, 
-0.191404050236997, -0.00100000000000477, 0.191317690837366, 
0.385587878912986, 0.58185061649499, 0.780147201043576, 0.98052022736806, 
1.18301364254367, 1.38767280376507, 1.59454453932747, 1.8036772129403, 
2.01512079159389, 2.2289269172185, 2.44514898239143, 2.66384221037106, 
2.88506373975716, 3.10887271410252, 3.33533037682741, 3.56450017181783, 
3.79644785012107, 4.03124158318781, 4.26895208314798, 4.50965273065185, 
4.75341971085473, 5.00033215817528, 5.25047231051605, 5.5039256736983, 
5.76078119693346, 6.0211314602326, 6.28507287474189, 6.55270589708883, 
6.82413525893183, 7.09947021302581, 7.37882479725053, 7.6623181181989, 
7.95007465608973, 8.24222459295915, 8.53890416629596, 8.84025605052572, 
9.14642976901742, 9.4575821395906, 9.77387775684628, 10.0954895150355, 
10.4225991756234, 10.7553979842143, 11.0940873420798, 11.4388795381941, 
11.7899985484402, 12.1476809095196, 12.5121766761071, 12.8837504709488, 
13.2626826389507, 13.6492705178637, 14.0438298399942, 14.4466962814944, 
14.8582271782782, 15.2788034305446, 15.7088316213421, 16.1487463787078, 
16.5990130157781, 17.0601304890717, 17.5326347220986, 18.0171023498054, 
18.5141549494667, 19.0244638358841, 19.5487555136925, 20.0878178978825, 
20.6425074362012, 21.2137572950404, 21.8025868052466, 22.4101124079681, 
23.0375603957970, 23.6862818145741, 24.3577699810305, 25.0536811873909, 
25.7758593150578, 26.5263652779014, 27.3075124789449, -0.934621706320542, 
-0.751505962843567, -0.566620957734585, -0.379932168001829, -0.191404050236997, 
-0.00100000000000477, 0.191317690837366, 0.385587878912986, 0.58185061649499, 
0.780147201043576, 0.98052022736806, 1.18301364254367, 1.38767280376507, 
1.59454453932747, 1.8036772129403, 2.01512079159389, 2.2289269172185, 
2.44514898239143, 2.66384221037106, 2.88506373975716, 3.10887271410252, 
3.33533037682741, 3.56450017181783, 3.79644785012107, 4.03124158318781, 
4.26895208314798, 4.50965273065185, 4.75341971085473, 5.00033215817528, 
5.25047231051605, 5.5039256736983, 5.76078119693346, 6.0211314602326, 
6.28507287474189, 6.55270589708883, 6.82413525893183, 7.09947021302581, 
7.37882479725053, 7.6623181181989, 7.95007465608973, 8.24222459295915, 
8.53890416629596, 8.84025605052572, 9.14642976901742, 9.4575821395906, 
9.77387775684628, 10.0954895150355, 10.4225991756234, 10.7553979842143, 
11.0940873420798, 11.4388795381941, 11.7899985484402, 12.1476809095196, 
12.5121766761071, 12.8837504709488, 13.2626826389507, 13.6492705178637, 
14.0438298399942, 14.4466962814944, 14.8582271782782, 15.2788034305446, 
15.7088316213421, 16.1487463787078, 16.5990130157781, 17.0601304890717, 
17.5326347220986, 18.0171023498054, 18.5141549494667, 19.0244638358841, 
19.5487555136925, 20.0878178978825, 20.6425074362012, 21.2137572950404, 
21.8025868052466, 22.4101124079681, 23.0375603957970, 23.6862818145741, 
24.3577699810305, 25.0536811873909, 25.7758593150578, 26.5263652779014, 
27.3075124789449, -0.934621706320542, -0.751505962843567, -0.566620957734585, 
-0.379932168001829, -0.191404050236997, -0.00100000000000477, 
0.191317690837366, 0.385587878912986, 0.58185061649499, 0.780147201043576, 
0.98052022736806, 1.18301364254367, 1.38767280376507, 1.59454453932747, 
1.8036772129403, 2.01512079159389, 2.2289269172185, 2.44514898239143, 
2.66384221037106, 2.88506373975716, 3.10887271410252, 3.33533037682741, 
3.56450017181783, 3.79644785012107, 4.03124158318781, 4.26895208314798, 
4.50965273065185, 4.75341971085473, 5.00033215817528, 5.25047231051605, 
5.5039256736983, 5.76078119693346, 6.0211314602326, 6.28507287474189, 
6.55270589708883, 6.82413525893183, 7.09947021302581, 7.37882479725053, 
7.6623181181989, 7.95007465608973, 8.24222459295915, 8.53890416629596, 
8.84025605052572, 9.14642976901742, 9.4575821395906, 9.77387775684628, 
10.0954895150355, 10.4225991756234, 10.7553979842143, 11.0940873420798, 
11.4388795381941, 11.7899985484402, 12.1476809095196, 12.5121766761071, 
12.8837504709488, 13.2626826389507, 13.6492705178637, 14.0438298399942, 
14.4466962814944, 14.8582271782782, 15.2788034305446, 15.7088316213421, 
16.1487463787078, 16.5990130157781, 17.0601304890717, 17.5326347220986, 
18.0171023498054, 18.5141549494667, 19.0244638358841, 19.5487555136925, 
20.0878178978825, 20.6425074362012, 21.2137572950404, 21.8025868052466, 
22.4101124079681, 23.0375603957970, 23.6862818145741, 24.3577699810305, 
25.0536811873909, 25.7758593150578, 26.5263652779014, 27.3075124789449, 
-0.934621706320542, -0.751505962843567, -0.566620957734585, -0.379932168001829, 
-0.191404050236997, -0.00100000000000477, 0.191317690837366, 
0.385587878912986, 0.58185061649499, 0.780147201043576, 0.98052022736806, 
1.18301364254367, 1.38767280376507, 1.59454453932747, 1.8036772129403, 
2.01512079159389, 2.2289269172185, 2.44514898239143, 2.66384221037106, 
2.88506373975716, 3.10887271410252, 3.33533037682741, 3.56450017181783, 
3.79644785012107, 4.03124158318781, 4.26895208314798, 4.50965273065185, 
4.75341971085473, 5.00033215817528, 5.25047231051605, 5.5039256736983, 
5.76078119693346, 6.0211314602326, 6.28507287474189, 6.55270589708883, 
6.82413525893183, 7.09947021302581, 7.37882479725053, 7.6623181181989, 
7.95007465608973, 8.24222459295915, 8.53890416629596, 8.84025605052572, 
9.14642976901742, 9.4575821395906, 9.77387775684628, 10.0954895150355, 
10.4225991756234, 10.7553979842143, 11.0940873420798, 11.4388795381941, 
11.7899985484402, 12.1476809095196, 12.5121766761071, 12.8837504709488, 
13.2626826389507, 13.6492705178637, 14.0438298399942, 14.4466962814944, 
14.8582271782782, 15.2788034305446, 15.7088316213421, 16.1487463787078, 
16.5990130157781, 17.0601304890717, 17.5326347220986, 18.0171023498054, 
18.5141549494667, 19.0244638358841, 19.5487555136925, 20.0878178978825, 
20.6425074362012, 21.2137572950404, 21.8025868052466, 22.4101124079681, 
23.0375603957970, 23.6862818145741, 24.3577699810305, 25.0536811873909, 
25.7758593150578, 26.5263652779014, 27.3075124789449, -0.934621706320542, 
-0.751505962843567, -0.566620957734585, -0.379932168001829, -0.191404050236997, 
-0.00100000000000477, 0.191317690837366, 0.385587878912986, 0.58185061649499, 
0.780147201043576, 0.98052022736806, 1.18301364254367, 1.38767280376507, 
1.59454453932747, 1.8036772129403, 2.01512079159389, 2.2289269172185, 
2.44514898239143, 2.66384221037106, 2.88506373975716, 3.10887271410252, 
3.33533037682741, 3.56450017181783, 3.79644785012107, 4.03124158318781, 
4.26895208314798, 4.50965273065185, 4.75341971085473, 5.00033215817528, 
5.25047231051605, 5.5039256736983, 5.76078119693346, 6.0211314602326, 
6.28507287474189, 6.55270589708883, 6.82413525893183, 7.09947021302581, 
7.37882479725053, 7.6623181181989, 7.95007465608973, 8.24222459295915, 
8.53890416629596, 8.84025605052572, 9.14642976901742, 9.4575821395906, 
9.77387775684628, 10.0954895150355, 10.4225991756234, 10.7553979842143, 
11.0940873420798, 11.4388795381941, 11.7899985484402, 12.1476809095196, 
12.5121766761071, 12.8837504709488, 13.2626826389507, 13.6492705178637, 
14.0438298399942, 14.4466962814944, 14.8582271782782, 15.2788034305446, 
15.7088316213421, 16.1487463787078, 16.5990130157781, 17.0601304890717, 
17.5326347220986, 18.0171023498054, 18.5141549494667, 19.0244638358841, 
19.5487555136925, 20.0878178978825, 20.6425074362012, 21.2137572950404, 
21.8025868052466, 22.4101124079681, 23.0375603957970, 23.6862818145741, 
24.3577699810305, 25.0536811873909, 25.7758593150578, 26.5263652779014, 
27.3075124789449), .Dim = c(82, 7)), pseudo = c(32, 28, 24, 20, 
16, 12, 8), NPSEUDO = 7, plt = c(0.184615384615385, 0.881318681318681, 
0.168131868131868, 0.864835164835165)), .Names = c("pseudox", 
"pseudoy", "pseudo", "NPSEUDO", "plt"))
"skewt.lines" <-
function(temp, pressure, ...)
{
#
# Copyright 2001,2002 Tim Hoar
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
	v <- skewty(pressure[pressure > 100])
	u <- skewtx(temp[pressure > 100], v)
	lines(u, v, ...)
}
"skewt.points" <-
function(temp, pressure, ...)
{
#
# Copyright 2001,2002 Tim Hoar
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
	v <- skewty(pressure)
	u <- skewtx(temp, v)
	points(u, v, ...)
}
"skewtx" <-
function(temp, ycoord)
{
#
# Copyright 2001,2002 Tim Hoar
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
	#
	# Determine x-coordinate on skew-T, log p diagram given
	#           temperature (C)
	# and y-coordinate from FUNCTION SKEWTY.  X-origin at T=0c.
	#
	0.54000000000000004 * temp + 0.90691999999999995 * ycoord
}
"skewty" <-
function(pres)
{
#
# Copyright 2001,2002 Tim Hoar
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
	#
	# y-coordinate on skew-T, log p diagram given pressure (mb).
	# Y-origin at p=1000 mb.
	# SKEWTY = 132.182 - 44.061 * ALOG10(PRES)
	#
	132.18199999999999 - 44.061 * log10(pres)
}
"station.symbol" <-
function (cx, cy, direction = 0, speed = 0, fill = 0, color = "green",
    temp = NULL, press = NULL, dewpt = NULL, circle=TRUE, cex = 2)
{
#
# Copyright 2001,2002 Eric Gilleland, and Doug Nychka
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
    tpar <- par()
    size <- tpar$csi
    scalex <- (tpar$usr[2] - tpar$usr[1])/(tpar$pin[1])
    scaley <- (tpar$usr[4] - tpar$usr[3])/(tpar$pin[2])
    scalex <- (cex * (scalex * size))/5
    scaley <- (cex * (scaley * size))/5
    xs <- if (speed > 0) {
        X1 <- 0
        X2 <- 0
        Y1 <- 0
        Y2 <- 5
        if (speed >= 5 & speed < 10) {
            X1 <- c(X1, 0)
            X2 <- c(X2, 1)
            Y1 <- c(Y1, 5)
            Y2 <- c(Y2, 5)
        }
        if (speed >= 10 & speed < 15) {
            X1 <- c(X1, 0)
            X2 <- c(X2, 2)
            Y1 <- c(Y1, 5)
            Y2 <- c(Y2, 5)
        }
        if (speed >= 15 & speed < 20) {
            X1 <- c(X1, 0, 0)
            X2 <- c(X2, 1, 2)
            Y1 <- c(Y1, 4, 5)
            Y2 <- c(Y2, 4, 5)
        }
        if (speed >= 20 & speed < 25) {
            X1 <- c(X1, 0, 0)
            X2 <- c(X2, 2, 2)
            Y1 <- c(Y1, 4, 5)
            Y2 <- c(Y2, 4, 5)
        }
        if (speed >= 25 & speed < 30) {
            X1 <- c(X1, 0, 0, 0)
            X2 <- c(X2, 1, 2, 2)
            Y1 <- c(Y1, 3, 4, 5)
            Y2 <- c(Y2, 3, 4, 5)
        }
        if (speed >= 30 & speed < 35) {
            X1 <- c(X1, 0, 0, 0)
            X2 <- c(X2, 2, 2, 2)
            Y1 <- c(Y1, 3, 4, 5)
            Y2 <- c(Y2, 3, 4, 5)
        }
        if (speed >= 35 & speed < 40) {
            X1 <- c(X1, 0, 0, 0, 0)
            X2 <- c(X2, 1, 2, 2, 2)
            Y1 <- c(Y1, 2, 3, 4, 5)
            Y2 <- c(Y2, 2, 3, 4, 5)
        }
        if (speed >= 40 & speed < 45) {
            X1 <- c(X1, 0, 0, 0, 0)
            X2 <- c(X2, 2, 2, 2, 2)
            Y1 <- c(Y1, 2, 3, 4, 5)
            Y2 <- c(Y2, 2, 3, 4, 5)
        }
        if (speed >= 45 & speed < 50) {
            X1 <- c(X1, 0, 0, 0, 0, 0)
            X2 <- c(X2, 1, 2, 2, 2, 2)
            Y1 <- c(Y1, 1, 2, 3, 4, 5)
            Y2 <- c(Y2, 1, 2, 3, 4, 5)
        }
        if (speed >= 50 & speed < 55) {
            X1 <- c(X1, 0, 0)
            X2 <- c(X2, 2, 2)
            Y1 <- c(Y1, 4, 5)
            Y2 <- c(Y2, 4.5, 4.5)
        }
        if (speed >= 55 & speed < 60) {
            X1 <- c(X1, 0, 0, 0)
            X2 <- c(X2, 1, 2, 2)
            Y1 <- c(Y1, 3, 4, 5)
            Y2 <- c(Y2, 3, 4.5, 4.5)
        }
        if (speed >= 60 & speed < 65) {
            X1 <- c(X1, 0, 0, 0)
            X2 <- c(X2, 2, 2, 2)
            Y1 <- c(Y1, 3, 4, 5)
            Y2 <- c(Y2, 3, 4.5, 4.5)
        }
        direction <- (direction/360) * 2 * pi
        rot <- cbind(c(cos(direction), -sin(direction)), c(sin(direction),
            cos(direction)))
        S1 <- rbind(X1, Y1)
        S2 <- rbind(X2, Y2)
        S1 <- rot %*% S1
        S2 <- rot %*% S2
        S1 <- S1 * c(scalex, scaley) + c(cx, cy)
        S2 <- S2 * c(scalex, scaley) + c(cx, cy)
    }
    if (speed > 0) {
        segments(S1[1, ], S1[2, ], S2[1, ], S2[2, ])
    }

    #
    # Add circle to base of station annotation symbol if desired.
    #

    if(circle) {
        ts <- seq(0, 2 * pi, , 200)
        RX <- sin(ts) * scalex
        X1 <- RX + cx
        RY <- cos(ts) * scaley
        Y1 <- RY + cy
        if (speed == 0) {
            lines(RX * 2 + cx, RY * 2 + cy)
        }
        if (fill > 0) {
            lim <- c(51, 101, 151, 200)
            polygon(c(cx, X1[1:lim[fill]]), c(cy, Y1[1:lim[fill]]),
                density = -1, col = color)
        }
        lines(RX + cx, RY + cy)
        if (!is.null(temp)) {
            temp.text <- paste(temp, sep = "")
            temp.x <- cx - 3.25 * scalex
            temp.y <- cy + 1.25 * scaley
            text(temp.x, temp.y, labels = temp.text)
        }
        if (!is.null(press)) {
            press.text <- paste( press, sep = "")
            press.x <- cx + 4.75 * scalex
            press.y <- cy + 1.25 * scaley
            text(press.x, press.y, labels = press.text)
        }
        if (!is.null(dewpt)) {
            dewpt.text <- paste( dewpt, sep = "")
            dewpt.x <- cx - 3.25 * scalex
            dewpt.y <- cy - 2.25 * scaley
            text(dewpt.x, dewpt.y, labels = dewpt.text)
        }
    } # end of if circle stmt

invisible()
}
td.to.q <- function(temp, td, p)
{
  # calculate specific humidity (g/kg) using temperature and dew-point T
  es <- 6.1121 * exp((temp * 17.67)/(temp + 243.5))
  e <- 6.1121 * exp((td * 17.67)/(td + 243.5))
  q <- (1000. * (0.62197 * e))/(p - (1. - 0.62197) * e)
  return(q)
}
"wobf" <-
function(temp)
{
#
# Copyright 2001,2002 Tim Hoar
#
# This file is part of the RadioSonde library for R and related languages.
#
# RadioSonde is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# RadioSonde is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RadioSonde; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

	#-----------------------------------------------------------------------
	#
	# this function calculates the difference of the wet-bulb potential
	# temperatures for saturated and dry air given the temperature.
	#
	#-----------------------------------------------------------------------
	# include 'lib_dev:[gudoc]edfvaxbox.for/list'
	# baker, schlatter  17-may-1982	  original version.
	#      let wbpts = wet-bulb potential temperature for saturated
	# air at temperature t (celsius). let wbptd = wet-bulb potential
	# temperature for completely dry air at the same temperature t.
	# the wobus function wobf (in degrees celsius) is defined by
	#                    wobf(t) = wbpts-wbptd.
	# although wbpts and wbptd are functions of both pressure and
	# temperature, their difference is a function of temperature only.
	#      to understand why, consider a parcel of dry air at tempera-
	# ture t and pressure p. the thermodynamic state of the parcel is
	# represented by a point on a pseudoadiabatic chart. the wet-bulb
	# potential temperature curve (moist adiabat) passing through this
	# point is wbpts. now t is the equivalent temperature for another
	# parcel saturated at some lower temperature tw, but at the same
	# pressure p.  to find tw, ascend along the dry adiabat through
	# (t,p). at a great height, the dry adiabat and some moist
	# adiabat will nearly coincide. descend along this moist adiabat
	# back to p. the parcel temperature is now tw. the wet-bulb
	# potential temperature curve (moist adiabat) through (tw,p) is wbptd.
	# the difference (wbpts-wbptd) is proportional to the heat imparted
	# to a parcel saturated at temperature tw if all its water vapor
	# were condensed. since the amount of water vapor a parcel can
	# hold depends upon temperature alone, (wbptd-wbpts) must depend
	# on temperature alone.
	#      the wobus function is useful for evaluating several thermo-
	# dynamic quantities.  by definition:
	#		    wobf(t) = wbpts-wbptd.               (1)
	# if t is at 1000 mb, then t is a potential temperature pt and
	# wbpts = pt. thus
	#		    wobf(pt) = pt-wbptd.                 (2)
	# if t is at the condensation level, then t is the condensation
	# temperature tc and wbpts is the wet-bulb potential temperature
	# wbpt. thus
	#		    wobf(tc) = wbpt-wbptd.               (3)
	# if wbptd is eliminated from (2) and (3), there results
	#		    wbpt = pt-wobf(pt)+wobf(tc).
	# if wbptd is eliminated from (1) and (2), there results
	#		    wbpts = pt-wobf(pt)+wobf(t).
	#      if t is an equivalent potential temperature ept (implying
	# that the air at 1000 mb is completely dry), then wbpts = ept
	# and wbptd = wbpt. thus
	#		    wobf(ept) = ept-wbpt.
	# this form is the basis for a polynomial approximation to wobf.
	# in table 78 on pp.319-322 of the smithsonian meteorological
	# tables by roland list (6th revised edition), one finds wet-bulb
	# potential temperatures and the corresponding equivalent potential
	# temperatures listed together. herman wobus, a mathematician for-
	# merly at the navy weather research facility, norfolk, virginia, 
	# and now retired, computed the coefficients for the polynomial
	# approximation from numbers in this table.
	#
	#                                  notes by t.w. schlatter
	#                                  noaa/erl/profs program office
	#                                  august 1981
	x <- temp - 20.
	if(x <= 0.) {
		pol <- 1. + x * (-0.0088416604999999992 + x * (
			0.00014714143000000001 + x * (-9.6719890000000006e-07 +
			x * (-3.2607217000000002e-08 + x * (
			-3.8598072999999999e-10)))))
		wbts <- 15.130000000000001/pol^4
	}
	else {
		pol <- 1. + x * (0.0036182989000000001 + x * (-1.3603273e-05 +
			x * (4.9618921999999997e-07 + x * (
			-6.1059364999999998e-09 + x * (3.9401550999999998e-11 +
			x * (-1.2588129e-13 + x * (1.668828e-16)))))))
		wbts <- 29.93/pol^4 + 0.95999999999999996 * x - 
			14.800000000000001
	}
	return(wbts)
}
