build_dz: Build Atlantis dz Values

Description Usage Arguments Details Value Examples

View source: R/utils.R

Description

Build dz layer values for Atlantis from a bottom value, up through successive intervals. Each value is the positive offset required to rise to the top of the current interval.

Usage

1
2
3
4
build_dz(
  z,
  zlayers = c(-Inf, -2000, -1000, -750, -400, -300, -200, -100, -50, -20, 0)
)

Arguments

z

lowermost value

zlayers

intervals of layer values

Details

Offset values are returned to move from z against the intervals in zlayers. The intervals are assumed to be sorted and increasing in value from -Infinity. Once the maximum layer is reached the result is padded by that top value.

Value

numeric vector of offset values

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## sanity tests
build_dz(-5000)
build_dz(-1500)
##build_dz(300)  ## error
build_dz(0)    ## ok
## data
dd <- c(-4396.49, -2100.84, -4448.81, -411.96, -2703.56, -5232.96, 
       -4176.25, -2862.37, -3795.6, -1024.64, -897.93, -1695.82, -4949.76, 
    -5264.24, -2886.81)
## all values in a matrix for checking
## [zlayers, dd]
dzvals <- sapply(dd, build_dz)
## process into text
f1 <- function(x) sprintf("somelabel,%i,%s", x, paste(build_dz(dd[x]), collapse = ","))
tex1 <- sapply(seq(length(dd)),  f1)
## for example
f2 <- function(x) {
sprintf("morelabel,%i,%s", x, paste(as.integer(build_dz(dd[x])), collapse = ","))
}
tex2 <- sapply(seq(length(dd)),  f2)

mdsumner/rbgm documentation built on April 20, 2020, 9:43 p.m.