-
Notifications
You must be signed in to change notification settings - Fork 406
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
Add relative humidity from temp/dewpoint function #680
Conversation
@@ -25,6 +26,14 @@ | |||
from metpy.testing import assert_almost_equal, assert_array_almost_equal, assert_nan | |||
from metpy.units import units | |||
|
|||
def test_relative_humidity_from_dewpoint(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E302 expected 2 blank lines, found 1
metpy/calc/tests/test_thermo.py
Outdated
@@ -25,6 +26,14 @@ | |||
from metpy.testing import assert_almost_equal, assert_array_almost_equal, assert_nan | |||
from metpy.units import units | |||
|
|||
def test_relative_humidity_from_dewpoint(): | |||
"""Test Relative Humidity calculation""" | |||
assert_almost_equal(relative_humidity_from_dewpoint(25. * units.degC, 15. * units.degC), 53.83*units.percent, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E501 line too long (116 > 95 characters)
E226 missing whitespace around arithmetic operator
metpy/calc/tests/test_thermo.py
Outdated
"""Test Relative Humidity calculation""" | ||
assert_almost_equal(relative_humidity_from_dewpoint(25. * units.degC, 15. * units.degC), 53.83*units.percent, 2) | ||
|
||
def test_relative_humidity_from_dewpoint_with_f(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E302 expected 2 blank lines, found 1
metpy/calc/tests/test_thermo.py
Outdated
|
||
def test_relative_humidity_from_dewpoint_with_f(): | ||
"""Test Relative Humidity accepts temperature in Fahrenheit""" | ||
assert_almost_equal(relative_humidity_from_dewpoint(70. * units.degF, 55. * units.degF), 58.96*units.percent, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E501 line too long (116 > 95 characters)
E226 missing whitespace around arithmetic operator
@@ -21,6 +21,43 @@ | |||
|
|||
sat_pressure_0c = 6.112 * units.millibar | |||
|
|||
@exporter.export |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E302 expected 2 blank lines, found 1
metpy/calc/thermo.py
Outdated
""" | ||
|
||
|
||
a = 17.269 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E303 too many blank lines (2)
metpy/calc/thermo.py
Outdated
|
||
|
||
a = 17.269 | ||
e = 6.1078*units.mb * np.exp(a*(dewpt-(273.16*units.kelvin))/(dewpt-(35.86*units.kelvin))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E226 missing whitespace around arithmetic operator
metpy/calc/thermo.py
Outdated
|
||
a = 17.269 | ||
e = 6.1078*units.mb * np.exp(a*(dewpt-(273.16*units.kelvin))/(dewpt-(35.86*units.kelvin))) | ||
e_s = 6.1078*units.mb * np.exp(a*(temperature-273.16*units.kelvin)/(temperature-35.86*units.kelvin)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E226 missing whitespace around arithmetic operator
E501 line too long (104 > 95 characters)
metpy/calc/thermo.py
Outdated
e = 6.1078*units.mb * np.exp(a*(dewpt-(273.16*units.kelvin))/(dewpt-(35.86*units.kelvin))) | ||
e_s = 6.1078*units.mb * np.exp(a*(temperature-273.16*units.kelvin)/(temperature-35.86*units.kelvin)) | ||
|
||
return 100. * (e/e_s) * units.percent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E226 missing whitespace around arithmetic operator
metpy/calc/tests/test_thermo.py
Outdated
def test_relative_humidity_from_dewpoint(): | ||
"""Test Relative Humidity calculation""" | ||
assert_almost_equal(relative_humidity_from_dewpoint(25. * units.degC, 15. * units.degC), | ||
53.83 * units.percent, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
metpy/calc/tests/test_thermo.py
Outdated
def test_relative_humidity_from_dewpoint_with_f(): | ||
"""Test Relative Humidity accepts temperature in Fahrenheit""" | ||
assert_almost_equal(relative_humidity_from_dewpoint(70. * units.degF, 55. * units.degF), | ||
58.96 * units.percent, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
metpy/calc/thermo.py
Outdated
|
||
a = 17.269 | ||
e = 6.1078 * units.mb * np.exp(a * (dewpt - (273.16 * units.kelvin)) | ||
/ (dewpt - (35.86 * units.kelvin))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
W503 line break before binary operator
metpy/calc/thermo.py
Outdated
e = 6.1078 * units.mb * np.exp(a * (dewpt - (273.16 * units.kelvin)) | ||
/ (dewpt - (35.86 * units.kelvin))) | ||
e_s = 6.1078 * units.mb * np.exp(a * (temperature - 273.16 * units.kelvin) | ||
/ (temperature - 35.86 * units.kelvin)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
W503 line break before binary operator
metpy/calc/thermo.py
Outdated
e_s = 6.1078 * units.mb * np.exp(a * (temperature - 273.16 * units.kelvin) | ||
/ (temperature - 35.86 * units.kelvin)) | ||
|
||
return 100. * (e/e_s) * units.percent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E226 missing whitespace around arithmetic operator
e_s = 6.1078 * units.mb * np.exp(a * (temperature - 273.16 * units.kelvin) / | ||
(temperature - 35.86 * units.kelvin)) | ||
|
||
return 100. * (e/e_s) * units.percent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E226 missing whitespace around arithmetic operator
Closed so I can fix all the pep8 errors. I will resubmit a pull request after styling is correct, sorry for the issues. |
No worries! That's the bot's job, to catch the style issues; not an issue at all that your initial submission didn't match our style. Thanks for your interest in contributing. For future reference, it would have been perfectly acceptable to just keep pushing commits to this PR. You can use |
Good to know, thanks! I re-submitted my pull request here #681, let me know if there's anything else I need to do. |
I added a function to calculate relative humidity from temperature and dewpoint to calc (metpy.calc.relative_humidity_from_dewpoint).
This is my first ever pull request to an open source project, if there's anything I've done wrong please feel free to let me know.