Skip to content

Commit e99207d

Browse files
committed
Fix numpy array syntax in scaling.py and update tests
1 parent cdf3a7b commit e99207d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Deprecations
1414

1515
Bug fixes
1616
~~~~~~~~~
17+
* Fix a bug in :py:func:`pvlib.scaling.latlon_to_xy` where latitude
18+
scaling was incorrectly applied to both latitude and longitude components.
19+
(:issue:`2614`, :pull:` `)
1720
* Fix a division-by-zero condition in
1821
:py:func:`pvlib.transformer.simple_efficiency` when ``load_loss = 0``.
1922
(:issue:`2645`, :pull:`2646`)

pvlib/scaling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def latlon_to_xy(coordinates):
196196
m_per_deg_lon = r_earth * np.cos(np.pi/180 * meanlat) * np.pi/180
197197

198198
# Conversion
199-
pos = coordinates * np.array(m_per_deg_lat, m_per_deg_lon)
199+
pos = coordinates * np.array([m_per_deg_lat, m_per_deg_lon])
200200

201201
# reshape as (x,y) pairs to return
202202
try:

tests/test_scaling.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def time_500ms(clear_sky_index):
5252
@pytest.fixture
5353
def positions():
5454
# Sample positions based on the previous lat/lon (calculated manually)
55-
expect_xpos = np.array([554863.4, 555975.4, 557087.3])
55+
expect_xpos = np.array([546433.8, 547528.9, 548623.9])
5656
expect_ypos = np.array([1110838.8, 1111950.8, 1113062.7])
5757
return np.array([pt for pt in zip(expect_xpos, expect_ypos)])
5858

@@ -89,14 +89,16 @@ def expect_wavelet():
8989
@pytest.fixture
9090
def expect_cs_smooth():
9191
# Expected smoothed clear sky index for indices 5000:5004 (Matlab)
92-
return np.array([1., 1., 1.05774, 0.94226, 1.])
92+
return np.array([1., 1., 1.057735, 0.942265, 1.])
9393

9494

9595
@pytest.fixture
9696
def expect_vr():
9797
# Expected VR for expecttmscale
98-
return np.array([3., 3., 3., 3., 3., 3., 2.9997844, 2.9708118, 2.6806291,
99-
2.0726611, 1.5653324, 1.2812714, 1.1389995])
98+
return np.array([3., 3., 3., 3., 3.,
99+
2.99999999, 2.99976775, 2.96971249,
100+
2.67505872, 2.06592527, 1.5611084,
101+
1.27910582, 1.13793164])
100102

101103

102104
def test_latlon_to_xy_zero():

0 commit comments

Comments
 (0)