Skip to content

Commit

Permalink
Merge branch 'autocut' into parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
kuadrat committed Jun 27, 2024
2 parents fce7256 + ca8af7c commit 84ecc27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions R/autocut.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,16 @@ PhenologicalAutocut = R6Class(
last_cut_DOY = i0 + lower[[1]]
}

# Time between cuts
integer_n_cuts = round(self$n_cuts)
delta = floor((last_cut_DOY - first_cut_DOY) / (integer_n_cuts - 1))
self$cut_DOYs = (((1:integer_n_cuts) - 1) * delta) + first_cut_DOY
# Calculate time between cuts
# Round n_cuts but apply at least 1
integer_n_cuts = max(1, round(self$n_cuts))
if (integer_n_cuts != 1) {
delta = floor((last_cut_DOY - first_cut_DOY) / (integer_n_cuts - 1))
self$cut_DOYs = (((1:integer_n_cuts) - 1) * delta) + first_cut_DOY
} else {
# If there's just one cut, apply it at end of season
self$cut_DOYs = c(last_cut_DOY)
}
},

#' @description Does a cut occur on *DOY*?
Expand Down
3 changes: 2 additions & 1 deletion R/environment.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ ModvegeEnvironment = R6Class(
param_file = NULL,
#' @field weather_file Name of supplied weather file.
weather_file = NULL,
#' @field management_file Name of supplied management file.
#' @field management_file Name of supplied management file or management
#' intensity for [Autocut] ('high', 'middle', 'low', 'extensive').
management_file = NULL,
#' @field parameters A [ModvegeParameters] object.
parameters = NULL,
Expand Down

0 comments on commit 84ecc27

Please sign in to comment.