cpf2df: Convert CPForage model (list structure) to dataframe.

Description Usage Arguments Value Examples

View source: R/cpf2df.R

Description

Convert CPForage model (list structure) to dataframe.

Usage

1
cpf2df(modelRun)

Arguments

modelRun

CPForage model

Value

Dataframe containing spatial data from CPForage simulation

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
#Create test world for run
nu_i<-0.15/3600 #Nectar production/hr for a single flower
flDens<-200 #Flower density/m2 - represents early canola bloom
e_i<-14.35 #Energetic value/unit
l_i<-0.87 #Canola standing crop (0.87uL)
f_i<-3 #Inter-flower flight time
#World structure
cellSize<-10 #10m cells (100m^2)
worldSize<-120 #120x120m field (100x100m field with 10m buffer zone with weeds in it)
world1<-list(mu=matrix(1/3600,worldSize/cellSize,worldSize/cellSize),  #Weeds produce 1uL/hr
             flDens=matrix(3*(cellSize^2),worldSize/cellSize,worldSize/cellSize), #1 fls/m2
             e=matrix(8,worldSize/cellSize,worldSize/cellSize), #worth about 75% of canola
             l=matrix(3,worldSize/cellSize,worldSize/cellSize), #max nectar = 3uL
             f=matrix(5,worldSize/cellSize,worldSize/cellSize), #5 second flight time b/w fls
             alphaVal=matrix(0.013,worldSize/cellSize,worldSize/cellSize), #Alpha value (J/s*uL)
             cellSize=cellSize,
             forageType='random') #Competition for flowers within patch
world1$mu[c(2:11),c(2:11)]<-nu_i #Per-flower nectar production in
# canola-filled cells
world1$flDens[c(2:11),c(2:11)]<-flDens*cellSize^2 #Flower number per cell
world1$e[c(2:11),c(2:11)]<-e_i #Energy production in canola-filled cells
world1$l[c(2:11),c(2:11)]<-l_i #Standing crop in cells with no competition
world1$f[c(2:11),c(2:11)]<-f_i #Inter-flower flight time world1$patchLev

#Constants for foragers
honeybeeConstants<-list(L_max=59.5, #Max load capacity (uL)
                        v=7.8, #Velocity (m/s) - Unloaded flight speed
                        betaVal=0.102/59.5, #Proportion reduction in completely loaded flight speed (1-v/v_l)
                        p_i=1, # Max loading rate (uL/s)
                        h=1.5, #Handling time per flower (s)
                        c_f=0.05, #Unloaded flight energetic cost (J/s)
                        c_i=0.0042, #Cost of non-flying activity
                        H=100) #Time spent in the hive (s)

#Nest structure (social rate maximizers)
nests1<-list(xloc=1,yloc=1,n=1000,whatCurr='rat',sol=FALSE,
             constants=honeybeeConstants,eps=0,steps=c(50,5,1))

#Run model
testOutput1<-forageMod(world1,nests1,2000,verbose=FALSE,parallel=FALSE)

nests_df <- cpf2df(nests1) #Convert to dataframe
head(nests_df)

samuelVJrobinson/CPForage documentation built on Jan. 20, 2021, 6:22 p.m.