grib_opts: Set options for grib files

View source: R/grib_opts.R

grib_optsR Documentation

Set options for grib files

Description

In general options for grib files do not need to be explicitly set. However, if you wish to be explicit about how to find a field in a grib file you make use of the param_find argument. Here you pass a named list with the parameters given in e.g. read_forecast or read_grid you wish to be explicit about as the names. The helper functions use_grib_* can be used to set key value pairs to use in the search.

Usage

grib_opts(
  meta = TRUE,
  multi = FALSE,
  param_find = NULL,
  level_find = NULL,
  step_find = NULL,
  ...
)

use_grib_key(key, value)

use_grib_indicatorOfParameter(value)

use_grib_parameterNumber(value)

use_grib_paramId(value)

use_grib_shortName(value)

use_grib_key_level(key, value, level = -999)

use_grib_indicatorOfTypeOfLevel(value, level = -999)

use_grib_typeOfLevel(value, level = -999)

use_grib_heightAboveGround(level = -999)

use_grib_pressure(level = -999)

use_grib_hybrid(level = -999)

use_grib_model(level = -999)

use_grib_surface()

use_grib_meanSea()

use_grib_stepRange(value)

Arguments

meta

Logical. Whether to read metadata

multi

Logical. Whether there are multi field grib messages.

param_find

A named list with names being the parameters to find in the grib files. Each element of the named list is a list with names "key" and "value". The default is NULL, which means to attempt to automatically find the parameter using shortName from the appropriate grib table.

level_find

A named list with names being the parameters to find in the grib files. Each element of the named list is a list with names "key", "value" and "level". Here "key" is the grib key to be used to find the level, "value" is the value of the grib key and "level" is the value of the level. Set level = -999 to select all available levels. The default is NULL, which means to attempt to automatically find the level.

step_find

A named list with names being the parameters to find in the grib files. Each element of the named list is a list with names "key", "value" and "level". Here "key" is the grib key to be used to find the step, "value" is the value of the grib key. step_find would typically be used to find the filter the data by the stepRange grib key - the helper function use_grib_stepRange() will automatically use the stepRange key.

...

Any other options that may exist in future Rgrib2 versions.

key

A grib key

value

The value of the grib key to use

level

The grib level to use.

Details

If harp is not aware of the grib shortName for the field you wish to read, or harp has the wrong shortName you can set param_find using use_grib_shortName(). Alternatively if the field you wish to read does not have a shortName, but has a value for indicatorOfParameter you can set param_find using use_grib_indicatorOfParameter(), and the same applies for paramId using use_grib_paramId().

You can use other grib key value pairs to find fields in a grib file by setting param_find with use_grib_key giving it the key and value to search for. Finally, each element of param_find can be simply set using a list with names "key" and "value".

Similarly, although harp knows the type of vertical level most parameters are on, you may need to set this explicitly with the level_find argument which is a list that selects which grib key to use to find the type of level, the value of that grib key that corresponds to the desired type of level and the value of the level itself. As for param_find, there are helper functions to help you to set the desired values for level_find.

You can use use_grib_key_level to set the grib key, value and level explicitly; use_grib_typeOfLevel to use the typeOfLevel grib key and explicitly set the value and level, similarly with use_grib_indicatorOfTypeOfLevel; use_grib_heightAboveGround, use_grib_pressure, use_grib_hybrid to set a height, pressure or hybrid level respectively; and use_grib_surface and use_grib_meanSea to select the surface and mean sea levels respectively.

Value

A list of options for reading grib files.

Examples

grib_opts()
grib_opts(param_find = list(S10m = list(key = "shortName", value = "WS10")))
grib_opts(param_find = list(S10m = use_grib_key("shortName", "WS10")))
grib_opts(param_find = list(S10m = use_grib_shortName("WS10")))
grib_opts(
  param_find = list(T2m = use_grib_shortName("t")),
  level_find = list(T2m = use_grib_typeOfLevel("heightAboveGround", 2))
)
use_grib_key("indicatorOfParameter", 65)
use_grib_indicatorOfParameter(65)
use_grib_key("paramId", 33)
use_grib_paramId(33)
use_grib_key("shortName", "tp")
use_grib_shortName("tp")
use_grib_key_level("typeOfLevel", "heightAboveGround", 2)
use_grib_typeOfLevel("heightAboveGround", 2)
use_grib_heightAboveGround(2)
use_grib_indicatorOfTypeOfLevel(105, 2)
use_grib_pressure(500)
use_grib_surface()

andrew-MET/harpIO documentation built on March 7, 2024, 7:48 p.m.