changeset 3:24fa0d35a8bf draft

Uploaded
author greg
date Thu, 09 Nov 2017 14:20:42 -0500
parents 07444af6824f
children e7b1fc0133bb
files insect_phenology_model.R insect_phenology_model.xml test-data/asheville2014.csv test-data/output.pdf test-data/state_college.csv tool-data/locations.txt.sample tool-data/years.txt.sample
diffstat 7 files changed, 372 insertions(+), 614 deletions(-) [+]
line wrap: on
line diff
--- a/insect_phenology_model.R	Mon Aug 14 13:47:50 2017 -0400
+++ b/insect_phenology_model.R	Thu Nov 09 14:20:42 2017 -0500
@@ -6,19 +6,18 @@
     make_option(c("-a", "--adult_mort"), action="store", dest="adult_mort", type="integer", help="Adjustment rate for adult mortality"),
     make_option(c("-b", "--adult_accum"), action="store", dest="adult_accum", type="integer", help="Adjustment of DD accumulation (old nymph->adult)"),
     make_option(c("-c", "--egg_mort"), action="store", dest="egg_mort", type="integer", help="Adjustment rate for egg mortality"),
-    make_option(c("-d", "--latitude"), action="store", dest="latitude", type="double", help="Latitude of selected location"),
     make_option(c("-e", "--location"), action="store", dest="location", help="Selected location"),
     make_option(c("-f", "--min_clutch_size"), action="store", dest="min_clutch_size", type="integer", help="Adjustment of minimum clutch size"),
     make_option(c("-i", "--max_clutch_size"), action="store", dest="max_clutch_size", type="integer", help="Adjustment of maximum clutch size"),
     make_option(c("-j", "--nymph_mort"), action="store", dest="nymph_mort", type="integer", help="Adjustment rate for nymph mortality"),
     make_option(c("-k", "--old_nymph_accum"), action="store", dest="old_nymph_accum", type="integer", help="Adjustment of DD accumulation (young nymph->old nymph)"),
+    make_option(c("-n", "--num_days"), action="store", dest="num_days", type="integer", help="Total number of days in the temperature dataset"),
     make_option(c("-o", "--output"), action="store", dest="output", help="Output dataset"),
     make_option(c("-p", "--oviposition"), action="store", dest="oviposition", type="integer", help="Adjustment for oviposition rate"),
     make_option(c("-q", "--photoperiod"), action="store", dest="photoperiod", type="double", help="Critical photoperiod for diapause induction/termination"),
     make_option(c("-s", "--replications"), action="store", dest="replications", type="integer", help="Number of replications"),
     make_option(c("-t", "--se_plot"), action="store", dest="se_plot", help="Plot SE"),
-    make_option(c("-u", "--year"), action="store", dest="year", type="integer", help="Starting year"),
-    make_option(c("-v", "--temperature_dataset"), action="store", dest="temperature_dataset", help="Temperature data for selected location"),
+    make_option(c("-v", "--input"), action="store", dest="input", help="Temperature data for selected location"),
     make_option(c("-y", "--young_nymph_accum"), action="store", dest="young_nymph_accum", type="integer", help="Adjustment of DD accumulation (egg->young nymph)")
 )
 
@@ -26,40 +25,42 @@
 args <- parse_args(parser, positional_arguments=TRUE)
 opt <- args$options
 
-data.input=function(loc, year, temperature.dataset)
+convert_csv_to_rdata=function(temperature_data, data_matrix)
 {
-    expdata <- matrix(rep(0, 365 * 3), nrow=365)
-    namedat <- paste(loc,  year, ".Rdat", sep="")
-    temp.data <- read.csv(file=temperature.dataset, header=T)
-
-    expdata[,1] <- c(1:365)
+    # Integer day of the year.
+    data_matrix[,1] <- c(1:opt$num_days)
     # Minimum
-    expdata[,2] <- temp.data[c(1:365), 3]
+    data_matrix[,2] <- temperature_data[c(1:opt$num_days), 5]
     # Maximum
-    expdata[,3] <- temp.data[c(1:365), 2]
-    save(expdata, file=namedat)
+    data_matrix[,3] <- temperature_data[c(1:opt$num_days), 6]
+    namedat <- "tempdata.Rdat"
+    save(data_matrix, file=namedat)
     namedat
 }
 
-daylength=function(latitude)
+daylength=function(latitude, num_days)
 {
-    # from Forsythe 1995
+    # From Forsythe 1995.
     p=0.8333
     dl <- NULL
-    for (i in 1:365) {
+    for (i in 1:num_days) {
         theta <- 0.2163108 + 2 * atan(0.9671396 * tan(0.00860 * (i - 186)))
         phi <- asin(0.39795 * cos(theta))
         dl[i] <- 24 - 24 / pi * acos((sin(p * pi / 180) + sin(latitude * pi / 180) * sin(phi)) / (cos(latitude * pi / 180) * cos(phi)))
     }
-    dl   # return a vector of daylength in 365 days
+    # Return a vector of daylength for the number of
+    # days specified in the input temperature data.
+    dl
 }
 
-hourtemp=function(latitude, date, temperature_file_path)
+hourtemp=function(latitude, date, temperature_file_path, num_days)
 {
     load(temperature_file_path)
-    threshold <- 14.17  # base development threshold for BMSB
-    dnp <- expdata[date, 2]  # daily minimum
-    dxp <- expdata[date, 3]  # daily maximum
+    # Base development threshold for Brown Marmolated Stink Bug
+    # insect phenology model.
+    threshold <- 14.17
+    dnp <- data_matrix[date, 2]  # daily minimum
+    dxp <- data_matrix[date, 3]  # daily maximum
     dmean <- 0.5 * (dnp + dxp)
     dd <- 0  # initialize degree day accumulation
 
@@ -67,22 +68,30 @@
         dd <- 0
     }
     else {
-        dlprofile <- daylength(latitude)  # extract daylength data for entire year
-        T <- NULL  # initialize hourly temperature
-        dh <- NULL #initialize degree hour vector
-        # date <- 200
-        y <- dlprofile[date]  # calculate daylength in given date
-        z <- 24 - y     # night length
-        a <- 1.86     # lag coefficient
-        b <- 2.20     # night coefficient
-        #tempdata <- read.csv("tempdata.csv") #import raw data set
-        # Should be outside function otherwise its redundant
-        risetime <- 12 - y / 2      # sunrise time
-        settime <- 12 + y / 2       # sunset time
+        # Extract daylength data for the number of
+        # days specified in the input temperature data.
+        dlprofile <- daylength(latitude, num_days)
+        # Initialize hourly temperature.
+        T <- NULL
+        # Initialize degree hour vector.
+        dh <- NULL
+        # Calculate daylength in given date.
+        y <- dlprofile[date]
+        # Night length.
+        z <- 24 - y
+        # Lag coefficient.
+        a <- 1.86
+        # Night coefficient.
+        b <- 2.20
+        # Sunrise time.
+        risetime <- 12 - y / 2
+        # Sunset time.
+        settime <- 12 + y / 2
         ts <- (dxp - dnp) * sin(pi * (settime - 5) / (y + 2 * a)) + dnp
         for (i in 1:24) {
             if (i > risetime && i<settime) {
-                m <- i - 5  # number of hours after Tmin until sunset
+                # Number of hours after Tmin until sunset.
+                m <- i - 5
                 T[i]=(dxp - dnp) * sin(pi * m / (y + 2 * a)) + dnp
                 if (T[i]<8.4) {
                     dh[i] <- 0
@@ -189,73 +198,64 @@
     return
 }
 
-cat("Replications: ", opt$replications, "\n")
-cat("Photoperiod: ", opt$photoperiod, "\n")
-cat("Oviposition rate: ", opt$oviposition, "\n")
-cat("Egg mortality rate: ", opt$egg_mort, "\n")
-cat("Nymph mortality rate: ", opt$nymph_mort, "\n")
-cat("Adult mortality rate: ", opt$adult_mort, "\n")
-cat("Min clutch size: ", opt$min_clutch_size, "\n")
-cat("Max clutch size: ", opt$max_clutch_size, "\n")
-cat("(egg->young nymph): ", opt$young_nymph_accum, "\n")
-cat("(young nymph->old nymph): ", opt$old_nymph_accum, "\n")
-cat("(old nymph->adult): ", opt$adult_accum, "\n")
+# Read in the input temperature datafile into a Data Frame object.
+temperature_data <- read.csv(file=opt$input, header=T, sep=",")
+start_date <- temperature_data[c(1:1), 3]
+end_date <- temperature_data[c(opt$num_days:opt$num_days), 3]
+raw_data_matrix <- matrix(rep(0, opt$num_days * 6), nrow=opt$num_days)
+temperature_file_path <- convert_csv_to_rdata(temperature_data, raw_data_matrix)
+latitude <- temperature_data[1, 1]
 
-# Read in the input temperature datafile
-temperature_file_path <- data.input(opt$location, opt$year, opt$temperature_dataset)
+cat("Number of days: ", opt$num_days, "\n")
 
-# Initialize matrix for results from all replications
-S0.rep <- S1.rep <- S2.rep <- S3.rep <- S4.rep <- S5.rep <- matrix(rep(0, 365 * opt$replications), ncol = opt$replications)
-newborn.rep <- death.rep <- adult.rep <- pop.rep <- g0.rep <- g1.rep <- g2.rep <- g0a.rep <- g1a.rep <- g2a.rep <- matrix(rep(0, 365 * opt$replications), ncol=opt$replications)
+# Initialize matrix for results from all replications.
+S0.rep <- S1.rep <- S2.rep <- S3.rep <- S4.rep <- S5.rep <- matrix(rep(0, opt$num_days * opt$replications), ncol = opt$replications)
+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)
 
 # loop through replications
 for (N.rep in 1:opt$replications) {
-    # during each replication
-    # start with 1000 individuals -- user definable as well?
+    # During each replication start with 1000 individuals.
+    # TODO: user definable as well?
     n <- 1000
-    # Generation, Stage, DD, T, Diapause
+    # Generation, Stage, DD, T, Diapause.
     vec.ini <- c(0, 3, 0, 0, 0)
-    # overwintering, previttelogenic, DD=0, T=0, no-diapause
+    # Overwintering, previttelogenic, DD=0, T=0, no-diapause.
     vec.mat <- rep(vec.ini, n)
-    # complete matrix for the population
-    vec.mat <- t(matrix(vec.mat, nrow=5))
-    # complete photoperiod profile in a year, requires daylength function
-    ph.p <- daylength(opt$latitude)
+    # Complete matrix for the population.
+    vec.mat <- base::t(matrix(vec.mat, nrow=5))
+    # Complete photoperiod profile in a year, requires daylength function.
+    ph.p <- daylength(latitude, opt$num_days)
 
-    # time series of population size
+    # Time series of population size.
     tot.pop <- NULL
-    # gen.0 pop size
-    gen0.pop <- rep(0, 365)
-    gen1.pop <- rep(0, 365)
-    gen2.pop <- rep(0, 365)
-    S0 <- S1 <- S2 <- S3 <- S4 <- S5 <- rep(0, 365)
-    g0.adult <- g1.adult <- g2.adult <- rep(0, 365)
-    N.newborn <- N.death <- N.adult <- rep(0, 365)
-    dd.day <- rep(0, 365)
+    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)
+    dd.day <- rep(0, opt$num_days)
 
-    # start tick
-    ptm <- proc.time()
-
-    # all the days
-    for (day in 1:365) {
-        # photoperiod in the day
+    # All the days included in the input temperature dataset.
+    for (day in 1:opt$num_days) {
+        # Photoperiod in the day.
         photoperiod <- ph.p[day]
-        temp.profile <- hourtemp(opt$latitude, day, temperature_file_path)
+        temp.profile <- hourtemp(latitude, day, temperature_file_path, opt$num_days)
         mean.temp <- temp.profile[1]
         dd.temp <- temp.profile[2]
         dd.day[day] <- dd.temp
-        # trash bin for death
+        # Trash bin for death.
         death.vec <- NULL
-        # new born
+        # Newborn.
         birth.vec <- NULL
 
-        # all individuals
+        # All individuals.
         for (i in 1:n) {
-            # find individual record
+            # Find individual record.
             vec.ind <- vec.mat[i,]
-            # first of all, still alive?  
-            # adjustment for late season mortality rate
-            if (opt$latitude < 40.0) {
+            # First of all, still alive?
+            # Adjustment for late season mortality rate.
+            if (latitude < 40.0) {
                 post.mort <- 1
                 day.kill <- 300
             }
@@ -264,19 +264,19 @@
                 day.kill <- 250
             }
             if (vec.ind[2] == 0) {
-                # egg
+                # Egg.
                 death.prob = opt$egg_mort * mortality.egg(mean.temp)
             }
             else if (vec.ind[2] == 1 | vec.ind[2] == 2) {
                 death.prob = opt$nymph_mort * mortality.nymph(mean.temp)
             }
             else if (vec.ind[2] == 3 | vec.ind[2] == 4 | vec.ind[2] == 5) {
-                # for adult
+                # For adult.
                 if (day < day.kill) {
                     death.prob = opt$adult_mort * mortality.adult(mean.temp)
                 }
                 else {
-                    # increase adult mortality after fall equinox
+                    # Increase adult mortality after fall equinox.
                     death.prob = opt$adult_mort * post.mort * mortality.adult(mean.temp)
                 }
             }
@@ -286,218 +286,216 @@
                 death.vec <- c(death.vec, i)
             } 
             else {
-                # aggregrate index of dead bug
-                # event 1 end of diapause
+                # Aggregrate index of dead bug.
+                # Event 1 end of diapause.
                 if (vec.ind[1] == 0 && vec.ind[2] == 3) {
-                    # overwintering adult (previttelogenic)
+                    # Overwintering adult (previttelogenic).
                     if (photoperiod > opt$photoperiod && vec.ind[3] > 68 && day < 180) {
-                        # add 68C to become fully reproductively matured
-                        # transfer to vittelogenic
+                        # Add 68C to become fully reproductively matured.
+                        # Transfer to vittelogenic.
                         vec.ind <- c(0, 4, 0, 0, 0)
                         vec.mat[i,] <- vec.ind
                     }
                     else {
-                        # add to DD
+                        # Add to dd.
                         vec.ind[3] <- vec.ind[3] + dd.temp
-                        # add 1 day in current stage
+                        # Add 1 day in current stage.
                         vec.ind[4] <- vec.ind[4] + 1
                         vec.mat[i,] <- vec.ind
                     }
                 }
                 if (vec.ind[1] != 0 && vec.ind[2] == 3) {
-                    # NOT overwintering adult (previttelogenic)
+                    # Not overwintering adult (previttelogenic).
                     current.gen <- vec.ind[1]
                     if (vec.ind[3] > 68) {
-                        # add 68C to become fully reproductively matured
-                        # transfer to vittelogenic
+                        # Add 68C to become fully reproductively matured.
+                        # Transfer to vittelogenic.
                         vec.ind <- c(current.gen, 4, 0, 0, 0)
                         vec.mat[i,] <- vec.ind
                     }
                     else {
-                        # add to DD
+                        # Add to dd.
                         vec.ind[3] <- vec.ind[3] + dd.temp
-                        # add 1 day in current stage
+                        # Add 1 day in current stage.
                         vec.ind[4] <- vec.ind[4] + 1
                         vec.mat[i,] <- vec.ind
                     }
                 }
 
-                # event 2 oviposition -- where population dynamics comes from
+                # Event 2 oviposition -- where population dynamics comes from.
                 if (vec.ind[2] == 4 && vec.ind[1] == 0 && mean.temp > 10) {
-                    # vittelogenic stage, overwintering generation
+                    # Vittelogenic stage, overwintering generation.
                     if (vec.ind[4] == 0) {
-                        # just turned in vittelogenic stage
+                        # Just turned in vittelogenic stage.
                         n.birth=round(runif(1, 2 + opt$min_clutch_size, 8 + opt$max_clutch_size))
                     }
                     else {
-                        # daily probability of birth
+                        # Daily probability of birth.
                         p.birth = opt$oviposition * 0.01
                         u1 <- runif(1)
                         if (u1 < p.birth) {
                             n.birth=round(runif(1, 2, 8))
                         }
                     }
-                    # add to DD
+                    # Add to dd.
                     vec.ind[3] <- vec.ind[3] + dd.temp
-                    # add 1 day in current stage
+                    # Add 1 day in current stage.
                     vec.ind[4] <- vec.ind[4] + 1
                     vec.mat[i,] <- vec.ind
                     if (n.birth > 0) {
-                        # add new birth -- might be in different generations
-                        # generation + 1
+                        # Add new birth -- might be in different generations.
                         new.gen <- vec.ind[1] + 1
-                        # egg profile
+                        # Egg profile.
                         new.ind <- c(new.gen, 0, 0, 0, 0)
                         new.vec <- rep(new.ind, n.birth)
-                        # update batch of egg profile
+                        # Update batch of egg profile.
                         new.vec <- t(matrix(new.vec, nrow=5))
-                        # group with total eggs laid in that day
+                        # Group with total eggs laid in that day.
                         birth.vec <- rbind(birth.vec, new.vec)
                     }
                 }
 
-                # event 2 oviposition -- for gen 1.
+                # Event 2 oviposition -- for gen 1.
                 if (vec.ind[2] == 4 && vec.ind[1] == 1 && mean.temp > 12.5 && day < 222) {
-                    # vittelogenic stage, 1st generation
+                    # Vittelogenic stage, 1st generation
                     if (vec.ind[4] == 0) {
-                        # just turned in vittelogenic stage
+                        # Just turned in vittelogenic stage.
                         n.birth=round(runif(1, 2 + opt$min_clutch_size, 8 + opt$max_clutch_size))
                     }
                     else {
-                        # daily probability of birth
+                        # Daily probability of birth.
                         p.birth = opt$oviposition * 0.01
                         u1 <- runif(1)
                         if (u1 < p.birth) {
                             n.birth = round(runif(1, 2, 8))
                         }
                     }
-                    # add to DD
+                    # Add to dd.
                     vec.ind[3] <- vec.ind[3] + dd.temp
-                    # add 1 day in current stage
+                    # Add 1 day in current stage.
                     vec.ind[4] <- vec.ind[4] + 1
                     vec.mat[i,] <- vec.ind
                     if (n.birth > 0) {
-                        # add new birth -- might be in different generations
-                        # generation + 1
+                        # Add new birth -- might be in different generations.
                         new.gen <- vec.ind[1] + 1
-                        # egg profile
+                        # Egg profile.
                         new.ind <- c(new.gen, 0, 0, 0, 0)
                         new.vec <- rep(new.ind, n.birth)
-                        # update batch of egg profile
+                        # Update batch of egg profile.
                         new.vec <- t(matrix(new.vec, nrow=5))
-                        # group with total eggs laid in that day
+                        # Group with total eggs laid in that day.
                         birth.vec <- rbind(birth.vec, new.vec)
                     }
                 }
 
-                # event 3 development (with diapause determination)
-                # event 3.1 egg development to young nymph (vec.ind[2]=0 -> egg)
+                # Event 3 development (with diapause determination).
+                # Event 3.1 egg development to young nymph (vec.ind[2]=0 -> egg).
                 if (vec.ind[2] == 0) {
-                    # egg stage
-                    # add to DD
+                    # Egg stage.
+                    # Add to dd.
                     vec.ind[3] <- vec.ind[3] + dd.temp
                     if (vec.ind[3] >= (68 + opt$young_nymph_accum)) {
-                        # from egg to young nymph, DD requirement met
+                        # From egg to young nymph, DD requirement met.
                         current.gen <- vec.ind[1]
-                        # transfer to young nym stage
+                        # Transfer to young nymph stage.
                         vec.ind <- c(current.gen, 1, 0, 0, 0)
                     }
                     else {
-                        # add 1 day in current stage
+                        # Add 1 day in current stage.
                         vec.ind[4] <- vec.ind[4] + 1
                     }
                     vec.mat[i,] <- vec.ind
                 }
 
-                # event 3.2 young nymph to old nymph (vec.ind[2]=1 -> young nymph: determines diapause)
+                # Event 3.2 young nymph to old nymph (vec.ind[2]=1 -> young nymph: determines diapause).
                 if (vec.ind[2] == 1) {
-                    # young nymph stage
-                    # add to DD
+                    # young nymph stage.
+                    # add to dd.
                     vec.ind[3] <- vec.ind[3] + dd.temp
                     if (vec.ind[3] >= (250 + opt$old_nymph_accum)) {
-                        # from young to old nymph, DD requirement met
+                        # From young to old nymph, dd requirement met.
                         current.gen <- vec.ind[1]
-                        # transfer to old nym stage
+                        # Transfer to old nym stage.
                         vec.ind <- c(current.gen, 2, 0, 0, 0)
                         if (photoperiod < opt$photoperiod && day > 180) {
                             vec.ind[5] <- 1
-                        } # prepare for diapausing
+                        } # Prepare for diapausing.
                     }
                     else {
-                        # add 1 day in current stage
+                        # Add 1 day in current stage.
                         vec.ind[4] <- vec.ind[4] + 1
                     }
                     vec.mat[i,] <- vec.ind
                 }  
 
-                # event 3.3 old nymph to adult: previttelogenic or diapausing?
+                # Event 3.3 old nymph to adult: previttelogenic or diapausing?
                 if (vec.ind[2] == 2) {
-                    # old nymph stage
-                    # add to DD
+                    # Old nymph stage.
+                    # add to dd.
                     vec.ind[3] <- vec.ind[3] + dd.temp
                     if (vec.ind[3] >= (200 + opt$adult_accum)) {
-                        # from old to adult, DD requirement met
+                        # From old to adult, dd requirement met.
                         current.gen <- vec.ind[1]
                         if (vec.ind[5] == 0) {
-                            # non-diapausing adult -- previttelogenic
+                            # Non-diapausing adult -- previttelogenic.
                             vec.ind <- c(current.gen, 3, 0, 0, 0)
                         }
                         else {
-                            # diapausing 
+                            # Diapausing.
                             vec.ind <- c(current.gen, 5, 0, 0, 1)
                         }
                     }
                     else {
-                        # add 1 day in current stage
+                        # Add 1 day in current stage.
                         vec.ind[4] <- vec.ind[4] + 1
                     }
                     vec.mat[i,] <- vec.ind
                 }
 
-                # event 4 growing of diapausing adult (unimportant, but still necessary)## 
+                # Event 4 growing of diapausing adult (unimportant, but still necessary).
                 if (vec.ind[2] == 5) {
                     vec.ind[3] <- vec.ind[3] + dd.temp
                     vec.ind[4] <- vec.ind[4] + 1
                     vec.mat[i,] <- vec.ind
                 }
-            } # else if it is still alive
-        } # end of the individual bug loop
+            } # Else if it is still alive.
+        } # End of the individual bug loop.
 
-        # find how many died
+        # Find how many died.
         n.death <- length(death.vec)
         if (n.death > 0) {
             vec.mat <- vec.mat[-death.vec, ]
         }
-        # remove record of dead
-        # find how many new born  
+        # Remove record of dead.
+        # Find how many new born.
         n.newborn <- length(birth.vec[,1])
         vec.mat <- rbind(vec.mat, birth.vec)
-        # update population size for the next day
+        # Update population size for the next day.
         n <- n - n.death + n.newborn 
 
-        # aggregate results by day
+        # Aggregate results by day.
         tot.pop <- c(tot.pop, n) 
-        # egg
+        # Egg.
         s0 <- sum(vec.mat[,2] == 0)
-        # young nymph
+        # Young nymph.
         s1 <- sum(vec.mat[,2] == 1)
-        # old nymph
+        # Old nymph.
         s2 <- sum(vec.mat[,2] == 2)
-        # previtellogenic
+        # Previtellogenic.
         s3 <- sum(vec.mat[,2] == 3)
-        # vitellogenic
+        # Vitellogenic.
         s4 <- sum(vec.mat[,2] == 4)
-        # diapausing
+        # Diapausing.
         s5 <- sum(vec.mat[,2] == 5)
-        # overwintering adult
+        # Overwintering adult.
         gen0 <- sum(vec.mat[,1] == 0)
-        # first generation
+        # First generation.
         gen1 <- sum(vec.mat[,1] == 1)
-        # second generation
+        # Second generation.
         gen2 <- sum(vec.mat[,1] == 2)
-        # sum of all adults
+        # Sum of all adults.
         n.adult <- sum(vec.mat[,2] == 3) + sum(vec.mat[,2] == 4) + sum(vec.mat[,2] == 5)
-        # gen.0 pop size
+        # Gen eration 0 pop size.
         gen0.pop[day] <- gen0
         gen1.pop[day] <- gen1
         gen2.pop[day] <- gen2
@@ -514,11 +512,10 @@
         N.newborn[day] <- n.newborn
         N.death[day] <- n.death
         N.adult[day] <- n.adult
-        #print(c(N.rep, day, n, n.adult))
-    }   # end of 365 days
+    }   # end of days specified in the input temperature data
 
     dd.cum <- cumsum(dd.day)
-    # collect all the outputs
+    # Collect all the outputs.
     S0.rep[,N.rep] <- S0
     S1.rep[,N.rep] <- S1
     S2.rep[,N.rep] <- S2
@@ -537,15 +534,11 @@
     g2a.rep[,N.rep] <- g2.adult
 }
 
-# save(dd.day, dd.cum, S0.rep, S1.rep, S2.rep, S3.rep, S4.rep, S5.rep, newborn.rep, death.rep, adult.rep, pop.rep, g0.rep, g1.rep, g2.rep, g0a.rep, g1a.rep, g2a.rep, file=opt$output)
-# maybe do not need to export this bit, but for now just leave it as-is
-# do we need to export this Rdat file? 
-
 # Data analysis and visualization
 # default: plot 1 year of result
 # but can be expanded to accommodate multiple years
 n.yr <- 1
-day.all <- c(1:365 * n.yr)
+day.all <- c(1:opt$num_days * n.yr)
 
 # mean value for adults
 sa <- apply((S3.rep + S4.rep + S5.rep), 1, mean)
@@ -593,30 +586,32 @@
 par(mar = c(5, 6, 4, 4), mfrow=c(3, 1))
 
 # Subfigure 2: population size by life stage
-plot(day.all, sa, main = "BSMB Total Population Size by Life Stage", 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)
-# Young and old nymphs
-lines(day.all, sn, lwd = 2, lty = 1, col = 2)
+title <- paste("BSMB Total Population Size by Life Stage:", opt$location, ", Latitude:", latitude, ", Temperature Dates:", start_date, "to", end_date, sep=" ")
+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)
+# Young and old nymphs.
+lines(day.all, sn, lwd=2, lty=1, col=2)
 # Eggs
-lines(day.all, se, lwd = 2, lty = 1, col = 4)
-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"))
+lines(day.all, se, lwd=2, lty=1, col=4)
+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"))
 axis(2, cex.axis = 2)
 leg.text <- c("Egg", "Nymph", "Adult")
-legend("topleft", leg.text, lty = c(1, 1, 1), col = c(4, 2, 1), cex = 2)
+legend("topleft", leg.text, lty=c(1, 1, 1), col=c(4, 2, 1), cex=2)
 if (opt$se_plot == 1) {
     # add SE lines to plot
     # SE for adults
-    lines (day.all, sa + sa.se, lty = 2)
-    lines (day.all, sa - sa.se, lty = 2) 
+    lines (day.all, sa + sa.se, lty=2)
+    lines (day.all, sa - sa.se, lty=2) 
     # SE for nymphs
-    lines (day.all, sn + sn.se, col = 2, lty = 2)
-    lines (day.all, sn - sn.se, col = 2, lty = 2) 
+    lines (day.all, sn + sn.se, col=2, lty=2)
+    lines (day.all, sn - sn.se, col=2, lty=2) 
     # SE for eggs
-    lines (day.all, se + se.se, col = 4, lty = 2)
-    lines (day.all, se - se.se, col = 4, lty = 2) 
+    lines (day.all, se + se.se, col=4, lty=2)
+    lines (day.all, se - se.se, col=4, lty=2) 
 }
 
 # Subfigure 3: population size by generation
-plot(day.all, g0, main = "BSMB Total Population Size by Generation", 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)
+title <- paste("BSMB Total Population Size by Generation:", opt$location, ", Latitude:", latitude, ", Temperature Dates:", start_date, "to", end_date, sep=" ")
+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)
 lines(day.all, g1, lwd = 2, lty = 1, col = 2)
 lines(day.all, g2, lwd = 2, lty = 1, col = 4)
 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"))
@@ -637,7 +632,8 @@
 }
 
 # Subfigure 4: adult population size by generation
-plot(day.all, g0a, ylim = c(0, max(g2a) + 100), main = "BSMB Adult Population Size by Generation", type = "l", axes = F, lwd = 2, xlab = "Year", ylab = "Number", cex = 2, cex.lab = 2, cex.axis = 2, cex.main = 2)
+title <- paste("BSMB Adult Population Size by Generation:", opt$location, ", Latitude:", latitude, ", Temperature Dates:", start_date, "to", end_date, sep=" ")
+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)
 lines(day.all, g1a, lwd = 2, lty = 1, col = 2)
 lines(day.all, g2a, lwd = 2, lty = 1, col = 4)
 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"))
--- a/insect_phenology_model.xml	Mon Aug 14 13:47:50 2017 -0400
+++ b/insect_phenology_model.xml	Thu Nov 09 14:20:42 2017 -0500
@@ -1,34 +1,31 @@
 <?xml version="."?>
-<tool id="insect_phenology_model" name="Insect phenology model" version="1.0.0">
+<tool id="insect_phenology_model" name="Insect phenology model" version="1.1.0">
     <description>expressing stage-specific phenology and population dynamics</description>
     <requirements>
-         <requirement type="package" version="1.3.2">r-optparse</requirement>
+         <requirement type="package" version="1.4.4">r-optparse</requirement>
     </requirements>
     <command detect_errors="exit_code"><![CDATA[
 Rscript '$__tool_directory__/insect_phenology_model.R'
 -a $adult_mort
 -b $adult_accum
 -c $egg_mort
--d $latitude
 -e '$location'
 -f $max_clutch_size
 -i $min_clutch_size
 -j $nymph_mort
 -k $old_nymph_accum
+-n $input.metadata.data_lines
 -o '$output'
 -p $oviposition
 -q $photoperiod
 -s $replications
 -t $se_plot
--u $year
--v '$temperature_data'
+-v '$input'
 -y $young_nymph_accum
     ]]></command>
     <inputs>
         <param name="location" type="text" value="" optional="false" label="Location" />
-        <param name="latitude" type="float" value="0.0" label="Latitude of selected location" />
-        <param name="temperature_data" type="data" format="csv" label="Temperature data" />
-        <param name="year" type="integer" value="2017" min="1995" label="Temperature data year" />
+        <param name="input" type="data" format="csv" label="Temperature data" />
         <param name="replications" type="integer" value="10" min="1" label="Number of replications" />
         <param name="photoperiod" type="float" value="13.5" min="0" label="Critical photoperiod for diapause induction/termination" />
         <param name="egg_mort" type="integer" value="1" min="0" label="Adjustment rate for egg mortality" />
@@ -46,14 +43,13 @@
         </param>
     </inputs>
     <outputs>
-        <data name="output" format="pdf" label="${tool.name} ${location}, ${year} lat:${latitude} on ${on_string}" />
+        <data name="output" format="pdf" label="${tool.name} ${location}, on ${on_string}" />
     </outputs>
     <tests>
         <test>
-            <param name="temperature_data" value="asheville2014.csv" ftype="csv" />
-            <param name="location" value="asheville:35.58" />
-            <param name="year" value="2014" />
-            <param name="replications" value="3" />
+            <param name="input" value="state_college.csv" ftype="csv" />
+            <param name="location" value="State College PA" />
+            <param name="replications" value="10" />
             <output name="output" file="output.pdf" ftype="pdf" compare="contains" />
         </test>
     </tests>
@@ -68,7 +64,6 @@
 
  * **Location** - the location associated with the selected temperature data.
  * **Temperature data** - select the dataset from your history containing the temperature data.
- * **Temperature data year** - the year during which the temperature data was recorded.
  * **Number of replications** - number of replications.
  * **Critical photoperiod for diapause induction/termination** - critical photoperiod for diapause induction/termination.
  * **Adjustment rate for egg mortality** - adjustment rate for egg mortality.
@@ -85,5 +80,7 @@
     </help>
     <citations>
         <citation type="doi">10.3389/fphys.2016.00165</citation>
+        <citation type="doi">10.1175/JTECH-D-11-00103.1</citation>
+        <citation type="doi">10.7289/V5D21VHZ</citation>
     </citations>
 </tool>
--- a/test-data/asheville2014.csv	Mon Aug 14 13:47:50 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,366 +0,0 @@
-"","TMAX","TMIN"
-"100746",3.9,-1.7
-"100747",7.8,-3.3
-"100748",7.8,-7.8
-"100749",-3.9,-11.1
-"100750",6.7,-6.7
-"100751",11.1,5
-"100752",8.3,-17.2
-"100753",-6.7,-18.3
-"100754",8.3,-12.8
-"100755",10.6,-5
-"100756",12.2,1.7
-"100757",15,6.1
-"100758",12.8,3.3
-"100759",12.8,-0.6
-"100760",10.6,0.6
-"100761",3.3,-3.3
-"100762",6.1,-6.7
-"100763",9.4,-3.9
-"100764",2.8,-8.3
-"100765",7.2,-2.8
-"100766",16.7,-3.3
-"100767",6.1,-8.9
-"100768",-2.8,-12.8
-"100769",-2.8,-12.8
-"100770",-2.2,-16.7
-"100771",3.3,-10
-"100772",12.2,-3.9
-"100773",9.4,-6.1
-"100774",-5.6,-9.4
-"100775",-3.3,-13.3
-"100776",3.9,-14.4
-"100777",10.6,-7.2
-"100778",16.1,-3.9
-"100779",17.8,-1.1
-"100780",15,2.8
-"100781",7.2,2.8
-"100782",12.8,-2.8
-"100783",0.6,-4.4
-"100784",5.6,-3.9
-"100785",10,0
-"100786",11.7,-1.1
-"100787",3.3,-1.1
-"100788",1.1,-1.1
-"100789",-1.1,-5
-"100790",0.6,-3.3
-"100791",12.8,-2.2
-"100792",5,-3.3
-"100793",11.1,-3.9
-"100794",8.9,-1.1
-"100795",17.2,2.2
-"100796",20,7.2
-"100797",20.6,7.8
-"100798",17.2,3.3
-"100799",17.8,3.3
-"100800",20.6,2.2
-"100801",10,2.2
-"100802",10.6,0.6
-"100803",3.3,-2.8
-"100804",5.6,-6.1
-"100805",8.3,-5
-"100806",14.4,1.1
-"100807",19.4,1.1
-"100808",14.4,-2.2
-"100809",7.2,-2.8
-"100810",15.6,-0.6
-"100811",6.1,0.6
-"100812",12.2,1.1
-"100813",18.3,1.1
-"100814",16.1,7.2
-"100815",20,1.7
-"100816",24.4,3.9
-"100817",20.6,-1.7
-"100818",3.9,-3.3
-"100819",15,-3.9
-"100820",17.8,7.8
-"100821",10.6,5
-"100822",5,0
-"100823",10.6,0
-"100824",13.3,4.4
-"100825",13.9,6.7
-"100826",17.8,0
-"100827",20.6,7.2
-"100828",12.2,3.3
-"100829",11.7,-1.7
-"100830",5.6,-2.8
-"100831",6.1,-5
-"100832",14.4,-2.8
-"100833",14.4,9.4
-"100834",17.2,2.8
-"100835",10.6,0
-"100836",23.9,0.6
-"100837",26.1,7.2
-"100838",27.8,7.2
-"100839",27.2,12.2
-"100840",21.7,13.9
-"100841",16.7,5.6
-"100842",15.6,7.2
-"100843",13.3,6.1
-"100844",13.3,7.2
-"100845",15,5.6
-"100846",21.7,1.7
-"100847",23.9,7.2
-"100848",25,10
-"100849",25,13.3
-"100850",18.9,15.6
-"100851",16.1,0.6
-"100852",14.4,-2.2
-"100853",16.7,2.2
-"100854",11.7,5.6
-"100855",12.8,7.2
-"100856",22.2,5.6
-"100857",24.4,5.6
-"100858",18.9,11.7
-"100859",19.4,9.4
-"100860",22.8,5
-"100861",23.9,13.3
-"100862",26.1,8.3
-"100863",27.8,9.4
-"100864",25.6,16.1
-"100865",22.8,16.1
-"100866",21.7,15
-"100867",18.3,11.7
-"100868",20.6,8.3
-"100869",21.1,7.8
-"100870",26.7,11.1
-"100871",31.7,12.8
-"100872",30.6,13.3
-"100873",29.4,11.7
-"100874",30,12.2
-"100875",24.4,15
-"100876",21.1,14.4
-"100877",29.4,12.8
-"100878",28.9,15
-"100879",30,16.7
-"100880",26.7,15.6
-"100881",20,8.9
-"100882",16.7,6.1
-"100883",16.7,3.9
-"100884",16.1,7.8
-"100885",21.1,6.7
-"100886",25.6,10
-"100887",28.3,12.2
-"100888",27.8,15.6
-"100889",26.7,15
-"100890",26.1,12.2
-"100891",25.6,10.6
-"100892",28.3,14.4
-"100893",27.8,16.1
-"100894",28.9,15
-"100895",28.3,15.6
-"100896",27.8,17.8
-"100897",25.6,17.8
-"100898",22.8,16.7
-"100899",25.6,13.3
-"100900",26.1,13.9
-"100901",30,14.4
-"100902",27.2,17.8
-"100903",27.8,17.8
-"100904",28.9,17.2
-"100905",28.3,20
-"100906",28.3,15.6
-"100907",31.1,16.7
-"100908",27.2,17.8
-"100909",25,17.2
-"100910",27.2,16.7
-"100911",28.3,15.6
-"100912",28.9,16.1
-"100913",28.9,20
-"100914",31.7,17.2
-"100915",32.2,18.3
-"100916",31.7,17.8
-"100917",31.1,16.7
-"100918",29.4,18.3
-"100919",30,17.2
-"100920",28.3,20
-"100921",26.7,18.9
-"100922",27.2,18.9
-"100923",30,18.3
-"100924",28.3,20
-"100925",26.7,20
-"100926",29.4,19.4
-"100927",28.3,18.3
-"100928",32.2,19.4
-"100929",32.2,20.6
-"100930",30,18.3
-"100931",25.6,15
-"100932",27.2,11.7
-"100933",28.3,13.3
-"100934",30,15.6
-"100935",30.6,17.2
-"100936",26.7,18.3
-"100937",27.8,17.8
-"100938",29.4,18.3
-"100939",30,18.3
-"100940",30.6,19.4
-"100941",31.7,19.4
-"100942",26.1,18.3
-"100943",25,13.9
-"100944",26.1,13.3
-"100945",20.6,17.2
-"100946",18.9,16.7
-"100947",26.7,16.7
-"100948",25.6,18.9
-"100949",27.8,19.4
-"100950",28.3,18.9
-"100951",28.3,18.9
-"100952",28.9,17.8
-"100953",30.6,18.3
-"100954",31.1,19.4
-"100955",25,17.2
-"100956",25,15
-"100957",26.1,11.1
-"100958",20.6,13.9
-"100959",23.9,16.1
-"100960",26.7,17.2
-"100961",27.8,18.3
-"100962",26.1,16.1
-"100963",28.9,17.2
-"100964",29.4,15.6
-"100965",27.8,17.2
-"100966",23.9,18.9
-"100967",28.3,19.4
-"100968",23.9,17.8
-"100969",28.3,18.9
-"100970",27.8,19.4
-"100971",22.8,16.1
-"100972",27.2,12.8
-"100973",27.8,14.4
-"100974",27.2,15
-"100975",29.4,17.8
-"100976",28.9,20
-"100977",28.9,19.4
-"100978",32.2,17.8
-"100979",31.1,17.2
-"100980",31.7,19.4
-"100981",31.1,20
-"100982",26.1,20
-"100983",27.8,18.3
-"100984",28.9,14.4
-"100985",31.1,14.4
-"100986",32.8,16.1
-"100987",31.1,18.3
-"100988",30,19.4
-"100989",31.7,20
-"100990",32.2,20
-"100991",31.7,18.9
-"100992",31.7,17.8
-"100993",29.4,19.4
-"100994",31.1,18.9
-"100995",30.6,19.4
-"100996",30,18.3
-"100997",24.4,18.3
-"100998",29.4,17.8
-"100999",26.1,18.9
-"101000",29.4,17.8
-"101001",31.1,18.9
-"101002",25,17.2
-"101003",21.1,16.1
-"101004",27.2,16.1
-"101005",27.2,17.8
-"101006",25,16.7
-"101007",25.6,14.4
-"101008",24.4,15.6
-"101009",26.1,16.1
-"101010",28.3,12.8
-"101011",21.1,12.2
-"101012",21.1,8.9
-"101013",23.3,10
-"101014",23.9,15.6
-"101015",23.9,17.2
-"101016",24.4,15.6
-"101017",24.4,13.3
-"101018",19.4,16.1
-"101019",26.1,14.4
-"101020",27.8,11.1
-"101021",27.8,12.2
-"101022",23.3,16.1
-"101023",16.1,6.7
-"101024",18.3,1.1
-"101025",20,5
-"101026",20,12.2
-"101027",25,13.9
-"101028",27.2,10.6
-"101029",28.3,13.3
-"101030",25,16.7
-"101031",17.8,13.3
-"101032",21.1,12.8
-"101033",20,15
-"101034",19.4,10
-"101035",15.6,10
-"101036",24.4,7.2
-"101037",17.2,9.4
-"101038",18.9,7.8
-"101039",22.2,5
-"101040",17.8,7.2
-"101041",13.3,5.6
-"101042",16.7,5
-"101043",19.4,3.9
-"101044",21.1,3.3
-"101045",22.8,8.9
-"101046",26.7,7.2
-"101047",26.7,8.9
-"101048",16.7,7.2
-"101049",13.3,2.2
-"101050",13.9,2.2
-"101051",2.2,-0.6
-"101052",6.1,-1.1
-"101053",19.4,-2.8
-"101054",22.2,2.2
-"101055",17.8,6.7
-"101056",20.6,6.7
-"101057",8.3,1.7
-"101058",15,-1.1
-"101059",17.2,1.7
-"101060",18.3,1.1
-"101061",22.2,2.2
-"101062",17.8,6.1
-"101063",6.1,-1.7
-"101064",-1.1,-6.1
-"101065",6.7,-7.8
-"101066",12.8,1.7
-"101067",12.2,-5
-"101068",-2.8,-8.3
-"101069",6.1,-10
-"101070",11.1,-1.7
-"101071",10.6,0
-"101072",13.9,-1.7
-"101073",12.8,5
-"101074",22.2,11.7
-"101075",13.3,6.1
-"101076",10,3.3
-"101077",3.9,-2.2
-"101078",5,-3.9
-"101079",15.6,-2.8
-"101080",20,1.1
-"101081",21.1,4.4
-"101082",13.9,7.8
-"101083",16.7,10.6
-"101084",14.4,6.7
-"101085",11.1,7.2
-"101086",14.4,5.6
-"101087",10.6,2.2
-"101088",5,0.6
-"101089",4.4,0
-"101090",2.2,-0.6
-"101091",3.9,-2.2
-"101092",10,-4.4
-"101093",12.2,-1.7
-"101094",9.4,-1.7
-"101095",15.6,-3.9
-"101096",16.1,6.1
-"101097",8.3,2.8
-"101098",11.7,0.6
-"101099",10.6,2.8
-"101100",7.8,3.9
-"101101",9.4,3.9
-"101102",8.9,3.9
-"101103",11.1,3.9
-"101104",12.8,6.1
-"101105",8.3,1.7
-"101106",15.6,-2.2
-"101107",16.7,2.8
-"101108",14.4,10
-"101109",13.9,6.7
-"101110",6.7,0.6
--- a/test-data/output.pdf	Mon Aug 14 13:47:50 2017 -0400
+++ b/test-data/output.pdf	Thu Nov 09 14:20:42 2017 -0500
@@ -1,8 +1,5 @@
-%PDF-1.4
-%ρ\r
 1 0 obj
 <<
-/Title (R Graphics Output)
 /Creator (R)
 >>
 endobj
@@ -12,8 +9,6 @@
 7 0 obj
 << /Type /Page /Parent 3 0 R /Contents 8 0 R /Resources 4 0 R >>
 endobj
-8 0 obj
-endobj
 3 0 obj
 << /Type /Pages /Kids [ 7 0 R ] /Count 1 /MediaBox [0 0 1440 1440] >>
 endobj
@@ -28,7 +23,8 @@
 5 0 obj
 [/ICCBased 6 0 R]
 endobj
-6 0 obj
+9 0 obj
+<<
 /Type /Encoding /BaseEncoding /WinAnsiEncoding
 /Differences [ 45/minus 96/quoteleft
 144/dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
@@ -43,8 +39,6 @@
 << /Type /Font /Subtype /Type1 /Name /F3 /BaseFont /Helvetica-Bold
 /Encoding 9 0 R >>
 endobj
-xref
-0 12
 trailer
 << /Size 12 /Info 1 0 R /Root 2 0 R >>
 startxref
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/state_college.csv	Thu Nov 09 14:20:42 2017 -0500
@@ -0,0 +1,184 @@
+LATITUDE,LONGITUDE,DATE,DOY,TMIN,TMAX
+ 40.81849,-77.84637,2017-04-01,091,3.30,7.66
+ 40.81849,-77.84637,2017-04-02,092,1.69,15.19
+ 40.81849,-77.84637,2017-04-03,093,3.48,18.81
+ 40.81849,-77.84637,2017-04-04,094,9.28,18.75
+ 40.81849,-77.84637,2017-04-05,095,8.14,19.01
+ 40.81849,-77.84637,2017-04-06,096,4.59,12.02
+ 40.81849,-77.84637,2017-04-07,097,1.19,3.66
+ 40.81849,-77.84637,2017-04-08,098,-0.56,13.85
+ 40.81849,-77.84637,2017-04-09,099,-2.32,21.96
+ 40.81849,-77.84637,2017-04-10,100,7.90,26.25
+ 40.81849,-77.84637,2017-04-11,101,9.25,26.48
+ 40.81849,-77.84637,2017-04-12,102,8.95,19.78
+ 40.81849,-77.84637,2017-04-13,103,4.00,15.47
+ 40.81849,-77.84637,2017-04-14,104,5.09,20.10
+ 40.81849,-77.84637,2017-04-15,105,8.44,25.02
+ 40.81849,-77.84637,2017-04-16,106,14.13,26.54
+ 40.81849,-77.84637,2017-04-17,107,8.23,20.59
+ 40.81849,-77.84637,2017-04-18,108,3.27,20.96
+ 40.81849,-77.84637,2017-04-19,109,9.76,13.40
+ 40.81849,-77.84637,2017-04-20,110,10.70,25.45
+ 40.81849,-77.84637,2017-04-21,111,11.74,22.34
+ 40.81849,-77.84637,2017-04-22,112,4.90,13.43
+ 40.81849,-77.84637,2017-04-23,113,0.43,20.16
+ 40.81849,-77.84637,2017-04-24,114,1.21,17.18
+ 40.81849,-77.84637,2017-04-25,115,9.93,14.30
+ 40.81849,-77.84637,2017-04-26,116,11.38,23.36
+ 40.81849,-77.84637,2017-04-27,117,12.42,23.94
+ 40.81849,-77.84637,2017-04-28,118,11.79,25.11
+ 40.81849,-77.84637,2017-04-29,119,11.14,24.38
+ 40.81849,-77.84637,2017-04-30,120,12.08,25.29
+ 40.81849,-77.84637,2017-05-01,121,13.37,25.43
+ 40.81849,-77.84637,2017-05-02,122,10.78,15.74
+ 40.81849,-77.84637,2017-05-03,123,5.09,16.41
+ 40.81849,-77.84637,2017-05-04,124,4.07,14.99
+ 40.81849,-77.84637,2017-05-05,125,8.04,17.02
+ 40.81849,-77.84637,2017-05-06,126,5.92,12.78
+ 40.81849,-77.84637,2017-05-07,127,2.90,12.05
+ 40.81849,-77.84637,2017-05-08,128,1.22,13.07
+ 40.81849,-77.84637,2017-05-09,129,-1.45,17.87
+ 40.81849,-77.84637,2017-05-10,130,5.94,19.31
+ 40.81849,-77.84637,2017-05-11,131,7.90,11.11
+ 40.81849,-77.84637,2017-05-12,132,8.75,12.95
+ 40.81849,-77.84637,2017-05-13,133,5.68,14.39
+ 40.81849,-77.84637,2017-05-14,134,5.94,19.81
+ 40.81849,-77.84637,2017-05-15,135,7.37,22.14
+ 40.81849,-77.84637,2017-05-16,136,5.18,26.96
+ 40.81849,-77.84637,2017-05-17,137,11.12,31.63
+ 40.81849,-77.84637,2017-05-18,138,15.39,32.05
+ 40.81849,-77.84637,2017-05-19,139,13.92,29.51
+ 40.81849,-77.84637,2017-05-20,140,9.38,13.55
+ 40.81849,-77.84637,2017-05-21,141,12.60,17.19
+ 40.81849,-77.84637,2017-05-22,142,10.93,23.45
+ 40.81849,-77.84637,2017-05-23,143,6.24,21.30
+ 40.81849,-77.84637,2017-05-24,144,10.97,21.61
+ 40.81849,-77.84637,2017-05-25,145,11.91,18.55
+ 40.81849,-77.84637,2017-05-26,146,13.00,19.09
+ 40.81849,-77.84637,2017-05-27,147,9.28,22.35
+ 40.81849,-77.84637,2017-05-28,148,13.02,19.25
+ 40.81849,-77.84637,2017-05-29,149,15.61,25.52
+ 40.81849,-77.84637,2017-05-30,150,14.89,20.32
+ 40.81849,-77.84637,2017-05-31,151,12.29,24.32
+ 40.81849,-77.84637,2017-06-01,152,9.02,22.91
+ 40.81849,-77.84637,2017-06-02,153,10.83,22.70
+ 40.81849,-77.84637,2017-06-03,154,10.01,25.36
+ 40.81849,-77.84637,2017-06-04,155,8.05,16.85
+ 40.81849,-77.84637,2017-06-05,156,14.04,23.52
+ 40.81849,-77.84637,2017-06-06,157,13.20,21.63
+ 40.81849,-77.84637,2017-06-07,158,9.99,17.12
+ 40.81849,-77.84637,2017-06-08,159,9.42,23.51
+ 40.81849,-77.84637,2017-06-09,160,10.71,25.54
+ 40.81849,-77.84637,2017-06-10,161,15.90,29.01
+ 40.81849,-77.84637,2017-06-11,162,15.11,31.46
+ 40.81849,-77.84637,2017-06-12,163,15.59,31.82
+ 40.81849,-77.84637,2017-06-13,164,18.19,34.21
+ 40.81849,-77.84637,2017-06-14,165,19.55,29.87
+ 40.81849,-77.84637,2017-06-15,166,17.02,27.22
+ 40.81849,-77.84637,2017-06-16,167,17.59,26.76
+ 40.81849,-77.84637,2017-06-17,168,17.43,29.03
+ 40.81849,-77.84637,2017-06-18,169,20.91,31.44
+ 40.81849,-77.84637,2017-06-19,170,17.51,24.38
+ 40.81849,-77.84637,2017-06-20,171,14.80,25.74
+ 40.81849,-77.84637,2017-06-21,172,13.97,26.99
+ 40.81849,-77.84637,2017-06-22,173,12.72,29.78
+ 40.81849,-77.84637,2017-06-23,174,19.03,25.44
+ 40.81849,-77.84637,2017-06-24,175,15.76,27.33
+ 40.81849,-77.84637,2017-06-25,176,12.89,24.84
+ 40.81849,-77.84637,2017-06-26,177,9.91,23.03
+ 40.81849,-77.84637,2017-06-27,178,10.84,20.57
+ 40.81849,-77.84637,2017-06-28,179,8.10,25.23
+ 40.81849,-77.84637,2017-06-29,180,14.48,29.26
+ 40.81849,-77.84637,2017-06-30,181,19.94,30.59
+ 40.81849,-77.84637,2017-07-01,182,20.79,29.10
+ 40.81849,-77.84637,2017-07-02,183,17.01,29.60
+ 40.81849,-77.84637,2017-07-03,184,17.01,29.60
+ 40.81849,-77.84637,2017-07-04,185,20.43,23.44
+ 40.81849,-77.84637,2017-07-05,186,20.43,23.44
+ 40.81849,-77.84637,2017-07-06,187,19.56,22.32
+ 40.81849,-77.84637,2017-07-07,188,19.35,28.04
+ 40.81849,-77.84637,2017-07-08,189,15.93,25.53
+ 40.81849,-77.84637,2017-07-09,190,11.83,26.33
+ 40.81849,-77.84637,2017-07-10,191,12.38,27.23
+ 40.81849,-77.84637,2017-07-11,192,17.98,28.99
+ 40.81849,-77.84637,2017-07-12,193,21.06,29.84
+ 40.81849,-77.84637,2017-07-13,194,21.07,28.19
+ 40.81849,-77.84637,2017-07-14,195,19.22,28.46
+ 40.81849,-77.84637,2017-07-15,196,16.50,24.54
+ 40.81849,-77.84637,2017-07-16,197,14.44,28.05
+ 40.81849,-77.84637,2017-07-17,198,17.26,30.80
+ 40.81849,-77.84637,2017-07-18,199,17.44,31.69
+ 40.81849,-77.84637,2017-07-19,200,16.67,32.40
+ 40.81849,-77.84637,2017-07-20,201,19.12,32.13
+ 40.81849,-77.84637,2017-07-21,202,20.94,31.43
+ 40.81849,-77.84637,2017-07-22,203,19.30,28.36
+ 40.81849,-77.84637,2017-07-23,204,20.25,30.59
+ 40.81849,-77.84637,2017-07-24,205,18.56,28.17
+ 40.81849,-77.84637,2017-07-25,206,15.18,22.72
+ 40.81849,-77.84637,2017-07-26,207,12.03,26.34
+ 40.81849,-77.84637,2017-07-27,208,16.35,29.74
+ 40.81849,-77.84637,2017-07-28,209,16.35,26.24
+ 40.81849,-77.84637,2017-07-29,210,11.05,23.78
+ 40.81849,-77.84637,2017-07-30,211,7.73,28.01
+ 40.81849,-77.84637,2017-07-31,212,13.66,30.13
+ 40.81849,-77.84637,2017-08-01,213,15.11,30.81
+ 40.81849,-77.84637,2017-08-02,214,16.56,30.22
+ 40.81849,-77.84637,2017-08-03,215,15.69,28.57
+ 40.81849,-77.84637,2017-08-04,216,16.07,30.48
+ 40.81849,-77.84637,2017-08-05,217,12.30,23.46
+ 40.81849,-77.84637,2017-08-06,218,11.46,23.44
+ 40.81849,-77.84637,2017-08-07,219,15.40,18.35
+ 40.81849,-77.84637,2017-08-08,220,12.19,25.48
+ 40.81849,-77.84637,2017-08-09,221,9.23,26.69
+ 40.81849,-77.84637,2017-08-10,222,9.53,25.78
+ 40.81849,-77.84637,2017-08-11,223,16.54,26.25
+ 40.81849,-77.84637,2017-08-12,224,16.29,26.87
+ 40.81849,-77.84637,2017-08-13,225,14.17,26.51
+ 40.81849,-77.84637,2017-08-14,226,13.98,22.43
+ 40.81849,-77.84637,2017-08-15,227,17.69,28.88
+ 40.81849,-77.84637,2017-08-16,228,14.84,29.43
+ 40.81849,-77.84637,2017-08-17,229,13.40,29.96
+ 40.81849,-77.84637,2017-08-18,230,19.42,29.00
+ 40.81849,-77.84637,2017-08-19,231,14.40,28.28
+ 40.81849,-77.84637,2017-08-20,232,12.31,27.77
+ 40.81849,-77.84637,2017-08-21,233,14.27,30.25
+ 40.81849,-77.84637,2017-08-22,234,18.44,31.05
+ 40.81849,-77.84637,2017-08-23,235,14.22,24.64
+ 40.81849,-77.84637,2017-08-24,236,10.30,23.00
+ 40.81849,-77.84637,2017-08-25,237,12.57,21.39
+ 40.81849,-77.84637,2017-08-26,238,10.93,23.29
+ 40.81849,-77.84637,2017-08-27,239,9.96,23.45
+ 40.81849,-77.84637,2017-08-28,240,9.26,22.38
+ 40.81849,-77.84637,2017-08-29,241,13.80,19.09
+ 40.81849,-77.84637,2017-08-30,242,10.88,24.45
+ 40.81849,-77.84637,2017-08-31,243,13.15,24.42
+ 40.81849,-77.84637,2017-09-01,244,7.82,17.91
+ 40.81849,-77.84637,2017-09-02,245,6.20,13.16
+ 40.81849,-77.84637,2017-09-03,246,12.37,19.35
+ 40.81849,-77.84637,2017-09-04,247,10.67,26.97
+ 40.81849,-77.84637,2017-09-05,248,15.39,21.54
+ 40.81849,-77.84637,2017-09-06,249,13.80,18.10
+ 40.81849,-77.84637,2017-09-07,250,9.30,18.45
+ 40.81849,-77.84637,2017-09-08,251,8.86,18.11
+ 40.81849,-77.84637,2017-09-09,252,8.44,18.21
+ 40.81849,-77.84637,2017-09-10,253,3.93,9.19
+ 40.81849,-77.84637,2017-09-11,254,4.98,22.12
+ 40.81849,-77.84637,2017-09-12,255,8.70,24.06
+ 40.81849,-77.84637,2017-09-13,256,12.75,23.14
+ 40.81849,-77.84637,2017-09-14,257,16.60,19.18
+ 40.81849,-77.84637,2017-09-15,258,14.89,25.28
+ 40.81849,-77.84637,2017-09-16,259,14.73,25.42
+ 40.81849,-77.84637,2017-09-17,260,14.85,27.42
+ 40.81849,-77.84637,2017-09-18,261,16.12,26.18
+ 40.81849,-77.84637,2017-09-19,262,13.36,25.46
+ 40.81849,-77.84637,2017-09-20,263,10.90,28.76
+ 40.81849,-77.84637,2017-09-21,264,11.68,28.44
+ 40.81849,-77.84637,2017-09-22,265,13.10,29.03
+ 40.81849,-77.84637,2017-09-23,266,10.11,30.51
+ 40.81849,-77.84637,2017-09-24,267,12.33,31.11
+ 40.81849,-77.84637,2017-09-25,268,15.03,31.81
+ 40.81849,-77.84637,2017-09-26,269,16.01,30.96
+ 40.81849,-77.84637,2017-09-27,270,15.03,31.27
+ 40.81849,-77.84637,2017-09-28,271,9.61,21.39
+ 40.81849,-77.84637,2017-09-29,272,6.03,20.71
+ 40.81849,-77.84637,2017-09-30,273,2.85,15.23
--- a/tool-data/locations.txt.sample	Mon Aug 14 13:47:50 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-Asheville NC	asheville_nc:35.58
-Bridgeton NJ	bridgeton_nj:39.43
-Davis CA	davis_ca:38.55
-Geneva NY	geneva_ny:42.88
-Homestead FL	homestead_fl:25.47
-NJ_companion	nj_companion:39.62
-NJ_management	nj_management:39.66
-PA_companion	pa_companion:39.98
-PA_management	pa_management:39.97
-Riverside CA	riverside_ca:33.95
-Salem OR	salem_or:44.93
-VA_companion	va_companion:39.15
-VA_management	va_management:39.13
-Wenatchee WA	wneatchee_wa:47.42
-WV_companion	wv_companion:39.38
-WV_management	wv_management:39.52
--- a/tool-data/years.txt.sample	Mon Aug 14 13:47:50 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-1995	1995
-1996	1996
-1997	1997
-1998	1998
-1999	1999
-2000	2000
-2001	2001
-2002	2002
-2003	2003
-2004	2004
-2005	2005
-2006	2006
-2007	2007
-2008	2008
-2009	2009
-2010	2010
-2011	2011
-2012	2012
-2013	2013
-2014	2014
-2015	2015
-2016	2016
-2017	2017
-2018	2018
-2019	2019
-2020	2020
-2021	2021
-2022	2022
-2023	2023
-2024	2024
-2025	2025