Mercurial > repos > greg > insect_phenology_model
changeset 47:d6482112bf35 draft
Uploaded
author | greg |
---|---|
date | Mon, 13 Nov 2017 10:53:31 -0500 |
parents | d7e406de8094 |
children | 66712cdec7c0 |
files | insect_phenology_model.R |
diffstat | 1 files changed, 27 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/insect_phenology_model.R Mon Nov 13 10:42:31 2017 -0500 +++ b/insect_phenology_model.R Mon Nov 13 10:53:31 2017 -0500 @@ -60,7 +60,8 @@ dxp <- temperature_data[row, 6] # Mean temperature for current row. dmean <- 0.5 * (dnp + dxp) - dd <- 0 # initialize degree day accumulation + # Initialize degree day accumulation + dd <- 0 if (dxp < threshold) { dd <- 0 } @@ -239,7 +240,7 @@ temp.profile <- get_temperature_at_hour(latitude, temperature_data, daylight_length_vector, row, opt$num_days) mean.temp <- temp.profile[1] dd.temp <- temp.profile[2] - dd.day[day] <- dd.temp + dd.day[row] <- dd.temp # Trash bin for death. death.vec <- NULL # Newborn. @@ -268,7 +269,7 @@ } else if (vec.ind[2] == 3 | vec.ind[2] == 4 | vec.ind[2] == 5) { # For adult. - if (day < day.kill) { + if (doy < day.kill) { death.prob = opt$adult_mort * mortality.adult(mean.temp) } else { @@ -286,7 +287,7 @@ # Event 1 end of diapause. if (vec.ind[1] == 0 && vec.ind[2] == 3) { # Overwintering adult (previttelogenic). - if (photoperiod > opt$photoperiod && vec.ind[3] > 68 && day < 180) { + if (photoperiod > opt$photoperiod && vec.ind[3] > 68 && doy < 180) { # Add 68C to become fully reproductively matured. # Transfer to vittelogenic. vec.ind <- c(0, 4, 0, 0, 0) @@ -352,7 +353,7 @@ } # Event 2 oviposition -- for gen 1. - if (vec.ind[2] == 4 && vec.ind[1] == 1 && mean.temp > 12.5 && day < 222) { + if (vec.ind[2] == 4 && vec.ind[1] == 1 && mean.temp > 12.5 && doy < 222) { # Vittelogenic stage, 1st generation if (vec.ind[4] == 0) { # Just turned in vittelogenic stage. @@ -413,7 +414,7 @@ current.gen <- vec.ind[1] # Transfer to old nym stage. vec.ind <- c(current.gen, 2, 0, 0, 0) - if (photoperiod < opt$photoperiod && day > 180) { + if (photoperiod < opt$photoperiod && doy > 180) { vec.ind[5] <- 1 } # Prepare for diapausing. } @@ -491,26 +492,30 @@ gen2 <- sum(vec.mat[,1] == 2) # Sum of all adults. n.adult <- sum(vec.mat[,2] == 3) + sum(vec.mat[,2] == 4) + sum(vec.mat[,2] == 5) - # Gen eration 0 pop size. - gen0.pop[day] <- gen0 - gen1.pop[day] <- gen1 - gen2.pop[day] <- gen2 - S0[day] <- s0 - S1[day] <- s1 - S2[day] <- s2 - S3[day] <- s3 - S4[day] <- s4 - S5[day] <- s5 - g0.adult[day] <- sum(vec.mat[,1] == 0) - g1.adult[day] <- sum((vec.mat[,1] == 1 & vec.mat[,2] == 3) | (vec.mat[,1] == 1 & vec.mat[,2] == 4) | (vec.mat[,1] == 1 & vec.mat[,2] == 5)) - g2.adult[day] <- sum((vec.mat[,1]== 2 & vec.mat[,2] == 3) | (vec.mat[,1] == 2 & vec.mat[,2] == 4) | (vec.mat[,1] == 2 & vec.mat[,2] == 5)) + + # Generation 0 pop size. + gen0.pop[row] <- gen0 + gen1.pop[row] <- gen1 + gen2.pop[row] <- gen2 - N.newborn[day] <- n.newborn - N.death[day] <- n.death - N.adult[day] <- n.adult + S0[row] <- s0 + S1[row] <- s1 + S2[row] <- s2 + S3[row] <- s3 + S4[row] <- s4 + S5[row] <- s5 + + g0.adult[row] <- sum(vec.mat[,1] == 0) + g1.adult[row] <- sum((vec.mat[,1] == 1 & vec.mat[,2] == 3) | (vec.mat[,1] == 1 & vec.mat[,2] == 4) | (vec.mat[,1] == 1 & vec.mat[,2] == 5)) + g2.adult[row] <- sum((vec.mat[,1]== 2 & vec.mat[,2] == 3) | (vec.mat[,1] == 2 & vec.mat[,2] == 4) | (vec.mat[,1] == 2 & vec.mat[,2] == 5)) + + N.newborn[row] <- n.newborn + N.death[row] <- n.death + N.adult[row] <- n.adult } # end of days specified in the input temperature data dd.cum <- cumsum(dd.day) + # Collect all the outputs. S0.rep[,N.rep] <- S0 S1.rep[,N.rep] <- S1