Skip to content

Commit 3a77400

Browse files
committed
Made changes to the soiling tests Addresses (pvlib#970)
1 parent c8c3758 commit 3a77400

File tree

1 file changed

+29
-38
lines changed

1 file changed

+29
-38
lines changed

pvlib/tests/test_soiling.py

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,40 @@ def expected_output():
1919
end=pd.Timestamp(2019, 1, 1, 23, 59, 0), freq='1h')
2020

2121
expected_no_cleaning = pd.Series(
22-
data=[0.884980357535360, 0.806308930084762, 0.749974647038078,
23-
0.711804155175089, 0.687489866078621, 0.672927554408964,
24-
0.664714899337491, 0.660345851212099, 0.658149551658860,
25-
0.657104593968981, 0.656633344364056, 0.656431630729954,
26-
0.656349579062171, 0.656317825078228, 0.656306121502393,
27-
0.656302009396500, 0.656300630853678, 0.656300189543417,
28-
0.656300054532516, 0.656300015031680, 0.656300003971846,
29-
0.656300001006533, 0.656300000244750, 0.656300000057132],
22+
data=[0.97230454, 0.95036146, 0.93039061, 0.91177978, 0.89427556,
23+
0.8777455 , 0.86211038, 0.84731759, 0.83332881, 0.82011354,
24+
0.80764549, 0.79590056, 0.78485556, 0.77448749, 0.76477312,
25+
0.75568883, 0.74721046, 0.73931338, 0.73197253, 0.72516253,
26+
0.7188578 , 0.71303268, 0.7076616 , 0.70271919],
3027
index=dt)
31-
3228
return expected_no_cleaning
3329

34-
3530
@pytest.fixture
3631
def expected_output_1():
37-
return np.array([
38-
0.99927224, 0.99869067, 0.99815393, 0.99764437, 1.0,
39-
0.99927224, 0.99869067, 0.99815393, 1.0, 1.0,
40-
0.99927224, 0.99869067, 0.99815393, 0.99764437, 0.99715412,
41-
0.99667873, 0.99621536, 0.99576203, 0.99531731, 0.9948801,
42-
0.99444954, 0.99402494, 0.99360572, 0.99319142])
43-
32+
dt = pd.date_range(start=pd.Timestamp(2019, 1, 1, 0, 0, 0),
33+
end=pd.Timestamp(2019, 1, 1, 23, 59, 0), freq='1h')
34+
expected_output_1 = pd.Series(
35+
data=[0.9872406 , 0.97706269, 0.96769693, 0.95884032, 1.,
36+
0.9872406 , 0.97706269, 0.96769693, 1. , 1. ,
37+
0.9872406 , 0.97706269, 0.96769693, 0.95884032, 0.95036001,
38+
0.94218263, 0.93426236, 0.92656836, 0.91907873, 0.91177728,
39+
0.9046517 , 0.89769238, 0.89089165, 0.88424329],
40+
index=dt)
41+
return expected_output_1
4442

4543
@pytest.fixture
46-
def expected_output_2(expected_output):
47-
# Sample output (calculated manually)
44+
def expected_output_2():
4845
dt = pd.date_range(start=pd.Timestamp(2019, 1, 1, 0, 0, 0),
4946
end=pd.Timestamp(2019, 1, 1, 23, 59, 0), freq='1h')
47+
expected_output_2 = pd.Series(
48+
data = [0.97229869, 0.95035106, 0.93037619, 0.91176175, 1.,
49+
1. , 1. , 0.97229869, 1. , 1. ,
50+
1. , 1. , 0.97229869, 0.95035106, 0.93037619,
51+
0.91176175, 0.89425431, 1. , 1. , 1. ,
52+
1. , 0.97229869, 0.95035106, 0.93037619],
53+
index=dt)
5054

51-
expected_no_cleaning = expected_output
52-
53-
expected = pd.Series(index=dt, dtype='float64')
54-
expected[dt[:4]] = expected_no_cleaning[dt[:4]]
55-
expected[dt[4:7]] = 1.
56-
expected[dt[7]] = expected_no_cleaning[dt[0]]
57-
expected[dt[8:12]] = 1.
58-
expected[dt[12:17]] = expected_no_cleaning[dt[:5]]
59-
expected[dt[17:21]] = 1.
60-
expected[dt[21:]] = expected_no_cleaning[:3]
61-
62-
return expected
63-
55+
return expected_output_2
6456

6557
@pytest.fixture
6658
def rainfall_input():
@@ -81,7 +73,7 @@ def test_hsu_no_cleaning(rainfall_input, expected_output):
8173
rainfall = rainfall_input
8274
pm2_5 = 1.0
8375
pm10 = 2.0
84-
depo_veloc = {'2_5': 1.0, '10': 1.0}
76+
depo_veloc = {'2_5': 1.0e-5, '10': 1.0e-4}
8577
tilt = 0.
8678
expected_no_cleaning = expected_output
8779

@@ -99,16 +91,15 @@ def test_hsu(rainfall_input, expected_output_2):
9991
rainfall = rainfall_input
10092
pm2_5 = 1.0
10193
pm10 = 2.0
102-
depo_veloc = {'2_5': 1.0, '10': 1.0}
94+
depo_veloc = {'2_5': 1.0e-4, '10': 1.0e-4}
10395
tilt = 0.
104-
expected = expected_output_2
10596

10697
# three cleaning events at 4:00-6:00, 8:00-11:00, and 17:00-20:00
10798
result = hsu(rainfall=rainfall, cleaning_threshold=0.5, tilt=tilt,
10899
pm2_5=pm2_5, pm10=pm10, depo_veloc=depo_veloc,
109100
rain_accum_period=pd.Timedelta('3h'))
110101

111-
assert_series_equal(result, expected)
102+
assert_series_equal(result, expected_output_2)
112103

113104

114105
@requires_scipy
@@ -119,8 +110,8 @@ def test_hsu_defaults(rainfall_input, expected_output_1):
119110
accumulation period.
120111
"""
121112
result = hsu(
122-
rainfall=rainfall_input, cleaning_threshold=0.5, tilt=0.0, pm2_5=1.0,
123-
pm10=2.0)
113+
rainfall=rainfall_input, cleaning_threshold=0.5, tilt=0.0, pm2_5=1.0e-2,
114+
pm10=2.0e-2)
124115
assert np.allclose(result.values, expected_output_1)
125116

126117

0 commit comments

Comments
 (0)