TransFunc: Transition function

Description Usage Arguments Details Examples

Description

Function computes organism's vertical movement based on one single environmental factor.

Usage

1
TransFunc(par, UL, LL, MOV = -1, RI = 1)

Arguments

par

numeric vector of single environmental parameter.

UL

numeric, species specific parameter threshold located in upper water column.

LL

numeric, species specific parameter threshold located in lower water column.

MOV

numeric, direction of movement when threshold is reached, Default: -1.

RI

numeric, parameter weight, Default: 1.

Details

Code generates transition function and applies that to the vertical profile of a single environmental factor (e.g. water temperature). Further details in example below...

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
## Not run: 

#Example for induced species' movement by ambient salinity and oxygen content (par)
#Generating customized salinity and oxygen profile by executing HydroGen()
set.seed(1231)
hydFic <- HydroGen(data = data.frame(Salinity = c(7,8,9,18,20),
                                     Oxygen = c(6,5,4,3,0)), by = 25)
 
#Generating a bunch of randomly distributed individuals (n = 20)
ind <- data.frame(runif(20, 1, nrow(hydFic)))
 
#Executing transition functions by applying TransFunc()
#Salinity: Maximum strength of downward movement (MOV = -1) when par <= upper limit (UL)
#Oxygen: Maximum strength of upward movement (MOV = 1) when par <= lower limit (LL)

movSal <- TransFunc(par = hydFic$Salinity, UL = 8, LL = 11)
movOx  <- TransFunc(par = hydFic$Oxygen, UL = 2, LL = 1, MOV = 1)
 
#Assigning strength and direction of movement to each individual
ind$movSal <- movSal[ind[,1]]
ind$movOx  <- movOx[ind[,1]]
colnames(ind) <- c("CurrentDepthOfIndividual", "PredictedMovementBy:Sal", "PredictedMovementBy:Ox")
head(ind, 10)
 
#Setting graphical paramaters
sig        <- c(25, 21, 24)
pa         <- cbind(hydFic$Salinity, hydFic$Oxygen)
col        <- c("limegreen", "blue")
ind$simSal <- sig[sign(movSal[ind[,1]])+2]
ind$simOx  <- sig[sign(movOx[ind[,1]])+2]
lsal       <- c(tail(which(hydFic$Salinity <= 8), 1), tail(which(hydFic$Salinity <= 11), 1))
lox        <- c(head(which(hydFic$Oxygen <= 2), 1), head(which(hydFic$Oxygen <= 1), 1))
limline    <- cbind(lsal, lox)
tit        <- c("Salinity profile including", "Oxygen profile including", 
                "predicted individual movement\nand its strength")
xl         <- c("Practical salinity [PSU]", "Oxygen content [ml/l]")
yl         <- c("Water depth [m]", "")
 
#Plotting
par(mfrow = c(1,2),
    mar = c(5.1, 4.1, 4.1, 2.1))
for(i in 1:2){
  plot(pa[,i], c(1:length(pa[,i])), ylim = c(length(pa[,i]),1), xlab = xl[i], ylab = yl[i],
       type = "l", col = col[i], lwd = 2, main = paste(tit[i], tit[3], sep = "\n"))
  abline(h = limline[,i], col = "gray60", lty = 2)
  text(c(19, 5.5)[i], c(limline[1,i]+2, limline[2,i]+2), c("UL", "LL"))
  points(seq(min(pa[,i]), max(pa[,i]), length.out = 20), ind[,1], 
         pch = ind[,i+3], cex = (ind[,i+1] * -1.3) ^ 4 + 2, bg = "grey")
  }

## End(Not run)

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