add_grid: Add grid to an LPJmLData object

View source: R/LPJmLData.R

add_gridR Documentation

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, ...)

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.

Value

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

Examples

## Not run: 

# 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)


## End(Not run)


lpjmlkit documentation built on March 31, 2023, 9:35 p.m.