changeset 98:d33a401c0153 draft

Uploaded
author greg
date Mon, 04 Dec 2017 11:54:10 -0500
parents 58bc1a2ca936
children 51045fde125e
files insect_phenology_model.R
diffstat 1 files changed, 24 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/insect_phenology_model.R	Mon Dec 04 11:21:25 2017 -0500
+++ b/insect_phenology_model.R	Mon Dec 04 11:54:10 2017 -0500
@@ -235,9 +235,18 @@
     gen0.pop <- rep(0, opt$num_days)
     gen1.pop <- rep(0, opt$num_days)
     gen2.pop <- rep(0, opt$num_days)
-    S0 <- S1 <- S2 <- S3 <- S4 <- S5 <- rep(0, opt$num_days)
-    g0.adult <- g1.adult <- g2.adult <- rep(0, opt$num_days)
-    N.newborn <- N.death <- N.adult <- rep(0, opt$num_days)
+    S0 <- rep(0, opt$num_days)
+    S1 <- rep(0, opt$num_days)
+    S2 <- rep(0, opt$num_days)
+    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)
+    N.newborn <- rep(0, opt$num_days)
+    N.death <- rep(0, opt$num_days)
+    N.adult <- rep(0, opt$num_days)
     degree_days.day <- rep(0, opt$num_days)
     # All the days included in the input temperature dataset.
     for (row in 1:opt$num_days) {
@@ -485,18 +494,18 @@
         # Diapausing.
         sum_diapausing <- sum(vector.matrix[,2] == 5)
         # Overwintering adult.
-        gen0 <- sum(vector.matrix[,1] == 0)
+        sum_overwintering_adults <- sum(vector.matrix[,1] == 0)
         # First generation.
-        gen1 <- sum(vector.matrix[,1] == 1)
+        sum_first_generation <- sum(vector.matrix[,1] == 1)
         # Second generation.
-        gen2 <- sum(vector.matrix[,1] == 2)
+        sum_second_generation <- sum(vector.matrix[,1] == 2)
         # Sum of all adults.
         num_insects.adult <- sum(vector.matrix[,2] == 3) + sum(vector.matrix[,2] == 4) + sum(vector.matrix[,2] == 5)
 
-        # Generation 0 pop size.
-        gen0.pop[row] <- gen0
-        gen1.pop[row] <- gen1
-        gen2.pop[row] <- gen2
+        # Population sizes.
+        gen0.pop[row] <- sum_overwintering_adults
+        gen1.pop[row] <- sum_first_generation
+        gen2.pop[row] <- sum_second_generation
 
         S0[row] <- sum_eggs
         S1[row] <- sum_young_nymphs
@@ -552,7 +561,7 @@
 # Mean value for F1 adult.
 g1a <- apply(g1a.replications, 1, mean)
 # Mean value for F2 adult.
-g2a <- apply(g2a.replications, 1, mean)
+F2_adult_mean <- apply(g2a.replications, 1, mean)
 
 # Standard error for adults.
 adult_mean.std_error <- apply((S3.replications + S4.replications + S5.replications), 1, sd) / sqrt(opt$replications)
@@ -632,9 +641,9 @@
 
 # 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(g2a) + 100), main=title, type="l", axes=F, lwd=2, xlab="", ylab="", cex=3, cex.lab=3, cex.axis=3, cex.main=3)
+plot(day.all, g0a, ylim=c(0, max(F2_adult_mean) + 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)
-lines(day.all, g2a, lwd = 2, lty = 1, col=4)
+lines(day.all, F2_adult_mean, 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)
@@ -647,8 +656,8 @@
     lines (day.all, g1a+g1a.std_error, col=2, lty=2)
     lines (day.all, g1a-g1a.std_error, col=2, lty=2)
     # Standard error for eggs
-    lines (day.all, g2a+g2a.std_error, col=4, lty=2)
-    lines (day.all, g2a-g2a.std_error, col=4, lty=2)
+    lines (day.all, F2_adult_mean+g2a.std_error, col=4, lty=2)
+    lines (day.all, F2_adult_mean-g2a.std_error, col=4, lty=2)
 }
 
 # Turn off device driver to flush output.