EvalFunc: Evaluation function

Description Usage Arguments Details Examples

Description

Function computes the organism's vertical movement based on a set of single environmental factors.

Usage

1
2
EvalFunc(hydro, faclist, nInd, mSpeed = 1, tStep = 1, rWalk = c("ND",
  0, 0.1, 0.1), dimList)

Arguments

hydro

data frame including set of environmental parameters.

faclist

data frame specifying the species specific thresholds that induce a vertical movement.

nInd

numeric, number of individuals that are included in modelled environment.

mSpeed

numeric, maximum vertical distance that can be reached per time interval, Default: 1.

tStep

numeric, number of time increments, Default: 1.

dimList

numeric, intended return. See 'Details'.

rwalk

numeric vector indicating the demographic noise of the modelled population. A pre-defined random walk is included by default. See 'Details'.

rWalkOff

logical, if TRUE, demographic noise is turned off. If FLASE, a pre-defined random walk is included (default). See 'Details'.

Details

The arguments hydro and faclist should be of class data.frame. Note that colnames of hydro and faclist have to be equal. Required layouts are given in 'Examples'.

If the argument nInd is provided, the model output includes the position of each individual for each time increament. The individuals are randomly distributed over the entire water column when the calculations begin. Note that computation time is strongly correlated with the amount of individuals included in the model environment.

Note that the arguments mSpeed and tStep are linked, i.e. mSpeed is the vertical distance each individual can reach in a time interval given by tStep. For example, if you aim to predict the vertical ditribution for an entire day with one-minute-intervals, than tStep is set to 1440 minutes, and consequently, mSpeed must be converted to meter per minute. For further details see 'Examples'.

The argument dimList provides three diffrent options of what specific data type is returned. Further details need to be written. See 'Examples'.

Function makes use of RWalk. Default: c("ND", 0, 0.1, 0.1). If rWalk is set to NULL, the random walk is turned off and each individual would remain at the given water depth as long as the ambient environment stays sufficient enough.

Further details in 'Examples'.

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
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
## Not run: 

#-1-----Example for static hydrography (stat.hyd) and given factor list (fl)
#-1.1---Generating hydrography commonly found in the Bornholm Basin (Baltic Sea)
set.seed(123456)
stat.hyd <- HydroGen(data.frame(Temp = c(17,13,4,4.8,8),
                                Ox = c(6,5,3,2,0),
                                Sal = c(7,8,9,18,20)), by = 25)
                               
#-1.2---Generating factor list for any kind of organism
fac  <- c("UL", "LL", "MOV", "RI")
temp <- c(  10,    8,    -1,  0.33)
ox   <- c(   1,  0.5,     1,  0.33)
sal  <- c(  10,   11,    -1,  0.33)
fl   <- data.frame(rbind(temp, ox, sal))
colnames(fl) <- fac
rownames(fl) <- colnames(stat.hyd)

#-1.3.1-Executing EvalFunc(defaults) and calculating free vertival range of organisms
output.a <- EvalFunc(hydro = stat.hyd, faclist = fl)
FVR.a    <- which(output.a[,"PredMovByAllPar",] == 0)

#-1.3.2-Alternatively use EvalFunc(dimList = 2) for extracting "PredMovByAllPar"
output.b <- EvalFunc(hydro = stat.hyd, faclist = fl, dimList = 2)
FVR.b    <- which(output.b$PredMovByAllPar == 0)

#-1.4---Plotting
par(mfrow = c(1,1))
df <- as.data.frame(output.a)
plot(x = 0, ylim = c(nrow(df), 0), xlim = c(min(df[,1:3]), max(df[,1:3])), 
     type = "n", ylab = "Water depth [m]", main = "Hydrography and free vertical range (shaded area)",
     xlab = "Temperature (T) / Oxygen (O) / Salinty (S)")
rect(0, max(FVR.a), 20, min(FVR.a), angle = 45, density = 6, col = "grey70")
for(i in 1:3){
  c <- c("red", "blue", "darkgreen")
  lines(df[,i], as.numeric(rownames(df)), lty = i, lwd = 2, col = c[i])
  posY <- round(nrow(df) * 0.9, 0)
  points(df[posY,i], posY, pch = 21, bg = "white", cex = 4)
  text(df[posY,i], posY, substr(colnames(df)[i], 1, 1))
}

#-2-----Example for dynamic hydrography (DynHyd) including intra daily light regimes 
#-2.1---Generating interpolated hydrography profiles for CTDs by use of InterPro()
set.seed(123)
hyd.a <- HydroGen(data.frame(Temp = c(12,7,5,7,8,9), Ox = c(8,7,5,3,2,0)), by = 20)
hyd.b <- HydroGen(data.frame(Temp = c(10,7,4.8,7,8), Ox = c(8,7,6,5,0)), by = 25)
hyd.c <- HydroGen(data.frame(Temp = c(11,4,8), Ox = c(8,4,0)), by = 50)
hyd.d <- HydroGen(data.frame(Temp = c(11,7,4,6,8), Ox = c(8,7,6,4,0)), by = 25)
hyds <- list(hyd.a, hyd.b, hyd.c, hyd.d)
tp <- matrix(c(1,2,2,3,3,4), ncol = 3)
dyn.hyd <- list()
for(i in 1:3){dyn.hyd <- c(dyn.hyd, InterPro(data = list(hyds[[tp[1,i]]], hyds[[tp[2,i]]]), 
                                             steps = 59, opList = TRUE))}

#-2.2---Generating light regimes (19:00 - 22:00) by use of date-at-location specific regression 
light <- LightBornholm(depth   = c(0:99), ATTk = -0.16, lx = TRUE,
                       daytime = seq(19,22,0.01666667), min = 2)

for(i in 1:180){dyn.hyd[[i]] <- cbind(dyn.hyd[[i]], light[,i], light[,i])
colnames(dyn.hyd[[i]]) <- c(colnames(hyd.a), "UpperLight", "LowerLight")}

hyd <- array(unlist(dyn.hyd), dim = c(dim(dyn.hyd[[1]]), length(dyn.hyd)), 
             dimnames = list(NULL,colnames(dyn.hyd[[1]]), NULL))

#-2.3---Generating factor list for any kind of organism (e.g. European sprat)
fac      <- c("UL",  "LL", "MOV", "RI")
temp     <- c(  4,     5,      0,  0.5)
ox       <- c(   1,   0.5,     1,  0.5)
lightUp  <- c( 500,    10,    -1,  0.2)
lightLo  <- c( 0.1, 0.005,     1,  0.2)
fl       <- data.frame(rbind(temp, ox, lightUp, lightLo))
colnames(fl) <- fac
rownames(fl) <-  colnames(hyd)

#-2.3---Executing EvalFunc() for given hydro (including light regimes) and factor list
df     <- EvalFunc(hydro = hyd, faclist = fl)
head(df[,,1],10)

#-2.4---Plotting
lists  <- EvalFunc(hydro = hyd, faclist = fl, dimList = 2)
PVD    <- lists$PredVerDi
image  <- as.raster(PVD)
time   <- format(seq(from = as.POSIXct("2001-06-04 19:00"), 
                     to = as.POSIXct("2001-06-04 22:00"), 
                     by = "min"), "%H:%M")[c(1,31,61, 91,121,151,181)]

AS <- function(m) t(m)[,nrow(m):1]
FS <- function(x) (x-min(x))/(max(x)-min(x)) 

layout(matrix(c(1,2,3), 3, 1), 
       widths=c(1,1,1), heights=c(1,1,2))

#-2.4.1-Temperature profile
par(mar = c(0.5,4.1,2.1,2.1))
colfunc <- colorRampPalette(c("blue1", "lightblue", "limegreen", "yellowgreen", 
                              "yellow", "orange", "red"))
image(AS(lists$Temp), useRaster=TRUE, col = colfunc(500), axes = FALSE, ylab = "Water depth [m]")
legend(-0.04, 1.05, "TEMP",  bty="n", cex = 1.8, xjust = 0, yjust = 1)
abline(v = seq(0,1,length.out = 7), h = seq(0,1,0.2), col = "grey70", lty = 3)
axis(2, at = seq(0,1,0.2), labels = seq(100,0,-20), las = 2); box()

#-2.4.2-Oxygen profile
par(mar = c(2,4.1,0.5,2.1))
colfunc <- colorRampPalette(c("slategray4", "slategray", "slategray3", "slategray2", 
                              "slategray1", "white", "orangered1"))
image(AS(lists$Ox), useRaster=TRUE, col = rev(colfunc(500)), axes = FALSE, ylab = "Water depth [m]")
legend(-0.04, 1.05, "OX",  bty="n", cex = 1.8, xjust = 0, yjust = 1)
abline(v = seq(0,1,length.out = 7), h = seq(0,1,0.2), col = "grey70", lty = 3)
axis(2, at = seq(0,1,0.2), labels = seq(100,0,-20), las = 2); box()

#-2.4.2-Predicted vertical distribution of sprat - high probabilty (bright araes) vs. low prob (dark areas)
par(mar = c(5.1,4.1,0.5,2.1))
colfunc <- colorRampPalette(c("black", "white"))
image(AS(lists$PredVerDi), useRaster=TRUE, col = colfunc(500), axes = FALSE, ylab = "Water depth [m]", 
      xlab = "Day time [UTC+2]")
legend(-0.04, 1.03, "MODEL",  bty="n", cex = 1.8, xjust = 0, yjust = 1)
abline(v = seq(0,1,length.out = 7), h = seq(0,1,0.2), col = "grey70", lty = 3)
axis(2, at = seq(0,1,0.2), labels = seq(100,0,-20), las = 2)
axis(1, at = seq(0,1,length.out = 7), labels = time); box()

#-2.4.2-Adding movement pattern for 60 individuals of European sprat
set.seed(12345)
nIndivi <- 60
testInd <- EvalFunc(hydro = hyd, faclist = fl, nInd = nIndivi, mSpeed = 3, rWalk = c("ND", 0, 0.1, 0.03))
colfunc <- colorRampPalette(c("blue", "limegreen", "yellow", "orange", "red"))
for(i in 1:nIndivi){
  lines(FS(c(1:length(testInd[i,]))), 1-testInd[i,]/nrow(lists$PredVerDi), 
        col = colfunc(nIndivi)[i], cex = 1.2)
}

par(mfrow = c(1,1))

## End(Not run)

herrmannrobert/VerDi documentation built on June 10, 2019, 7:32 a.m.