% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read_cru_dt.R
\name{read_cru_dt}
\alias{read_cru_dt}
\title{Create a data.table of CRU CL v. 2.0 climatology elements}
\source{
\describe{
\item{pre}{\url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_pre.dat.gz}}
\item{rd0}{\url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_rd0.dat.gz}}
\item{tmp}{\url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_tmp.dat.gz}}
\item{dtr}{\url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_dtr.dat.gz}}
\item{reh}{\url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_reh.dat.gz}}
\item{sunp}{\url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_sunp.dat.gz}}
\item{frs}{\url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_frs.dat.gz}}
\item{wnd}{\url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_wnd.dat.gz}, areas originally including Antarctica are removed.}
\item{elv}{\url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_elv.dat.gz}, values are converted from kilometres to metres.}
}
This package crops all spatial outputs to an extent of ymin = -60, ymax = 85,
xmin = -180, xmax = 180.
}
\usage{
read_cru_dt(
  pre = FALSE,
  pre_cv = FALSE,
  rd0 = FALSE,
  tmp = FALSE,
  dtr = FALSE,
  reh = FALSE,
  tmn = FALSE,
  tmx = FALSE,
  sunp = FALSE,
  frs = FALSE,
  wnd = FALSE,
  elv = FALSE,
  x = NULL
)
}
\arguments{
\item{pre}{Read precipitation (millimetres/month) and return it, \code{TRUE}.
Defaults to \code{FALSE}.}

\item{pre_cv}{Read cv of precipitation (percent) and return it, \code{TRUE}.
Defaults to \code{FALSE}. NOTE. Setting this to \code{TRUE} will always results in
\code{pre} being set to \code{TRUE} and returned as well.}

\item{rd0}{Read wet-days (number days with >0.1 millimetres rain per
month) and return it, \code{TRUE}. Defaults to \code{FALSE}.}

\item{tmp}{Reads temperature (degrees Celsius) and return it, TRUE\verb{. Defaults to }FALSE`.}

\item{dtr}{Read mean diurnal temperature range (degrees Celsius)
and return it, \code{TRUE}. Defaults to \code{FALSE}.}

\item{reh}{Read relative humidity and return it, \code{TRUE}. Defaults to
\code{FALSE}.}

\item{tmn}{Calculate minimum temperature values (degrees Celsius)
and return it, \code{TRUE}. Defaults to \code{FALSE}.}

\item{tmx}{Calculate maximum temperature (degrees Celsius) and return it,
\code{TRUE}. Defaults to \code{FALSE}.}

\item{sunp}{Read sunshine, percent of maximum possible (percent of
day length) and return it, \code{TRUE}. Defaults to \code{FALSE}.}

\item{frs}{Read ground-frost records (number of days with ground-
frost per month) and return it, \code{TRUE}. Defaults to \code{FALSE}.}

\item{wnd}{Read 10 m wind speed (metres/second) and return it, \code{TRUE}.
Defaults to \code{FALSE}.}

\item{elv}{Read elevation (converted to metres) and return it, \code{TRUE}.
Defaults to \code{FALSE}.}

\item{x}{An optional local file path where \acronym{CRU} \acronym{CL} v.2.0
.dat.gz files are located.  If this is empty, the requested data will
automatically be downloaded from the server.}
}
\value{
A \link[data.table:data.table]{data.table::data.table} object of \acronym{CRU} \acronym{CL} v.
2.0 climatology elements.
}
\description{
Automates importing \acronym{CRU} \acronym{CL} v.2.0 climatology data and
from either the CRU server or local files and creates a \CRANpkg{data.table}
of the data. If requested, minimum and maximum temperature may also be
calculated as described in the data
\href{https://crudata.uea.ac.uk/cru/data/hrg/tmc/readme.txt}{readme.txt} file and
returned.
}
\section{Nomenclature and Units}{

\describe{
\item{pre}{precipitation (millimetres/month)}
\describe{
\item{cv}{cv of precipitation (percent)}
}
\item{rd0}{wet-days (number days with >0.1 millimetres rain per month)}
\item{tmp}{mean temperature (degrees Celsius)}
\item{dtr}{mean diurnal temperature range (degrees Celsius)}
\item{reh}{relative humidity (percent)}
\item{sunp}{sunshine (percent of maximum possible (percent of day length))}
\item{frs}{ground-frost (number of days with ground-frost per month)}
\item{wnd}{10 metre wind speed (metres/second)}
\item{elv}{elevation (automatically converted to metres from kilometres)}
}
For more information see the description of the data provided by
\acronym{CRU}, \url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/readme.txt}
}

\examples{
\dontshow{if (interactive()) withAutoprint(\{ # examplesIf}
# Create a data frame of temperature from locally available files in the
# tempdir() directory.
library(fs)

f <- path(path_temp(), "grid_10min_tmp.dat.gz")

download.file(
  url = "https://crudata.uea.ac.uk/cru/data/hrg/tmc/grid_10min_tmp.dat.gz",
  destfile = f
)


cru_tmp <- read_cru_dt(tmp = TRUE, x = f)

cru_tmp

# or downloading directly from the CRU server

cru_tmp <- read_cru_dt(tmp = TRUE)

cru_tmp
\dontshow{\}) # examplesIf}
}
\references{
New, Mark, et al. "A high-resolution data set of surface climate
over global land areas." Climate research 21.1 (2002): 1-25.
\url{https://crudata.uea.ac.uk/cru/data/hrg/tmc/new_et_al_10minute_climate_CR.pdf}
}
\seealso{
\link{read_cru_rast}.
}
\author{
Adam H. Sparks, \email{adamhsparks@gmail.com}
}
