parameter_definitions: Parameter definitions for reading from files

parameter_definitionsR Documentation

Parameter definitions for reading from files

Description

add_param_def adds a new parameter definition to the input list and modify_param_def modifies an entry for an existing parameter. Use show_param_defs to show the names and descriptions of the paramaters in the param_defs list, and pass the file format as an argument to show the parameters for that file format.

Usage

add_param_def(
  param,
  param_defs = get("harp_params"),
  description = "",
  min = -Inf,
  max = Inf,
  grib = NULL,
  netcdf = NULL,
  v = NULL,
  fa = NULL,
  obsoul = NULL,
  func = NULL,
  ...
)

modify_param_def(
  param,
  param_defs = get("harp_params"),
  description = NULL,
  min = NULL,
  max = NULL,
  grib = NULL,
  netcdf = NULL,
  v = NULL,
  fa = NULL,
  obsoul = NULL,
  func = NULL,
  ...
)

get_param_def(param, file_format = NULL, param_defs = get("harp_params"))

show_param_defs(file_format = NULL, param_defs = get("harp_params"))

Arguments

param

The name of a parameter to extract from param_defs

param_defs

A list of parameter definitions to modify. Defaults to the built in list of parameters.

description

A description of the parameter.

min, max

The minimum and maximumvalues the parameter can have - only used when reading observations to do a gross error check.

grib

A list with the grib shortName, and optionally levelType and level. Use new_grib_param to generate.

netcdf

A list with the name of the parameter in the netcdf file and optionally a named list of suffixes to add to the parameter name for different vertical coordinate systems. Use new_netcdf_param to generate.

v

A list with the name of the parameter in vfld / vobs files, the output name, units and type (synop or temp). Use new_v_param to generate.

fa

A list with the name of the parameter in FA files and its units. Use new_fa_param to generate.

obsoul

A list with the name of the paramater in obsoul files (this is usually numeric), its units and the output name. Use new_obsoul_param to generate.

func

A function to apply on reading. For the function to be used, the "name" element of the list for the file type must be a named list with names matching the names of the function arguments. See, for example, harp_params$ws10m for how this should be done.

...

Other file types.

file_format

If given, the parameter names that exist in param_defs for the file format are shown.

Value

A modified version of the param_defs input to the function.

Examples

add_param_def(
  "u100m",
  description = "Zonal wind Speed at 100m above ground",
  grib = new_grib_param("u", "heightAboveGround", 100),
  netcdf = new_netcdf_param("x_wind_100m"),
  v = new_v_param("U100", "u100m", "m/s", "SYNOP")
)

# Use a function to convert sea level pressure to hPa from Pa for grib files
my_params <- modify_param_def(
  "pmsl",
  grib = new_grib_param(
    name = list(p = "msl"),
    level_type = c("meanSea", "heightAboveSea"),
    level = 0
  ),
  func = function(p) p / 100
)
my_params$pmsl

# Get parameter definition for topography
get_param_def("topo")

# For grib files
get_param_def("topo", "grib")

# Aliases also work - stored in the \code{other_names} entry
get_param_def("terrain")

# Show parameter definitions
show_param_defs()
show_param_defs("grib")
show_param_defs("netcdf")

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