Learn R Programming

rNOMADS (version 1.0.1)

GribGrab: Download GFS model data from the NOMADS server.

Description

This function interfaces with the programming API at http://nomads.ncep.noaa.gov/ to download GFS model data. The data arrives in grib (gridded binary) format that can be read with ReadGrib. Forecasts are available to 192 hours from the latest model run.

Usage

GribGrab(levels, variables, which.fcst = "back", local.dir = ".", 
    file.name = "fcst.grb", model.date = Sys.time(), 
    fcst.date = Sys.time(), model.domain = NULL, 
    tidy = FALSE, verbose = TRUE)

Arguments

levels
A list of model levels to download.
variables
A list of model variables to download.
which.fcst
Whether to download the nearest forecast before the requested time ("back") or the nearest forecast after the requested time ("foreward"). Defaults to "back".
local.dir
Where to save the grib file, defaults to the current directory.
file.name
What to name the grib file, defaults to "fcst.grb".
model.date
The date and time of the requested model run, in GMT and POSIXlt format, defaults to current system time
fcst.date
The requested forecast date, defaults to current system time
model.domain
A vector of latitudes and longitudes that specify the area to return a forecast for. This is a rectangle with elements: west longitude, east longitude, north latitude, south latitude.
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

Value

  • file.namethe name of the grib file that was downloaded.
  • model.dateDate at which the model was run
  • fcst.dateDate which forecast is for

Details

This function requires an Internet connection to work. Also, the NOMADS web site can go down occasionally, causing GribGrab to fail. In this case, wait an hour or two and try again.

References

http://nomads.ncep.noaa.gov/

See Also

GetModelRunHour

Examples

Run this code
#Get the latest model date
model.date <- Sys.time()

#Get the forecast 6 hours from now - addition is defined in seconds
fcst.date <- model.date + 6 * 3600

#What region of the atmosphere to get data for
levels <- c("2 m above ground", "800 mb") 

#What data to return
variables <- c("TMP", "RH") #Temperature and relative humidity

#What region of the world to get data for - omit this and you get the whole planet!
model.domain <- c(-84, -74, 37, 32) #Get the area around North Carolina, USA

#Get the data
file.name <- GribGrab(levels, variables, model.date = model.date,
    fcst.date = fcst.date, model.domain = model.domain)

Run the code above in your browser using DataLab