Package 'lpjclass'

Title: LPJ Class Functions
Description: Package containing the LPJ-Object-Class together with relevant functions and methods.
Authors: Katharina Waha [aut], Benjamin Bodirsky [aut], Susanne Roliniski [aut], Jan Philipp Dietrich [aut, cre], Marcos P. P. Alves [aut]
Maintainer: Jan Philipp Dietrich <[email protected]>
License: LGPL-3 | file LICENSE
Version: 1.19.7
Built: 2024-11-11 03:43:48 UTC
Source: https://github.com/pik-piam/lpjclass

Help Index


LPJ Class Functions

Description

Package containing the LPJ-Object-Class together with relevant functions and methods.

Details

Package: lpjclass
Type: Package
Version: 1.11
Date: 2016-09-20
License: LGPL-3
LazyLoad: yes

Author(s)

Susanne Roliniski, Benjamin Bodirsky, Katharina Waha, Jan Philipp Dietrich

Maintainer: Susanne Rolinski <[email protected]>


area.weighted.yield

Description

Function calculates cell-and crop-specific area-weighted mean yield from rainfed and irrigated yield from a lpj object.

Usage

area.weighted.yield(data, nbands=32, year=2000, landusefile,
gridfile)

Arguments

data

lpj object

nbands

integer. Number of bands in yield and landuse input file from LPJmL run.

year

integer. Landuse input file will be read only for this year and used as weight.

landusefile

character. Name of landuse input file used in LPJmL run incl. name of folder

gridfile

character. Name of grid output file from LPJmL run incl. name of folder

Details

Default for nbands is 32 for LPJmL runs with 16 crops (incl. sugarcane and bioenergy), default for year is 2000

Value

The function returns a list, with 2 lpj objects: "data" containing the yield and "croparea" containing the crop area in ha

Author(s)

Katharina Waha

See Also

readLPJ, new.lpj

Examples

## Not run: mean.yield<-area.weighted.yield(yield,landusefile="D:/LPJ/input/cft1700_2005_16cfts_SR.bin",
					     gridfile="D:/LPJ/run1/grid.bin")
## End(Not run)

Class "lpj" ~~~

Description

The LPJ class is a data format for cellular LPJ data with a close relationship to the array data format. is.lpj tests if x is an LPJ-object, as.lpj transforms x to an LPJ-object (if possible).

Arguments

x

An object that should be either tested or transformed as/to an LPJ-object.

Author(s)

Jan Philipp Dietrich, Susanne Rolinski, Katharina Waha, Benjamin Bodirsky

See Also

readLPJ, read.LPJ_input

Examples

showClass("lpj")

lpjclassdata

Description

General LPJ-class-dataset

Details

Please do not directly access that data. It should be only used by library functions.

Author(s)

Jan Philipp Dietrich


new.lpj

Description

Creates a new LPJ object

Usage

new.lpj(cells_and_regions,years,names,irrigation)

Arguments

cells_and_regions

dimnames for cells in the format "country.cellnumber"

years

dimnames for years in the format "yXXXX"

names

dimnames for names

irrigation

dimnames for irrigation

Value

an empty lpj object filled with NAs, with the given dimnames

Author(s)

Benjamin Bodirsky, Katharina Waha

See Also

lpj,readLPJ

Examples

cells <- c("Russia.1","Russia.2")
 years <- "y1995"
 categories <- c("TeCe","TrRi")
 irrigation <- c("rainfed","irrigated")
 a <- new.lpj(cells_and_regions=cells,years=years,names=categories,irrigation=irrigation)
 a

read.LPJ_input

Description

Reads a LPJmL input file and converts it to a LPJ-object

Usage

read.LPJ_input(
  file_name,
  out_years = c("y1995", "y2005"),
  namesum = FALSE,
  four_d = FALSE,
  ncells = 59199,
  swap = "little",
  rule4binary = NULL
)

Arguments

file_name

Filename with extension and folder

out_years

years to be red out in the form of a vector of year strings, e.g. c(y1995,y2005)

namesum

if true, all bands/colums of the dataset are added. Sometimes useful to handle large datasets. Overwrites four_d

four_d

if true, it is assumed that data exists for both rainfed and irrigated crops.

ncells

number of cells

swap

Depends on the binary format of the data

rule4binary

Rule based transformation of the outputs into binary values

Details

This function reads in LPJ-input files, using its header information. So far, tested for landuse input. 'rule4binary' combined with 'namesum = T' allow for the rule based counting of events.

Value

x

LPJ-object

Author(s)

Benjamin Bodirsky, Susanne Roliniski, Marcos Alves

See Also

readLPJ


readLPJ

Description

Reads a file which contains LPJ/LPJmL output and converts to a LPJ-object

Usage

readLPJ(
  file_name,
  wyears,
  syear = 1901,
  averaging_range = NULL,
  file_folder = "",
  file_type = NULL,
  bands = 41,
  monthly = FALSE,
  bytes = 4,
  years = NULL,
  ncells = 59199,
  soilcells = FALSE,
  headlines = 0,
  datatype = numeric(),
  gridfile = "",
  cellyear = FALSE,
  flexbands = FALSE
)

Arguments

file_name

a character string naming a file with extension but without folder

wyears

integer. a vector containing the years of interest

syear

integer. The first year

averaging_range

integer.

file_folder

a character string naming the folder where the file is stored

file_type

a character string, usually "bin" for binary files

bands

integer. The number of bands (e.g. crops, months). Will be 12 if monthly==TRUE

monthly

logical.

bytes

integer. The size of data type

years

integer. The number of years in file

ncells

integer.

soilcells

Bool. If 67420 cells are present in the file, should only the 59199 for MAgPIE be returned?

headlines

integer. The size of header, for output files = 0

datatype

a R data type

gridfile

a character string, currently not used

cellyear

Switch for input data format. Cellyear is the new lpjml input format. When reading in lpjml outputs set to false.

flexbands

reads in cfts for any number of bands, assumes only cfts, must be named later

Details

This function reads in LPJ/LPJmL output files. So far, tested for yield, monthly runoff, monthly temperature, monthly precipiation. Note, that number of years in file will be calculated automatically if years=NULL

Value

x

LPJ-object

Author(s)

Susanne Rolinski, Benjamin Bodirsky

See Also

read.LPJ_input

Examples

## Example for the LPJmL output file pft_harvest.pft.bin containing crop yields in gC/m2
## Not run: 
yield <- readLPJ(file_name = "pft_harvest.pft.bin", wyears = c(1998:2002),
  file_folder = "D:/LPJ/Trunk_2010_03_25/output/simulated_sdate/",
        bands = 26, gridfile = "D:/LPJ/Trunk_2010_03_25/output/simulated_sdate/grid.bin")

## End(Not run)

Round-method for LPJ objects

Description

Round-method for LPJ-objects respectively. Works exactly as for arrays.

Methods

x = "lpj"

works as round(x) for arrays.


whatis

Description

Helps to understand cropnames and abbreviation used in LPJmL and MAgPIE

Usage

whatis(x)

Arguments

x

a character with quotes.

Value

a list with four list elements on: LPJmLName - the LPJmL name, CropAreaLPJmL - the crops whose cultivated areas are contained in the LPJmL landuse input file, CropGroupMAgPIE - the FAO crops whose areas and yields are compared to MAgPIE areas and yield, RepresentativeCropLPJmL - the parameters from this crop are used for the whole group in LPJmL.

Author(s)

Katharina Waha

See Also

readLPJ,read.LPJ_input

Examples

whatis("tece")