LPJmLMetaData: LPJmL meta data class

LPJmLMetaDataR Documentation

LPJmL meta data class

Description

A meta data container for LPJmL input and output meta data. Container - because an LPJmLMetaData object is an environment in which the meta data are stored after read_meta() (or read_io()). Each attribute can be accessed via ⁠$<attribute>⁠. To get an overview over available attributes, print the object or export it as a list as_list(). The enclosing environment is locked and cannot be altered.

Active bindings

sim_name

Simulation name (works as identifier in LPJmL Runner).

source

LPJmL version (character string).

history

Character string of the call used to run LPJmL. This normally includes the path to the LPJmL executable and the path to the configuration file for the simulation.

variable

Name of the input/output variable, e.g. "npp" or "runoff".

descr

Description of the input/output variable.

unit

Unit of the input/output variable.

nbands

Number (numeric) of bands (categoric dimension). Please note that nbands follows the convention in LPJmL, which uses the plural form for bands as opposed to nyear or ncell.

band_names

Name of the bands (categoric dimension). Not included if nbands = 1.

nyear

Number (numeric) of data years in the parent LPJmLData object.

firstyear

First calendar year (numeric) in the parent LPJmLData object.

lastyear

Last calendar year (numeric) in the parent LPJmLData object.

nstep

Number (numeric) of intra-annual time steps. 1 for annual, 12 for monthly, and 365 for daily data.

timestep

Number (numeric) of years between time steps. timestep = 5 means that output is written every 5 years.

ncell

Number (numeric) of cells in the parent LPJmLData object.

firstcell

First cell (numeric) in the parent LPJmLData object.

cellsize_lon

Longitude cellsize in degrees (numeric).

cellsize_lat

Latitude cellsize in degrees (numeric).

datatype

File data type (character string), e.g. "float". Note that data are converted into R-internal data type by read_io().

scalar

Conversion factor (numeric) applied when reading raw data from file. The parent LPJmLData object contains the values after the application of the conversion factor.

order

Order of the data items in the file, either "cellyear", "yearcell", "cellindex", or "cellseq". The structure of the data array in the parent LPJmLData object may differ from the original order in the file depending on the dim_order parameter used in read_io().

offset

Offset (numeric) at the start of the binary file before the actual data start.

bigendian

(Logical) Endianness refers to the order in which bytes are stored in a multi-byte value, with big-endian storing the most significant byte at the lowest address and little-endian storing the least significant byte at the lowest address.

format

Binary format (character string) of the file containing the actual data. Either "raw", "clm" (raw with header), or "cdf" for NetCDF format.

filename

Name of the file containing the actual data.

subset

Logical. Whether parent LPJmLData object is subsetted.

map

Character vector describing how to map the bands in an input file to the bands used inside LPJmL. May be used by read_io() to construct a band_names attribute.

version

Version of data file.

._data_dir_

Internal character string containing the directory from which the file was loaded.

._subset_space_

Internal logical. Whether space dimensions are subsetted in the parent LPJmLData object.

._fields_set_

Internal character vector of names of attributes set by the meta file.

._time_format_

Internal character string describing the time dimension format, either "time" or "year_month_day".

._space_format_

Internal character string describing the space dimension format, either "cell" or "lon_lat".

._dimension_map_

Internal dictionary/list of space and time dimension formats with categories and namings.

Methods

Public methods


Method as_list()

Method to coerce (convert) an LPJmLMetaData object into a list.
See also as_list().

Usage
LPJmLMetaData$as_list()

Method as_header()

Method to coerce (convert) an LPJmLMetaData object into an LPJmL binary file header. More information about file headers at create_header()).

Usage
LPJmLMetaData$as_header(...)
Arguments
...

See as_header().


Method print()

Method to print an LPJmLMetaData object. See also print.

Usage
LPJmLMetaData$print(all = TRUE, spaces = "")
Arguments
all

Logical. Should all attributes be printed or only the most relevant (all = FALSE)?

spaces

Internal parameter Spaces to be printed at the start.


Method .__init_grid__()

!Internal method only to be used for package development!

Usage
LPJmLMetaData$.__init_grid__()

Method .__update_subset__()

!Internal method only to be used for package development!

Usage
LPJmLMetaData$.__update_subset__(
  subset,
  cell_dimnames = NULL,
  time_dimnames = NULL,
  year_dimnames = NULL
)
Arguments
subset

List of subset arguments, see also subset.LPJmLData().

cell_dimnames

Optional list of new cell_dimnames of subset data to update meta data. Required if spatial dimensions are subsetted.

time_dimnames

Optional list of new time_dimnames of subset data to update meta data. Required if time dimension is subsetted.

year_dimnames

Optional list of new year_dimnames of subset data to update meta data. Required if year dimension is subsetted.


Method .__transform_time_format__()

!Internal method only to be used for package development!

Usage
LPJmLMetaData$.__transform_time_format__(time_format)
Arguments
time_format

Character. Choose between "year_month_day" and "time".


Method .__transform_space_format__()

!Internal method only to be used for package development!

Usage
LPJmLMetaData$.__transform_space_format__(space_format)
Arguments
space_format

Character. Choose between "lon_lat" and "cell".


Method .__set_attribute__()

!Internal method only to be used for package development!

Usage
LPJmLMetaData$.__set_attribute__(key, value)
Arguments
key

Name of the attribute, e.g. "variable"

value

Value of the attribute, e.g. "grid"


Method new()

Create a new LPJmLMetaData object.

Usage
LPJmLMetaData$new(x, additional_attributes = list(), data_dir = NULL)
Arguments
x

A list (not nested) with meta data.

additional_attributes

A list of additional attributes to be set that are not included in file header or JSON meta file. These are ⁠c"(band_names", "variable", "descr", "unit")⁠

data_dir

Directory containing the file this LPJmLMetaData object refers to. Used to "lazy load" grid.


Method clone()

The objects of this class are cloneable with this method.

Usage
LPJmLMetaData$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


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