read a radiosonde file to an R dataframe.

Share:

Description

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

Usage

1
 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!

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").

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.

Note

The Quality Control information (flags): qp, qt, qh, qu, qv, and quv are generated at JOSS are based on the automated or visual checks made. The JOSS QC flags are as follows:
99.0 means it is unchecked,
1.0 implies datum seems physically reasonable (good),
2.0 implies datum seems questionable on physical basis (maybe),
3.0 implies datum seems to be in error (bad),
4.0 implies datum is interpolated (estimated), and
9.0 implies datum was missing in original file (missing).

Author(s)

Doug Nychka,Eric Gilleland

See Also

plotsonde , skewt.points , skewt.lines

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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")