Learn R Programming

RadioSonde (version 1.4)

getsonde: read a radiosonde file to an R dataframe.

Description

getsonde takes a common radiosonde data file and reads it in as an R dataframe.

Usage

getsonde(filename, datakey="------", varkey=" Time", unitkey="  sec")

Arguments

filename

Full path and file name of radiosonde data.

datakey

character string identifying the line preceeding the datastream. The string gets compared to the first N characters of each line, so all whitespace is important!

varkey

character string identifying the line containing the variable names. The string gets compared to the first N characters of each line, so all whitespace is important!

unitkey

character string identifying the line containing the units of the variables. The string gets compared to the first N characters of each line, so all whitespace is important!

Value

Returns a dataframe with the following items, if present in the input file. Note that each of these items can be present in any order in the input file.

time

time in seconds since weather balloon launched or recording begins.

press

Pressure in mb.

temp

Dry-bulb Temperature in degrees C.

dewpt

Dew point temperature in degrees C.

rhum

Relative Humidity (Percent).

uwind

East-West wind component (m/s).

vwind

North-South wind component (m/s).

wspd

Wind speed (m/s).

wdir

Wind direction (deg.).

dz

Ascension rate of weather balloon (m/s).

lon

Longitude of weather balloon.

lat

Latitude of weather balloon .

rng

Range (see warning below)

az

Azimuth of weather balloon from originating station (see warning below)

alt

Altitude of weather balloon (m).

qp

Quality Control (QC) flag for pressure (see note below)

qt

QC flag for temperature (see note below)

qh

QC flag for humidity (see note below)

qu

QC flag for U Component (see note below)

qv

QC flag for V Component (see note below)

quv

QC flag for Ascension rate (see note below)

If the units are avialable in the datafile, they are included in the dataframe as the attribute units. Rather than throw away the original header information, which usually contains valuable metadata, it is included as another attribute: metadata.

Warning

The connotation of fields is not exactly standard. Different recording systems use these fields in different ways. Hence, they cannot be automatically interpreted without knowledge of the recording system.

Details

getsonde assumes the data is in a very common format for radiosonde data. The files are typically ASCII files with a header of unknown length stating such things as the location and time of the data collection etc. Appended to this is a table of data where each column is a particular quantity and each row corresponds to the time of the observation. This typically has a header identifying the quantity in each of the columns and is separated from the data by a particular character string. The location of this string in the file is crucial in deciphering the start of the datastream from the metadata. For much more about the file format, look at the example in RadioSonde/inst/exampleData/ExampleSonde.txt. To find the exact path and file name on your system try system.file("exampleData", "ExampleSonde.txt", package = "RadioSonde").

See Also

plotsonde , skewt.points , skewt.lines

Examples

Run this code
# NOT RUN {
# Read a typical radiosonde (ASCII) datafile, headers and all.
# The datakey,varkey,and unitkey arguments come from examining 
# the datafile. The whitespace is important.

# The Sonde text file is stored in this package as a text dataset (this is just
# to make it easier to include in the package.)
# First create a real text file to read in
  data( ExampleSondeText)
  write( ExampleSondeText, file="SondeFile.txt")

  sample.sonde <- getsonde("SondeFile.txt")
# NOTE this assumes that the default datakey, varkey and unitkey. 
# it is best to check the file for these choices!
  attr(sample.sonde,"units")
  attr(sample.sonde,"metadata")

#  skewt plot of data
  plotsonde(sample.sonde,title="SondeFile.txt")

#
# Read the same radiosonde dataset, but ignore the units ... 
#
  datakey  <- "------"
  varkey   <- " Time"
  sample.sonde <- getsonde("SondeFile.txt",datakey,varkey)
  attr(sample.sonde,"metadata")
# }

Run the code above in your browser using DataLab