Skip to content

Commit

Permalink
Fixed doc broken reference and added more tests to wind chill
Browse files Browse the repository at this point in the history
  • Loading branch information
tlmquintino committed Nov 11, 2024
1 parent f0286e4 commit 1b76858
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
21 changes: 18 additions & 3 deletions tests/test_scalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,26 @@ def test_apparent_temperature(self):
# print(f"at {at}")
assert at == pytest.approx(299.86678322384626, abs=1e-6)

def test_windchill(self):
def test_wind_chill(self):
t2_k = np.array([270])
va = np.array([10])
wc = np.array([tmf.calculate_wind_chill(t2_k, va)])
assert wc == pytest.approx(261.92338925380074, abs=1e-6)
wc_k = np.array([tmf.calculate_wind_chill(t2_k, va)])
assert wc_k == pytest.approx(261.92338925380074, abs=1e-6)
# reference result from from wikipedia article https://en.wikipedia.org/wiki/Wind_chill
t2_k = np.array([tmf.celsius_to_kelvin(-20)]) # -20C to K
va = np.array([5 / 3.6]) # 5 km/h to m/s
wc_k = np.array([tmf.calculate_wind_chill(t2_k, va)])
wc_c = tmf.kelvin_to_celsius(wc_k)
assert wc_c == pytest.approx(
-24.27850328, abs=1e-6
) # around ~ -24C for wind chill (not exact)
va = np.array([30 / 3.6]) # 30 km/h to m/s
wc_k = np.array([tmf.calculate_wind_chill(t2_k, va)])
wc_c = tmf.kelvin_to_celsius(wc_k)
print(f"wc_c {wc_c}")
assert wc_c == pytest.approx(
-32.56804448, abs=1e-6
) # around ~ -33C for wind chill (not exact)

def test_heat_index_simplified(self):
t2_k = np.array([tmf.celsius_to_kelvin(21.0)])
Expand Down
6 changes: 3 additions & 3 deletions thermofeel/thermofeel.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,11 @@ def calculate_wind_chill(t2_k, va):
:param t2_k: (float array) 2m Temperature [K]
:param va: (float array) wind speed at 10 meters [m/s]
returns wind chill [K]
Temperature must be between -50°C and 5°C; wind speed must be between 5km/h and 80km/h
Wind chill from input values outside those ranges are not to be considered valid
Computation is only valid for temperatures between -50°C and 5°C and wind speeds between 5km/h and 80km/h.
For input values outside those ranges, computed results not be considered valid.
Reference: Blazejczyk et al. (2012)
https://doi.org/10.1007/s00484-011-0453-2
See also: http://www.ec.gc.ca/meteo-weather/default.asp?lang=n&n=5FBF816A-1#wc6
See also: https://web.archive.org/web/20130627223738/http://climate.weatheroffice.gc.ca/prods_servs/normals_documentation_e.html # noqa
"""
t2_c = kelvin_to_celsius(t2_k) # kelvin_to_celsius(tk)
v = va * 3.6 # convert to kilometers per hour
Expand Down

0 comments on commit 1b76858

Please sign in to comment.