Mercurial > repos > greg > insect_phenology_model
comparison insect_phenology_model.R @ 60:a3bdf0d35d1d draft
Uploaded
author | greg |
---|---|
date | Mon, 13 Nov 2017 12:26:48 -0500 |
parents | 1d4e864b7720 |
children | 82668ca72b08 |
comparison
equal
deleted
inserted
replaced
59:1d4e864b7720 | 60:a3bdf0d35d1d |
---|---|
33 p = 0.8333 | 33 p = 0.8333 |
34 daylight_length_vector <- NULL | 34 daylight_length_vector <- NULL |
35 for (i in 1:num_days) { | 35 for (i in 1:num_days) { |
36 # Get the day of the year from the current row | 36 # Get the day of the year from the current row |
37 # of the temperature data for computation. | 37 # of the temperature data for computation. |
38 doy <- temperature_data[c(i:i), 4] | 38 doy <- temperature_data[i, 4] |
39 theta <- 0.2163108 + 2 * atan(0.9671396 * tan(0.00860 * (doy - 186))) | 39 theta <- 0.2163108 + 2 * atan(0.9671396 * tan(0.00860 * (doy - 186))) |
40 phi <- asin(0.39795 * cos(theta)) | 40 phi <- asin(0.39795 * cos(theta)) |
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 } |
232 dd.day <- rep(0, opt$num_days) | 232 dd.day <- rep(0, opt$num_days) |
233 | 233 |
234 # All the days included in the input temperature dataset. | 234 # All the days included in the input temperature dataset. |
235 for (row in 1:opt$num_days) { | 235 for (row in 1:opt$num_days) { |
236 # Get the integer day of the year for the current row. | 236 # Get the integer day of the year for the current row. |
237 doy <- temperature_data[c(row:row), 4] | 237 doy <- temperature_data[row, 4] |
238 # Photoperiod in the day. | 238 # Photoperiod in the day. |
239 photoperiod <- daylight_length_vector[row] | 239 photoperiod <- daylight_length_vector[row] |
240 temp.profile <- get_temperature_at_hour(latitude, temperature_data, daylight_length_vector, row, opt$num_days) | 240 temp.profile <- get_temperature_at_hour(latitude, temperature_data, daylight_length_vector, row, opt$num_days) |
241 mean.temp <- temp.profile[1] | 241 mean.temp <- temp.profile[1] |
242 dd.temp <- temp.profile[2] | 242 dd.temp <- temp.profile[2] |