@@ -404,28 +404,57 @@ def test_disc_min_cos_zenith_max_zenith():
404
404
times = pd .DatetimeIndex (['2016-07-19 06:11:00' ], tz = 'America/Phoenix' )
405
405
out = irradiance .disc (ghi = 1.0 , solar_zenith = 89.99 , datetime_or_doy = times )
406
406
expected = pd .DataFrame (np .array (
407
- [[0.00000000e+00 , 1.16046346e-02 , 3.63954476e+01 ]]),
407
+ [[0.00000000e+00 , 1.16046346e-02 , 12.0 ]]),
408
408
columns = columns , index = times )
409
409
assert_frame_equal (out , expected )
410
410
411
+ # max_zenith and/or max_airmass keep these results reasonable
411
412
out = irradiance .disc (ghi = 1.0 , solar_zenith = 89.99 , datetime_or_doy = times ,
412
413
min_cos_zenith = 0 )
413
414
expected = pd .DataFrame (np .array (
414
- [[0.00000000e+00 , 1.0 , 3.63954476e+01 ]]),
415
+ [[0.00000000e+00 , 1.0 , 12.0 ]]),
415
416
columns = columns , index = times )
416
417
assert_frame_equal (out , expected )
417
418
419
+ # still get reasonable values because of max_airmass=12 limit
418
420
out = irradiance .disc (ghi = 1.0 , solar_zenith = 89.99 , datetime_or_doy = times ,
419
421
max_zenith = 100 )
420
422
expected = pd .DataFrame (np .array (
421
- [[6.68577449e+03 , 1.16046346e-02 , 3.63954476e+01 ]]),
423
+ [[0. , 1.16046346e-02 , 12.0 ]]),
422
424
columns = columns , index = times )
423
425
assert_frame_equal (out , expected )
424
426
427
+ # still get reasonable values because of max_airmass=12 limit
425
428
out = irradiance .disc (ghi = 1.0 , solar_zenith = 89.99 , datetime_or_doy = times ,
426
429
min_cos_zenith = 0 , max_zenith = 100 )
427
430
expected = pd .DataFrame (np .array (
428
- [[7.21238390e+03 , 1.00000000e+00 , 3.63954476e+01 ]]),
431
+ [[277.50185968 , 1.0 , 12.0 ]]),
432
+ columns = columns , index = times )
433
+ assert_frame_equal (out , expected )
434
+
435
+ # max_zenith keeps this result reasonable
436
+ out = irradiance .disc (ghi = 1.0 , solar_zenith = 89.99 , datetime_or_doy = times ,
437
+ min_cos_zenith = 0 , max_airmass = 100 )
438
+ expected = pd .DataFrame (np .array (
439
+ [[0.00000000e+00 , 1.0 , 36.39544757 ]]),
440
+ columns = columns , index = times )
441
+ assert_frame_equal (out , expected )
442
+
443
+ # allow zenith to be close to 90 and airmass to be infinite
444
+ # and we get crazy values
445
+ out = irradiance .disc (ghi = 1.0 , solar_zenith = 89.99 , datetime_or_doy = times ,
446
+ max_zenith = 100 , max_airmass = 100 )
447
+ expected = pd .DataFrame (np .array (
448
+ [[6.68577449e+03 , 1.16046346e-02 , 3.63954476e+01 ]]),
449
+ columns = columns , index = times )
450
+ assert_frame_equal (out , expected )
451
+
452
+ # allow min cos zenith to be 0, zenith to be close to 90,
453
+ # and airmass to be very big and we get even higher DNI values
454
+ out = irradiance .disc (ghi = 1.0 , solar_zenith = 89.99 , datetime_or_doy = times ,
455
+ min_cos_zenith = 0 , max_zenith = 100 , max_airmass = 100 )
456
+ expected = pd .DataFrame (np .array (
457
+ [[7.21238390e+03 , 1. , 3.63954476e+01 ]]),
429
458
columns = columns , index = times )
430
459
assert_frame_equal (out , expected )
431
460
@@ -497,13 +526,18 @@ def test_dirint_min_cos_zenith_max_zenith():
497
526
expected = pd .Series ([0.0 , 0.0 ], index = times , name = 'dni' )
498
527
assert_series_equal (out , expected )
499
528
500
- out = irradiance .dirint (ghi , solar_zenith , times , max_zenith = 100 )
501
- expected = pd .Series ([862.198 , 848.387 ], index = times , name = 'dni' )
529
+ out = irradiance .dirint (ghi , solar_zenith , times , max_zenith = 90 )
530
+ expected = pd .Series ([0.0 , 0.0 ], index = times , name = 'dni' )
531
+ assert_series_equal (out , expected , check_less_precise = True )
532
+
533
+ out = irradiance .dirint (ghi , solar_zenith , times , min_cos_zenith = 0 ,
534
+ max_zenith = 90 )
535
+ expected = pd .Series ([0.0 , 144.264507 ], index = times , name = 'dni' )
502
536
assert_series_equal (out , expected , check_less_precise = True )
503
537
504
538
out = irradiance .dirint (ghi , solar_zenith , times , min_cos_zenith = 0 ,
505
539
max_zenith = 100 )
506
- expected = pd .Series ([147655.5994 , 3749.8542 ], index = times , name = 'dni' )
540
+ expected = pd .Series ([0.0 , 144.264507 ], index = times , name = 'dni' )
507
541
assert_series_equal (out , expected , check_less_precise = True )
508
542
509
543
@@ -670,13 +704,13 @@ def test_dirindex_min_cos_zenith_max_zenith():
670
704
assert_series_equal (out , expected )
671
705
672
706
out = irradiance .dirindex (ghi , ghi_clearsky , dni_clearsky , solar_zenith ,
673
- times , max_zenith = 100 )
674
- expected = pd .Series ([0. , 5. ], index = times )
707
+ times , max_zenith = 90 )
708
+ expected = pd .Series ([nan , nan ], index = times )
675
709
assert_series_equal (out , expected )
676
710
677
711
out = irradiance .dirindex (ghi , ghi_clearsky , dni_clearsky , solar_zenith ,
678
712
times , min_cos_zenith = 0 , max_zenith = 100 )
679
- expected = pd .Series ([0. , 5. ], index = times )
713
+ expected = pd .Series ([nan , 5. ], index = times )
680
714
assert_series_equal (out , expected )
681
715
682
716
0 commit comments