Mercurial > repos > greg > insect_phenology_model
comparison insect_phenology_model.R @ 32:5517d380c337 draft
Uploaded
author | greg |
---|---|
date | Thu, 09 Nov 2017 13:32:40 -0500 |
parents | e56529d02c3e |
children | a374a8fab830 |
comparison
equal
deleted
inserted
replaced
31:e56529d02c3e | 32:5517d380c337 |
---|---|
23 | 23 |
24 parser <- OptionParser(usage="%prog [options] file", option_list=option_list) | 24 parser <- OptionParser(usage="%prog [options] file", option_list=option_list) |
25 args <- parse_args(parser, positional_arguments=TRUE) | 25 args <- parse_args(parser, positional_arguments=TRUE) |
26 opt <- args$options | 26 opt <- args$options |
27 | 27 |
28 convert_csv_to_rdata=function(data_matrix) | 28 convert_csv_to_rdata=function(temperature_data, data_matrix) |
29 { | 29 { |
30 # Also stores the current year. | |
31 date <- data_matrix[1, 3] | |
32 year <- substr(date, 1, 4) | |
33 # Integer day of the year. | 30 # Integer day of the year. |
34 data_matrix[,1] <- c(1:opt$num_days) | 31 data_matrix[,1] <- c(1:opt$num_days) |
35 # Minimum | 32 # Minimum |
36 data_matrix[,2] <- temperature_data[c(1:opt$num_days), 5] | 33 data_matrix[,2] <- temperature_data[c(1:opt$num_days), 5] |
37 # Maximum | 34 # Maximum |
201 return | 198 return |
202 } | 199 } |
203 | 200 |
204 # Read in the input temperature datafile into a Data Frame object. | 201 # Read in the input temperature datafile into a Data Frame object. |
205 temperature_data <- read.csv(file=opt$input, header=T, sep=",") | 202 temperature_data <- read.csv(file=opt$input, header=T, sep=",") |
203 date <- temperature_data[c(1:1), 3] | |
204 year <- substr(date, 1, 4) | |
206 raw_data_matrix <- matrix(rep(0, opt$num_days * 6), nrow=opt$num_days) | 205 raw_data_matrix <- matrix(rep(0, opt$num_days * 6), nrow=opt$num_days) |
207 temperature_file_path <- convert_csv_to_rdata(raw_data_matrix) | 206 temperature_file_path <- convert_csv_to_rdata(raw_data_matrix) |
208 latitude <- temperature_data[1, 1] | 207 latitude <- temperature_data[1, 1] |
209 | 208 |
210 cat("Number of days: ", opt$num_days, "\n") | 209 cat("Number of days: ", opt$num_days, "\n") |