grib_list: List contents of GRIB file

View source: R/grib_list.R

grib_listR Documentation

List contents of GRIB file

Description

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.

Usage

grib_list(gribObj, filter = "none", namespace = "ls", output = "table")

Arguments

gribObj

GRIB class object.

filter

optional character string that controls what keys will be filtered out of the resulting GRIB message. The default is "none". See 'Details' for other options

namespace

optional character string that can control what special, pre-defined group of keys gets return. Defaults to returning all. See 'Details' for full description.

output

optional character string that controls the output format. The default is "table" and will display the results in a data.frame for easy subsetting. The other option is "string" which will output each messages keys as a character vector of strings.

Details

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.

Value

Returns a character vector containing the keys subset for each message.

See Also

grep grib_get_message

Examples

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)

nawendt/gribr documentation built on July 15, 2024, 10:51 a.m.