Mercurial > repos > greg > insect_phenology_model
comparison insect_phenology_model.R @ 101:691b677d8f83 draft
Uploaded
author | greg |
---|---|
date | Mon, 04 Dec 2017 13:34:28 -0500 |
parents | 52114847afff |
children | ce996e90f5a7 |
comparison
equal
deleted
inserted
replaced
100:52114847afff | 101:691b677d8f83 |
---|---|
229 # Overwintering, previttelogenic, degree-days=0, T=0, no-diapause. | 229 # Overwintering, previttelogenic, degree-days=0, T=0, no-diapause. |
230 vector.matrix <- rep(vector.ini, num_insects) | 230 vector.matrix <- rep(vector.ini, num_insects) |
231 # Complete matrix for the population. | 231 # Complete matrix for the population. |
232 vector.matrix <- base::t(matrix(vector.matrix, nrow=5)) | 232 vector.matrix <- base::t(matrix(vector.matrix, nrow=5)) |
233 # Time series of population size. | 233 # Time series of population size. |
234 tot.pop <- NULL | 234 total.population <- NULL |
235 gen0.pop <- rep(0, opt$num_days) | 235 overwintering_adult.population <- rep(0, opt$num_days) |
236 gen1.pop <- rep(0, opt$num_days) | 236 first_generation.population <- rep(0, opt$num_days) |
237 gen2.pop <- rep(0, opt$num_days) | 237 second_generation.population <- rep(0, opt$num_days) |
238 S0 <- rep(0, opt$num_days) | 238 S0 <- rep(0, opt$num_days) |
239 S1 <- rep(0, opt$num_days) | 239 S1 <- rep(0, opt$num_days) |
240 S2 <- rep(0, opt$num_days) | 240 S2 <- rep(0, opt$num_days) |
241 S3 <- rep(0, opt$num_days) | 241 S3 <- rep(0, opt$num_days) |
242 S4 <- rep(0, opt$num_days) | 242 S4 <- rep(0, opt$num_days) |
478 vector.matrix <- rbind(vector.matrix, birth.vector) | 478 vector.matrix <- rbind(vector.matrix, birth.vector) |
479 # Update population size for the next day. | 479 # Update population size for the next day. |
480 num_insects <- num_insects - num_insects.death + num_insects.newborn | 480 num_insects <- num_insects - num_insects.death + num_insects.newborn |
481 | 481 |
482 # Aggregate results by day. | 482 # Aggregate results by day. |
483 tot.pop <- c(tot.pop, num_insects) | 483 total.population <- c(total.population, num_insects) |
484 | 484 |
485 # All adults population size. | 485 # All adults population size. |
486 num_insects.adult <- sum(vector.matrix[,2] == 3) + sum(vector.matrix[,2] == 4) + sum(vector.matrix[,2] == 5) | 486 num_insects.adult <- sum(vector.matrix[,2] == 3) + sum(vector.matrix[,2] == 4) + sum(vector.matrix[,2] == 5) |
487 | 487 |
488 # Overwintering adult population size. | 488 # Overwintering adult population size. |
489 gen0.pop[row] <- sum(vector.matrix[,1] == 0) | 489 overwintering_adult.population[row] <- sum(vector.matrix[,1] == 0) |
490 # First generation population size. | 490 # First generation population size. |
491 gen1.pop[row] <- sum(vector.matrix[,1] == 1) | 491 first_generation.population[row] <- sum(vector.matrix[,1] == 1) |
492 # Second generation population size. | 492 # Second generation population size. |
493 gen2.pop[row] <- sum(vector.matrix[,1] == 2) | 493 second_generation.population[row] <- sum(vector.matrix[,1] == 2) |
494 | 494 |
495 # Egg population size. | 495 # Egg population size. |
496 S0[row] <- sum(vector.matrix[,2] == 0) | 496 S0[row] <- sum(vector.matrix[,2]==0) |
497 # Young nymph population size. | 497 # Young nymph population size. |
498 S1[row] <- sum(vector.matrix[,2] == 1) | 498 S1[row] <- sum(vector.matrix[,2]==1) |
499 # Old nymph population size. | 499 # Old nymph population size. |
500 S2[row] <- sum(vector.matrix[,2] == 2) | 500 S2[row] <- sum(vector.matrix[,2]==2) |
501 # Previtellogenic population size. | 501 # Previtellogenic population size. |
502 S3[row] <- sum(vector.matrix[,2] == 3) | 502 S3[row] <- sum(vector.matrix[,2]==3) |
503 # Vitellogenic population size. | 503 # Vitellogenic population size. |
504 S4[row] <- sum(vector.matrix[,2] == 4) | 504 S4[row] <- sum(vector.matrix[,2]==4) |
505 # Diapausing population size. | 505 # Diapausing population size. |
506 S5[row] <- sum(vector.matrix[,2] == 5) | 506 S5[row] <- sum(vector.matrix[,2]==5) |
507 | 507 |
508 P.adult[row] <- sum(vector.matrix[,1] == 0) | 508 P.adult[row] <- sum(vector.matrix[,1]==0) |
509 F1.adult[row] <- sum((vector.matrix[,1] == 1 & vector.matrix[,2] == 3) | (vector.matrix[,1] == 1 & vector.matrix[,2] == 4) | (vector.matrix[,1] == 1 & vector.matrix[,2] == 5)) | 509 F1.adult[row] <- sum((vector.matrix[,1]==1 & vector.matrix[,2]==3) | (vector.matrix[,1]==1 & vector.matrix[,2]==4) | (vector.matrix[,1]==1 & vector.matrix[,2]==5)) |
510 F2.adult[row] <- sum((vector.matrix[,1]== 2 & vector.matrix[,2] == 3) | (vector.matrix[,1] == 2 & vector.matrix[,2] == 4) | (vector.matrix[,1] == 2 & vector.matrix[,2] == 5)) | 510 F2.adult[row] <- sum((vector.matrix[,1]==2 & vector.matrix[,2]==3) | (vector.matrix[,1]==2 & vector.matrix[,2]==4) | (vector.matrix[,1]==2 & vector.matrix[,2]==5)) |
511 | 511 |
512 N.newborn[row] <- num_insects.newborn | 512 N.newborn[row] <- num_insects.newborn |
513 N.death[row] <- num_insects.death | 513 N.death[row] <- num_insects.death |
514 N.adult[row] <- num_insects.adult | 514 N.adult[row] <- num_insects.adult |
515 } # end of days specified in the input temperature data | 515 } # end of days specified in the input temperature data |
524 S4.replications[,N.replications] <- S4 | 524 S4.replications[,N.replications] <- S4 |
525 S5.replications[,N.replications] <- S5 | 525 S5.replications[,N.replications] <- S5 |
526 newborn.replications[,N.replications] <- N.newborn | 526 newborn.replications[,N.replications] <- N.newborn |
527 death.replications[,N.replications] <- N.death | 527 death.replications[,N.replications] <- N.death |
528 adult.replications[,N.replications] <- N.adult | 528 adult.replications[,N.replications] <- N.adult |
529 pop.replications[,N.replications] <- tot.pop | 529 pop.replications[,N.replications] <- total.population |
530 P.replications[,N.replications] <- gen0.pop | 530 P.replications[,N.replications] <- overwintering_adult.population |
531 F1.replications[,N.replications] <- gen1.pop | 531 F1.replications[,N.replications] <- first_generation.population |
532 F2.replications[,N.replications] <- gen2.pop | 532 F2.replications[,N.replications] <- second_generation.population |
533 P_adults.replications[,N.replications] <- P.adult | 533 P_adults.replications[,N.replications] <- P.adult |
534 F1_adults.replications[,N.replications] <- F1.adult | 534 F1_adults.replications[,N.replications] <- F1.adult |
535 F2_adults.replications[,N.replications] <- F2.adult | 535 F2_adults.replications[,N.replications] <- F2.adult |
536 } | 536 } |
537 | 537 |