Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: legacy effective temperature #379

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions ladybug_comfort/et.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
"""Effective temperature transitioned from legacy code of @stgeorges"""

def effective_temperature(Ta, ws, rh, SR, ac):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a docstring here

# inputs: (Ta, ws, rh, SR, ac):
if ws <= 0.2:
# formula by Missenard
TE = Ta - 0.4*(Ta - 10)*(1-rh/100)
elif ws > 0.2:
# modified formula by Gregorczuk (WMO, 1972; Hentschel, 1987)
TE = 37 - ( (37-Ta)/(0.68-(0.0014*rh)+(1/(1.76+1.4*(ws**0.75)))) ) - (0.29 * Ta * (1-0.01*rh))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spacing here needs to follow PEP8. As do all of the variable names:

https://peps.python.org/pep-0008/


# Radiative-effective temperature
TRE = TE + ((1 - 0.01*ac)*SR) * ((0.0155 - 0.00025*TE) - (0.0043 - 0.00011*TE))

if TRE < 1:
effectTE = -4
comfortable = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole set of conditionals should be in a separate function. Much like you see here in the apparent temperature module:

https://github.com/ladybug-tools/ladybug-comfort/blob/master/ladybug_comfort/at.py

Also, we don't need the 0/1 for comfortable. We can infer that from the category.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chriswmackey im working on documentation at the moment and had a question, do you know what the variable effectTE is? I would like to document it

elif TRE >= 1 and TE < 9:
effectTE = -3
comfortable = 0
elif TRE >= 9 and TE < 17:
effectTE = -2
comfortable = 0
elif TRE >= 17 and TE < 21:
effectTE = -1
comfortable = 0
elif TRE >= 21 and TE < 23:
effectTE = 0
comfortable = 1
elif TRE >= 23 and TE < 27:
effectTE = 1
comfortable = 0
elif TRE >= 27:
effectTE = 2
comfortable = 0

return TRE, effectTE, comfortable, []



1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ladybug-core==0.43.18
numpy
18 changes: 18 additions & 0 deletions tests/et_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# coding utf-8

import pytest

from ladybug_comfort.et import effective_temperature

def test_effective_temperature():
"""Test the effective_temperature function"""
et_obj = effective_temperature(Ta=13.7,
ws=7.8,
rh=74,
SR=104,
ac=318)
assert et_obj[0] == 0.07758930406978726
assert et_obj[1] == -4
assert et_obj[2] == 0
assert et_obj[3] == []