output.operation: output.operation Do user defined operations on LPJ outputs.

View source: R/output.operation.r

output.operationR Documentation

output.operation Do user defined operations on LPJ outputs.

Description

Convert one LPJ output file by a user defined operation. Write out new data in LPJ output (clm) format.

Usage

output.operation(outfile, operation, newfile = paste(outfile[["path"]],
  "_new", sep = ""), VERBOSE = FALSE)

Arguments

outfile

the information list of LPJ output, see example.

operation

a user defined function/operation. Note: this function should have only one scalar/vector as an argument and return a scalar/vector value too.

Examples

lpjoutfile<-list()
lpjoutfile[["path"]]="../tests/test_data/soilc.bin"
lpjoutfile[["nyears"]]=40
lpjoutfile[["nbands"]]=1
lpjoutfile[["ncells"]]=67420
lpjoutfile[["start_year"]]=1901

fun<-function(old){ # here identify the user operation
    new <- old
    new[old>0] <- old/1000
    return((old/10000))
}
output.operation(lpjoutfile, fun, newfile="soilc_new.bin")

sinanshi/LPJmL_RUtil documentation built on Feb. 8, 2023, 5:56 p.m.