Functions to calculate thermal comfort indices
Project description
thermal-comfort
Installation
via pypi
pip install thermal-comfort
via https
pip install git+https://github.com/RUBclim/thermal-comfort
via ssh
pip install git+ssh://git@github.com/RUBclim/thermal-comfort
[!NOTE] For this to work, you will have to have
gitandgfortraninstalled
For every release, pre-compiled ABI-3 wheels are provided under releases
Run the tests
On version 3.12 for example...
tox -e py312
Documentation
Docs can be found here: https://rubclim.github.io/thermal-comfort/.
Quick start
The thermal-comfort package provides a limited set of commonly used functions. Which work for scalar values, but are mainly optimized for large array calculation of hundreds of thousands of values.
scalars
from thermal_comfort import utci_approx
utci_approx(ta=20.3, tmrt=50.9, v=2.7, rh=50.5)
arrays
1-dimensional arrays
import numpy as np
from thermal_comfort import utci_approx
utci_approx(
ta=np.array([20.3, 28.5]),
tmrt=np.array([50.9, 70.3]),
v=np.array([2.7, 1.9]),
rh=np.array([50.5, 70.3]),
)
n-dimensional arrays
The functions only accept 1-dimensional arrays, multi dimensional arrays must be reshaped before and after.
import numpy as np
from thermal_comfort import utci_approx
# 2D arrays e.g. a raster
ta = np.array([[20.3, 28.5], [20.3, 28.5]])
tmrt = np.array([[50.9, 70.3], [50.9, 70.3]])
v = np.array([[2.7, 1.9], [2.7, 1.9]])
rh = np.array([[50.5, 70.3], [50.5, 70.3]])
# retrieve the initial shape
orig_shape = ta.shape
# reshape the array to be 1-dimensional
ta = np.ravel(ta)
tmrt = np.ravel(tmrt)
v = np.ravel(v)
rh = np.ravel(rh)
# calculate the UTCI along the 1-dimensional array
utci = utci_approx( ta=ta, tmrt=tmrt, v=v, rh=rh)
# restore the original shape
utci = utci.reshape(orig_shape)
API
For a complete documentation look at the docs
Mean Radiant Temperature (MRT)
Calculate the mean radiant temperature based on DIN EN ISO 7726.
mean_radiant_temp(ta, tg, v, d = 0.15, e = 0.95)
ta: air temperature in °Ctg: black globe temperature in °C
UTCI
Calculate the Universal Thermal Climate Index (UTCI)
utci_approx(ta, tmrt, v, rh)
ta: Air temperature in °Ctmrt: Mean radiant temperature in °Cv: Wind speed in m/srh: Relative humidity in %
PET
Calculate the Physiological Equivalent Temperature (PET).
pet_static(ta, tmrt, v, rh, p)
ta: air temperature in °Crh: relative humidity in %v: wind speed in m/stmrt: mean radiant temperature in °Cp: atmospheric pressure in hPa
Heat Index
Calculate the heat index following Steadman R.G (1979) & Rothfusz L.P (1990).
heat_index(ta, rh)
ta: air temperature in °Crh: relative humidity in %
Extended Heat Index
Calculate the heat index following Steadman R.G (1979) & Rothfusz L.P (1990), but extends the range following The National Weather Service Weather Predicion Center.
heat_index_extended(ta, rh)
ta: air temperature in °Crh: relative humidity in %
Wet Bulb Temperature (TWB)
Calculate the wet bulb temperature following the Stull (2011) equation
wet_bulb_temp(ta, rh)
ta: air temperature in °Crh: relative humidity in %
Saturation Vapor Pressure
Over water
sat_vap_press_water(ta)
ta: air temperature in °C
Over ice
sat_vap_press_ice(ta)
ta: air temperature in °C
Dew Point Temperature
dew_point(ta, rh)
ta: air temperature in °Crh: relative humidity in %
Absolute Humidity
absolute_humidity(ta, rh)
ta: air temperature in °Crh: relative humidity in %
Specific Humidity
specific_humidity(ta, rh)
ta: air temperature in °Crh: relative humidity in %
Performance
The benchmark was ran using an array of 100,000 values and 4 threads
(OMP_NUM_THREADS=4). See the benchmark directory for more details on the benchmarks.
The hardware used is:
- 2x AMD EPYC 7702 64-Core Processor
- ubuntu 22.04
using an array of length 100,000 the following results were found:
comparing to pythermalcomfort
| Benchmark | pythermalcomfort (bf9febd) | thermal-comfort | thermal-comfort (unsafe) | thermal-comfort (Open MPI) | thermal-comfort (unsafe & Open MPI) |
|---|---|---|---|---|---|
| tmrt scalar | 21.0 us | 20.3 us: 1.03x faster | 2.21 us: 9.50x faster | 23.3 us: 1.11x slower | 4.38 us: 4.79x faster |
| tmrt array | 11.9 ms | 5.77 ms: 2.06x faster | 11.3 ms: 1.05x faster | 3.86 ms: 3.07x faster | 1.29 ms: 9.17x faster |
| twb scalar | 11.2 us | 2.43 us: 4.59x faster | 1.31 us: 8.52x faster | 2.44 us: 4.57x faster | 1.27 us: 8.80x faster |
| twb array | 8.86 ms | 2.54 ms: 3.49x faster | 2.52 ms: 3.52x faster | 2.63 ms: 3.37x faster | 1.73 ms: 5.13x faster |
| heat index scalar | 34.9 us | 2.38 us: 14.67x faster | 1.24 us: 28.10x faster | 5.06 us: 6.89x faster | 3.68 us: 9.47x faster |
| heat index array | 4.06 ms | 2.27 ms: 1.79x faster | 2.44 ms: 1.66x faster | 1.92 ms: 2.11x faster | 859 us: 4.72x faster |
| utci scalar | 59.5 us | 22.7 us: 2.62x faster | 2.23 us: 26.66x faster | 26.0 us: 2.29x faster | 4.45 us: 13.36x faster |
| utci array | 37.1 ms | 5.93 ms: 6.25x faster | 11.4 ms: 3.25x faster | 3.82 ms: 9.71x faster | 1.24 ms: 29.84x faster |
| pet scalar | 6.04 ms | 5.86 us: 1031.44x faster | 6.73 us: 897.57x faster | 8.68 us: 696.14x faster | 6.56 us: 922.14x faster |
| pet array | 189 sec | 284 ms: 665.14x faster | 804 ms: 234.82x faster | 117 ms: 1611.19x faster | 113 ms: 1669.13x faster |
| Geometric mean | (ref) | 10.00x faster | 13.83x faster | 10.45x faster | 23.64x faster |
comparing to umep
| Benchmark | umep | umep (njit) |
pythermalcomfort (bf9febd) | thermal-comfort | thermal-comfort (unsafe) | thermal-comfort (Open MPI) | thermal-comfort (unsafe & Open MPI) |
|---|---|---|---|---|---|---|---|
| utci scalar | 44.5 us | 6.56 us: 6.79x faster | 59.5 us: 1.34x slower | 22.7 us: 1.96x faster | 2.23 us: 19.97x faster | 26.0 us: 1.72x faster | 4.45 us: 10.00x faster |
| utci array | 6.87 sec | 313 ms: 21.95x faster | 37.1 ms: 185.23x faster | 5.93 ms: 1157.28x faster | 11.4 ms: 602.16x faster | 3.82 ms: 1798.79x faster | 1.24 ms: 5526.68x faster |
| pet scalar | 388 us | 3.17 us: 122.51x faster | 6.04 ms: 15.56x slower | 5.86 us: 66.29x faster | 6.73 us: 57.69x faster | 8.68 us: 44.74x faster | 6.56 us: 59.26x faster |
| pet array | 62.6 sec | 1.33 sec: 48.25x faster | 189 sec: 3.02x slower | 284 ms: 220.43x faster | 804 ms: 77.82x faster | 117 ms: 533.95x faster | 113 ms: 553.15x faster |
| Geometric mean | (ref) | 35.61x faster | 2.07x faster | 53.17x faster | 88.52x faster | 51.68x faster | 148.51x faster |
While njit already gives a huge performance boost, the difference between umep
(njit) and thermal-comfort increases for larger arrays e.g. 1,000,000 values as shown
here:
| Benchmark | umep (njit) |
thermal-comfort |
|---|---|---|
| utci scalar | 6.53 us | 22.9 us: 3.51x slower |
| utci array | 3.09 sec | 48.5 ms: 63.77x faster |
| pet scalar | 3.15 us | 5.84 us: 1.85x slower |
| pet array | 13.3 sec | 2.80 sec: 4.75x faster |
| Geometric mean | (ref) | 2.61x faster |
[!CAUTION] If you're after the last bit of performance and don't care about input validation, you may use the underscored functions e.g.
_utci_approxor_pet_staticwhich fully avoid any computations in python. However, you will have to guarantee that all your arrays have the same length otherwise undefined behavior may happen. For performance reasons this package is not compiled using-fcheck=boundscompiler-flag.
Compilation
You can set the cmake flag -DUSE_OPENMP=1 to compile the package with
OpenMP support
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file thermal_comfort-1.1.0-cp313-cp313-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c704cebc2ed1e8a4d82f12225ce20ef626e8d0ab4288ca5d1bf1240298acf9e0
|
|
| MD5 |
9b1447b7d5a40559bfa80f107359c60d
|
|
| BLAKE2b-256 |
eac75ef71eb7ca2aa54df9f941910f1c60ef183b28ad11584367d8e83b3b3cdc
|
File details
Details for the file thermal_comfort-1.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4a7e08c807ce930fade2c3595cd7a927848ad320b7e08d994137a15622c673b
|
|
| MD5 |
345536c008f578a68740d81227c18fec
|
|
| BLAKE2b-256 |
0d0ecaa25c7d95000cc6c9a24024e2e1cc1accf9e3b08e250f97fddfe82ee404
|
File details
Details for the file thermal_comfort-1.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 523.7 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cbe8cf91699c6bb282cefe56405c31719c7df07bf060298468a916a05eeb6c1
|
|
| MD5 |
3f44bb268ca85a64419336d4febd9cdd
|
|
| BLAKE2b-256 |
92b034559bef6a565cea00eba8573b4d5c2522146b7cbc47f98034dde378dd65
|
File details
Details for the file thermal_comfort-1.1.0-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7c49496defc4bbcb1d35557172a0aea7553971db503dcfcabe89a0eae435d73
|
|
| MD5 |
d02c253b422ed481b80331e26dcfda8f
|
|
| BLAKE2b-256 |
8cb1a7cfdccda87bca1ac154eb009e53d512268b55bc9c622dedaf8fe3ae7c25
|
File details
Details for the file thermal_comfort-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88d554c990b95c798b7f0e60d7b913260998db672c2dcc6a09e4186684a7f498
|
|
| MD5 |
0898e813e3e5c661fd66c4c0aeae47fd
|
|
| BLAKE2b-256 |
1933cf3c8f47f26b14d72ed30add7ccf9e105745b1f9ab3557c9f716e8a73d6b
|
File details
Details for the file thermal_comfort-1.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 523.7 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d033335b6fe8a64c0b54eebd2180c3fcde5ca836ecb4bb9db0d38f3645cd1563
|
|
| MD5 |
7315f4bc6bfae4f69148241b99a181f0
|
|
| BLAKE2b-256 |
c1ea2fe75397ccec54183f32e0cab913e6c7bf54fca4472e774dc9a296c1f0ab
|
File details
Details for the file thermal_comfort-1.1.0-cp311-cp311-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.11, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc41c113f52124600fe696fb27b728854a403a608068956b4a7dba2f8ae6d021
|
|
| MD5 |
f5aa5512f79214fd5fbe6dbc6b81a2be
|
|
| BLAKE2b-256 |
1ab84d71b0031a9566afaaf2a7acc3c5d8aee0c7a93f61579621ea3171f5fe43
|
File details
Details for the file thermal_comfort-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9674564f435d64b30039d5eff231473fd562d3d1793ef533127a6a4f499a0816
|
|
| MD5 |
0dd894a604a83da862177a296b88dc2b
|
|
| BLAKE2b-256 |
1706736cb3e801e59b5cc2f5bc05c557271b65dd85bb7872ca3f4ddaf1bbd3ae
|
File details
Details for the file thermal_comfort-1.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 523.8 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
679ce67bf511433f25e0a266cfdaacdd4dc12a62bc4ecd4294796eca68a6b773
|
|
| MD5 |
99969dc42b7ba5e87a0e6daa63896dc3
|
|
| BLAKE2b-256 |
18713835cef6daa7ec7a77872e48af0364e362f45861794df049a9d3977ced69
|
File details
Details for the file thermal_comfort-1.1.0-cp310-cp310-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.10, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
821a81648ded779d1deb4b8679237fa4cd282ee4abe8230bb369e1a7d33195ca
|
|
| MD5 |
ddf789b7e53798be15cb97a86297acfb
|
|
| BLAKE2b-256 |
876615f85205857ef18d954fb789e90dce4038f1dc437a27107f2a1d6040c451
|
File details
Details for the file thermal_comfort-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91e1a95a85958437aac7bab5495044190b323e7e641185d146eafbe2efd38cd2
|
|
| MD5 |
52af5d97ab9bd5718ea395736f26d7e3
|
|
| BLAKE2b-256 |
3efa0fcd3da0c7377234f9cd3d43ae20607ce7b316fa065a6a69eafa847e3483
|
File details
Details for the file thermal_comfort-1.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 523.8 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2dae89b133e9816d0e5684bf06f72666119d6a29591ce7f312dd951df5bc514
|
|
| MD5 |
7fddd6189487edfa8e4858e8d1292eb7
|
|
| BLAKE2b-256 |
da2d6cc10b846f7dba644e30d6a1f989471437da72dbcf7dc7465e509f9519ed
|
File details
Details for the file thermal_comfort-1.1.0-cp39-cp39-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp39-cp39-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.9, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fac7e8a63df4762b19e8329cd03a3224609c1e6eb5e8ad88d3cc36955f255fed
|
|
| MD5 |
924b941e8cfc5a2f74d02f8cc1395ed2
|
|
| BLAKE2b-256 |
8bb3bb0279373b6bd13fc47f4207d3f926f06aee980f25358fe5abfa6a466ed6
|
File details
Details for the file thermal_comfort-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e1c5b495e02fc0b4f3348d00cc8f2b8a38c0aef4ec3c4ceb215cfdd52ce955c
|
|
| MD5 |
f87ac5ddedca72967bf6b35e86132b81
|
|
| BLAKE2b-256 |
8c9efccbedd4595caecf4dacc6be30859f22bf19ac316594c75e29cbbd361279
|
File details
Details for the file thermal_comfort-1.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: thermal_comfort-1.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 523.9 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72d5f83756c2d1cc52fa801b29a73e0c98728efccf4bde4dff760aef4b313f53
|
|
| MD5 |
f3b72c3d121ee8294f132162311adcaa
|
|
| BLAKE2b-256 |
95d83c2e149384f21940874bb97b7694b005b35182e1b30c08927f052b864bdf
|