Skip to content

Commit

Permalink
compute heat index even without wind
Browse files Browse the repository at this point in the history
closes #623
  • Loading branch information
akrherz committed Jun 21, 2022
1 parent 4e6aafd commit da330ea
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ the social media posts for products that are more mudane (#604).
- Fixed missing `ENH` and `MDT` from `spcpts.THRESHOLD_ORDER`.
- Fixed jabber/twitter message generation for a VTEC product with multiple
segments with the same vtec action (read tropical products).
- Heat index is now computed without the presence of wind info (#623).
- Improved logic behind `pyiem.plot.util.pretty_bins`, it no longer exactly
returns the specified number of bins, but tries to do the right thing!
- Increase remark trimming for LSR tweets for more length safety.
Expand Down
7 changes: 4 additions & 3 deletions src/pyiem/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
try:
from zoneinfo import ZoneInfo # type: ignore
except ImportError:
from backports.zoneinfo import ZoneInfo
from backports.zoneinfo import ZoneInfo # type: ignore

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -245,13 +245,14 @@ def calc(self):
if self.data["feel"] is None and None not in [
self.data["tmpf"],
self.data["relh"],
self.data["sknt"],
]:
# sknt is not a hard requirement
sk = self.data["sknt"] if self.data["sknt"] is not None else np.nan
self.data["feel"] = bounded(
mcalc.apparent_temperature(
self.data["tmpf"] * munits.degF,
self.data["relh"] * munits.percent,
self.data["sknt"] * munits.knots,
sk * munits.knots,
mask_undefined=False, # less confusion this way
)
.to(munits.degF)
Expand Down
15 changes: 15 additions & 0 deletions tests/test_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ def test_calc():
assert (ob.data["relh"] - 53.6) < 0.1


def test_gh623_feelslike_without_wind():
"""Test that we can compute feelslike without wind speed."""
ts = utc(2018)
ob = observation.Observation("FAKE", "FAKE", ts)
ob.data["tmpf"] = 89.0
ob.data["dwpf"] = 70.0
ob.calc()
assert (ob.data["feel"] - 94.3) < 0.1
ob = observation.Observation("FAKE", "FAKE", ts)
ob.data["tmpf"] = -19.0
ob.data["dwpf"] = -22.0
ob.calc()
assert ob.data["feel"] is None


@pytest.fixture
def iemob():
"""Database."""
Expand Down

0 comments on commit da330ea

Please sign in to comment.