Learn R Programming

lpjmlkit (version 1.0.11)

add_grid: Add grid to an LPJmLData object

Description

Function to add a grid to an LPJmLData object. The function acts as a read_io() wrapper for the grid file and adds it as an LPJmLData object itself to the $grid attribute of the main object.

Usage

add_grid(x, ...)

Value

A copy of x (LPJmLData object) with added $grid attribute.

Arguments

x

LPJmLData object.

...

Arguments passed to read_io(). Without any arguments, add_grid() will search for a file name starting with "grid" in the same directory that x was loaded from. This supports grid files in "meta" and "clm" format. If the grid file is in "raw" format or should be loaded from a different directory, supply all necessary read_io() parameters.

Details

Important:

  • If "file_type" == "raw" prescribe variable = "grid" to ensure data are recognized as a grid.

  • Do not use read_io() argument subset here. add_grid will use the subset of the parent LPJmLData object x.

Examples

Run this code
if (FALSE) {

# Read in vegetation carbon data with meta file
vegc <- read_io(filename = "./vegc.bin.json")

# Add grid as attribute (via grid file in output directory)
vegc_with_grid <- add_grid(vegc)

}

Run the code above in your browser using DataLab