| Previous changeset 101:691b677d8f83 (2017-12-04) Next changeset 103:4d9e40d8af0f (2017-12-05) |
|
Commit message:
Uploaded |
|
modified:
insect_phenology_model.R |
| b |
| diff -r 691b677d8f83 -r ce996e90f5a7 insect_phenology_model.R --- a/insect_phenology_model.R Mon Dec 04 13:34:28 2017 -0500 +++ b/insect_phenology_model.R Tue Dec 05 10:32:04 2017 -0500 |
| [ |
| b'@@ -3,14 +3,14 @@\n suppressPackageStartupMessages(library("optparse"))\n \n option_list <- list(\n- make_option(c("-a", "--adult_mort"), action="store", dest="adult_mort", type="integer", help="Adjustment rate for adult mortality"),\n- make_option(c("-b", "--adult_accum"), action="store", dest="adult_accum", type="integer", help="Adjustment of degree-days accumulation (old nymph->adult)"),\n- make_option(c("-c", "--egg_mort"), action="store", dest="egg_mort", type="integer", help="Adjustment rate for egg mortality"),\n+ make_option(c("-a", "--adult_mortality"), action="store", dest="adult_mortality", type="integer", help="Adjustment rate for adult mortality"),\n+ make_option(c("-b", "--adult_accumulation"), action="store", dest="adult_accumulation", type="integer", help="Adjustment of degree-days accumulation (old nymph->adult)"),\n+ make_option(c("-c", "--egg_mortality"), action="store", dest="egg_mortality", type="integer", help="Adjustment rate for egg mortality"),\n make_option(c("-e", "--location"), action="store", dest="location", help="Selected location"),\n make_option(c("-f", "--min_clutch_size"), action="store", dest="min_clutch_size", type="integer", help="Adjustment of minimum clutch size"),\n make_option(c("-i", "--max_clutch_size"), action="store", dest="max_clutch_size", type="integer", help="Adjustment of maximum clutch size"),\n- make_option(c("-j", "--nymph_mort"), action="store", dest="nymph_mort", type="integer", help="Adjustment rate for nymph mortality"),\n- make_option(c("-k", "--old_nymph_accum"), action="store", dest="old_nymph_accum", type="integer", help="Adjustment of degree-days accumulation (young nymph->old nymph)"),\n+ make_option(c("-j", "--nymph_mortality"), action="store", dest="nymph_mortality", type="integer", help="Adjustment rate for nymph mortality"),\n+ make_option(c("-k", "--old_nymph_accumulation"), action="store", dest="old_nymph_accumulation", type="integer", help="Adjustment of degree-days accumulation (young nymph->old nymph)"),\n make_option(c("-n", "--num_days"), action="store", dest="num_days", type="integer", help="Total number of days in the temperature dataset"),\n make_option(c("-o", "--output"), action="store", dest="output", help="Output dataset"),\n make_option(c("-p", "--oviposition"), action="store", dest="oviposition", type="integer", help="Adjustment for oviposition rate"),\n@@ -18,7 +18,7 @@\n make_option(c("-s", "--replications"), action="store", dest="replications", type="integer", help="Number of replications"),\n make_option(c("-t", "--std_error_plot"), action="store", dest="std_error_plot", help="Plot Standard error"),\n make_option(c("-v", "--input"), action="store", dest="input", help="Temperature data for selected location"),\n- make_option(c("-y", "--young_nymph_accum"), action="store", dest="young_nymph_accum", type="integer", help="Adjustment of degree-days accumulation (egg->young nymph)"),\n+ make_option(c("-y", "--young_nymph_accumulation"), action="store", dest="young_nymph_accumulation", type="integer", help="Adjustment of degree-days accumulation (egg->young nymph)"),\n make_option(c("-x", "--insect"), action="store", dest="insect", help="Insect name")\n )\n \n@@ -26,23 +26,6 @@\n args <- parse_args(parser, positional_arguments=TRUE)\n opt <- args$options\n \n-parse_input_data = function(input_file, num_rows) {\n- # Read in the input temperature datafile into a data frame.\n- temperature_data_frame <- read.csv(file=input_file, header=T, strip.white=TRUE, sep=",")\n- num_columns <- dim(temperature_data_frame)[2]\n- if (num_columns == 6) {\n- # The input data has the following 6 columns:\n- # LATITUDE, LONGITUDE, DATE, DOY, TMIN, TMAX\n- # Set the column names for access when adding daylight length..\n- colnames(temperature_data_frame) <- c("LATITUDE","LONGITUDE", "DATE", "DOY", "TMIN", "TMAX")\n- # Add a column containing the daylight length for each day.\n- temp'..b', lwd=2, lty=1, col=4)\n-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"))\n-axis(2, cex.axis=3)\n-legend("topleft", c("Egg", "Nymph", "Adult"), lty=c(1, 1, 1), col=c(4, 2, 1), cex=3)\n-if (opt$std_error_plot == 1) {\n- # Add Standard error lines to plot\n- # Standard error for adults\n- lines (day.all, adults+adults.std_error, lty=2)\n- lines (day.all, adults-adults.std_error, lty=2)\n- # Standard error for nymphs\n- lines (day.all, nymphs+nymphs.std_error, col=2, lty=2)\n- lines (day.all, nymphs-nymphs.std_error, col=2, lty=2)\n- # Standard error for eggs\n- lines (day.all, eggs+eggs.std_error, col=4, lty=2)\n- lines (day.all, eggs-eggs.std_error, col=4, lty=2)\n-}\n+maxval <- max(eggs+eggs.std_error, nymphs+nymphs.std_error, adults+adults.std_error)\n+render_chart("pop_size_by_life_stage", opt$insect, opt$location, latitude, start_date, end_date, days.all, maxval,\n+ opt$std_error_plot, adults, nymphs, eggs, adults.std_error, nymphs.std_error, eggs.std_error)\n \n # Subfigure 2: population size by generation\n-title <- paste(opt$insect, ": Total pop. by generation :", opt$location, ": Lat:", latitude, ":", start_date, "-", end_date, sep=" ")\n-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)\n-lines(day.all, F1, lwd = 2, lty = 1, col=2)\n-lines(day.all, F2, lwd = 2, lty = 1, col=4)\n-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"))\n-axis(2, cex.axis=3)\n-legend("topleft", c("P", "F1", "F2"), lty=c(1, 1, 1), col=c(1, 2, 4), cex=3)\n-if (opt$std_error_plot == 1) {\n- # Add Standard error lines to plot\n- # Standard error for adults\n- lines (day.all, P+P.std_error, lty=2)\n- lines (day.all, P-P.std_error, lty=2)\n- # Standard error for nymphs\n- lines (day.all, F1+F1.std_error, col=2, lty=2)\n- lines (day.all, F1-F1.std_error, col=2, lty=2)\n- # Standard error for eggs\n- lines (day.all, F2+F2.std_error, col=4, lty=2)\n- lines (day.all, F2-F2.std_error, col=4, lty=2)\n-}\n+maxval <- max(F2)\n+render_chart("pop_size_by_generation", opt$insect, opt$location, latitude, start_date, end_date, days.all, maxval,\n+ opt$std_error_plot, P, F1, F2, P.std_error, F1.std_error, F2.std_error)\n+\n \n # Subfigure 3: adult population size by generation\n-title <- paste(opt$insect, ": Adult pop. by generation :", opt$location, ": Lat:", latitude, ":", start_date, "-", end_date, sep=" ")\n-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)\n-lines(day.all, F1_adults, lwd = 2, lty = 1, col=2)\n-lines(day.all, F2_adults, lwd = 2, lty = 1, col=4)\n-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"))\n-axis(2, cex.axis=3)\n-legend("topleft", c("P", "F1", "F2"), lty=c(1, 1, 1), col=c(1, 2, 4), cex=3)\n-if (opt$std_error_plot == 1) {\n- # Add Standard error lines to plot\n- # Standard error for adults\n- lines (day.all, P_adults+P_adults.std_error, lty=2)\n- lines (day.all, P_adults-P_adults.std_error, lty=2)\n- # Standard error for nymphs\n- lines (day.all, F1_adults+F1_adults.std_error, col=2, lty=2)\n- lines (day.all, F1_adults-F1_adults.std_error, col=2, lty=2)\n- # Standard error for eggs\n- lines (day.all, F2_adults+F2_adults.std_error, col=4, lty=2)\n- lines (day.all, F2_adults-F2_adults.std_error, col=4, lty=2)\n-}\n+maxval <- max(F2_adults) + 100\n+render_chart("adult_pop_size_by_generation", opt$insect, opt$location, latitude, start_date, end_date, days.all, maxval,\n+ opt$std_error_plot, P_adults, F1_adults, F2_adults, P_adults.std_error, F1_adults.std_error, F2_adults2.std_error)\n+\n \n # Turn off device driver to flush output.\n dev.off()\n' |