Methods to compute temperature indices over a time series

temperature(object, ...)

# S3 method for default
temperature(object, tmin, ..., timeseries = FALSE)

# S3 method for data.frame
temperature(object, day.one, span = NULL, ..., timeseries = FALSE)

# S3 method for array
temperature(object, day.one, span = NULL, ..., timeseries = FALSE)

# S3 method for sf
temperature(
  object,
  day.one,
  span = NULL,
  ...,
  timeseries = FALSE,
  as.sf = TRUE
)

Arguments

object

a numeric vector with the maximum temperature, or a data.frame with geographical coordinates (lonlat), or an object of class sf with geometry 'POINT' or 'POLYGON', or an array with two dimensions containing the maximum and minimum temperature, in that order. See details

...

additional arguments passed to methods. See details

tmin

a numeric vector with the minimum temperature

timeseries

logical, FALSE for a single point time series observation or TRUE for a time series based on intervals

day.one

a vector of class Date or any other object that can be coerced to Date (e.g. integer, character YYYY-MM-DD) for the starting day to capture the climate data

span

an integer or a vector with integers (optional if last.day is given) for the length of the time series to be captured

as.sf

logical, to return an object of class 'sf'

Value

A dataframe with temperature indices:

maxDT

maximun day temperature (degree Celsius)

minDT

minimum day temperature (degree Celsius)

maxNT

maximun night temperature (degree Celsius)

minNT

minimum night temperature (degree Celsius)

DTR

diurnal temperature range (mean difference between DT and NT (degree Celsius))

SU

summer days, number of days with maximum temperature > 30 (degree Celsius)

TR

tropical nights, number of nights with maximum temperature > 25 (degree Celsius)

CFD

consecutive frosty days, number of days with temperature bellow 0 degree Celsius

WSDI

maximum warm spell duration, consecutive days with temperature > 90th percentile

CSDI

maximum cold spell duration, consecutive nights with temperature < 10th percentile

T10p

the 10th percentile of night tempeture (degree Celsius)

T90p

the 90th percentile of day tempeture (degree Celsius)

Details

Additional arguments:

intervals: an integer (no lower than 5), for the days intervals when timeseries = TRUE

last.day: optional to span, an object of class Date or any other object that can be coerced to Date (e.g. integer, character YYYY-MM-DD) for the last day of the time series. For data.frame, array and sf methods

dates: a character (or Date or numeric) vector for the dates of tmax and tmin in the default method

data.from: character for the source of remote data. Current remote source is: 'nasapower'

pars: character vector for the temperature data to be fetched. If data.from is 'nasapower', the temperature can be adjusted to 2 m, the default, c("T2M_MAX", "T2M_MIN") or 10 m c("T10M_MAX", "T10M_MIN")

days.before: optional, an integer for the number of days before day.one to be included in the timespan.

# S3 Methods

The array method assumes that object contains climate data available in your R section; this requires an array with two dimensions, 1st dimension contains the day temperature and 2nd dimension the night temperature, see help("temp_dat", package = "climatrends") for an example on input structure.

The data.frame and the sf methods assumes that the climate data will be fetched from a remote (cloud) source that be adjusted using the argument data.from.

When timeseries = TRUE, an id is created, which is the index for the rownames of the inputted object.

References

Aguilar E., et al. (2005). Journal of Geophysical Research, 110(D23), D23107.
https://doi.org/10.1029/2005JD006119

See also

Other temperature functions: ETo(), GDD(), crop_sensitive()

Examples

# the default method
data("innlandet", package = "climatrends")

# a single temporal observation
temperature(innlandet$tmax, innlandet$tmin)

# return as timeseries with 30-day intervals
temperature(innlandet$tmax,
            innlandet$tmin,
            dates = innlandet$dates,
            timeseries = TRUE,
            intervals = 30)

#####################################################

# array method
data("temp_dat", package = "climatrends")

temperature(temp_dat,
            day.one = "2013-10-28",
            span = 12)

# \donttest{
#####################################################

# Using remote sources of climate data
library("nasapower")
library("sf")
data("lonlatsf", package = "climatrends")

# some random dates provided as integers and coerced to Dates internally
set.seed(2718279)
dates <- as.integer(runif(5, 17660, 17675))

# get temperature indices for 30 days after day.one
# return a data.frame
temp1 <- temperature(lonlatsf,
                     day.one = dates,
                     span = 30,
                     as.sf = FALSE)
temp1

# get temperature indices from "2010-12-01" to "2011-01-31"
temp2 <- temperature(lonlatsf,
                     day.one = "2010-12-01",
                     last.day = "2011-01-31")
temp2

# }