comparison insect_phenology_model.R @ 5:1878a03f9c9f draft

Uploaded
author greg
date Wed, 22 Nov 2017 13:22:49 -0500
parents e7b1fc0133bb
children fe3f86012394
comparison
equal deleted inserted replaced
4:e7b1fc0133bb 5:1878a03f9c9f
16 make_option(c("-p", "--oviposition"), action="store", dest="oviposition", type="integer", help="Adjustment for oviposition rate"), 16 make_option(c("-p", "--oviposition"), action="store", dest="oviposition", type="integer", help="Adjustment for oviposition rate"),
17 make_option(c("-q", "--photoperiod"), action="store", dest="photoperiod", type="double", help="Critical photoperiod for diapause induction/termination"), 17 make_option(c("-q", "--photoperiod"), action="store", dest="photoperiod", type="double", help="Critical photoperiod for diapause induction/termination"),
18 make_option(c("-s", "--replications"), action="store", dest="replications", type="integer", help="Number of replications"), 18 make_option(c("-s", "--replications"), action="store", dest="replications", type="integer", help="Number of replications"),
19 make_option(c("-t", "--se_plot"), action="store", dest="se_plot", help="Plot SE"), 19 make_option(c("-t", "--se_plot"), action="store", dest="se_plot", help="Plot SE"),
20 make_option(c("-v", "--input"), action="store", dest="input", help="Temperature data for selected location"), 20 make_option(c("-v", "--input"), action="store", dest="input", help="Temperature data for selected location"),
21 make_option(c("-y", "--young_nymph_accum"), action="store", dest="young_nymph_accum", type="integer", help="Adjustment of DD accumulation (egg->young nymph)") 21 make_option(c("-y", "--young_nymph_accum"), action="store", dest="young_nymph_accum", type="integer", help="Adjustment of DD accumulation (egg->young nymph)"),
22 make_option(c("-x", "--insect"), action="store", dest="insect", help="Insect name")
22 ) 23 )
23 24
24 parser <- OptionParser(usage="%prog [options] file", option_list=option_list) 25 parser <- OptionParser(usage="%prog [options] file", option_list=option_list)
25 args <- parse_args(parser, positional_arguments=TRUE) 26 args <- parse_args(parser, positional_arguments=TRUE)
26 opt <- args$options 27 opt <- args$options
27 28
28 get_daylight_length = function(latitude, temperature_data, num_days) 29 parse_input_data = function(input_file, num_rows) {
29 { 30 # Read in the input temperature datafile into a data frame.
31 temperature_data_frame <- read.csv(file=input_file, header=T, strip.white=TRUE, sep=",")
32 num_columns <- dim(temperature_data_frame)[2]
33 if (num_columns == 6) {
34 # The input data has the following 6 columns:
35 # LATITUDE, LONGITUDE, DATE, DOY, TMIN, TMAX
36 # Set the column names for access when adding daylight length..
37 colnames(temperature_data_frame) <- c("LATITUDE","LONGITUDE", "DATE", "DOY", "TMIN", "TMAX")
38 # Add a column containing the daylight length for each day.
39 temperature_data_frame <- add_daylight_length(temperature_data_frame, num_columns, num_rows)
40 # Reset the column names with the additional column for later access.
41 colnames(temperature_data_frame) <- c("LATITUDE","LONGITUDE", "DATE", "DOY", "TMIN", "TMAX", "DAYLEN")
42 }
43 return(temperature_data_frame)
44 }
45
46 add_daylight_length = function(temperature_data_frame, num_columns, num_rows) {
30 # Return a vector of daylight length (photoperido profile) for 47 # Return a vector of daylight length (photoperido profile) for
31 # the number of days specified in the input temperature data 48 # the number of days specified in the input temperature data
32 # (from Forsythe 1995). 49 # (from Forsythe 1995).
33 p = 0.8333 50 p = 0.8333
51 latitude <- temperature_data_frame$LATITUDE[1]
34 daylight_length_vector <- NULL 52 daylight_length_vector <- NULL
35 for (i in 1:num_days) { 53 for (i in 1:num_rows) {
36 # Get the day of the year from the current row 54 # Get the day of the year from the current row
37 # of the temperature data for computation. 55 # of the temperature data for computation.
38 doy <- temperature_data[i, 4] 56 doy <- temperature_data_frame$DOY[i]
39 theta <- 0.2163108 + 2 * atan(0.9671396 * tan(0.00860 * (doy - 186))) 57 theta <- 0.2163108 + 2 * atan(0.9671396 * tan(0.00860 * (doy - 186)))
40 phi <- asin(0.39795 * cos(theta)) 58 phi <- asin(0.39795 * cos(theta))
41 # Compute the length of daylight for the day of the year. 59 # Compute the length of daylight for the day of the year.
42 daylight_length_vector[i] <- 24 - (24 / pi * acos((sin(p * pi / 180) + sin(latitude * pi / 180) * sin(phi)) / (cos(latitude * pi / 180) * cos(phi)))) 60 daylight_length_vector[i] <- 24 - (24 / pi * acos((sin(p * pi / 180) + sin(latitude * pi / 180) * sin(phi)) / (cos(latitude * pi / 180) * cos(phi))))
43 } 61 }
44 daylight_length_vector 62 # Append daylight_length_vector as a new column to temperature_data_frame.
45 } 63 temperature_data_frame[, num_columns+1] <- daylight_length_vector
46 64 return(temperature_data_frame)
47 get_temperature_at_hour = function(latitude, temperature_data, daylight_length_vector, row, num_days) 65 }
48 { 66
67 get_temperature_at_hour = function(latitude, temperature_data_frame, row, num_days) {
49 # Base development threshold for Brown Marmolated Stink Bug 68 # Base development threshold for Brown Marmolated Stink Bug
50 # insect phenology model. 69 # insect phenology model.
51 # TODO: Pass insect on the command line to accomodate more 70 # TODO: Pass insect on the command line to accomodate more
52 # the just the Brown Marmolated Stink Bub. 71 # the just the Brown Marmolated Stink Bub.
53 threshold <- 14.17 72 threshold <- 14.17
54
55 # Input temperature currently has the following columns.
56 # # LATITUDE, LONGITUDE, DATE, DOY, TMIN, TMAX
57 # Minimum temperature for current row. 73 # Minimum temperature for current row.
58 dnp <- temperature_data[row, 5] 74 dnp <- temperature_data_frame$TMIN[row]
59 # Maximum temperature for current row. 75 # Maximum temperature for current row.
60 dxp <- temperature_data[row, 6] 76 dxp <- temperature_data_frame$TMAX[row]
61 # Mean temperature for current row. 77 # Mean temperature for current row.
62 dmean <- 0.5 * (dnp + dxp) 78 dmean <- 0.5 * (dnp + dxp)
63 # Initialize degree day accumulation 79 # Initialize degree day accumulation
64 dd <- 0 80 dd <- 0
65 if (dxp < threshold) { 81 if (dxp < threshold) {
69 # Initialize hourly temperature. 85 # Initialize hourly temperature.
70 T <- NULL 86 T <- NULL
71 # Initialize degree hour vector. 87 # Initialize degree hour vector.
72 dh <- NULL 88 dh <- NULL
73 # Daylight length for current row. 89 # Daylight length for current row.
74 y <- daylight_length_vector[row] 90 y <- temperature_data_frame$DAYLEN[row]
75 # Darkness length. 91 # Darkness length.
76 z <- 24 - y 92 z <- 24 - y
77 # Lag coefficient. 93 # Lag coefficient.
78 a <- 1.86 94 a <- 1.86
79 # Darkness coefficient. 95 # Darkness coefficient.
116 } 132 }
117 } 133 }
118 } 134 }
119 dd <- sum(dh) / 24 135 dd <- sum(dh) / 24
120 } 136 }
121 return=c(dmean, dd) 137 return(c(dmean, dd))
122 return 138 }
123 } 139
124 140 dev.egg = function(temperature) {
125 dev.egg = function(temperature)
126 {
127 dev.rate= -0.9843 * temperature + 33.438 141 dev.rate= -0.9843 * temperature + 33.438
128 return = dev.rate 142 return(dev.rate)
129 return 143 }
130 } 144
131 145 dev.young = function(temperature) {
132 dev.young = function(temperature)
133 {
134 n12 <- -0.3728 * temperature + 14.68 146 n12 <- -0.3728 * temperature + 14.68
135 n23 <- -0.6119 * temperature + 25.249 147 n23 <- -0.6119 * temperature + 25.249
136 dev.rate = mean(n12 + n23) 148 dev.rate = mean(n12 + n23)
137 return = dev.rate 149 return(dev.rate)
138 return 150 }
139 } 151
140 152 dev.old = function(temperature) {
141 dev.old = function(temperature)
142 {
143 n34 <- -0.6119 * temperature + 17.602 153 n34 <- -0.6119 * temperature + 17.602
144 n45 <- -0.4408 * temperature + 19.036 154 n45 <- -0.4408 * temperature + 19.036
145 dev.rate = mean(n34 + n45) 155 dev.rate = mean(n34 + n45)
146 return = dev.rate 156 return(dev.rate)
147 return 157 }
148 } 158
149 159 dev.emerg = function(temperature) {
150 dev.emerg = function(temperature)
151 {
152 emerg.rate <- -0.5332 * temperature + 24.147 160 emerg.rate <- -0.5332 * temperature + 24.147
153 return = emerg.rate 161 return(emerg.rate)
154 return 162 }
155 } 163
156 164 mortality.egg = function(temperature) {
157 mortality.egg = function(temperature)
158 {
159 if (temperature < 12.7) { 165 if (temperature < 12.7) {
160 mort.prob = 0.8 166 mort.prob = 0.8
161 } 167 }
162 else { 168 else {
163 mort.prob = 0.8 - temperature / 40.0 169 mort.prob = 0.8 - temperature / 40.0
164 if (mort.prob < 0) { 170 if (mort.prob < 0) {
165 mort.prob = 0.01 171 mort.prob = 0.01
166 } 172 }
167 } 173 }
168 return = mort.prob 174 return(mort.prob)
169 return 175 }
170 } 176
171 177 mortality.nymph = function(temperature) {
172 mortality.nymph = function(temperature)
173 {
174 if (temperature < 12.7) { 178 if (temperature < 12.7) {
175 mort.prob = 0.03 179 mort.prob = 0.03
176 } 180 }
177 else { 181 else {
178 mort.prob = temperature * 0.0008 + 0.03 182 mort.prob = temperature * 0.0008 + 0.03
179 } 183 }
180 return = mort.prob 184 return(mort.prob)
181 return 185 }
182 } 186
183 187 mortality.adult = function(temperature) {
184 mortality.adult = function(temperature)
185 {
186 if (temperature < 12.7) { 188 if (temperature < 12.7) {
187 mort.prob = 0.002 189 mort.prob = 0.002
188 } 190 }
189 else { 191 else {
190 mort.prob = temperature * 0.0005 + 0.02 192 mort.prob = temperature * 0.0005 + 0.02
191 } 193 }
192 return = mort.prob 194 return(mort.prob)
193 return 195 }
194 } 196
195 197 temperature_data_frame <- parse_input_data(opt$input, opt$num_days)
196 # Read in the input temperature datafile into a Data Frame object. 198 # All latitude values are the same,
197 # The input data currently must have 6 columns: 199 # so get the value from the first row.
198 # LATITUDE, LONGITUDE, DATE, DOY, TMIN, TMAX 200 latitude <- temperature_data_frame$LATITUDE[1]
199 temperature_data <- read.csv(file=opt$input, header=T, strip.white=TRUE, sep=",")
200 start_date <- temperature_data[1, 3]
201 end_date <- temperature_data[opt$num_days, 3]
202 latitude <- temperature_data[1, 1]
203 daylight_length_vector <- get_daylight_length(latitude, temperature_data, opt$num_days)
204 201
205 cat("Number of days: ", opt$num_days, "\n") 202 cat("Number of days: ", opt$num_days, "\n")
206 203
207 # Initialize matrix for results from all replications. 204 # Initialize matrix for results from all replications.
208 S0.rep <- S1.rep <- S2.rep <- S3.rep <- S4.rep <- S5.rep <- matrix(rep(0, opt$num_days * opt$replications), ncol = opt$replications) 205 S0.rep <- S1.rep <- S2.rep <- S3.rep <- S4.rep <- S5.rep <- matrix(rep(0, opt$num_days * opt$replications), ncol = opt$replications)
209 newborn.rep <- death.rep <- adult.rep <- pop.rep <- g0.rep <- g1.rep <- g2.rep <- g0a.rep <- g1a.rep <- g2a.rep <- matrix(rep(0, opt$num_days * opt$replications), ncol=opt$replications) 206 newborn.rep <- death.rep <- adult.rep <- pop.rep <- g0.rep <- g1.rep <- g2.rep <- g0a.rep <- g1a.rep <- g2a.rep <- matrix(rep(0, opt$num_days * opt$replications), ncol=opt$replications)
210 207
211 # loop through replications 208 # Loop through replications.
212 for (N.rep in 1:opt$replications) { 209 for (N.rep in 1:opt$replications) {
213 # During each replication start with 1000 individuals. 210 # During each replication start with 1000 individuals.
214 # TODO: user definable as well? 211 # TODO: user definable as well?
215 n <- 1000 212 n <- 1000
216 # Generation, Stage, DD, T, Diapause. 213 # Generation, Stage, DD, T, Diapause.
226 gen2.pop <- rep(0, opt$num_days) 223 gen2.pop <- rep(0, opt$num_days)
227 S0 <- S1 <- S2 <- S3 <- S4 <- S5 <- rep(0, opt$num_days) 224 S0 <- S1 <- S2 <- S3 <- S4 <- S5 <- rep(0, opt$num_days)
228 g0.adult <- g1.adult <- g2.adult <- rep(0, opt$num_days) 225 g0.adult <- g1.adult <- g2.adult <- rep(0, opt$num_days)
229 N.newborn <- N.death <- N.adult <- rep(0, opt$num_days) 226 N.newborn <- N.death <- N.adult <- rep(0, opt$num_days)
230 dd.day <- rep(0, opt$num_days) 227 dd.day <- rep(0, opt$num_days)
231
232 # All the days included in the input temperature dataset. 228 # All the days included in the input temperature dataset.
233 for (row in 1:opt$num_days) { 229 for (row in 1:opt$num_days) {
234 # Get the integer day of the year for the current row. 230 # Get the integer day of the year for the current row.
235 doy <- temperature_data[row, 4] 231 doy <- temperature_data_frame$DOY[row]
236 # Photoperiod in the day. 232 # Photoperiod in the day.
237 photoperiod <- daylight_length_vector[row] 233 photoperiod <- temperature_data_frame$DAYLEN[row]
238 temp.profile <- get_temperature_at_hour(latitude, temperature_data, daylight_length_vector, row, opt$num_days) 234 temp.profile <- get_temperature_at_hour(latitude, temperature_data_frame, row, opt$num_days)
239 mean.temp <- temp.profile[1] 235 mean.temp <- temp.profile[1]
240 dd.temp <- temp.profile[2] 236 dd.temp <- temp.profile[2]
241 dd.day[row] <- dd.temp 237 dd.day[row] <- dd.temp
242 # Trash bin for death. 238 # Trash bin for death.
243 death.vec <- NULL 239 death.vec <- NULL
244 # Newborn. 240 # Newborn.
245 birth.vec <- NULL 241 birth.vec <- NULL
246
247 # All individuals. 242 # All individuals.
248 for (i in 1:n) { 243 for (i in 1:n) {
249 # Find individual record. 244 # Find individual record.
250 vec.ind <- vec.mat[i,] 245 vec.ind <- vec.mat[i,]
251 # First of all, still alive? 246 # First of all, still alive?
314 # Add 1 day in current stage. 309 # Add 1 day in current stage.
315 vec.ind[4] <- vec.ind[4] + 1 310 vec.ind[4] <- vec.ind[4] + 1
316 vec.mat[i,] <- vec.ind 311 vec.mat[i,] <- vec.ind
317 } 312 }
318 } 313 }
319
320 # Event 2 oviposition -- where population dynamics comes from. 314 # Event 2 oviposition -- where population dynamics comes from.
321 if (vec.ind[2] == 4 && vec.ind[1] == 0 && mean.temp > 10) { 315 if (vec.ind[2] == 4 && vec.ind[1] == 0 && mean.temp > 10) {
322 # Vittelogenic stage, overwintering generation. 316 # Vittelogenic stage, overwintering generation.
323 if (vec.ind[4] == 0) { 317 if (vec.ind[4] == 0) {
324 # Just turned in vittelogenic stage. 318 # Just turned in vittelogenic stage.
347 new.vec <- t(matrix(new.vec, nrow=5)) 341 new.vec <- t(matrix(new.vec, nrow=5))
348 # Group with total eggs laid in that day. 342 # Group with total eggs laid in that day.
349 birth.vec <- rbind(birth.vec, new.vec) 343 birth.vec <- rbind(birth.vec, new.vec)
350 } 344 }
351 } 345 }
352 346 # Event 2 oviposition -- for generation 1.
353 # Event 2 oviposition -- for gen 1.
354 if (vec.ind[2] == 4 && vec.ind[1] == 1 && mean.temp > 12.5 && doy < 222) { 347 if (vec.ind[2] == 4 && vec.ind[1] == 1 && mean.temp > 12.5 && doy < 222) {
355 # Vittelogenic stage, 1st generation 348 # Vittelogenic stage, 1st generation
356 if (vec.ind[4] == 0) { 349 if (vec.ind[4] == 0) {
357 # Just turned in vittelogenic stage. 350 # Just turned in vittelogenic stage.
358 n.birth=round(runif(1, 2 + opt$min_clutch_size, 8 + opt$max_clutch_size)) 351 n.birth=round(runif(1, 2 + opt$min_clutch_size, 8 + opt$max_clutch_size))
380 new.vec <- t(matrix(new.vec, nrow=5)) 373 new.vec <- t(matrix(new.vec, nrow=5))
381 # Group with total eggs laid in that day. 374 # Group with total eggs laid in that day.
382 birth.vec <- rbind(birth.vec, new.vec) 375 birth.vec <- rbind(birth.vec, new.vec)
383 } 376 }
384 } 377 }
385
386 # Event 3 development (with diapause determination). 378 # Event 3 development (with diapause determination).
387 # Event 3.1 egg development to young nymph (vec.ind[2]=0 -> egg). 379 # Event 3.1 egg development to young nymph (vec.ind[2]=0 -> egg).
388 if (vec.ind[2] == 0) { 380 if (vec.ind[2] == 0) {
389 # Egg stage. 381 # Egg stage.
390 # Add to dd. 382 # Add to dd.
399 # Add 1 day in current stage. 391 # Add 1 day in current stage.
400 vec.ind[4] <- vec.ind[4] + 1 392 vec.ind[4] <- vec.ind[4] + 1
401 } 393 }
402 vec.mat[i,] <- vec.ind 394 vec.mat[i,] <- vec.ind
403 } 395 }
404
405 # Event 3.2 young nymph to old nymph (vec.ind[2]=1 -> young nymph: determines diapause). 396 # Event 3.2 young nymph to old nymph (vec.ind[2]=1 -> young nymph: determines diapause).
406 if (vec.ind[2] == 1) { 397 if (vec.ind[2] == 1) {
407 # young nymph stage. 398 # young nymph stage.
408 # add to dd. 399 # add to dd.
409 vec.ind[3] <- vec.ind[3] + dd.temp 400 vec.ind[3] <- vec.ind[3] + dd.temp
420 # Add 1 day in current stage. 411 # Add 1 day in current stage.
421 vec.ind[4] <- vec.ind[4] + 1 412 vec.ind[4] <- vec.ind[4] + 1
422 } 413 }
423 vec.mat[i,] <- vec.ind 414 vec.mat[i,] <- vec.ind
424 } 415 }
425
426 # Event 3.3 old nymph to adult: previttelogenic or diapausing? 416 # Event 3.3 old nymph to adult: previttelogenic or diapausing?
427 if (vec.ind[2] == 2) { 417 if (vec.ind[2] == 2) {
428 # Old nymph stage. 418 # Old nymph stage.
429 # add to dd. 419 # add to dd.
430 vec.ind[3] <- vec.ind[3] + dd.temp 420 vec.ind[3] <- vec.ind[3] + dd.temp
444 # Add 1 day in current stage. 434 # Add 1 day in current stage.
445 vec.ind[4] <- vec.ind[4] + 1 435 vec.ind[4] <- vec.ind[4] + 1
446 } 436 }
447 vec.mat[i,] <- vec.ind 437 vec.mat[i,] <- vec.ind
448 } 438 }
449
450 # Event 4 growing of diapausing adult (unimportant, but still necessary). 439 # Event 4 growing of diapausing adult (unimportant, but still necessary).
451 if (vec.ind[2] == 5) { 440 if (vec.ind[2] == 5) {
452 vec.ind[3] <- vec.ind[3] + dd.temp 441 vec.ind[3] <- vec.ind[3] + dd.temp
453 vec.ind[4] <- vec.ind[4] + 1 442 vec.ind[4] <- vec.ind[4] + 1
454 vec.mat[i,] <- vec.ind 443 vec.mat[i,] <- vec.ind
455 } 444 }
456 } # Else if it is still alive. 445 } # Else if it is still alive.
457 } # End of the individual bug loop. 446 } # End of the individual bug loop.
458
459 # Find how many died. 447 # Find how many died.
460 n.death <- length(death.vec) 448 n.death <- length(death.vec)
461 if (n.death > 0) { 449 if (n.death > 0) {
462 vec.mat <- vec.mat[-death.vec, ] 450 vec.mat <- vec.mat[-death.vec, ]
463 } 451 }
534 } 522 }
535 523
536 # Data analysis and visualization can currently 524 # Data analysis and visualization can currently
537 # plot only within a single calendar year. 525 # plot only within a single calendar year.
538 # TODO: enhance this to accomodate multiple calendar years. 526 # TODO: enhance this to accomodate multiple calendar years.
527 start_date <- temperature_data_frame$DATE[1]
528 end_date <- temperature_data_frame$DATE[opt$num_days]
529
539 n.yr <- 1 530 n.yr <- 1
540 day.all <- c(1:opt$num_days * n.yr) 531 day.all <- c(1:opt$num_days * n.yr)
541 532
542 # mean value for adults 533 # mean value for adults
543 sa <- apply((S3.rep + S4.rep + S5.rep), 1, mean) 534 sa <- apply((S3.rep + S4.rep + S5.rep), 1, mean)
583 pdf(file=opt$output, width=20, height=30, bg="white") 574 pdf(file=opt$output, width=20, height=30, bg="white")
584 575
585 par(mar = c(5, 6, 4, 4), mfrow=c(3, 1)) 576 par(mar = c(5, 6, 4, 4), mfrow=c(3, 1))
586 577
587 # Subfigure 1: population size by life stage 578 # Subfigure 1: population size by life stage
588 title <- paste("BSMB total population by life stage :", opt$location, ": Lat:", latitude, ":", start_date, "to", end_date, sep=" ") 579 title <- paste(opt$insect, ": Total pop. by life stage :", opt$location, ": Lat:", latitude, ":", start_date, "-", end_date, sep=" ")
589 plot(day.all, sa, main=title, type="l", ylim=c(0, max(se + se.se, sn + sn.se, sa + sa.se)), axes=F, lwd=2, xlab="", ylab="", cex=3, cex.lab=3, cex.axis=3, cex.main=3) 580 plot(day.all, sa, main=title, type="l", ylim=c(0, max(se + se.se, sn + sn.se, sa + sa.se)), axes=F, lwd=2, xlab="", ylab="", cex=3, cex.lab=3, cex.axis=3, cex.main=3)
590 # Young and old nymphs. 581 # Young and old nymphs.
591 lines(day.all, sn, lwd=2, lty=1, col=2) 582 lines(day.all, sn, lwd=2, lty=1, col=2)
592 # Eggs 583 # Eggs
593 lines(day.all, se, lwd=2, lty=1, col=4) 584 lines(day.all, se, lwd=2, lty=1, col=4)
607 lines (day.all, se + se.se, col=4, lty=2) 598 lines (day.all, se + se.se, col=4, lty=2)
608 lines (day.all, se - se.se, col=4, lty=2) 599 lines (day.all, se - se.se, col=4, lty=2)
609 } 600 }
610 601
611 # Subfigure 2: population size by generation 602 # Subfigure 2: population size by generation
612 title <- paste("BSMB total population by generation :", opt$location, ": Lat:", latitude, ":", start_date, "to", end_date, sep=" ") 603 title <- paste(opt$insect, ": Total pop. by generation :", opt$location, ": Lat:", latitude, ":", start_date, "-", end_date, sep=" ")
613 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) 604 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)
614 lines(day.all, g1, lwd = 2, lty = 1, col=2) 605 lines(day.all, g1, lwd = 2, lty = 1, col=2)
615 lines(day.all, g2, lwd = 2, lty = 1, col=4) 606 lines(day.all, g2, lwd = 2, lty = 1, col=4)
616 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")) 607 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"))
617 axis(2, cex.axis=3) 608 axis(2, cex.axis=3)
629 lines (day.all, g2+g2.se, col=4, lty=2) 620 lines (day.all, g2+g2.se, col=4, lty=2)
630 lines (day.all, g2-g2.se, col=4, lty=2) 621 lines (day.all, g2-g2.se, col=4, lty=2)
631 } 622 }
632 623
633 # Subfigure 3: adult population size by generation 624 # Subfigure 3: adult population size by generation
634 title <- paste("BSMB adult population by generation :", opt$location, ": Lat:", latitude, ":", start_date, "to", end_date, sep=" ") 625 title <- paste(opt$insect, ": Adult pop. by generation :", opt$location, ": Lat:", latitude, ":", start_date, "-", end_date, sep=" ")
635 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) 626 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)
636 lines(day.all, g1a, lwd = 2, lty = 1, col=2) 627 lines(day.all, g1a, lwd = 2, lty = 1, col=2)
637 lines(day.all, g2a, lwd = 2, lty = 1, col=4) 628 lines(day.all, g2a, lwd = 2, lty = 1, col=4)
638 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")) 629 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"))
639 axis(2, cex.axis=3) 630 axis(2, cex.axis=3)