Download an atmospheric sounding file from the University of Wyoming Department of Atmospheric science website at https://weather.uwyo.edu/upperair/sounding.html.
Usage
dod.met.sounding(
station = "73110",
year,
month,
day,
region = "naconf",
destdir = ".",
age = 0,
debug = 0
)
Arguments
- station
character value indicating the station identifier. The default is for a station near Halifax, Nova Scotia.
- year
integer or character value indicating the year. If this is not supplied, the present year is used.
- month
integer or character value indicating the month. If this is not supplied, the present month is used.
- day
integer or character value indicating the day If this is not supplied, the present day is used.
- region
character value indicating the region. For example, stations in north America seem to be associated with region
"naconf"
(which is the default).- 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
(which is the default) forces a download.- 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 (FALSE) {
# Download
tempdir <- tempfile()
dir.create(tempdir)
station <- "73110"
year <- "2023"
month <- "01"
day <- "08"
file <- dod.met.sounding(station, year=year, month=month, day=day, destdir=tempdir)
# Read data, extracting the table crudely.
lines <- readLines(file)
start <- grep("<PRE>", lines)[1]
end <- grep("</PRE>", lines)[1]
table <- lines[seq(start+5, end-1)]
col.names <- strsplit(gsub("^ [ ]*", "", lines[start+2]), "[ ]+")[[1]]
# Must read in fixed-width format because missing data are blanked out
data <- read.fwf(file=textConnection(table),
widths=rep(7, 11), col.names=col.names)
# Plot mixing ratio variation with height
plot(data$MIXR, data$HGHT, type="l", cex=0.5, pch=20, col=4,
xlab="Mixing Ratio", ylab="Height [m]")
unlink(tempdir, recursive=TRUE)
}