Learn R Programming

meteor (version 0.4-5)

globe: Globe temperature

Description

Globe temperatures (Tg, Tnwb, WBGT).

The can be computed for either a data.frame or a SpatRasterDataset. These must have variables "temp" (C), "rhum" (%), "wind" (m s-1), and "srad" (J s-1 m-2). The data.frame must also have a variable "date".

Usage

# S4 method for data.frame
Tg(x, latitude)
# S4 method for SpatRasterDataset
Tg(x, filename="", overwrite=FALSE, ...)

# S4 method for data.frame Tnwb(x, latitude, kelvin=FALSE) # S4 method for SpatRasterDataset Tnwb(x, kelvin=FALSE, filename="", overwrite=FALSE, ...)

# S4 method for data.frame WBGT(x, latitude, kelvin=FALSE) # S4 method for SpatRasterDataset WBGT(x, kelvin=FALSE, mask=NULL, filename="", overwrite=FALSE, ...)

Value

numeric or SpatRaster

Arguments

x

data.frame or SpatRasterDataset

latitude

numeric

filename

character. Output filename

overwrite

logical. If TRUE, filename is overwritten

...

additional arguments for writing files as in writeRaster

kelvin

logical. Set to TRUE of the units of temperature are in Kelvin

mask

NULL of SpatRaster. if a SpatRaster is used, it should have one layer. No computations are done for cells that are NA, and these are set to NA in the output

Examples

Run this code
wd <- data.frame(date=as.Date("2003-08-28") + 1:3, 
		temp=c(19.1, 20.6, 19.4), 
		rhum=c(66,71,73), 
		wind=c(3.3, 1.9, 1.1), 
		srad=c(168, 178, 125))
Tg(wd, 40.96) 

Tnwb(wd, 40.96) 

WBGT(wd, 40.96) 


library(terra)
r <- rast(ncol=2, nrow=2, nlyr=1)
temp <- setValues(r, 21:24)
time(temp) <- as.Date("2000-01-01")
rhum <- setValues(r, 81:84)
wind <- setValues(r, 9:12)
srad <- setValues(r, 100:103)
s <- sds(list(temp=temp, rhum=rhum, wind=wind, srad=srad))

x <- Tg(s)
y <- WBGT(s)

Run the code above in your browser using DataLab