Learn R Programming

CSIndicators (version 1.2.0)

HeatIndex: Heat Index on multidimensional array objects

Description

Heat Index computes the perceived temperature resulting from the combined effects of air temperature and relative humidity. It is used to indicate discomfort or potential health risks due to heat. The computation is based on an empirical formula developed by the U.S. National Weather Service (NWS), which estimates the apparent temperature under warm and humid conditions.

The index increases with higher humidity levels because the body's ability to cool itself through evaporation (sweating) becomes less effective.

Usage

HeatIndex(
  temp,
  rh,
  dates = NULL,
  start = NULL,
  end = NULL,
  temp_units_input = "K",
  temp_units_output = "C",
  fun = mean,
  time_dim = "time",
  ncores = NULL,
  na.rm = FALSE,
  ...
)

Value

An array with the same dimensions as temp and rh, containing the Heat Index.

Arguments

temp

A multidimensional array, vector or scalar with Temperatures expressed in Fahrenheit.

rh

A multidimensional array, vector or scalar with Relative humidity expressed in percentage.

dates

A multidimensional array of dates with named dimensions matching the temporal dimensions on parameter 'data'. By default it is NULL, to select aperiod this parameter must be provided.

start

An optional parameter to define the initial date of the period to select from the data by providing a list of two elements: the initial date of the period and the initial month of the period. By default it is set to NULL and the indicator is computed using all the data provided in data.

end

An optional parameter to defined the final date of the period to select from the data by providing a list of two elements: the final day of the period and the final month of the period. By default it is set to NULL and the indicator is computed using all the data provided in data.

temp_units_input

A character string indicating the name of the units to of the temp variable. By default, it is set to 'K', Kelvin.

temp_units_output

A character string indicating the name of the units to compute the indicator. By default, it is set to 'C', Celsius.

fun

A function to be applied along the time dimension to aggregate the Heat Index. By default, the mean Heat Index is computed over time_dim. To keep the original temporal resolution (i.e., return values for each time step), set `fun = NULL`, in which case no aggregation is applied.

time_dim

A character string indicating the name of the dimension to compute the indicator. By default, it is set to 'time'. More than one dimension name matching the dimensions provided in the object data$data can be specified.

ncores

An integer indicating the number of cores to use in parallel computation.

na.rm

A logical value indicating whether to ignore NA values (TRUE) or not (FALSE).

...

Additional arguments passed to the aggregation function

Author

Alberto Bojaly, alberto.bojaly@bsc.es

References

National Weather Service (NWS): [Heat Index Equation](https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml)

Examples

Run this code

# Example 1 : Heat Index (fun = NULL)
temp <- array(runif(6, min = 290, max = 315), dim = c(time = 2, member = 3, region = 1))  # K
rh   <- array(runif(6, min = 40, max = 90), dim = c(time = 2, member = 3, region = 1)) # %

HI <- HeatIndex(temp = temp, rh = rh, temp_units_input = "Kelvin", 
                temp_units_output = "Celsius", fun = NULL)
HI

# Example 2 : mean Heat Index (fun = mean by default) ---
temp2 <- array(runif(90, min = 290, max = 315), dim = c(time = 10, lat = 3, lon = 3))
rh2   <- array(runif(90, min = 40, max = 90), dim = c(time = 10, lat = 3, lon = 3))

HI_mean <- HeatIndex(temp = temp2, rh = rh2, temp_units_input = "Kelvin", 
                     temp_units_output = "Celsius", fun = mean, time_dim = "time")
HI_mean


Run the code above in your browser using DataLab