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 |
Package containing the LPJ-Object-Class together with relevant functions and methods.
Package: | lpjclass |
Type: | Package |
Version: | 1.11 |
Date: | 2016-09-20 |
License: | LGPL-3 |
LazyLoad: | yes |
Susanne Roliniski, Benjamin Bodirsky, Katharina Waha, Jan Philipp Dietrich
Maintainer: Susanne Rolinski <[email protected]>
Function calculates cell-and crop-specific area-weighted mean yield from rainfed and irrigated yield from a lpj object.
area.weighted.yield(data, nbands=32, year=2000, landusefile, gridfile)
area.weighted.yield(data, nbands=32, year=2000, landusefile, gridfile)
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 |
Default for nbands is 32 for LPJmL runs with 16 crops (incl. sugarcane and bioenergy), default for year is 2000
The function returns a list, with 2 lpj objects: "data" containing the yield and "croparea" containing the crop area in ha
Katharina Waha
## 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)
## 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)
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).
x |
An object that should be either tested or transformed as/to an LPJ-object. |
Jan Philipp Dietrich, Susanne Rolinski, Katharina Waha, Benjamin Bodirsky
showClass("lpj")
showClass("lpj")
General LPJ-class-dataset
Please do not directly access that data. It should be only used by library functions.
Jan Philipp Dietrich
Creates a new LPJ object
new.lpj(cells_and_regions,years,names,irrigation)
new.lpj(cells_and_regions,years,names,irrigation)
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 |
an empty lpj object filled with NAs, with the given dimnames
Benjamin Bodirsky, Katharina Waha
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
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
Reads a LPJmL input file and converts it to a LPJ-object
read.LPJ_input( file_name, out_years = c("y1995", "y2005"), namesum = FALSE, four_d = FALSE, ncells = 59199, swap = "little", rule4binary = NULL )
read.LPJ_input( file_name, out_years = c("y1995", "y2005"), namesum = FALSE, four_d = FALSE, ncells = 59199, swap = "little", rule4binary = NULL )
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 |
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.
x |
LPJ-object |
Benjamin Bodirsky, Susanne Roliniski, Marcos Alves
Reads a file which contains LPJ/LPJmL output and converts to a LPJ-object
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 )
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 )
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 |
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
x |
LPJ-object |
Susanne Rolinski, Benjamin Bodirsky
## 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)
## 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 respectively. Works exactly as for arrays.
works as round(x) for arrays.
Helps to understand cropnames and abbreviation used in LPJmL and MAgPIE
whatis(x)
whatis(x)
x |
a character with quotes. |
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.
Katharina Waha
whatis("tece")
whatis("tece")