Learn R Programming

rNOMADS (version 1.2.0)

rNOMADS-package: An interface to the NOAA Operational Model Archive and Distribution System

Description

Automatically download forecast data from the National Oceanic and Atmospheric Administration's Operational Model Archive and Distribution System (NOMADS) and read it into R. rNOMADS uses an external series of routines called wgrib2 to read the model data; get wgrib2 at http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/.

Arguments

Details

ll{ Package: rNOMADS Type: Package Version: 1.2.0 Date: 2013-10-28 License: GPL v3 }

References

NOMADS website: http://nomads.ncep.noaa.gov/ wgrib2 download page: http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/ wgrib2 reference: Ebisuzaki, W, Bokhorst, R., Hyvatti, J., Jovic, D., Nilssen, K, Pfeiffer, K., Romero, P., Schwarb, M., da Silva, A., Sondell, N., and Varlamov, S. (2011). wgrib2: read and write GRIB2 files. National Weather Service Climate Prediction Center, http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/

Examples

Run this code
#Getting temperature and relative humidity data for North Carolina, USA, 
#6-12 hours from now depending on when the GFS model was last run.
#Get values at the ground surface and at the 800 mb level
#Then make a contour plot of the surface temperature.

#Using the Global Forecast System 0.5x0.5 model
#Get the first two models available
urls.out <- CrawlModels(abbrev = "gfs0.5", depth = 2)

#Get predictions, variables, and levels
#If the first URL fails, try the second
#(sometimes there's a lag time between the URL appearing
#and the data becoming available)

model.parameters <- ParseModelPage(urls.out[1])

#Get the 6 hour prediction
pred.6 <- model.parameters$pred[grep("06$", model.parameters$pred)]

#What region of the atmosphere to get data for
#2 meters above the ground and at 800 mb

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

file.name <- "fcst.grb" #Name of file to save downloaded data to

#Get the data
GribGrab(urls.out[1], pred.6, levels, variables,
    model.domain = model.domain, file.name = file.name)

#Read the data, only capturing temperature at the 2 m above ground level
model.data <- ReadGrib(file.name, c("2 m above ground"), c("TMP"))

#Make it into an array
model.array <- ModelGrid(model.data)

#Make a contour plot of the temperature around North Carolina, USA:
contour(x = model.array$x, y = model.array$y, 
    model.array$z[1,1,,] - 273.15, xlab = "Longitude", ylab = "Latitude",
   main = paste("North Carolina Temperatures for", 
   model.array$fcst.date, "GMT in Celsius"))

Run the code above in your browser using DataLab