Mercurial > repos > greg > insect_phenology_model
changeset 100:52114847afff draft
Uploaded
author | greg |
---|---|
date | Mon, 04 Dec 2017 13:21:20 -0500 |
parents | 51045fde125e |
children | 691b677d8f83 |
files | insect_phenology_model.R |
diffstat | 1 files changed, 42 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/insect_phenology_model.R Mon Dec 04 13:04:11 2017 -0500 +++ b/insect_phenology_model.R Mon Dec 04 13:21:20 2017 -0500 @@ -212,11 +212,11 @@ death.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) adult.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) pop.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) -g0.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) -g1.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) -g2.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) -g0a.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) -g1a.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) +P.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) +F1.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) +F2.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) +P_adults.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) +F1_adults.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) F2_adults.replications <- matrix(rep(0, opt$num_days*opt$replications), ncol=opt$replications) # Loop through replications. @@ -241,9 +241,9 @@ S3 <- rep(0, opt$num_days) S4 <- rep(0, opt$num_days) S5 <- rep(0, opt$num_days) - g0.adult <- rep(0, opt$num_days) - g1.adult <- rep(0, opt$num_days) - g2.adult <- rep(0, opt$num_days) + P.adult <- rep(0, opt$num_days) + F1.adult <- rep(0, opt$num_days) + F2.adult <- rep(0, opt$num_days) N.newborn <- rep(0, opt$num_days) N.death <- rep(0, opt$num_days) N.adult <- rep(0, opt$num_days) @@ -505,9 +505,9 @@ # Diapausing population size. S5[row] <- sum(vector.matrix[,2] == 5) - g0.adult[row] <- sum(vector.matrix[,1] == 0) - g1.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)) - g2.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)) + P.adult[row] <- sum(vector.matrix[,1] == 0) + 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)) + 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)) N.newborn[row] <- num_insects.newborn N.death[row] <- num_insects.death @@ -527,12 +527,12 @@ death.replications[,N.replications] <- N.death adult.replications[,N.replications] <- N.adult pop.replications[,N.replications] <- tot.pop - g0.replications[,N.replications] <- gen0.pop - g1.replications[,N.replications] <- gen1.pop - g2.replications[,N.replications] <- gen2.pop - g0a.replications[,N.replications] <- g0.adult - g1a.replications[,N.replications] <- g1.adult - F2_adults.replications[,N.replications] <- g2.adult + P.replications[,N.replications] <- gen0.pop + F1.replications[,N.replications] <- gen1.pop + F2.replications[,N.replications] <- gen2.pop + P_adults.replications[,N.replications] <- P.adult + F1_adults.replications[,N.replications] <- F1.adult + F2_adults.replications[,N.replications] <- F2.adult } # Mean value for adults. @@ -542,15 +542,15 @@ # Mean value for eggs. eggs <- apply(S0.replications, 1, mean) # Mean value for P. -g0 <- apply(g0.replications, 1, mean) +P <- apply(P.replications, 1, mean) # Mean value for F1. -g1 <- apply(g1.replications, 1, mean) +F1 <- apply(F1.replications, 1, mean) # Mean value for F2. -g2 <- apply(g2.replications, 1, mean) +F2 <- apply(F2.replications, 1, mean) # Mean value for P adults. -g0a <- apply(g0a.replications, 1, mean) +P_adults <- apply(P_adults.replications, 1, mean) # Mean value for F1 adults. -g1a <- apply(g1a.replications, 1, mean) +F1_adults <- apply(F1_adults.replications, 1, mean) # Mean value for F2 adults. F2_adults <- apply(F2_adults.replications, 1, mean) @@ -561,15 +561,15 @@ # Standard error for eggs. eggs.std_error <- apply(S0.replications, 1, sd) / sqrt(opt$replications) # Standard error value for P. -g0.std_error <- apply(g0.replications, 1, sd) / sqrt(opt$replications) +P.std_error <- apply(P.replications, 1, sd) / sqrt(opt$replications) # Standard error for F1. -g1.std_error <- apply(g1.replications, 1, sd) / sqrt(opt$replications) +F1.std_error <- apply(F1.replications, 1, sd) / sqrt(opt$replications) # Standard error for F2. -g2.std_error <- apply(g2.replications, 1, sd) / sqrt(opt$replications) +F2.std_error <- apply(F2.replications, 1, sd) / sqrt(opt$replications) # Standard error for P adult. -g0a.std_error <- apply(g0a.replications, 1, sd) / sqrt(opt$replications) +P_adults.std_error <- apply(P_adults.replications, 1, sd) / sqrt(opt$replications) # Standard error for F1 adult. -g1a.std_error <- apply(g1a.replications, 1, sd) / sqrt(opt$replications) +F1_adults.std_error <- apply(F1_adults.replications, 1, sd) / sqrt(opt$replications) # Standard error for F2 adult. F2_adults.std_error <- apply(F2_adults.replications, 1, sd) / sqrt(opt$replications) @@ -611,29 +611,29 @@ # Subfigure 2: population size by generation title <- paste(opt$insect, ": Total pop. by generation :", opt$location, ": Lat:", latitude, ":", start_date, "-", end_date, sep=" ") -plot(day.all, g0, main=title, type="l", ylim=c(0, max(g2)), axes=F, lwd=2, xlab="", ylab="", cex=3, cex.lab=3, cex.axis=3, cex.main=3) -lines(day.all, g1, lwd = 2, lty = 1, col=2) -lines(day.all, g2, lwd = 2, lty = 1, col=4) +plot(day.all, P, main=title, type="l", ylim=c(0, max(F2)), axes=F, lwd=2, xlab="", ylab="", cex=3, cex.lab=3, cex.axis=3, cex.main=3) +lines(day.all, F1, lwd = 2, lty = 1, col=2) +lines(day.all, F2, lwd = 2, lty = 1, col=4) axis(1, at=c(1:12) * 30 - 15, cex.axis=3, labels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) axis(2, cex.axis=3) legend("topleft", c("P", "F1", "F2"), lty=c(1, 1, 1), col=c(1, 2, 4), cex=3) if (opt$std_error_plot == 1) { # Add Standard error lines to plot # Standard error for adults - lines (day.all, g0+g0.std_error, lty=2) - lines (day.all, g0-g0.std_error, lty=2) + lines (day.all, P+P.std_error, lty=2) + lines (day.all, P-P.std_error, lty=2) # Standard error for nymphs - lines (day.all, g1+g1.std_error, col=2, lty=2) - lines (day.all, g1-g1.std_error, col=2, lty=2) + lines (day.all, F1+F1.std_error, col=2, lty=2) + lines (day.all, F1-F1.std_error, col=2, lty=2) # Standard error for eggs - lines (day.all, g2+g2.std_error, col=4, lty=2) - lines (day.all, g2-g2.std_error, col=4, lty=2) + lines (day.all, F2+F2.std_error, col=4, lty=2) + lines (day.all, F2-F2.std_error, col=4, lty=2) } # Subfigure 3: adult population size by generation title <- paste(opt$insect, ": Adult pop. by generation :", opt$location, ": Lat:", latitude, ":", start_date, "-", end_date, sep=" ") -plot(day.all, g0a, ylim=c(0, max(F2_adults) + 100), main=title, type="l", axes=F, lwd=2, xlab="", ylab="", cex=3, cex.lab=3, cex.axis=3, cex.main=3) -lines(day.all, g1a, lwd = 2, lty = 1, col=2) +plot(day.all, P_adults, ylim=c(0, max(F2_adults) + 100), main=title, type="l", axes=F, lwd=2, xlab="", ylab="", cex=3, cex.lab=3, cex.axis=3, cex.main=3) +lines(day.all, F1_adults, lwd = 2, lty = 1, col=2) lines(day.all, F2_adults, lwd = 2, lty = 1, col=4) axis(1, at=c(1:12) * 30 - 15, cex.axis=3, labels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) axis(2, cex.axis=3) @@ -641,11 +641,11 @@ if (opt$std_error_plot == 1) { # Add Standard error lines to plot # Standard error for adults - lines (day.all, g0a+g0a.std_error, lty=2) - lines (day.all, g0a-g0a.std_error, lty=2) + lines (day.all, P_adults+P_adults.std_error, lty=2) + lines (day.all, P_adults-P_adults.std_error, lty=2) # Standard error for nymphs - lines (day.all, g1a+g1a.std_error, col=2, lty=2) - lines (day.all, g1a-g1a.std_error, col=2, lty=2) + lines (day.all, F1_adults+F1_adults.std_error, col=2, lty=2) + lines (day.all, F1_adults-F1_adults.std_error, col=2, lty=2) # Standard error for eggs lines (day.all, F2_adults+F2_adults.std_error, col=4, lty=2) lines (day.all, F2_adults-F2_adults.std_error, col=4, lty=2)