% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_era5.R
\name{get_era5}
\alias{get_era5}
\title{Fetch ERA5 Data from Open-Meteo for Multiple Locations}
\usage{
get_era5(
  data,
  days_around,
  date_col,
  study_col = "study",
  pars = c("temperature_2m", "relative_humidity_2m", "precipitation", "dewpoint_2m"),
  models = NULL,
  direction = "both"
)
}
\arguments{
\item{data}{A data frame containing the input data, including columns for \code{latitude}, \code{longitude},
and the date column specified by \code{date_col}.}

\item{days_around}{An integer specifying the number of days before and after the date in the date column
to download data.}

\item{date_col}{A character string specifying the name of the date column in the data frame.}

\item{study_col}{A character string specifying the name of the column containing the study identifier
in the input data frame (default: "study").}

\item{pars}{A character vector specifying the weather variables to fetch from Open-Meteo.
These are mapped to \code{nasapower} equivalents:
"temperature_2m" (T2M), "relative_humidity_2m" (RH2M), "precipitation" (PRECTOTCORR), etc.}

\item{models}{A character string specifying the reanalysis model(s) to use. If \code{NULL} (default),
Open-Meteo uses its "best_match" logic (ERA5, ERA5-Land, etc.).}

\item{direction}{Character string specifying the direction of the date range relative to the reference date.
Options are "both" (default), "back", or "forth".
"back" retrieves data from \code{date - days_around} to \code{date}.
"forth" retrieves data from \code{date} to \code{date + days_around}.
"both" retrieves data from \code{date - days_around} to \code{date + days_around}.}
}
\value{
A data frame (tibble) with daily weather data. Columns are named to match
\code{nasapower} conventions: \code{date}, \code{T2M}, \code{T2M_MAX}, \code{T2M_MIN}, \code{RH2M}, \code{PRECTOTCORR},
\code{T2MDEW}, \code{longitude}, \code{latitude}, and \code{study}.
}
\description{
This function downloads ERA5 historical weather data from the Open-Meteo API
for specified locations and dates. It mimics the functionality of \code{get_nasapower}
by fetching weather variables and returning a daily-aggregated data frame.
It uses the Open-Meteo Archive API and aggregates hourly data to daily values
to ensure all variables (including relative humidity and dew point) are available.
}
\details{
Since the Open-Meteo Archive API \code{daily} endpoint does not provide all variables
(like mean relative humidity) directly, this function fetches \code{hourly} data and
performs the daily aggregation manually:
\itemize{
\item \code{T2M}: Mean of hourly \code{temperature_2m}
\item \code{T2M_MAX}: Max of hourly \code{temperature_2m}
\item \code{T2M_MIN}: Min of hourly \code{temperature_2m}
\item \code{RH2M}: Mean of hourly \code{relative_humidity_2m}
\item \code{PRECTOTCORR}: Sum of hourly \code{precipitation}
\item \code{T2MDEW}: Mean of hourly \code{dewpoint_2m}
}
}
\seealso{
Other Disease modeling: 
\code{\link{get_brdwgd}()},
\code{\link{get_nasapower}()},
\code{\link{windowpane}()}
}
\concept{Disease modeling}
