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

Conversation

TfedUD
Copy link

@TfedUD TfedUD commented Nov 27, 2024

This PR adds the effective code for effective temperature from stgeorges code.

@TfedUD
Copy link
Author

TfedUD commented Dec 1, 2024

@chriswmackey the original had a bunch of args that were not used.
So this is basically just a cleaned up version of the legacy effective temperature calc, sans unused args.

Copy link
Member

@chriswmackey chriswmackey left a comment

Choose a reason for hiding this comment

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

Thanks, @TfedUD ,

You were right to strip out the unused inputs. There are just a few more tweaks to be made before merging. Notably, the code should be following PEP8 in the capitalization of the variables and the spacing around operators. I recommend pip installing flake8 or some other liter to help make sure your code is following PEP8.

# -*- 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


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

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/

@TfedUD
Copy link
Author

TfedUD commented Dec 3, 2024

Sounds good @chriswmackey I should be able to make the changes later this week if not next!

@TfedUD
Copy link
Author

TfedUD commented Dec 4, 2024

For some reason I couldn't get a linter to fix on save (problem for another day) but it turned into a great learning experience looking up the needed rules and reading through the docs on PEP8. fun file to work on

@TfedUD TfedUD requested a review from chriswmackey December 4, 2024 02:39
* tre: Radiant Effective Temperature
* effectTE
* Comfort: boolean value for whether or not the effective temp is comfortable
"""
Copy link
Member

Choose a reason for hiding this comment

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

This is very close to being merge-able. There's just one last change that we need to make. These docstrings are not formatted properly to be picked up by our Sphinx workflow that generates the Ladybug Tools SDK Doc pages. Once they are formatted similarly to the apparent temperature module, we will be in good shape to merge.

# Radiative-effective temperature
tre = te + ((1 - 0.01 * ac) * sr) * ((0.0155 - 0.00025 * te) - (0.0043 - 0.00011 * te))

return effective_temperature_conditions(tre, te)
Copy link
Member

Choose a reason for hiding this comment

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

Actually, I lied. This function should only return the TE and the TRE. No boolean value (is the docstring wrong?) And no category. the categorization is done separately.

Copy link
Author

Choose a reason for hiding this comment

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

you are correct! That was a mistake in the docstring

* ta: Air Temperature
* ws: Wind Speed
* rh: Relative Humidity
* sr: Solar Radiation
Copy link
Member

Choose a reason for hiding this comment

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

Also, what are the units of solar radiation here? And the units of all of these inputs for that matter?

* te: Thermal emission
Outputs:
* tre: Radiant effective temperature
* te: Effective temperature
Copy link
Member

Choose a reason for hiding this comment

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

Also this does not look right from what is returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants