Learn R Programming

rNOMADS (version 2.4.1)

ArchiveGribGrab: Download archived model data from the NOMADS server.

Description

This function interfaces with the programming API at http://nomads.ncdc.noaa.gov/ to download archived NOMADS model data. The available models can be viewed by calling NOMADSArchiveList without arguments. The data arrives in grib (gridded binary) format that can be read with ReadGrib. Some of these files are in GRIB format, others are in GRIB2 format; select the appropriate file type when calling ReadGrib.

Usage

ArchiveGribGrab(abbrev, model.date, model.run, preds,
    local.dir = NULL, file.names = NULL, tidy = FALSE,
    verbose = TRUE, download.method = NULL, file.type = "grib2")

Arguments

abbrev

Model abbreviation per NOMADSArchiveList.

model.date

The year, month, and day of the model run, in YYYYMMDD format

model.run

Which hour the model was run (i.e. 00, 06, 12, 18 for GFS)

preds

A scalar or vector of prediction to get (analysis is 00)

local.dir

Where to save the grib file, defaults to the current directory.

file.names

A list of length length(preds) of file names to which the downloaded GRIB files are directed to. Default NULL, meaning files will be named per their model date and time.

tidy

If TRUE, remove all files with the suffix ".grb" from local.dir prior to downloading a new grib file.

verbose

If TRUE, give information on connection status. Default TRUE

download.method

Allows the user to set the download method used by download.file: "internal", "wget" "curl", "lynx". If NULL (the default), let R decide.

file.type

Determine whether to get GRIB1 ("grib1") or GRIB2 ("grib2") file formats. Sometimes both are available, sometimes only one.

Value

grib.info$file.name

The path and file name of the grib file that was downloaded.

grib.info$url

The URL that the grib file was downloaded from

References

http://nomads.ncdc.noaa.gov/

See Also

CheckNOMADSArchive, NOMADSArchiveList, ReadGrib

Examples

Run this code
# NOT RUN {
#An example for the Global Forecast System
#Get data for January 1 2014
#Temperature at 2 m above ground
#3 hour prediction
# using GRIB

abbrev <- "gfsanl"
model.date <- 20140101
model.run <- 06
preds <- 3

# }
# NOT RUN {
model.info <- ArchiveGribGrab(abbrev, model.date, 
    model.run, preds, file.type = "grib2")
model.data <- ReadGrib(model.info[[1]]$file.name, c("2 m above ground"), c("TMP"))

#Get surface temperature in Chapel Hill, NC
lat <- 35.907605
lon <- -79.052147

profile <- BuildProfile(model.data, lon, lat, TRUE)
print(paste0("The temperature prediction in Chapel Hill was ", 
    sprintf("%.0f", profile[[1]]$profile.data[1,1,1] - 272.15), " degrees Celsius."))
# }

Run the code above in your browser using DataLab