Download an atmospheric sounding file from the University of Wyoming
Department of Atmospheric science website at
https://weather.uwyo.edu/upperair/sounding.html. This server has
changed over time, and the present code for dod.met.sounding()
reflects
its file and URL-query structure as inferred on 2025-08-21.
Usage
dod.met.sounding(
id = "71603",
time = Sys.Date() - 1,
destdir = ".",
age = 0,
debug = 0
)
Arguments
- id
character value indicating the station identifier. The default is for a station at Yarmouth, Nova Scotia.
- time
the time for which data are sought, in
POSIXct
,POSIXlt
orDate
format. The default is the previous day.- destdir
a character value indicating the directory in which to store downloaded files.
- age
a numerical value indicating a time interval, in days. If the file to be downloaded from the server already exists locally, and was created less than
age
days in the past, it will not be downloaded again. Settingage=0
forces a download, so that existing files will always be updated. By contrast, settingage
to a negative number prevents the updating of files that already exist locally, regardless of their age.- debug
an integer value indicating the level of debugging. If this exceeds 0, then some debugging messages will be printed. This value is passed down to related functions, but with 1 subtracted for each pass.
Examples
if (interactive()) { # pkgdown::build_site() cannot handle downloads
# Get yesterday's data at Yarmouth, Nova Scotia.
destdir <- tempdir(check = TRUE) # removed at end to pass CRAN checks
file <- dod.met.sounding(destdir = destdir)
data <- read.csv(file)
names(data) # discover names of data items
plot(data$temperature_C, data$pressure_hPa,
type = "l",
xlab = "Temperature [C]", ylab = "Pressure [hPa]", ylim = rev(range(data$pressure_hPa))
)
unlink(destdir, recursive = TRUE)
}