View source: R/assign_season.R
assign_season | R Documentation |
Filter detected cycles basing on dates of begin / end / peak, or limit the number of cycles allowed for any specified season.
assign_season(
pheno,
seasons = NA,
pop = NULL,
pop_win = NULL,
sos_win = NULL,
eos_win = NULL,
pop_name = "pop",
sos_name = "sos",
eos_name = "eos",
max_n_cycles = 2,
rm_unassigned = TRUE
)
pheno |
Cycle allocation (data table generated by |
seasons |
Character vector with the season names to be used. |
pop |
Vector with the expected dates of cycle peaks (one per season,
it must be of the same length of |
pop_win |
List with the allowed ranges for the dates of
cycle peaks (one per season): each element is a two-length character vector
with two elements, in the form |
sos_win |
List with the allowed ranges for the dates of
start of cycle (see |
eos_win |
Named list with the allowed ranges for the dates of
end of cycle (see |
pop_name |
Character name of the field in |
sos_name |
Character name of the field in |
eos_name |
Character name of the field in |
max_n_cycles |
(optional) Maximum number of cycles to be detected in one
season (default: Inf, meaning that all the identified cycles are kept).
If |
rm_unassigned |
(optional) Logical: should cycles which do not match with any season (basing on the settings) be dropped from the output? (Default: TRUE) |
The input data table, filtered basing on arguments and with the
addition of the field season
, containing the name of each season
(one among the ones specified in argument seasons
) associated to each
cycle.
If seasons = NA
this field is not returned.
Luigi Ranghetti, PhD (2020) luigi@ranghetti.info
# Load input data
data("dt_cycles")
data("dt_pheno")
data("ts_filled") # used for plots
# Filter one cycle per year, standard parameters (keep the most relevant cycle)
dt_cycles
dt_cycles_seas <- assign_season(dt_cycles, max_n_cycles = 1)
dt_cycles_seas
plot(ts_filled, pheno = dt_cycles_seas)
# Filter one cycle per year, keep the one with the peak clostest to 1st August
dt_pheno_seas1 <- assign_season(dt_pheno, max_n_cycles = 1, pop = "08-01")
plot(ts_filled, pheno = dt_pheno_seas1)
# Filter cycles with start of season between 1st February and 30th April
dt_pheno_seas2 <- assign_season(
dt_pheno,
sos_win = c("02-01", "04-30"),
)
plot(ts_filled, pheno = dt_pheno_seas2)
# Assign season names: "winter" for winter crops, "summer" for summer crops
# (defining winter crops as crops seeded between October and March,
# summer crops as crops seeded between April and August)
dt_pheno_seas3 <- assign_season(
dt_pheno,
seasons = c("winter", "summer"),
sos_win = list(c("10-01", "03-31"), c("04-01", "08-31")),
sos_name = "begin",
rm_unassigned = FALSE
)
# notice the new column "season"
dt_pheno_seas3
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.