Learn R Programming

Toolkit for Basic LPJmL Handling

R package lpjmlkit, version 1.0.11

Purpose and Functionality

A collection of basic functions to facilitate the work with the Dynamic Global Vegetation Model (DGVM) Lund-Potsdam-Jena managed Land (LPJmL) hosted at the Potsdam Institute for Climate Impact Research (PIK). It provides functions for performing LPJmL simulations, as well as reading, processing and writing model-related data such as inputs and outputs or configuration files.

Overview

LPJmL Runner  to perform LPJmL simulations

LPJmL Runner only supports appropriately configured Unix-based operating systems.

  • write_config() write config.json files using a data frame with parameters to be changed and a base configuration file
  • check_config() check if generated config.json files are valid for LPJmL simulations
  • run_lpjml() run LPJmL directly (e.g. single cell simulations) or  submit_lpjml() to SLURM (e.g. global simulations)

LPJmL Data  for reading and processing LPJmL data

  • read_io() read LPJmL input and output as a LPJmLData object, containing the data array and LPJmLMetaData

    • plot() the data or get insights via summary() and other base stats
    • transform() it to other time and space formats
    • subset() the underlying data
    • as_array(), as_tibble() and as_raster() / as_terra() to export into common R data formats
  • read_meta() read meta or header files as LPJmLMetaData object

miscellaneous

  • calc_cellarea() to calculate the area of LPJmLData objects underlying grid

or for other objects latitudes

  • functions to handle LPJmL file headers, read_header() read the header of LPJmL files, get_headersize() get the size of a file header or create_header() to create a header object for writing input files
  • get_datatype() get information on the data type used in different LPJmL files
  • asub() functionality of the subset method to be used on a base array, also to replace data
  • ... more functions via library(help = "lpjmlkit")

Installation

For installation of the most recent package version an additional repository has to be added in R:

options(repos = c(CRAN = "@CRAN@", pik = "https://rse.pik-potsdam.de/r/packages"))

The additional repository can be made available permanently by adding the line above to a file called .Rprofile stored in the home folder of your system (Sys.glob("~") in R returns the home directory).

After that the most recent version of the package can be installed using install.packages:

install.packages("lpjmlkit")

Package updates can be installed using update.packages (make sure that the additional repository has been added before running that command):

update.packages()

Tutorial

The package comes with vignettes describing the basic functionality of the package and how to use it. You can load them with the following command (the package needs to be installed):

vignette("lpjml-data")   # LPJmL Data
vignette("lpjml-runner") # LPJmL Runner

Questions / Problems

In case of questions / problems please contact Jannes Breier jannesbr@pik-potsdam.de.

Citation

To cite package lpjmlkit in publications use:

Breier J, Ostberg S, Wirth S, Minoli S, Stenzel F, Müller C (2023). lpjmlkit: Toolkit for Basic LPJmL Handling. doi: 10.5281/zenodo.7752812 (URL: https://doi.org/10.5281/zenodo.7752812), R package version 1.0.11, <URL: https://github.com/PIK-LPJmL/lpjmlkit>.

A BibTeX entry for LaTeX users is

@Manual{,
 title = {lpjmlkit: Toolkit for Basic LPJmL Handling},
 author = {Jannes Breier and Sebastian Ostberg and Stephen Björn Wirth and Sara Minoli and Fabian Stenzel and Christoph Müller},
 year = {2023},
 note = {R package version 1.0.11},
 doi = {10.5281/zenodo.7752812},
 url = {https://github.com/PIK-LPJmL/lpjmlkit},
}

Copy Link

Version

Install

install.packages('lpjmlkit')

Monthly Downloads

1

Version

1.0.11

License

AGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Jannes Breier

Last Published

March 24th, 2023

Functions in lpjmlkit (1.0.11)

LPJmLData

LPJmL data class
as_header

Coerce LPJmLMetaData to an LPJmL header object
as_terra

Coerce an LPJmLData object to a terra object
LPJmLMetaData

LPJmL meta data class
as_array

Coerce an LPJmLData object to an array
as_list

Coerce LPJmLMetaData to a list
LPJmLGridData

LPJmL grid data class
add_grid

Add grid to an LPJmLData object
as_tibble

Coerce an LPJmLData object to a tibble
as_raster

Coerce an LPJmLData object to a Raster* object
get_headersize

Determine the size of an LPJmL input/output file header
detect_io_type

Detect the file type of an LPJmL input/output file
check_config

Check the validity of LPJmL config JSON files
create_header

Create a new LPJmL input/output file header
get_header_item

Retrieve information from an LPJmL input/output file header
asub

Subset a named array
dimnames.LPJmLData

Dimnames of an LPJmLData data array
dim.LPJmLData

Dimensions of an LPJmLData data array
get_datatype

Data type of an LPJmL input/output file
set_header_item

Set information in an LPJmL input (or output) file header
run_lpjml

Run LPJmL model
plot.LPJmLData

Plot an LPJmLData object
make_lpjml

Compile LPJmL model
read_header

Read header (any version) from LPJmL input/output file
read_config

Read an LPJmL configuration file
calc_cellarea

Calculate the cell area of LPJmL cells
read_meta

Read an LPJmL meta file or binary file header
read_io

Read LPJmL input and output files
length.LPJmLData

Length of an LPJmLData data array
lpjmlkit-package

lpjmlkit: Toolkit for Basic LPJmL Handling
transform

Transform an LPJmLData object
summary.LPJmLData

LPJmLData object summary
write_config

Write LPJmL config files (JSON)
write_header

Write LPJmL header object to an LPJmL input (or output) file
submit_lpjml

Submit LPJmL model simulation to SLURM
subset.LPJmLData

Subset an LPJmLData object