Mercurial > repos > greg > insect_phenology_model
comparison insect_phenology_model.R @ 68:c0a950ae7902 draft
Uploaded
author | greg |
---|---|
date | Tue, 14 Nov 2017 13:09:31 -0500 |
parents | e8923653a5bf |
children | a6f3b6f7e68d |
comparison
equal
deleted
inserted
replaced
67:e8923653a5bf | 68:c0a950ae7902 |
---|---|
41 # Compute the length of daylight for the day of the year. | 41 # 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)))) | 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)))) |
43 } | 43 } |
44 # Append daylight_length_vector as a new column to temperature_data_matrix. | 44 # Append daylight_length_vector as a new column to temperature_data_matrix. |
45 cbind(temperature_data_matrix, newColumn=daylight_length_vector) | 45 cbind(temperature_data_matrix, newColumn=daylight_length_vector) |
46 # Return the altered temperature_data_matrix. | |
47 temperature_data_matrix | |
46 } | 48 } |
47 | 49 |
48 get_temperature_at_hour = function(latitude, temperature_data_matrix, row, num_days) { | 50 get_temperature_at_hour = function(latitude, temperature_data_matrix, row, num_days) { |
49 # Base development threshold for Brown Marmolated Stink Bug | 51 # Base development threshold for Brown Marmolated Stink Bug |
50 # insect phenology model. | 52 # insect phenology model. |
191 # LATITUDE, LONGITUDE, DATE, DOY, TMIN, TMAX | 193 # LATITUDE, LONGITUDE, DATE, DOY, TMIN, TMAX |
192 temperature_data_matrix <- read.csv(file=opt$input, header=T, strip.white=TRUE, sep=",") | 194 temperature_data_matrix <- read.csv(file=opt$input, header=T, strip.white=TRUE, sep=",") |
193 start_date <- temperature_data_matrix[1, 3] | 195 start_date <- temperature_data_matrix[1, 3] |
194 end_date <- temperature_data_matrix[opt$num_days, 3] | 196 end_date <- temperature_data_matrix[opt$num_days, 3] |
195 latitude <- temperature_data_matrix[1, 1] | 197 latitude <- temperature_data_matrix[1, 1] |
196 add_daylight_length(latitude, temperature_data_matrix, opt$num_days) | 198 temperature_data_matrix <- add_daylight_length(latitude, temperature_data_matrix, opt$num_days) |
197 | 199 |
198 cat("Number of days: ", opt$num_days, "\n") | 200 cat("Number of days: ", opt$num_days, "\n") |
199 | 201 |
200 # Initialize matrix for results from all replications. | 202 # Initialize matrix for results from all replications. |
201 S0.rep <- S1.rep <- S2.rep <- S3.rep <- S4.rep <- S5.rep <- matrix(rep(0, opt$num_days * opt$replications), ncol = opt$replications) | 203 S0.rep <- S1.rep <- S2.rep <- S3.rep <- S4.rep <- S5.rep <- matrix(rep(0, opt$num_days * opt$replications), ncol = opt$replications) |