Examples

Some example calculations

The heatindex package has two main functions: one of those functions has the same name as the package and the other function is named wetbulb. The heatindex function takes two arguments: the absolute air temperature in kelvin and the relative humidity from 0 to 1. The wetbulb function takes three arguments: the pressure in pascal, the air temperature in kelvin, and the relative humidity from 0 to 1. Below are some examples.

Calculate a single value of the heat index

Given a single temperature, e.g., 300 K, and a single relative humidity, e.g., 0.5, we can calculate the heat index as follows.

library(heatindex)
heatindex(300,0.5)
import heatindex as hi
hi.heatindex(300,0.5)

This returns the heat index in kelvin.

Calculate an array of heat index values

If, instead, we have an array of temperature and an array of relative humidity, we can feed those to heatindex and it will return an array of heat index values.

library(heatindex)
T <- matrix(301:312,nrow=3,byrow=TRUE)
rh <- matrix(1:12/12,nrow=3,byrow=TRUE)
heatindex(T,rh)
import heatindex as hi
import numpy as np
T = np.linspace(301, 312, 12).reshape(3, 4)
rh = np.linspace(1, 12, 12).reshape(3, 4)/12
hi.heatindex(T,rh)

This returns a 3 x 4 matrix of heat index values in kelvin.

Calculate a single value of the wet-bulb temperature

Given a single pressure, e.g., 1 bar, a single temperature, e.g., 300 K, and a single relative humidity, e.g., 0.5, we can calculate the thermodynamic wet-bulb temperature as follows.

library(heatindex)
wetbulb(1e5,300,0.5)
import heatindex as hi
hi.wetbulb(1e5,300,0.5)

This returns the wet-bulb temperature in kelvin.

Calculate an array of wet-bulb temperatures

If, instead, we have arrays of pressure, temperature, and relative humidity, we can feed those to wetbulb and it will return an array of thermodynamic wet-bulb temperatures.

library(heatindex)
p <- 1e5 - 5e3*matrix(1:12,nrow=3,byrow=TRUE)
T <- matrix(301:312,nrow=3,byrow=TRUE)
rh <- matrix(1:12/12,nrow=3,byrow=TRUE)
wetbulb(p,T,rh)
import heatindex as hi
import numpy as np
p = 1e5 - 5e3*np.linspace(1,12,12).reshape(3, 4)
T = np.linspace(301, 312, 12).reshape(3, 4)
rh = np.linspace(1, 12, 12).reshape(3, 4)/12
hi.wetbulb(p,T,rh)

This returns a 3 x 4 matrix of wet-bulb temperatures in kelvin.

Switch to psychrometric and/or an ice bulb

By default, wetbulb calculates the thermodynamic wet-bulb temperature, which is what is most often meant when someone refers to “the wet-bulb temperature.” Sometimes, however, we may want to calculate the temperature of a psychrometric (a.k.a., aspirated or ventilated) wet bulb. Or, we may wish to calculate the temperature of an ice bulb. These values can be accessed using optional arguments.

library(heatindex)
wetbulb(1e5,275,0.5) # thermodynamic wet-bulb temperature
wetbulb(1e5,275,0.5,psychrometric=TRUE) # psychrometric wet-bulb temperature
wetbulb(1e5,275,0.5,icebulb=TRUE) # thermodynamic ice-bulb temperature
wetbulb(1e5,275,0.5,psychrometric=TRUE,icebulb=TRUE) # psychrometric ice-bulb temperature
import heatindex as hi
print(hi.wetbulb(1e5,275,0.5)) # thermodynamic wet-bulb temperature
print(hi.wetbulb(1e5,275,0.5,psychrometric=True)) # psychrometric wet-bulb temperature
print(hi.wetbulb(1e5,275,0.5,icebulb=True)) # thermodynamic ice-bulb temperature
print(hi.wetbulb(1e5,275,0.5,psychrometric=True,icebulb=True)) # psychrometric ice-bulb temperature