integratefunDataFrame: Integration on the soil layers

Description Usage Arguments Value See Also Examples

Description

This function integrates the values of a zt-variable quantity within a certain thickness.

Usage

1
2
integratefunDataFrame(df, z = NULL, zrange = c(0, 500),
  formatter = "z%04d", factor = 10, rescaleWithDz = FALSE, ...)

Arguments

df

data frame or 'zoo' object with (modeled) time series.

z

vector of soil layer depths. Default is NULL and is taken from column names of df.

zrange

vector of soil layer thickness within which df values are integrated (or averaged) with approx and then integrated with integrate.

formatter

character string with decimal formatter. It is used if z or zout are string vectors. Default is "z%04d".

factor

unit factor used for conversion of z or zout from String vector to numeric vector and viceversa.

rescaleWithDz

logical value. If is TRUE the integrated value is rescaled with soil thickness (mean). Default is FALSE and the value is not rescaled.

...

further argument for approx

Value

The values of the df quantity interpolated in the zout soil depths.

See Also

approx,integrate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
data(MuntatschiniB2)
## OBSERVATION PROCESSING

obs_SWC <- MuntatschiniB2[str_detect(names(MuntatschiniB2),"SWC")]
zvalues <-  as.numeric(unlist(lapply(X=str_split(names(obs_SWC), pattern="", 
				n = Inf),FUN=function (x) {
					out <- as.numeric(x)
				    out <- out[!is.na(out)]
					out <- paste(out,collapse="")
				return(out)
})))
zformatter = "z%04d"
names(obs_SWC) <- sprintf(zformatter,zvalues)
obs_SWC <- lapply(X=obs_SWC,FUN=function(x){

				if (length(dim(x))>1) {
					max <- apply(X=x,MARGIN=1,FUN=max,na.rm=TRUE)
					min <- apply(X=x,MARGIN=1,FUN=min,na.rm=TRUE)
					mean <- apply(X=x,MARGIN=1,FUN=mean,na.rm=TRUE)
					sd <- apply(X=x,MARGIN=1,FUN=sd,na.rm=TRUE)
				} else {
				
					mean <- as.vector(x)
				 	max <-  as.vector(x)
					min <-  as.vector(x)
					sd <- NA

				}
				out <- data.frame(min=min,mean=mean,max=max,sd=sd)

				out <- as.zoo(out)
             index(out) <- as.POSIXlt(index(x))

				return(out)

})
###########
###########


simpath <- system.file("Muntatschini_pnt_1_225_B2_004",package="geotopOptim")
bin <-   "/home/ecor/local/geotop/GEOtop/bin/geotop-2.0.0"
runpath <- "/home/ecor/temp/geotopOptim_tests"

vars <- "SoilLiqContentProfileFile"

sim <- geotopZProfile(bin=bin,simpath=simpath,runpath=runpath,
clean=TRUE,variable=vars,data.frame=TRUE,level=1,zformatter=zformatter,intern=TRUE)[[vars]]

system.time(sim_int <- integratefunDataFrame(df=sim,formatter=zformatter))

ecor/geotopOptim documentation built on May 15, 2019, 8:54 p.m.