Mercurial > repos > greg > insect_phenology_model
comparison insect_phenology_model.R @ 48:66712cdec7c0 draft
Uploaded
author | greg |
---|---|
date | Mon, 13 Nov 2017 11:05:42 -0500 |
parents | d6482112bf35 |
children | d03ba99e25b6 |
comparison
equal
deleted
inserted
replaced
47:d6482112bf35 | 48:66712cdec7c0 |
---|---|
577 # SE for F1 adult | 577 # SE for F1 adult |
578 g1a.se <- apply(g1a.rep, 1, sd) / sqrt(opt$replications) | 578 g1a.se <- apply(g1a.rep, 1, sd) / sqrt(opt$replications) |
579 # SE for F2 adult | 579 # SE for F2 adult |
580 g2a.se <- apply(g2a.rep, 1, sd) / sqrt(opt$replications) | 580 g2a.se <- apply(g2a.rep, 1, sd) / sqrt(opt$replications) |
581 | 581 |
582 dev.new(width=20, height=20) | 582 dev.new(width=20, height=30) |
583 | 583 |
584 # Start PDF device driver to save charts to output. | 584 # Start PDF device driver to save charts to output. |
585 pdf(file=opt$output, height=20, width=20, bg="white") | 585 pdf(file=opt$output, width=20, height=30, bg="white") |
586 | 586 |
587 par(mar = c(5, 6, 4, 4), mfrow=c(3, 1)) | 587 par(mar = c(5, 6, 4, 4), mfrow=c(3, 1)) |
588 | 588 |
589 # Subfigure 2: population size by life stage | 589 # Subfigure 2: population size by life stage |
590 title <- paste("BSMB Total Population Size by Life Stage:", opt$location, ", Latitude:", latitude, ", Temperature Dates:", start_date, "to", end_date, sep=" ") | 590 title <- paste("BSMB Total Population Size by Life Stage:", opt$location, ", Latitude:", latitude, ", Temperature Dates:", start_date, "to", end_date, sep=" ") |
591 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="Number", cex=2, cex.lab=2, cex.axis=2, cex.main=2) | 591 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="Number", cex=3, cex.lab=2, cex.axis=2, cex.main=2) |
592 # Young and old nymphs. | 592 # Young and old nymphs. |
593 lines(day.all, sn, lwd=2, lty=1, col=2) | 593 lines(day.all, sn, lwd=2, lty=1, col=2) |
594 # Eggs | 594 # Eggs |
595 lines(day.all, se, lwd=2, lty=1, col=4) | 595 lines(day.all, se, lwd=2, lty=1, col=4) |
596 axis(1, at = c(1:12) * 30 - 15, cex.axis=2, labels=c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) | 596 axis(1, at = c(1:12) * 30 - 15, cex.axis=2, labels=c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) |
597 axis(2, cex.axis = 2) | 597 axis(2, cex.axis = 3) |
598 leg.text <- c("Egg", "Nymph", "Adult") | 598 leg.text <- c("Egg", "Nymph", "Adult") |
599 legend("topleft", leg.text, lty=c(1, 1, 1), col=c(4, 2, 1), cex=2) | 599 legend("topleft", leg.text, lty=c(1, 1, 1), col=c(4, 2, 1), cex=3) |
600 if (opt$se_plot == 1) { | 600 if (opt$se_plot == 1) { |
601 # add SE lines to plot | 601 # Add SE lines to plot |
602 # SE for adults | 602 # SE for adults |
603 lines (day.all, sa + sa.se, lty=2) | 603 lines (day.all, sa + sa.se, lty=2) |
604 lines (day.all, sa - sa.se, lty=2) | 604 lines (day.all, sa - sa.se, lty=2) |
605 # SE for nymphs | 605 # SE for nymphs |
606 lines (day.all, sn + sn.se, col=2, lty=2) | 606 lines (day.all, sn + sn.se, col=2, lty=2) |
607 lines (day.all, sn - sn.se, col=2, lty=2) | 607 lines (day.all, sn - sn.se, col=2, lty=2) |
608 # SE for eggs | 608 # SE for eggs |
609 lines (day.all, se + se.se, col=4, lty=2) | 609 lines (day.all, se + se.se, col=4, lty=2) |
610 lines (day.all, se - se.se, col=4, lty=2) | 610 lines (day.all, se - se.se, col=4, lty=2) |
611 } | 611 } |
612 | 612 |
613 # Subfigure 3: population size by generation | 613 # Subfigure 3: population size by generation |
614 title <- paste("BSMB Total Population Size by Generation:", opt$location, ", Latitude:", latitude, ", Temperature Dates:", start_date, "to", end_date, sep=" ") | 614 title <- paste("BSMB Total Population Size by Generation:", opt$location, ", Latitude:", latitude, ", Temperature Dates:", start_date, "to", end_date, sep=" ") |
615 plot(day.all, g0, main=title, type="l", ylim=c(0, max(g2)), axes=F, lwd=2, xlab="", ylab="Number", cex=2, cex.lab=2, cex.axis=2, cex.main=2) | 615 plot(day.all, g0, main=title, type="l", ylim=c(0, max(g2)), axes=F, lwd=2, xlab="", ylab="Number", cex=3, cex.lab=2, cex.axis=2, cex.main=2) |
616 lines(day.all, g1, lwd = 2, lty = 1, col = 2) | 616 lines(day.all, g1, lwd = 2, lty = 1, col = 2) |
617 lines(day.all, g2, lwd = 2, lty = 1, col = 4) | 617 lines(day.all, g2, lwd = 2, lty = 1, col = 4) |
618 axis(1, at = c(1:12) * 30 - 15, cex.axis = 2, labels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) | 618 axis(1, at = c(1:12) * 30 - 15, cex.axis = 2, labels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) |
619 axis(2, cex.axis = 2) | 619 axis(2, cex.axis = 3) |
620 leg.text <- c("P", "F1", "F2") | 620 leg.text <- c("P", "F1", "F2") |
621 legend("topleft", leg.text, lty = c(1, 1, 1), col =c(1, 2, 4), cex = 2) | 621 legend("topleft", leg.text, lty = c(1, 1, 1), col =c(1, 2, 4), cex = 2) |
622 if (opt$se_plot == 1) { | 622 if (opt$se_plot == 1) { |
623 # add SE lines to plot | 623 # Add SE lines to plot |
624 # SE for adults | 624 # SE for adults |
625 lines (day.all, g0 + g0.se, lty = 2) | 625 lines (day.all, g0 + g0.se, lty = 2) |
626 lines (day.all, g0 - g0.se, lty = 2) | 626 lines (day.all, g0 - g0.se, lty = 2) |
627 # SE for nymphs | 627 # SE for nymphs |
628 lines (day.all, g1 + g1.se, col = 2, lty = 2) | 628 lines (day.all, g1 + g1.se, col = 2, lty = 2) |
629 lines (day.all, g1 - g1.se, col = 2, lty = 2) | 629 lines (day.all, g1 - g1.se, col = 2, lty = 2) |
630 # SE for eggs | 630 # SE for eggs |
631 lines (day.all, g2 + g2.se, col = 4, lty = 2) | 631 lines (day.all, g2 + g2.se, col = 4, lty = 2) |
632 lines (day.all, g2 - g2.se, col = 4, lty = 2) | 632 lines (day.all, g2 - g2.se, col = 4, lty = 2) |
633 } | 633 } |
634 | 634 |
635 # Subfigure 4: adult population size by generation | 635 # Subfigure 4: adult population size by generation |
636 title <- paste("BSMB Adult Population Size by Generation:", opt$location, ", Latitude:", latitude, ", Temperature Dates:", start_date, "to", end_date, sep=" ") | 636 title <- paste("BSMB Adult Population Size by Generation:", opt$location, ", Latitude:", latitude, ", Temperature Dates:", start_date, "to", end_date, sep=" ") |
637 plot(day.all, g0a, ylim=c(0, max(g2a) + 100), main=title, type="l", axes=F, lwd=2, xlab="Year", ylab="Number", cex=2, cex.lab=2, cex.axis=2, cex.main=2) | 637 plot(day.all, g0a, ylim=c(0, max(g2a) + 100), main=title, type="l", axes=F, lwd=2, xlab="Year", ylab="Number", cex=3, cex.lab=2, cex.axis=2, cex.main=2) |
638 lines(day.all, g1a, lwd = 2, lty = 1, col = 2) | 638 lines(day.all, g1a, lwd = 2, lty = 1, col = 2) |
639 lines(day.all, g2a, lwd = 2, lty = 1, col = 4) | 639 lines(day.all, g2a, lwd = 2, lty = 1, col = 4) |
640 axis(1, at = c(1:12) * 30 - 15, cex.axis = 2, labels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) | 640 axis(1, at = c(1:12) * 30 - 15, cex.axis = 2, labels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) |
641 axis(2, cex.axis = 2) | 641 axis(2, cex.axis = 2) |
642 leg.text <- c("P", "F1", "F2") | 642 leg.text <- c("P", "F1", "F2") |
643 legend("topleft", leg.text, lty = c(1, 1, 1), col = c(1, 2, 4), cex = 2) | 643 legend("topleft", leg.text, lty = c(1, 1, 1), col = c(1, 2, 4), cex = 2) |
644 if (opt$se_plot == 1) { | 644 if (opt$se_plot == 1) { |
645 # add SE lines to plot | 645 # Add SE lines to plot |
646 # SE for adults | 646 # SE for adults |
647 lines (day.all, g0a + g0a.se, lty = 2) | 647 lines (day.all, g0a + g0a.se, lty = 2) |
648 lines (day.all, g0a - g0a.se, lty = 2) | 648 lines (day.all, g0a - g0a.se, lty = 2) |
649 # SE for nymphs | 649 # SE for nymphs |
650 lines (day.all, g1a + g1a.se, col = 2, lty = 2) | 650 lines (day.all, g1a + g1a.se, col = 2, lty = 2) |
651 lines (day.all, g1a - g1a.se, col = 2, lty = 2) | 651 lines (day.all, g1a - g1a.se, col = 2, lty = 2) |
652 # SE for eggs | 652 # SE for eggs |
653 lines (day.all, g2a + g2a.se, col = 4, lty = 2) | 653 lines (day.all, g2a + g2a.se, col = 4, lty = 2) |
654 lines (day.all, g2a - g2a.se, col = 4, lty = 2) | 654 lines (day.all, g2a - g2a.se, col = 4, lty = 2) |
655 } | 655 } |
656 | 656 |
657 # Turn off device driver to flush output. | 657 # Turn off device driver to flush output. |
658 dev.off() | 658 dev.off() |