grib_list | R Documentation |
grib_list
lists the contents of a GRIB file using a manageable subset
of the keys in each message. This can be used to efficiently grab the message
you want when used in conjunction with grep
and
grib_get_message
.
grib_list(gribObj, filter = "none", namespace = "ls", output = "table")
gribObj |
GRIB class object. |
filter |
optional |
namespace |
optional |
output |
optional |
The filter
parameter controls which keys will be filtered out of the
results. More information can be found in the
ecCodes Reference. Below are the options used in this package:
"none": no keys filtered
"readonly": skip readonly keys
"optional": skip optional keys
"edition": skip edition-specific keys
"coded": skip coded keys
"computed": skip keys computed from other keys
"duplicate: skip duplicate keys
"func": skip keys that are functions
The namespace
parameter is a quick and easy way to grab a subset of
the keys available in a GRIB file using pre-defined groups of related keys.
To get a full set of keys, extract a gribMessage
and view the
names
. More information about GRIB key namespaces can be found
here. The namespace
options used in this package are described below:
"ls": most commonly used keys
"parameter": keys related to the parameter
"statistics": keys related to statiscal values of the data
"time": keys related to the forecast time/initialization
"geography": keys describing the grid geometry
"vertical": keys describing levels and layers
"mars": ECMWF's Meteorological Archive and Retrieval System keys
NOTE: The output of grib_list
is predicated on having the
appropriate GRIB definition files available to ecCodes. By default that
location is in share/grib_api/definitions
directory in the ecCodes
root. Any locally defined paramters will not likely be displayed correctly
without first overriding the parameter definitions manually. You can read
more information about creating your own local definitions
here. Once your own definitions are created, be sure
to set the ECCODES_DEFINITION_PATH
environment variable to the location
of your local defintions before using this function to display the contents.
Returns a character
vector containing the keys subset for each
message.
grep
grib_get_message
g <- grib_open(system.file("extdata", "lfpw.grib1", package = "gribr"))
grib_list(g)
# Use grib_list output to help select messages
msg_loc_df <- which(grib_list(g)$shortName == "u")
gm <- grib_get_message(g, msg_loc_df)
msg_loc_str <- grep("shortName=2t", grib_list(g, output = "string")) # find 2m temp message
gm <- grib_get_message(g, msg_loc_str)
grib_close(g)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.