Extract data from grib file
This function wraps
wgrib, external grib file readers provided by the National Weather Service Climate Prediction Center (see http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/ and http://www.cpc.ncep.noaa.gov/products/wesley/wgrib.html).
ReadGrib extracts forecast data into R.
It does this by building an argument string, executing a system call to the appropriate external grib file reader, and extracting the result.
wgrib2 must be installed for
ReadGrib to work for current grib files, and
wgrib may need to be installed when looking at archived data.
The path and file name of the grib file to read.
The levels to extract.
The variables to extract.
Include model nodes in the specified region:
Whether the file is in GRIB (
Replace missing data in grib archive with this value.
This function constructs system calls to
Therefore, you must have installed these programs and made it available on the system path.
Unless you are interested in accessing archive data that's more than a few years old, you can
install wgrib2 only.
A description of
wgrib2 and installation links are available at http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/ and http://www.cpc.ncep.noaa.gov/products/wesley/wgrib.html.
Also, rNOMADS is focused towards GRIB2 files; I have included GRIB1 format support as a convenience.
A structure with a series of elements containing data extracted from the grib file.
Daniel C. Bowman firstname.lastname@example.org
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/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#Operational Forecast Data Extraction #NCEP output is always in GRIB2 format - this makes things easy for us #An example for the Global Forecast System 0.5 degree model #Get the latest model url ## Not run: urls.out <- CrawlModels(abbrev = "gfs_0p50", depth = 1) #Get a list of forecasts, variables and levels model.parameters <- ParseModelPage(urls.out) #Figure out which one is the 6 hour forecast #provided by the latest model run #(will be the forecast from 6-12 hours from the current date) my.pred <- model.parameters$pred[grep("06$", model.parameters$pred)] #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 #Get the data model.info <- GribGrab(urls.out, my.pred, levels, variables) #Extract the data model.data <- ReadGrib(model.info$file.name, levels, variables) #Reformat it model.grid <- ModelGrid(model.data, c(0.5, 0.5)) #Show an image of world temperature at ground level image(model.grid$z[2, 1,,]) #Archived Data Extraction #This is sometimes in GRIB1 format #This example is in GRIB1 abbrev <- "gfsanl" model.date <- 20040302 #March 2, 2004 model.run <- 18 #1800 GMT model run pred <- 0 #Analysis grib.info <- ArchiveGribGrab(abbrev, model.date, model.run, pred, file.type = "grib1") model.data <- ReadGrib(grib.info$file.name, c("1000 mb"), c("TMP"), file.type = "grib1") ## End(Not run)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.