Skip to content

Commit 852cd20

Browse files
committed
Can't test with the paper data, wtf
1 parent 9ceaf5b commit 852cd20

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

pvlib/tests/test_shading.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22
import pandas as pd
33

4+
from numpy.testing import assert_allclose
45
from pandas.testing import assert_series_equal
56
from numpy.testing import assert_allclose, assert_approx_equal
67
import pytest
@@ -309,7 +310,40 @@ def test_shaded_fraction1d(sf1d_premises_and_expected):
309310
assert isinstance(sf_vec, pd.Series)
310311

311312

312-
def test_martinez_shade_factor():
313+
def martinez_shade_factor_Table2():
314+
"""
315+
Data provided in Table 2, [1] of martinez_shade_factor
316+
Returns tuple with (input: pandas.DataFrame, output: pandas.Series)
317+
Output is POWER LOSS, not POWER CORRECTION, so model result must be
318+
subtracted from 1
319+
"""
320+
test_data = pd.DataFrame(
321+
columns=["F_GS-H", "F_GS-V", "N_shaded_blocks", "power_reduction"],
322+
data=[
323+
[1.00, 0.09, 24, 0.88],
324+
[1.00, 0.18, 24, 0.89],
325+
[1.00, 0.36, 24, 0.90],
326+
[0.04, 0.64, 1, 0.08],
327+
[0.17, 0.45, 3, 0.22],
328+
[0.29, 0.27, 5, 0.33],
329+
[0.50, 0.09, 8, 0.46],
330+
[0.13, 1.00, 2, 0.21],
331+
[0.25, 1.00, 4, 0.40],
332+
[0.38, 1.00, 6, 0.56],
333+
[0.50, 1.00, 8, 0.54],
334+
[0.58, 0.82, 10, 0.74],
335+
[0.75, 0.73, 12, 0.81],
336+
[0.92, 0.64, 15, 0.89],
337+
] # fmt: skip
338+
)
339+
test_data["N_total_blocks"] = 24 # total blocks is 24 for all cases
340+
test_data["shaded_fraction"] = test_data["F_GS-H"] * test_data["F_GS-V"]
341+
test_data.drop(columns=["F_GS-H", "F_GS-V"], inplace=True)
342+
return (test_data.drop(columns="power_reduction"), test_data["power_reduction"])
343+
344+
345+
def test_martinez_shade_factor(martinez_shade_factor_Table2):
313346
"""Tests pvlib.shading.martinez_shade_factor"""
314-
# TODO
315-
pass
347+
premises, power_reduction_expected = martinez_shade_factor_Table2
348+
power_loss_factor = 1 - shading.martinez_shade_factor(**premises)
349+
assert_allclose(power_loss_factor, power_reduction_expected)

0 commit comments

Comments
 (0)