@@ -313,38 +313,56 @@ def test_shaded_fraction1d(sf1d_premises_and_expected):
313
313
@pytest .fixture
314
314
def martinez_shade_factor_Table2 ():
315
315
"""
316
- Data provided in Table 2, [1] of martinez_shade_factor
316
+ Original data used in [1] (see shading.martinez_shade_factor) to validate
317
+ the model. Some of the data is provided from Table 2.
317
318
Returns tuple with (input: pandas.DataFrame, output: pandas.Series)
318
- Output is POWER LOSS, not POWER CORRECTION, so model result must be
319
- subtracted from 1
319
+ Output is IRRADIANCE LOSS, not IRRADIANCE CORRECTION, so model result must
320
+ be subtracted from 1
320
321
"""
321
322
test_data = pd .DataFrame (
322
- columns = ["F_GS-H" , "F_GS-V" , "N_shaded_blocks" , "power_reduction" ],
323
+ columns = [
324
+ "F_GS-H" ,
325
+ "F_GS-V" ,
326
+ "N_shaded_blocks" ,
327
+ "direct" ,
328
+ "diffuse" ,
329
+ "irrad_correction" ,
330
+ ],
323
331
data = [
324
- [1.00 , 0.09 , 24 , 0.88 ],
325
- [1.00 , 0.18 , 24 , 0.89 ],
326
- [1.00 , 0.36 , 24 , 0.90 ],
327
- [0.04 , 0.64 , 1 , 0.08 ],
328
- [0.17 , 0.45 , 3 , 0.22 ],
329
- [0.29 , 0.27 , 5 , 0.33 ],
330
- [0.50 , 0.09 , 8 , 0.46 ],
331
- [0.13 , 1.00 , 2 , 0.21 ],
332
- [0.25 , 1.00 , 4 , 0.40 ],
333
- [0.38 , 1.00 , 6 , 0.56 ],
334
- [0.50 , 1.00 , 8 , 0.54 ],
335
- [0.58 , 0.82 , 10 , 0.74 ],
336
- [0.75 , 0.73 , 12 , 0.81 ],
337
- [0.92 , 0.64 , 15 , 0.89 ],
338
- ] # fmt: skip
339
- )
340
- test_data ["N_total_blocks" ] = 24 # total blocks is 24 for all cases
332
+ # F-H, F-V, Nsb, direct, diffuse, effective_irrad_correction
333
+ [1.00 , 0.09 , 16 , 846.59 , 59.42 , 0.88 ],
334
+ [1.00 , 0.18 , 16 , 841.85 , 59.69 , 0.89 ],
335
+ [1.00 , 0.36 , 16 , 843.38 , 59.22 , 0.90 ],
336
+ [0.04 , 0.64 , 1 , 851.90 , 59.40 , 0.08 ],
337
+ [0.17 , 0.45 , 3 , 862.86 , 58.40 , 0.22 ],
338
+ [0.29 , 0.27 , 5 , 864.14 , 58.11 , 0.33 ],
339
+ [0.50 , 0.09 , 8 , 863.23 , 58.31 , 0.46 ],
340
+ [0.13 , 1.00 , 2 , 870.14 , 58.02 , 0.21 ],
341
+ [0.25 , 1.00 , 4 , 876.57 , 57.98 , 0.40 ],
342
+ [0.38 , 1.00 , 6 , 866.86 , 58.89 , 0.56 ],
343
+ [0.50 , 1.00 , 8 , 874.58 , 58.44 , 0.69 ],
344
+ [0.58 , 0.82 , 10 , 876.80 , 58.16 , 0.74 ],
345
+ [0.75 , 0.73 , 12 , 866.89 , 58.73 , 0.81 ],
346
+ [0.92 , 0.64 , 15 , 861.48 , 59.66 , 0.89 ],
347
+ ]
348
+ ) # fmt: skip
349
+ test_data ["N_total_blocks" ] = 16 # total blocks is 16 for all cases
341
350
test_data ["shaded_fraction" ] = test_data ["F_GS-H" ] * test_data ["F_GS-V" ]
342
- test_data .drop (columns = ["F_GS-H" , "F_GS-V" ], inplace = True )
343
- return (test_data .drop (columns = "power_reduction" ), test_data ["power_reduction" ])
351
+ test_data = test_data .drop (columns = ["F_GS-H" , "F_GS-V" ])
352
+ return (
353
+ test_data .drop (columns = "irrad_correction" ),
354
+ test_data ["irrad_correction" ],
355
+ )
344
356
345
357
346
358
def test_martinez_shade_factor (martinez_shade_factor_Table2 ):
347
359
"""Tests pvlib.shading.martinez_shade_factor"""
348
- premises , power_reduction_expected = martinez_shade_factor_Table2
349
- power_loss_factor = 1 - shading .martinez_shade_factor (** premises )
350
- assert_allclose (power_loss_factor , power_reduction_expected )
360
+ test_data , irrad_reduction_expected = martinez_shade_factor_Table2
361
+ correction_factor = shading .martinez_shade_factor (
362
+ ** test_data .drop (columns = ["direct" , "diffuse" ])
363
+ )
364
+ irrad_correction = 1 - (
365
+ (test_data ["direct" ] * correction_factor + test_data ["diffuse" ])
366
+ / (test_data ["direct" ] + test_data ["diffuse" ])
367
+ )
368
+ assert_allclose (irrad_correction , irrad_reduction_expected , atol = 1e-2 )
0 commit comments