0
# Conversion Indicators
1
2
Specialized indicators for converting between climate-related units and computing derived indices like heat index, wind chill, and humidity measures. These indicators are essential for human comfort assessment and meteorological applications.
3
4
## Capabilities
5
6
### Heat Stress Indices
7
8
Heat stress and thermal comfort indices for human health and safety assessment.
9
10
```python { .api }
11
def heat_index(tas, hurs, freq="YS"):
12
"""
13
Heat index combining temperature and humidity effects.
14
15
Parameters:
16
- tas: xr.DataArray, daily mean or maximum temperature
17
- hurs: xr.DataArray, daily relative humidity
18
- freq: str, resampling frequency (default "YS")
19
20
Returns:
21
xr.DataArray: Heat index values
22
"""
23
24
def humidex(tas, hurs, freq="YS"):
25
"""
26
Humidex (Canadian humidity index) for perceived temperature.
27
28
Parameters:
29
- tas: xr.DataArray, daily temperature
30
- hurs: xr.DataArray, daily relative humidity
31
- freq: str, resampling frequency
32
33
Returns:
34
xr.DataArray: Humidex values
35
"""
36
37
def wind_chill_index(tas, sfcwind, freq="YS"):
38
"""
39
Wind chill index for perceived cold temperature.
40
41
Parameters:
42
- tas: xr.DataArray, daily temperature
43
- sfcwind: xr.DataArray, daily wind speed
44
- freq: str, resampling frequency
45
46
Returns:
47
xr.DataArray: Wind chill index values
48
"""
49
```
50
51
### Unit Conversion Indicators
52
53
Temperature and precipitation unit conversion utilities.
54
55
```python { .api }
56
def temperature_sum(tas, thresh="0 degC", freq="YS"):
57
"""
58
Temperature sum above/below threshold with unit conversion.
59
60
Parameters:
61
- tas: xr.DataArray, daily temperature with units
62
- thresh: str, threshold temperature with units
63
- freq: str, resampling frequency
64
65
Returns:
66
xr.DataArray: Temperature sum in degree-days
67
"""
68
69
def rain_approximation(prsn, tas, thresh="0 degC", freq="YS"):
70
"""
71
Approximate rainfall from snowfall using temperature threshold.
72
73
Parameters:
74
- prsn: xr.DataArray, daily snowfall data
75
- tas: xr.DataArray, daily temperature
76
- thresh: str, temperature threshold for rain/snow (default "0 degC")
77
- freq: str, resampling frequency
78
79
Returns:
80
xr.DataArray: Approximated rainfall
81
"""
82
83
def snowfall_approximation(pr, tas, thresh="0 degC", freq="YS"):
84
"""
85
Approximate snowfall from precipitation using temperature threshold.
86
87
Parameters:
88
- pr: xr.DataArray, daily precipitation data
89
- tas: xr.DataArray, daily temperature
90
- thresh: str, temperature threshold for rain/snow (default "0 degC")
91
- freq: str, resampling frequency
92
93
Returns:
94
xr.DataArray: Approximated snowfall
95
"""
96
```
97
98
## Usage Examples
99
100
```python
101
import xarray as xr
102
import xclim.convert as xcc
103
104
# Load weather data
105
ds = xr.open_dataset("weather.nc")
106
tas = ds.tas
107
hurs = ds.hurs
108
sfcwind = ds.sfcwind
109
110
# Calculate heat stress indices
111
heat_idx = xcc.heat_index(tas, hurs, freq="YS")
112
humidex_vals = xcc.humidex(tas, hurs, freq="YS")
113
wind_chill = xcc.wind_chill_index(tas, sfcwind, freq="YS")
114
```