% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/detect_forages.R
\name{detect_forages}
\alias{detect_forages}
\title{Detect forages}
\usage{
detect_forages(
  ts,
  pheno,
  win = NULL,
  diff_thr = 10,
  ncuts_thr = 10,
  sliding = 90,
  reldiff = TRUE,
  byyear = TRUE
)
}
\arguments{
\item{ts}{Time series in \code{s2ts} format (generated using \code{fill_s2ts()}).}

\item{pheno}{Cycle allocation (data table generated by \code{extract_pheno()}
or \code{cut_cycles()}).}

\item{win}{List with the allowed ranges for the dates of
start of cycle (see \code{pop_seasons} for details about the format).}

\item{diff_thr}{First threshold to detect forages (TODO improve description)}

\item{ncuts_thr}{Second threshold to detect forages (TODO improve description)}

\item{sliding}{Length (in days) of the sliding window in which \code{diff_thr}
and \code{ncuts_thr} must be evaluated.}

\item{reldiff}{Logical: should argument \code{diff_thr} refer to relative (default)
or absolute values?}

\item{byyear}{Logical: compute aggregation by year (default) or globally
(this should make sense in case of permanent crops).}
}
\value{
A data table in the format of the input \code{pheno},
in which adjacent forage cycles are merged.
An additional logical field \code{forage} discriminates forages from non-forages.
}
\description{
Experimental function to detect forages (time series characterised
by a high "instability").
Already detected cycles are labelled as "forage" (adjacent ones are dissolved)
basing on arguments \code{diff_thr} and \code{ncuts_thr} (see).
}
\author{
Luigi Ranghetti, PhD (2021) \email{luigi@ranghetti.info}
}
