% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pheno_regional.R
\name{pheno_regional}
\alias{pheno_regional}
\title{Compile Regional Phenology Data and Climate Sensitivity Inputs}
\usage{
pheno_regional(
  pep,
  giss = NULL,
  lon_min = 4.2,
  lon_max = 8.1,
  lat_min = 44.7,
  lat_max = 48.1,
  species_name = "Triticum aestivum",
  functional_group = NULL,
  year_min = 1961,
  pep_for_giss = c("near", "aggregated"),
  phase = 60
)
}
\arguments{
\item{pep}{A data.table containing the full PEP725 dataset. Must include at
least columns: \code{species}, \code{year}, \code{phase_id}, \code{day},
\code{lat}, \code{lon}.}

\item{giss}{Optional. A data.table with GISS global temperature anomalies,
containing columns \code{year}, \code{dT}, and \code{dT_sm}. If \code{NULL},
GISS-related outputs are omitted.}

\item{lon_min}{Minimum longitude for spatial filtering of PEP data (default is \code{4.2})}

\item{lon_max}{Maximum longitude for spatial filtering of PEP data (default is \code{8.1})}

\item{lat_min}{Minimum latitude for spatial filtering of PEP data (default is \code{44.7})}

\item{lat_max}{Maximum latitude for spatial filtering of PEP data (default is \code{48.1})}

\item{species_name}{Character name of the species to be extracted (default is \code{"Triticum aestivum"})}

\item{functional_group}{Character. Optional functional group name to filter by (e.g., "C4_summer_cereals"). If provided, overwrites species_name filtering.}

\item{year_min}{Minimum year to include in all outputs (default is \code{1961})}

\item{pep_for_giss}{Selects which PEP data subset to use for merging with GISS
data. Either \code{"near"} (box-filtered) or \code{"aggregated"} (global).
Ignored if \code{giss} is \code{NULL}.}

\item{phase}{Integer or vector of phase_id(s) to extract (default is \code{60} = Heading). Named phase mappings are applied.}
}
\value{
A named list with the following elements:
\describe{
\item{\code{pep_agg}}{Global (non-spatially filtered) PEP725 time series for the selected phase(s)}
\item{\code{pep_cgi}}{Spatially filtered PEP725 time series based on lat/lon bounding box}
\item{\code{giss}}{Processed GISS global temperature anomaly data (if provided)}
\item{\code{pep_giss}}{Merged data frame of PEP phenology and GISS anomalies (if provided)}
\item{\code{species}}{Character species name used for filtering}
\item{\code{functional_group}}{Functional group if specified, otherwise \code{NA}}
\item{\code{phase}}{Integer phase ID(s) used for filtering}
}
}
\description{
Extracts and aggregates phenological observations for a selected species and
phenological phase from the PEP725 dataset (globally and spatially filtered).
Optionally links them with global temperature anomalies (GISS data) for
climate impact studies.
}
\details{
The function aggregates PEP observations by species, year, and phase,
calculates mean day-of-year (DOY), applies spatial filtering if needed,
and attaches GISS climate anomalies. It also maps \code{phase_id}s to
descriptive names and warns if expected phenological phase are missing
in the selected data.

If GISS data is provided, temperature anomalies are merged with the selected
PEP time series to support phenology-climate analysis.
}
\examples{
\donttest{
pep <- pep_download()

out <- pheno_regional(pep, species_name = "Triticum aestivum", phase = 60)
str(out)
}

}
\seealso{
\code{\link{pheno_plot}}, \code{\link{pep_download}}
}
\author{
Matthias Templ
}
