Skip to content

Commit d559e2a

Browse files
pasquierjbJBcwhanseRDaxini
authored
Fix _m_to_cm: multiply by 100 to convert meters to cm (#2725)
* Fix _m_to_cm: multiply by 100 to convert meters to cm * Apply suggestion from @cwhanse Co-authored-by: Cliff Hansen <cwhanse@sandia.gov> * Docs: document _m_to_cm conversion fix in changelog * Update tests/iotools/test_era5.py Co-authored-by: Rajiv Daxini <143435106+RDaxini@users.noreply.github.com> * Apply suggestion from @RDaxini Co-authored-by: Rajiv Daxini <143435106+RDaxini@users.noreply.github.com> --------- Co-authored-by: JB <jbpasquier@ombrea.fr> Co-authored-by: Cliff Hansen <cwhanse@sandia.gov> Co-authored-by: Rajiv Daxini <143435106+RDaxini@users.noreply.github.com>
1 parent 3ad5a9e commit d559e2a

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

docs/sphinx/source/whatsnew/v0.15.1.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Bug fixes
2020
* Fix a division-by-zero condition in
2121
:py:func:`pvlib.transformer.simple_efficiency` when ``load_loss = 0``.
2222
(:issue:`2645`, :pull:`2646`)
23+
* Fix a bug in :py:func:`pvlib.iotools.era5._m_to_cm` where meters were
24+
incorrectly divided by 100 instead of multiplied, causing precipitations to be
25+
underestimated by a factor of 10,000 when ``map_variables=True``.
26+
(:issue:`2724`, :pull:`2725`)
2327

2428
Enhancements
2529
~~~~~~~~~~~~
@@ -79,4 +83,5 @@ Contributors
7983
* Kevin Anderson (:ghuser:`kandersolar`)
8084
* Rohan Saxena (:ghuser:`r0hansaxena`)
8185
* Marco Fumagalli (:ghuser:`fuma900`)
86+
* Jean-Baptiste Pasquier (:ghuser:`pasquierjb`)
8287

pvlib/iotools/era5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _j_to_w(j):
3737

3838

3939
def _m_to_cm(m):
40-
return m / 100
40+
return m * 100
4141

4242

4343
UNITS = {

tests/iotools/test_era5.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,8 @@ def test_get_era5_timeout(params):
9292
match = 'Request timed out. Try increasing'
9393
with pytest.raises(requests.exceptions.Timeout, match=match):
9494
df, meta = pvlib.iotools.get_era5(**params, timeout=1)
95+
96+
97+
def test__m_to_cm():
98+
from pvlib.iotools.era5 import _m_to_cm
99+
assert _m_to_cm(0.01) == 1 # 0.01 m = 1 cm

0 commit comments

Comments
 (0)