Skip to content

Commit

Permalink
Merge pull request #33 from SusannePfeifer007/humidex
Browse files Browse the repository at this point in the history
Humidex
  • Loading branch information
larsbuntemeyer authored Oct 23, 2023
2 parents ea28f0c + f75da45 commit bce0df7
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 2 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: flake8
- id: check-yaml
- id: check-json
- id: end-of-file-fixer
Expand Down
28 changes: 28 additions & 0 deletions index_calculator/_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2896,3 +2896,31 @@ def compute(self, **params):
https://xclim.readthedocs.io/en/stable/api.html#xclim.indicators.atmos.sfcWindmax_max
"""
return self.compute_climate_indicator(params=params)


class HIX(ClimateIndicator):
"""temperature felt by a person.
When relative humidity is taken into account (tas, hurs)
"""

def __init__(self):
super().__init__()
self.func = xc.atmos.humidex

def compute(self, **params):
"""Calculate maximum number of consecutive heat days.
Returns
-------
xarray.DataArray
temperature felt by a person when relative humidity
is taken into account.
Notes
-----
For information on the input parameters see:
https://xclim.readthedocs.io/en/stable/api.html#xclim.indicators.atmos.humidex
"""
return self.compute_climate_indicator(params=params)
3 changes: 2 additions & 1 deletion index_calculator/tables/input_vars.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,6 @@
"FX": "sfcWindmax",
"FXx": "sfcWindmax",
"FXn": "sfcWindmax",
"CMD": "sfcWind"
"CMD": "sfcWind",
"HIX": ["tas", "hurs"]
}
6 changes: 6 additions & 0 deletions index_calculator/tables/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -484,5 +484,11 @@
"long_name": "Frost free season end (mean temperature < {thresh} degC)",
"units": "",
"description": "Calendar day of year, when the temperature is below {thresh} degC for at least {window} consecutive days."
},
"HIX": {
"standard_name": "humidex",
"long_name": "Temperature felt by a person when relative humidity is taken into account",
"units": "degC",
"description": "Temperature felt by a person when relative humidity is taken into account."
}
}
21 changes: 21 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[flake8]
ignore=
# whitespace before ':' - doesn't work well with black
E203
# module level import not at top of file
E402
# line too long - let black worry about that
E501
# do not assign a lambda expression, use a def
E731
# line break before binary operator
W503
exclude=
build
docs
.git

[isort]
profile = black
skip_gitignore = true
force_to_top = true
13 changes: 13 additions & 0 deletions tests/test_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,19 @@ def test_FXx():
np.testing.assert_allclose(result, [23], rtol=1e-03)


def test_HIX():
idx_class = indices.HIX()
result = idx_class.compute(
tas=tas_xarray(),
hurs=hurs_xarray(),
)
np.testing.assert_allclose(
result,
[-4.977235, -14.36269, -4.706667, 17.962594, 29.079492, 3.561291, -12.997314],
rtol=1e-03,
)


def test_CMD():
idx_class = indices.CMD()
result = idx_class.compute(
Expand Down

0 comments on commit bce0df7

Please sign in to comment.