From 95a81273f343b6dffacefdc33802214b9c817a1e Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 7 Mar 2023 17:08:36 -0700 Subject: [PATCH 01/55] use FARMS-DNI to compute DNI' --- farms/farms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/farms/farms.py b/farms/farms.py index c752013..dcd4dd9 100644 --- a/farms/farms.py +++ b/farms/farms.py @@ -20,6 +20,7 @@ from farms import CLEAR_TYPES, ICE_TYPES, WATER_TYPES, SOLAR_CONSTANT import farms.utilities as ut +from farms import farms_dni def water_phase(tau, De, solar_zenith_angle): @@ -208,6 +209,8 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, dni = Fd / solar_zenith_angle # eq 2b from [1] dhi = ghi - Fd # eq 7 from [1] + Fd, dni_farmsdni, dni0 = farms_dni.farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, ghi, F1) + clear_mask = np.in1d(cloud_type, CLEAR_TYPES).reshape(cloud_type.shape) if debug: # Return NaN if clear-sky, else return cloudy sky data @@ -224,4 +227,5 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, return fast_data else: # return only GHI - return np.where(clear_mask, np.nan, ghi) + return np.where(clear_mask, np.nan, ghi), np.where(clear_mask, np.nan, dni_farmsdni), np.where(clear_mask, np.nan, dni0) +# print( theta00, idx, muomega ) From 480d4f91a2928bd673325e14dfac51384342acf3 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 7 Mar 2023 17:19:39 -0700 Subject: [PATCH 02/55] update the files to use FARMS-DNI --- farms/Interomega.dat | 841 +++++++++++++++++++++++++++++++++++++++++ farms/farms_dni.py | 290 ++++++++++++++ farms/old/farms_dni.py | 253 +++++++++++++ 3 files changed, 1384 insertions(+) create mode 100644 farms/Interomega.dat create mode 100644 farms/farms_dni.py create mode 100644 farms/old/farms_dni.py diff --git a/farms/Interomega.dat b/farms/Interomega.dat new file mode 100644 index 0000000..7e6b3c5 --- /dev/null +++ b/farms/Interomega.dat @@ -0,0 +1,841 @@ + 0.00000 0.00590483 + 0.100000 0.00590620 + 0.200000 0.00590758 + 0.300000 0.00590895 + 0.400000 0.00591032 + 0.500000 0.00591169 + 0.600000 0.00591306 + 0.700000 0.00591444 + 0.800000 0.00591581 + 0.900000 0.00591718 + 1.00000 0.00591855 + 1.10000 0.00591993 + 1.20000 0.00592130 + 1.30000 0.00592267 + 1.40000 0.00592405 + 1.50000 0.00592542 + 1.60000 0.00592679 + 1.70000 0.00592816 + 1.80000 0.00592953 + 1.90000 0.00593091 + 2.00000 0.00593228 + 2.10000 0.00593590 + 2.20000 0.00593952 + 2.30000 0.00594314 + 2.40000 0.00594675 + 2.50000 0.00595037 + 2.60000 0.00595399 + 2.70000 0.00595761 + 2.80000 0.00596123 + 2.90000 0.00596485 + 3.00000 0.00596847 + 3.10000 0.00597208 + 3.20000 0.00597570 + 3.30000 0.00597932 + 3.40000 0.00598294 + 3.50000 0.00598656 + 3.60000 0.00599018 + 3.70000 0.00599379 + 3.80000 0.00599741 + 3.90000 0.00600103 + 4.00000 0.00600465 + 4.10000 0.00600483 + 4.20000 0.00600501 + 4.30000 0.00600519 + 4.40000 0.00600537 + 4.50000 0.00600555 + 4.60000 0.00600573 + 4.70000 0.00600591 + 4.80000 0.00600609 + 4.90000 0.00600627 + 5.00000 0.00600644 + 5.10000 0.00600662 + 5.20000 0.00600680 + 5.30000 0.00600698 + 5.40000 0.00600716 + 5.50000 0.00600734 + 5.60000 0.00600752 + 5.70000 0.00600770 + 5.80000 0.00600788 + 5.90000 0.00600806 + 6.00000 0.00600824 + 6.10000 0.00600801 + 6.20000 0.00600777 + 6.30000 0.00600754 + 6.40000 0.00600731 + 6.50000 0.00600708 + 6.60000 0.00600684 + 6.70000 0.00600661 + 6.80000 0.00600638 + 6.90000 0.00600615 + 7.00000 0.00600591 + 7.10000 0.00600568 + 7.20000 0.00600545 + 7.30000 0.00600522 + 7.40000 0.00600498 + 7.50000 0.00600475 + 7.60000 0.00600452 + 7.70000 0.00600429 + 7.80000 0.00600406 + 7.90000 0.00600382 + 8.00000 0.00600359 + 8.10000 0.00600320 + 8.20000 0.00600280 + 8.30000 0.00600241 + 8.40000 0.00600201 + 8.50000 0.00600162 + 8.60000 0.00600122 + 8.70000 0.00600083 + 8.80000 0.00600043 + 8.90000 0.00600004 + 9.00000 0.00599965 + 9.10000 0.00599925 + 9.20000 0.00599886 + 9.30000 0.00599846 + 9.40000 0.00599807 + 9.50000 0.00599767 + 9.60000 0.00599728 + 9.70000 0.00599688 + 9.80000 0.00599649 + 9.90000 0.00599609 + 10.0000 0.00599570 + 10.1000 0.00599476 + 10.2000 0.00599382 + 10.3000 0.00599288 + 10.4000 0.00599194 + 10.5000 0.00599100 + 10.6000 0.00599005 + 10.7000 0.00598911 + 10.8000 0.00598817 + 10.9000 0.00598723 + 11.0000 0.00598629 + 11.1000 0.00598535 + 11.2000 0.00598441 + 11.3000 0.00598347 + 11.4000 0.00598253 + 11.5000 0.00598159 + 11.6000 0.00598064 + 11.7000 0.00597970 + 11.8000 0.00597876 + 11.9000 0.00597782 + 12.0000 0.00597688 + 12.1000 0.00597445 + 12.2000 0.00597202 + 12.3000 0.00596960 + 12.4000 0.00596717 + 12.5000 0.00596474 + 12.6000 0.00596231 + 12.7000 0.00595988 + 12.8000 0.00595746 + 12.9000 0.00595503 + 13.0000 0.00595260 + 13.1000 0.00595017 + 13.2000 0.00594774 + 13.3000 0.00594532 + 13.4000 0.00594289 + 13.5000 0.00594046 + 13.6000 0.00593803 + 13.7000 0.00593560 + 13.8000 0.00593318 + 13.9000 0.00593075 + 14.0000 0.00592832 + 14.1000 0.00592701 + 14.2000 0.00592570 + 14.3000 0.00592439 + 14.4000 0.00592308 + 14.5000 0.00592177 + 14.6000 0.00592046 + 14.7000 0.00591915 + 14.8000 0.00591784 + 14.9000 0.00591653 + 15.0000 0.00591523 + 15.1000 0.00591392 + 15.2000 0.00591261 + 15.3000 0.00591130 + 15.4000 0.00590999 + 15.5000 0.00590868 + 15.6000 0.00590737 + 15.7000 0.00590606 + 15.8000 0.00590475 + 15.9000 0.00590344 + 16.0000 0.00590213 + 16.1000 0.00590074 + 16.2000 0.00589934 + 16.3000 0.00589795 + 16.4000 0.00589655 + 16.5000 0.00589516 + 16.6000 0.00589376 + 16.7000 0.00589237 + 16.8000 0.00589097 + 16.9000 0.00588958 + 17.0000 0.00588818 + 17.1000 0.00588679 + 17.2000 0.00588540 + 17.3000 0.00588400 + 17.4000 0.00588261 + 17.5000 0.00588121 + 17.6000 0.00587982 + 17.7000 0.00587842 + 17.8000 0.00587703 + 17.9000 0.00587563 + 18.0000 0.00587424 + 18.1000 0.00587173 + 18.2000 0.00586921 + 18.3000 0.00586670 + 18.4000 0.00586419 + 18.5000 0.00586167 + 18.6000 0.00585916 + 18.7000 0.00585665 + 18.8000 0.00585413 + 18.9000 0.00585162 + 19.0000 0.00584910 + 19.1000 0.00584659 + 19.2000 0.00584408 + 19.3000 0.00584156 + 19.4000 0.00583905 + 19.5000 0.00583654 + 19.6000 0.00583402 + 19.7000 0.00583151 + 19.8000 0.00582900 + 19.9000 0.00582648 + 20.0000 0.00582397 + 20.1000 0.00582024 + 20.2000 0.00581650 + 20.3000 0.00581277 + 20.4000 0.00580903 + 20.5000 0.00580530 + 20.6000 0.00580157 + 20.7000 0.00579783 + 20.8000 0.00579410 + 20.9000 0.00579036 + 21.0000 0.00578663 + 21.1000 0.00578290 + 21.2000 0.00577916 + 21.3000 0.00577543 + 21.4000 0.00577169 + 21.5000 0.00576796 + 21.6000 0.00576423 + 21.7000 0.00576049 + 21.8000 0.00575676 + 21.9000 0.00575302 + 22.0000 0.00574929 + 22.1000 0.00574687 + 22.2000 0.00574445 + 22.3000 0.00574203 + 22.4000 0.00573961 + 22.5000 0.00573719 + 22.6000 0.00573477 + 22.7000 0.00573235 + 22.8000 0.00572993 + 22.9000 0.00572751 + 23.0000 0.00572510 + 23.1000 0.00572268 + 23.2000 0.00572026 + 23.3000 0.00571784 + 23.4000 0.00571542 + 23.5000 0.00571300 + 23.6000 0.00571058 + 23.7000 0.00570816 + 23.8000 0.00570574 + 23.9000 0.00570332 + 24.0000 0.00570090 + 24.1000 0.00569727 + 24.2000 0.00569363 + 24.3000 0.00569000 + 24.4000 0.00568637 + 24.5000 0.00568274 + 24.6000 0.00567910 + 24.7000 0.00567547 + 24.8000 0.00567184 + 24.9000 0.00566821 + 25.0000 0.00566457 + 25.1000 0.00566094 + 25.2000 0.00565731 + 25.3000 0.00565368 + 25.4000 0.00565005 + 25.5000 0.00564641 + 25.6000 0.00564278 + 25.7000 0.00563915 + 25.8000 0.00563551 + 25.9000 0.00563188 + 26.0000 0.00562825 + 26.1000 0.00562424 + 26.2000 0.00562022 + 26.3000 0.00561621 + 26.4000 0.00561219 + 26.5000 0.00560818 + 26.6000 0.00560416 + 26.7000 0.00560015 + 26.8000 0.00559613 + 26.9000 0.00559212 + 27.0000 0.00558810 + 27.1000 0.00558409 + 27.2000 0.00558008 + 27.3000 0.00557606 + 27.4000 0.00557205 + 27.5000 0.00556803 + 27.6000 0.00556402 + 27.7000 0.00556000 + 27.8000 0.00555599 + 27.9000 0.00555197 + 28.0000 0.00554796 + 28.1000 0.00554317 + 28.2000 0.00553839 + 28.3000 0.00553360 + 28.4000 0.00552881 + 28.5000 0.00552403 + 28.6000 0.00551924 + 28.7000 0.00551445 + 28.8000 0.00550967 + 28.9000 0.00550488 + 29.0000 0.00550009 + 29.1000 0.00549531 + 29.2000 0.00549052 + 29.3000 0.00548574 + 29.4000 0.00548095 + 29.5000 0.00547616 + 29.6000 0.00547138 + 29.7000 0.00546659 + 29.8000 0.00546180 + 29.9000 0.00545702 + 30.0000 0.00545223 + 30.1000 0.00544585 + 30.2000 0.00543946 + 30.3000 0.00543308 + 30.4000 0.00542670 + 30.5000 0.00542031 + 30.6000 0.00541393 + 30.7000 0.00540755 + 30.8000 0.00540116 + 30.9000 0.00539478 + 31.0000 0.00538839 + 31.1000 0.00538201 + 31.2000 0.00537563 + 31.3000 0.00536924 + 31.4000 0.00536286 + 31.5000 0.00535648 + 31.6000 0.00535009 + 31.7000 0.00534371 + 31.8000 0.00533733 + 31.9000 0.00533094 + 32.0000 0.00532456 + 32.1000 0.00532113 + 32.2000 0.00531770 + 32.3000 0.00531426 + 32.4000 0.00531083 + 32.5000 0.00530740 + 32.6000 0.00530397 + 32.7000 0.00530054 + 32.8000 0.00529710 + 32.9000 0.00529367 + 33.0000 0.00529024 + 33.1000 0.00528681 + 33.2000 0.00528338 + 33.3000 0.00527994 + 33.4000 0.00527651 + 33.5000 0.00527308 + 33.6000 0.00526965 + 33.7000 0.00526622 + 33.8000 0.00526278 + 33.9000 0.00525935 + 34.0000 0.00525592 + 34.1000 0.00524949 + 34.2000 0.00524307 + 34.3000 0.00523664 + 34.4000 0.00523022 + 34.5000 0.00522379 + 34.6000 0.00521736 + 34.7000 0.00521094 + 34.8000 0.00520451 + 34.9000 0.00519809 + 35.0000 0.00519166 + 35.1000 0.00518523 + 35.2000 0.00517881 + 35.3000 0.00517238 + 35.4000 0.00516596 + 35.5000 0.00515953 + 35.6000 0.00515310 + 35.7000 0.00514668 + 35.8000 0.00514025 + 35.9000 0.00513383 + 36.0000 0.00512740 + 36.1000 0.00512218 + 36.2000 0.00511697 + 36.3000 0.00511175 + 36.4000 0.00510653 + 36.5000 0.00510132 + 36.6000 0.00509610 + 36.7000 0.00509088 + 36.8000 0.00508567 + 36.9000 0.00508045 + 37.0000 0.00507523 + 37.1000 0.00507002 + 37.2000 0.00506480 + 37.3000 0.00505959 + 37.4000 0.00505437 + 37.5000 0.00504915 + 37.6000 0.00504394 + 37.7000 0.00503872 + 37.8000 0.00503350 + 37.9000 0.00502829 + 38.0000 0.00502307 + 38.1000 0.00501537 + 38.2000 0.00500767 + 38.3000 0.00499998 + 38.4000 0.00499228 + 38.5000 0.00498458 + 38.6000 0.00497688 + 38.7000 0.00496919 + 38.8000 0.00496149 + 38.9000 0.00495379 + 39.0000 0.00494609 + 39.1000 0.00493840 + 39.2000 0.00493070 + 39.3000 0.00492300 + 39.4000 0.00491530 + 39.5000 0.00490761 + 39.6000 0.00489991 + 39.7000 0.00489221 + 39.8000 0.00488452 + 39.9000 0.00487682 + 40.0000 0.00486912 + 40.1000 0.00486418 + 40.2000 0.00485924 + 40.3000 0.00485430 + 40.4000 0.00484935 + 40.5000 0.00484441 + 40.6000 0.00483947 + 40.7000 0.00483453 + 40.8000 0.00482959 + 40.9000 0.00482465 + 41.0000 0.00481971 + 41.1000 0.00481476 + 41.2000 0.00480982 + 41.3000 0.00480488 + 41.4000 0.00479994 + 41.5000 0.00479500 + 41.6000 0.00479006 + 41.7000 0.00478511 + 41.8000 0.00478017 + 41.9000 0.00477523 + 42.0000 0.00477029 + 42.1000 0.00475930 + 42.2000 0.00474832 + 42.3000 0.00473733 + 42.4000 0.00472634 + 42.5000 0.00471535 + 42.6000 0.00470436 + 42.7000 0.00469338 + 42.8000 0.00468239 + 42.9000 0.00467140 + 43.0000 0.00466041 + 43.1000 0.00464943 + 43.2000 0.00463844 + 43.3000 0.00462745 + 43.4000 0.00461646 + 43.5000 0.00460548 + 43.6000 0.00459449 + 43.7000 0.00458350 + 43.8000 0.00457251 + 43.9000 0.00456153 + 44.0000 0.00455054 + 44.1000 0.00454559 + 44.2000 0.00454063 + 44.3000 0.00453568 + 44.4000 0.00453072 + 44.5000 0.00452577 + 44.6000 0.00452081 + 44.7000 0.00451586 + 44.8000 0.00451090 + 44.9000 0.00450595 + 45.0000 0.00450099 + 45.1000 0.00449604 + 45.2000 0.00449109 + 45.3000 0.00448613 + 45.4000 0.00448118 + 45.5000 0.00447622 + 45.6000 0.00447127 + 45.7000 0.00446631 + 45.8000 0.00446136 + 45.9000 0.00445640 + 46.0000 0.00445145 + 46.1000 0.00444520 + 46.2000 0.00443896 + 46.3000 0.00443271 + 46.4000 0.00442647 + 46.5000 0.00442022 + 46.6000 0.00441397 + 46.7000 0.00440773 + 46.8000 0.00440148 + 46.9000 0.00439524 + 47.0000 0.00438899 + 47.1000 0.00438274 + 47.2000 0.00437650 + 47.3000 0.00437025 + 47.4000 0.00436401 + 47.5000 0.00435776 + 47.6000 0.00435151 + 47.7000 0.00434527 + 47.8000 0.00433902 + 47.9000 0.00433278 + 48.0000 0.00432653 + 48.1000 0.00431831 + 48.2000 0.00431009 + 48.3000 0.00430187 + 48.4000 0.00429365 + 48.5000 0.00428543 + 48.6000 0.00427721 + 48.7000 0.00426899 + 48.8000 0.00426077 + 48.9000 0.00425255 + 49.0000 0.00424433 + 49.1000 0.00423612 + 49.2000 0.00422790 + 49.3000 0.00421968 + 49.4000 0.00421146 + 49.5000 0.00420324 + 49.6000 0.00419502 + 49.7000 0.00418680 + 49.8000 0.00417858 + 49.9000 0.00417036 + 50.0000 0.00416214 + 50.1000 0.00415042 + 50.2000 0.00413870 + 50.3000 0.00412699 + 50.4000 0.00411527 + 50.5000 0.00410355 + 50.6000 0.00409183 + 50.7000 0.00408011 + 50.8000 0.00406840 + 50.9000 0.00405668 + 51.0000 0.00404496 + 51.1000 0.00403324 + 51.2000 0.00402152 + 51.3000 0.00400981 + 51.4000 0.00399809 + 51.5000 0.00398637 + 51.6000 0.00397465 + 51.7000 0.00396293 + 51.8000 0.00395122 + 51.9000 0.00393950 + 52.0000 0.00392778 + 52.1000 0.00392101 + 52.2000 0.00391423 + 52.3000 0.00390746 + 52.4000 0.00390068 + 52.5000 0.00389391 + 52.6000 0.00388714 + 52.7000 0.00388036 + 52.8000 0.00387359 + 52.9000 0.00386681 + 53.0000 0.00386004 + 53.1000 0.00385327 + 53.2000 0.00384649 + 53.3000 0.00383972 + 53.4000 0.00383294 + 53.5000 0.00382617 + 53.6000 0.00381940 + 53.7000 0.00381262 + 53.8000 0.00380585 + 53.9000 0.00379907 + 54.0000 0.00379230 + 54.1000 0.00378461 + 54.2000 0.00377692 + 54.3000 0.00376922 + 54.4000 0.00376153 + 54.5000 0.00375384 + 54.6000 0.00374615 + 54.7000 0.00373846 + 54.8000 0.00373076 + 54.9000 0.00372307 + 55.0000 0.00371538 + 55.1000 0.00370769 + 55.2000 0.00370000 + 55.3000 0.00369230 + 55.4000 0.00368461 + 55.5000 0.00367692 + 55.6000 0.00366923 + 55.7000 0.00366154 + 55.8000 0.00365384 + 55.9000 0.00364615 + 56.0000 0.00363846 + 56.1000 0.00362986 + 56.2000 0.00362126 + 56.3000 0.00361266 + 56.4000 0.00360407 + 56.5000 0.00359547 + 56.6000 0.00358687 + 56.7000 0.00357827 + 56.8000 0.00356967 + 56.9000 0.00356107 + 57.0000 0.00355248 + 57.1000 0.00354388 + 57.2000 0.00353528 + 57.3000 0.00352668 + 57.4000 0.00351808 + 57.5000 0.00350948 + 57.6000 0.00350088 + 57.7000 0.00349229 + 57.8000 0.00348369 + 57.9000 0.00347509 + 58.0000 0.00346649 + 58.1000 0.00345696 + 58.2000 0.00344743 + 58.3000 0.00343791 + 58.4000 0.00342838 + 58.5000 0.00341885 + 58.6000 0.00340932 + 58.7000 0.00339980 + 58.8000 0.00339027 + 58.9000 0.00338074 + 59.0000 0.00337121 + 59.1000 0.00336169 + 59.2000 0.00335216 + 59.3000 0.00334263 + 59.4000 0.00333310 + 59.5000 0.00332358 + 59.6000 0.00331405 + 59.7000 0.00330452 + 59.8000 0.00329500 + 59.9000 0.00328547 + 60.0000 0.00327594 + 60.1000 0.00326526 + 60.2000 0.00325458 + 60.3000 0.00324391 + 60.4000 0.00323323 + 60.5000 0.00322255 + 60.6000 0.00321187 + 60.7000 0.00320120 + 60.8000 0.00319052 + 60.9000 0.00317984 + 61.0000 0.00316916 + 61.1000 0.00315849 + 61.2000 0.00314781 + 61.3000 0.00313713 + 61.4000 0.00312645 + 61.5000 0.00311578 + 61.6000 0.00310510 + 61.7000 0.00309442 + 61.8000 0.00308375 + 61.9000 0.00307307 + 62.0000 0.00306239 + 62.1000 0.00305003 + 62.2000 0.00303768 + 62.3000 0.00302532 + 62.4000 0.00301297 + 62.5000 0.00300061 + 62.6000 0.00298826 + 62.7000 0.00297590 + 62.8000 0.00296355 + 62.9000 0.00295119 + 63.0000 0.00293883 + 63.1000 0.00292648 + 63.2000 0.00291412 + 63.3000 0.00290177 + 63.4000 0.00288941 + 63.5000 0.00287706 + 63.6000 0.00286470 + 63.7000 0.00285235 + 63.8000 0.00283999 + 63.9000 0.00282764 + 64.0000 0.00281528 + 64.1000 0.00280613 + 64.2000 0.00279699 + 64.3000 0.00278784 + 64.4000 0.00277870 + 64.5000 0.00276955 + 64.6000 0.00276040 + 64.7000 0.00275126 + 64.8000 0.00274211 + 64.9000 0.00273297 + 65.0000 0.00272382 + 65.1000 0.00271467 + 65.2000 0.00270553 + 65.3000 0.00269638 + 65.4000 0.00268724 + 65.5000 0.00267809 + 65.6000 0.00266894 + 65.7000 0.00265980 + 65.8000 0.00265065 + 65.9000 0.00264151 + 66.0000 0.00263236 + 66.1000 0.00262276 + 66.2000 0.00261315 + 66.3000 0.00260355 + 66.4000 0.00259395 + 66.5000 0.00258435 + 66.6000 0.00257475 + 66.7000 0.00256514 + 66.8000 0.00255554 + 66.9000 0.00254594 + 67.0000 0.00253634 + 67.1000 0.00252673 + 67.2000 0.00251713 + 67.3000 0.00250753 + 67.4000 0.00249792 + 67.5000 0.00248832 + 67.6000 0.00247872 + 67.7000 0.00246912 + 67.8000 0.00245951 + 67.9000 0.00244991 + 68.0000 0.00244031 + 68.1000 0.00243031 + 68.2000 0.00242031 + 68.3000 0.00241031 + 68.4000 0.00240030 + 68.5000 0.00239030 + 68.6000 0.00238030 + 68.7000 0.00237030 + 68.8000 0.00236030 + 68.9000 0.00235030 + 69.0000 0.00234029 + 69.1000 0.00233029 + 69.2000 0.00232029 + 69.3000 0.00231029 + 69.4000 0.00230029 + 69.5000 0.00229029 + 69.6000 0.00228029 + 69.7000 0.00227028 + 69.8000 0.00226028 + 69.9000 0.00225028 + 70.0000 0.00224028 + 70.1000 0.00222992 + 70.2000 0.00221956 + 70.3000 0.00220919 + 70.4000 0.00219883 + 70.5000 0.00218847 + 70.6000 0.00217811 + 70.7000 0.00216775 + 70.8000 0.00215738 + 70.9000 0.00214702 + 71.0000 0.00213666 + 71.1000 0.00212630 + 71.2000 0.00211594 + 71.3000 0.00210557 + 71.4000 0.00209521 + 71.5000 0.00208485 + 71.6000 0.00207449 + 71.7000 0.00206413 + 71.8000 0.00205376 + 71.9000 0.00204340 + 72.0000 0.00203304 + 72.1000 0.00202236 + 72.2000 0.00201167 + 72.3000 0.00200099 + 72.4000 0.00199031 + 72.5000 0.00197963 + 72.6000 0.00196895 + 72.7000 0.00195826 + 72.8000 0.00194758 + 72.9000 0.00193690 + 73.0000 0.00192621 + 73.1000 0.00191553 + 73.2000 0.00190485 + 73.3000 0.00189417 + 73.4000 0.00188348 + 73.5000 0.00187280 + 73.6000 0.00186212 + 73.7000 0.00185144 + 73.8000 0.00184075 + 73.9000 0.00183007 + 74.0000 0.00181939 + 74.1000 0.00180847 + 74.2000 0.00179755 + 74.3000 0.00178664 + 74.4000 0.00177572 + 74.5000 0.00176480 + 74.6000 0.00175389 + 74.7000 0.00174297 + 74.8000 0.00173205 + 74.9000 0.00172113 + 75.0000 0.00171022 + 75.1000 0.00169930 + 75.2000 0.00168838 + 75.3000 0.00167746 + 75.4000 0.00166654 + 75.5000 0.00165563 + 75.6000 0.00164471 + 75.7000 0.00163379 + 75.8000 0.00162287 + 75.9000 0.00161196 + 76.0000 0.00160104 + 76.1000 0.00158991 + 76.2000 0.00157878 + 76.3000 0.00156765 + 76.4000 0.00155653 + 76.5000 0.00154540 + 76.6000 0.00153427 + 76.7000 0.00152314 + 76.8000 0.00151201 + 76.9000 0.00150088 + 77.0000 0.00148975 + 77.1000 0.00147863 + 77.2000 0.00146750 + 77.3000 0.00145637 + 77.4000 0.00144524 + 77.5000 0.00143411 + 77.6000 0.00142298 + 77.7000 0.00141185 + 77.8000 0.00140073 + 77.9000 0.00138960 + 78.0000 0.00137847 + 78.1000 0.00136718 + 78.2000 0.00135590 + 78.3000 0.00134461 + 78.4000 0.00133333 + 78.5000 0.00132204 + 78.6000 0.00131075 + 78.7000 0.00129947 + 78.8000 0.00128818 + 78.9000 0.00127690 + 79.0000 0.00126561 + 79.1000 0.00125432 + 79.2000 0.00124304 + 79.3000 0.00123175 + 79.4000 0.00122047 + 79.5000 0.00120918 + 79.6000 0.00119789 + 79.7000 0.00118661 + 79.8000 0.00117532 + 79.9000 0.00116404 + 80.0000 0.00115275 + 80.1000 0.00114134 + 80.2000 0.00112992 + 80.3000 0.00111851 + 80.4000 0.00110709 + 80.5000 0.00109568 + 80.6000 0.00108426 + 80.7000 0.00107285 + 80.8000 0.00106144 + 80.9000 0.00105002 + 81.0000 0.00103861 + 81.1000 0.00102719 + 81.2000 0.00101578 + 81.3000 0.00100437 + 81.4000 0.000992951 + 81.5000 0.000981537 + 81.6000 0.000970123 + 81.7000 0.000958708 + 81.8000 0.000947294 + 81.9000 0.000935880 + 82.0000 0.000924466 + 82.1000 0.000912979 + 82.2000 0.000901491 + 82.3000 0.000890005 + 82.4000 0.000878518 + 82.5000 0.000867031 + 82.6000 0.000855544 + 82.7000 0.000844056 + 82.8000 0.000832570 + 82.9000 0.000821083 + 83.0000 0.000809596 + 83.1000 0.000798109 + 83.2000 0.000786621 + 83.3000 0.000775135 + 83.4000 0.000763648 + 83.5000 0.000752161 + 83.6000 0.000740674 + 83.7000 0.000729186 + 83.8000 0.000717700 + 83.9000 0.000706213 + 84.0000 0.000694726 diff --git a/farms/farms_dni.py b/farms/farms_dni.py new file mode 100644 index 0000000..c2067fc --- /dev/null +++ b/farms/farms_dni.py @@ -0,0 +1,290 @@ +""" +Created on March 1, 2022 +FARMS-DNI model developed by Yu Xie (yu.xie@nrel.gov) +Must have Interomega.dat to compute DNI + +Literature +[1] Yu Xie, Manajit Sengupta, Yangang Liu, Hai Long, Qilong Min, Weijia Liu, Aron Habte, + A physics-based DNI model assessing all-sky circumsolar radiation, iScience +[2] Yu Xie, Jaemo Yang, Manajit Sengupta, Yangang Liu, Xin Zhou, + Improving the prediction of DNI with physics-based representation of all-sky circumsolar radaition, Solar Energy +[3] Jaemo Yang, Yu Xie, Manajit Sengupta, Yangang Liu, Hai Long, + Parameterization of cloud transmittance for expeditious assessment and forecasting of all-sky DNI, Solar Energy + +""" +import numpy as np +import sys +import pandas as pd + + +def Read_Two_Column_File(file_name): + with open(file_name, 'r') as data: + x = [] + y = [] + for line in data: + p = line.split() + x.append(float(p[0])) + y.append(float(p[1])) + + return x, y + +def find_nearest(array, value): + array = np.asarray(array) + idx = (np.abs(array - value)).argmin() + return array[idx], idx + + + +def TDD2(Z, Ftotal, F1): + + a = 5.94991536e-03 + b = 5.42116600e-01 + c = 331280.9859904468 + muomega = np.exp(-np.power(Z-b, 3.0)/c ) + + Fd2 = np.cos( Z*np.pi/180.0 )*(Ftotal - F1)*muomega/np.pi + return Fd2 + + +def TDDP(Z, tau, De, phase1, phase2): + + Tddcld = np.zeros_like(tau) + Tddcld[phase1] = Pwater( Z[phase1],tau[phase1], De[phase1] ) + Tddcld[phase2] = Pice( Z[phase2],tau[phase2], De[phase2] ) + + return Tddcld + + + +def Pwater(Z, tau, De): + + umu0 = np.cos( Z*np.pi/180.0 ) +### taup + taup = np.zeros_like(Z) + taup[(De<10.0) & (umu0<0.1391)] = 0.1 + taup[(De<10.0) & (umu0>=0.1391) & (umu0<0.2419)] = 0.2 + taup[(De<10.0) & (umu0>=0.2419) & (umu0<0.3090)] = 0.3 + taup[(De<10.0) & (umu0>=0.3090) & (umu0<0.4067)] = 0.4 + taup[(De<10.0) & (umu0>=0.4067) & (umu0<0.6156)] = 0.5 + taup[(De<10.0) & (umu0>=0.6156)] = 1.0 + + taup[(De>=10.0) & (umu0<0.1391)] = 0.1 + taup[(De>=10.0) & (umu0>=0.1391) & (umu0<0.2079)] = 0.2 + taup[(De>=10.0) & (umu0>=0.2079) & (umu0<0.3090)] = 0.3 + taup[(De>=10.0) & (umu0>=0.3090) & (umu0<0.3746)] = 0.4 + taup[(De>=10.0) & (umu0>=0.3746) & (umu0<0.6156)] = 0.5 + taup[(De>=10.0) & (umu0>=0.6156)] = 1.0 + +###Tddp + h = 0.005553*np.log(De) + 0.002503 + h[De==0] = 0.0 + Tddp = np.zeros_like(Z) + a1 = (umu0>=0.0) & (umu0<0.342) + Tddp[a1] = h[a1]*(-0.1787*umu0[a1]*umu0[a1] + 0.2207*umu0[a1] + 0.977) + a2 = (umu0>=0.342) & (umu0<0.4694) + Tddp[a2] = h[a2] + a3 = (umu0>=0.4694) & (umu0<0.7193) + Tddp[a3] = h[a3]*( 2.6399*umu0[a3]*umu0[a3] - 3.2111*umu0[a3] + 1.9434 ) + a4 = (umu0>=0.7193) & (umu0<0.8829) + Tddp[a4] = h[a4]*( -0.224*umu0[a4]*umu0[a4] + 0.0835*umu0[a4] + 1.056 ) + a5 = (umu0>=0.8829) & (umu0<0.9396) + Tddp[a5] = h[a5]*( -94.381*umu0[a5]*umu0[a5] + 170.32*umu0[a5] - 75.843 ) + a6 = (umu0>=0.9396) & (umu0<0.9945) + Tddp[a6] = h[a6]*( -12.794*umu0[a6]*umu0[a6] + 22.686*umu0[a6] - 8.9392 ) + a7 = (umu0>=0.9945) & (umu0<0.999) + Tddp[a7] = h[a7]*( 11248.61*umu0[a7]*umu0[a7] - 22441.07*umu0[a7] + 11193.59 ) + a8 = umu0>=0.999 + Tddp[a8] = 0.76*h[a8] + + a = 2.0339*np.power( umu0, -0.927 ) + b = 6.6421*np.power( umu0, 2.0672 ) + + Tddcld = np.zeros_like(Z) + a1 = tau<=0.9*taup + Tddcld[a1] = Tddp[a1]*np.tanh(a[a1]*tau[a1]) + a2 = (tau>0.9*taup) & (tau=taup + Tddcld[a3] = Tddp[a3]*np.tanh(b[a3]/np.power(tau[a3],2.0)) + + + return Tddcld + + + + +def Pice(Z, tau, De): + + umu0 = np.cos( Z*np.pi/180.0 ) +### taup + taup = np.zeros_like(Z) + a1 = (De>=5.0) & (De<14.0) & (umu0<0.1391) + taup[a1] = 0.1 + a2 = (De>=5.0) & (De<14.0) & (umu0>=0.1391) & (umu0<0.2079) + taup[a2] = 0.2 + a3 = (De>=5.0) & (De<14.0) & (umu0>=0.2079) & (umu0<0.3090) + taup[a3] = 0.3 + a4 = (De>=5.0) & (De<14.0) & (umu0>=0.3090) & (umu0<0.3746) + taup[a4] = 0.4 + a5 = (De>=5.0) & (De<14.0) & (umu0>=0.3746) & (umu0<0.6156) + taup[a5] = 0.5 + a6 = (De>=5.0) & (De<14.0) & (umu0>=0.6156) & (umu0<0.9994) + taup[a6] = 1.0 + a7 = (De>=5.0) & (De<14.0) & (umu0>=0.9994) + taup[a7] = 1.5 + + a8 = (De>=14.0) & (De<50.0) & (umu0<0.139173) + taup[a8] = 0.1 + a9 = (De>=14.0) & (De<50.0) & (umu0>=0.139173) & (umu0<-0.0011*De+0.2307) + taup[a9] = 0.2 + a10 = (De>=14.0) & (De<50.0) & (umu0>=-0.0011*De+0.2307) & (umu0<-0.0022*De+0.3340) + taup[a10] = 0.3 + a11 = (De>=14.0) & (De<50.0) & (umu0>=-0.0022*De+0.3340) & (umu0<-0.0020*De+0.4096) + taup[a11] = 0.4 + a12 = (De>=14.0) & (De<50.0) & (umu0>=-0.0020*De+0.4096) & (umu0<-0.0033*De+0.6461) + taup[a12] = 0.5 + a13 = (De>=14.0) & (De<50.0) & (umu0>=-0.0033*De+0.6461) & (umu0<-0.0049*De+1.0713) + taup[a13] = 1.0 + a14 = (De>=14.0) & (De<50.0) & (umu0>=-0.0049*De+1.0713) + taup[a14] = 1.5 + + a15 = (De>=50.0) & (umu0<-0.0006*De+0.2109) + taup[a15] = 0.2 + a16 = (De>=50.0) & (umu0>=-0.0006*De+0.2109) & (umu0<-0.0005*De+0.2581) + taup[a16] = 0.3 + a17 = (De>=50.0) & (umu0>=-0.0005*De+0.2581) & (umu0<-0.0010*De+0.3907) + taup[a17] = 0.4 + a18 = (De>=50.0) & (umu0>=-0.0010*De+0.3907) & (umu0<-0.0008*De+0.4900) + taup[a18] = 0.5 + a19 = (De>=50.0) & (umu0>=-0.0008*De+0.4900) & (umu0<-0.0017*De+0.8708) + taup[a19] = 1.0 + a20 = (De>=50.0) & (umu0>=-0.0017*De+0.8708) & (umu0<-0.0006*De+1.0367) + taup[a20] = 1.5 + a21 = (De>=50.0) & (umu0>=-0.0006*De+1.0367) + taup[a21] = 2.0 + +###Tddp + Tddp = np.zeros_like(Z) + b1 = (umu0>=0.9994) & (De<=10.0) + Tddp[b1] = 0.12269 + b2 = (umu0>=0.9994) & (De>10.0) & (De<=16.0) + Tddp[b2] = 0.0015*De[b2] + 0.1078 + b3 = (umu0>=0.9994) & (De>16.0) + Tddp[b3] = 0.1621*np.exp(-0.016*De[b3]) + + b4 = (umu0<0.9396) & (De<=10.0) + Tddp[b4] = 0.14991 + b5 = (umu0<0.9945) & (umu0>=0.9396) & (De<=10.0) + Tddp[b5] = -4.5171*np.power(umu0[b5],2.0) + 8.3056*umu0[b5] - 3.6476 + b6 = (umu0>=0.9945) & (umu0<0.9994) & (De<=10.0) + Tddp[b6] = 298.45*np.power(umu0[b6],2.0) - 601.33*umu0[b6] + 303.04 + + + ade = -0.000232338*np.power(De,2.0) + 0.012748726*De + 0.046745083 + b7 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0<=0.2419) + Tddp[b7] = (-8.454*np.power(umu0[b7],2.0) + 2.4095*umu0[b7] +0.8425)*ade[b7] + b8 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.2419) & (umu0<=0.3746) + Tddp[b8] = (-13.528*np.power(umu0[b8],2.0) + 7.8403*umu0[b8] -0.1221)*ade[b8] + b9 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.3746) & (umu0<=0.4694) + Tddp[b9] = (19.524*np.power(umu0[b9],2.0) - 16.5*umu0[b9] +4.4612)*ade[b9] + b10 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.4694) & (umu0<=0.5877) + Tddp[b10] = (16.737*np.power(umu0[b10],2.0) - 17.419*umu0[b10] +5.4881)*ade[b10] + b11 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.5877) & (umu0<=0.6691) + Tddp[b11] = (-39.493*np.power(umu0[b11],2.0) + 48.963*umu0[b11] -14.175)*ade[b11] + b12 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.6691) & (umu0<=0.7660) + Tddp[b12] = (0.4017*np.power(umu0[b12],2.0) - 0.243*umu0[b12] +0.9609)*ade[b12] + b13 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.7660) & (umu0<=0.8480) + Tddp[b13] = (-11.183*np.power(umu0[b13],2.0) + 18.126*umu0[b13] -6.3417)*ade[b13] + b14 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8480) & (umu0<=0.8987) + Tddp[b14] = (-163.36*np.power(umu0[b14],2.0) + 283.35*umu0[b14] -121.91)*ade[b14] + b15 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8987) & (umu0<=0.9396) + Tddp[b15] = (-202.72*np.power(umu0[b15],2.0) + 368.75*umu0[b15] -166.75)*ade[b15] + b16 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9396) & (umu0<=0.9702) + Tddp[b16] = (-181.72*np.power(umu0[b16],2.0) + 343.59*umu0[b16] -161.3)*ade[b16] + b17 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9702) & (umu0<=0.9945) + Tddp[b17] = (127.66*np.power(umu0[b17],2.0) - 255.73*umu0[b17] +129.03)*ade[b17] + b18 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9945) + Tddp[b18] = (908.66*np.power(umu0[b18],2.0) - 1869.3*umu0[b18] +961.63)*ade[b18] + + bde = 0.0000166112*np.power(De,2.0) - 0.00410998*De + 0.352026619 + b19 = (umu0<0.999) & (De>30.0) & (umu0<=0.2419) + Tddp[b19] = (-4.362*np.power(umu0[b19],2.0) - 0.0878*umu0[b19] +1.1218)*bde[b19] + b20 = (umu0<0.999) & (De>30.0) & (umu0>0.2419) & (umu0<=0.3746) + Tddp[b20] = (-49.566*np.power(umu0[b20],2.0) + 28.767*umu0[b20] -3.1299)*bde[b20] + b21 = (umu0<0.999) & (De>30.0) & (umu0>0.3746) & (umu0<=0.4694) + Tddp[b21] = (58.572*np.power(umu0[b21],2.0) - 49.5*umu0[b21] +11.363)*bde[b21] + b22 = (umu0<0.999) & (De>30.0) & (umu0>0.4694) & (umu0<=0.5877) + Tddp[b22] = (62.118*np.power(umu0[b22],2.0) - 63.037*umu0[b22] +16.875)*bde[b22] + b23 = (umu0<0.999) & (De>30.0) & (umu0>0.5877) & (umu0<=0.6691) + Tddp[b23] = (-237.68*np.power(umu0[b23],2.0) + 293.21*umu0[b23] -89.328)*bde[b23] + b24 = (umu0<0.999) & (De>30.0) & (umu0>0.6691) & (umu0<=0.7660) + Tddp[b24] = (1.2051*np.power(umu0[b24],2.0) - 0.7291*umu0[b24] +0.8826)*bde[b24] + b25 = (umu0<0.999) & (De>30.0) & (umu0>0.7660) & (umu0<=0.8480) + Tddp[b25] = (-55.6*np.power(umu0[b25],2.0) + 90.698*umu0[b25] -35.905)*bde[b25] + b26 = (umu0<0.999) & (De>30.0) & (umu0>0.8480) & (umu0<=0.8987) + Tddp[b26] = (-422.36*np.power(umu0[b26],2.0) + 733.97*umu0[b26] -317.89)*bde[b26] + b27 = (umu0<0.999) & (De>30.0) & (umu0>0.8987) & (umu0<=0.9396) + Tddp[b27] = (-457.09*np.power(umu0[b27],2.0) + 831.11*umu0[b27] -376.85)*bde[b27] + b28 = (umu0<0.999) & (De>30.0) & (umu0>0.9396) & (umu0<=0.9702) + Tddp[b28] = (-344.91*np.power(umu0[b28],2.0) + 655.67*umu0[b28] -310.5)*bde[b28] + b29 = (umu0<0.999) & (De>30.0) & (umu0>0.9702) & (umu0<=0.9945) + Tddp[b29] = (622.85*np.power(umu0[b29],2.0) - 1227.6*umu0[b29] +605.97)*bde[b29] + b30 = (umu0<0.999) & (De>30.0) & (umu0>0.9945) + Tddp[b30] = (6309.63*np.power(umu0[b30],2.0) - 12654.78*umu0[b30] +6346.15)*bde[b30] + +###Tddcld + a = 1.7686*np.power(umu0,-0.95) + b = 7.117*np.power(umu0,1.9658) + + Tddcld = np.zeros_like(Z) + a1 = tau<=0.9*taup + Tddcld[a1] = Tddp[a1]*np.tanh(a[a1]*tau[a1]) + a2 = (tau>0.9*taup) & (tau=taup + Tddcld[a3] = Tddp[a3]*np.tanh(b[a3]/np.power(tau[a3],2.0)) + + return Tddcld + + + + + +def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1): + + ############### scale tau + taudni = np.zeros_like(tau) + + a1 = np.where( (phase == 1) & (tau<8.0) ) + a2 = np.where( (phase == 1) & (tau>=8.0) ) + taudni[a1] = ( 0.254825*tau[a1] - 0.00232717*np.power(tau[a1], 2.0) \ + + (5.19320e-06)*np.power(tau[a1], 3.0) )*(1.0+(8.0-tau[a1])*0.07) + taudni[a2] = 0.2*np.power(tau[a2]-8.0, 1.5) + 2.10871 + + b1 = np.where( (phase == 2) & (tau<8.0) ) + b2 = np.where( (phase == 2) & (tau>=8.0) ) + taudni[b1] = 0.345353*tau[b1] - 0.00244671*np.power(tau[b1], 2.0) \ + + (4.74263E-06)*np.power(tau[b1], 3.0) + taudni[b2] = 0.2*np.power(tau[b2]-8.0, 1.5) + 2.91345 + ############### + + Z = np.arccos(solar_zenith_angle)*180.0/np.pi + dni0 = F0*Tddclr*np.exp(-tau/solar_zenith_angle) + + Tddcld0 = np.exp(-taudni/solar_zenith_angle) + Fd0 = solar_zenith_angle*F0*Tddcld0*Tddclr + + Tddcld1 = TDDP(Z, taudni, De, phase1, phase2) + Fd1 = solar_zenith_angle*F0*Tddclr*Tddcld1 + Fd2 = TDD2(Z, Ftotal, F1 ) + + Fd = Fd0 + Fd1 + Fd2 + dni_farmsdni = Fd/solar_zenith_angle + + return Fd, dni_farmsdni, dni0 + + + + diff --git a/farms/old/farms_dni.py b/farms/old/farms_dni.py new file mode 100644 index 0000000..52fa8d7 --- /dev/null +++ b/farms/old/farms_dni.py @@ -0,0 +1,253 @@ +""" +Created on March 1, 2022 +FARMS-DNI model developed by Yu Xie (yu.xie@nrel.gov) +Must have Interomega.dat to compute DNI + +Literature +[1] Yu Xie, Manajit Sengupta, Yangang Liu, Hai Long, Qilong Min, Weijia Liu, Aron Habte, + A physics-based DNI model assessing all-sky circumsolar radiation, iScience +[2] Yu Xie, Jaemo Yang, Manajit Sengupta, Yangang Liu, Xin Zhou, + Improving the prediction of DNI with physics-based representation of all-sky circumsolar radaition, Solar Energy +[3] Jaemo Yang, Yu Xie, Manajit Sengupta, Yangang Liu, Hai Long, + Parameterization of cloud transmittance for expeditious assessment and forecasting of all-sky DNI, Solar Energy + +""" +import numpy as np +import sys +import pandas as pd + + +def Read_Two_Column_File(file_name): + with open(file_name, 'r') as data: + x = [] + y = [] + for line in data: + p = line.split() + x.append(float(p[0])) + y.append(float(p[1])) + + return x, y + +def find_nearest(array, value): + array = np.asarray(array) + idx = (np.abs(array - value)).argmin() + return array[idx], idx + + + +def TDD2(Z, Ftotal, Fd1 ): + + theta0, mmuomega = Read_Two_Column_File('Interomega.dat') + theta00, idx = find_nearest(theta0, Z) + muomega = mmuomega[idx] + Fd2 = (Ftotal - Fd1)*muomega/np.pi +# print( theta00, idx, muomega ) + return Fd2 + + +def TDDP(Z, tau, De, phase): + +# Tddcld[phase1] = pwater( Z[phase1],tau[phase1], De[phase1] ) +# Tddcld[phase2] = pice( Z[phase1],tau[phase1], De[phase1] ) + + return Tddcld + + + +def Pwater(Z, tau, De): + + umu0 = np.cos( Z*np.pi/180.0 ) +### taup + taup = np.zeros_like(Z) + taup[umu0<0.1391] = 0.1 + taup[(umu0>=0.1391) & (umu0<0.2419)] = 0.2 + taup[(umu0>=0.2419) & (umu0<0.3090)] = 0.3 + taup[(umu0>=0.3090) & (umu0<0.4067)] = 0.4 + taup[(umu0>=0.4067) & (umu0<0.6156)] = 0.5 + taup[umu0>=0.6156] = 1.0 + +###Tddp + Tddp = np.zeros_like(Z) + a1 = (umu0>=0.0) & (umu0<0.45) + Tddp[a1] = 0.00628502*( np.log(De[a1]) + 0.035 ) + a2 = (umu0>=0.45) & (umu0<0.88) + Tddp[a2] = 0.00609272*( np.log(De[a2]) + 0.035 ) + a3 = (umu0>=0.88) & (umu0<0.92) + Tddp[a3] = ( -0.0128*umu0[a3] + 0.0175 )*( np.log(De[a3]) + 0.035 ) + a4 = (umu0>=0.92) & (umu0<0.99) + Tddp[a4] = ( -0.0103*umu0[a4] + 0.0163 )*( np.log(De[a4]) + 0.035 ) + a5 = (umu0>=0.99) & (umu0<0.999) + Tddp[a5] = ( -0.0326*umu0[a5] + 0.0392 )*( np.log(De[a5]) + 0.035 ) + a6 = umu0>=0.999 + Tddp[a6] = 0.0042*np.log(De[a6]) + 0.002 + + a = 2.0461*np.power( umu0, -0.816 ) + b = 6.5257*np.power( umu0, 1.819 ) + + Tddcld = np.zeros_like(Z) + a1 = tau<=0.9*taup + Tddcld[a1] = Tddp[a1]*np.tanh(a[a1]*tau[a1]) + a2 = (tau>0.9*taup) & (tau=taup + Tddcld[a3] = Tddp[a3]*np.tanh(b[a3]/np.power(tau[a3],2.0)) + + return Tddcld + + + + +def Pice(Z, tau, De): + + umu0 = np.cos( Z*np.pi/180.0 ) +### taup + taup = np.zeros_like(Z) + a1 = (De>=5.0) & (De<14.0) & (umu0<0.1045) + taup[a1] = 0.1 + a2 = (De>=5.0) & (De<14.0) & (umu0>=0.1045) & (umu0<0.1736) + taup[a2] = 0.2 + a3 = (De>=5.0) & (De<14.0) & (umu0>=0.1736) & (umu0<0.2756) + taup[a3] = 0.3 + a4 = (De>=5.0) & (De<14.0) & (umu0>=0.2756) & (umu0<0.3420) + taup[a4] = 0.4 + a5 = (De>=5.0) & (De<14.0) & (umu0>=0.3420) & (umu0<0.5877) + taup[a5] = 0.5 + a6 = (De>=5.0) & (De<14.0) & (umu0>=0.5877) & (umu0<0.9993) + taup[a6] = 1.0 + a7 = (De>=5.0) & (De<14.0) & (umu0>=0.9993) + taup[a7] = 1.5 + + a8 = (De>=14.0) & (De<50.0) & (umu0<0.10453) + taup[a8] = 0.1 + a9 = (De>=14.0) & (De<50.0) & (umu0>=0.10453) & (umu0<-0.0011*De+0.1966) + taup[a9] = 0.2 + a10 = (De>=14.0) & (De<50.0) & (umu0>=-0.0011*De+0.1966) & (umu0<-0.0022*De+0.3009) + taup[a10] = 0.3 + a11 = (De>=14.0) & (De<50.0) & (umu0>=-0.0022*De+0.3009) & (umu0<-0.0021*De+0.3774) + taup[a11] = 0.4 + a12 = (De>=14.0) & (De<50.0) & (umu0>=-0.0021*De+0.3774) & (umu0<-0.0034*De+0.6188) + taup[a12] = 0.5 + a13 = (De>=14.0) & (De<50.0) & (umu0>=-0.0034*De+0.6188) & (umu0<-0.0054*De+1.0743) + taup[a13] = 1.0 + a14 = (De>=14.0) & (De<50.0) & (umu0>=-0.0054*De+1.0743) + taup[a14] = 1.5 + + a15 = (De>=50.0) & (umu0<-0.0006*De+0.1766) + taup[a15] = 0.2 + a16 = (De>=50.0) & (umu0>=-0.0006*De+0.1766) & (umu0<-0.0005*De+0.2242) + taup[a16] = 0.3 + a17 = (De>=50.0) & (umu0>=-0.0005*De+0.2242) & (umu0<-0.0011*De+0.3583) + taup[a17] = 0.4 + a18 = (De>=50.0) & (umu0>=-0.0011*De+0.3583) & (umu0<-0.0008*De+0.4592) + taup[a18] = 0.5 + a19 = (De>=50.0) & (umu0>=-0.0008*De+0.4592) & (umu0<-0.0018*De+0.8521) + taup[a19] = 1.0 + a20 = (De>=50.0) & (umu0>=-0.0018*De+0.8521) & (umu0<-0.0007*De+1.0455) + taup[a20] = 1.5 + a21 = (De>=50.0) & (umu0>=-0.0007*De+1.0455) + taup[a21] = 2.0 + + + Tddp = np.zeros_like(Z) + b1 = (umu0>=0.999) & (De<=10.0) + Tddp[b1] = 0.12269 + b2 = (umu0>=0.999) & (De>10.0) & (De<=16.0) + Tddp[b2] = 0.0015*De[b2] + 0.1078 + b3 = (umu0>=0.999) & (De>16.0) + Tddp[b3] = 0.1621*np.exp(-0.016*De[b3]) + + b4 = (umu0<0.9271) & (De<=10.0) + Tddp[b4] = 0.1499 + b5 = (umu0<0.9902) & (umu0>=0.9271) & (De<=10.0) + Tddp[b5] = -3.1476*np.power(De[b5],2.0) + 5.6543*De[b5] - 2.3682 + b6 = (umu0>=0.9902) & (umu0<0.999) & (De<=10.0) + Tddp[b6] = 226.5*np.power(De[b6],2.0) - 454.41*De[b6] - 228.07 + + + ade = -0.000232338*np.power(De,2.0) + 0.012749*De + 0.046745 + b7 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0<=0.2079) + Tddp[b7] = (-8.3642*np.power(umu0[b7],2.0) + 1.8051*umu0[b7] +0.9168)*ade[b7] + b8 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.2079) & (umu0<=0.3420) + Tddp[b8] = (-13.253*np.power(umu0[b8],2.0) + 6.7924*umu0[b8] +0.1436)*ade[b8] + b9 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.3420) & (umu0<=0.4383) + Tddp[b9] = (18.976*np.power(umu0[b9],2.0) - 14.82*umu0[b9] +3.87)*ade[b9] + b10 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.4383) & (umu0<=0.5591) + Tddp[b10] = (16.078*np.power(umu0[b10],2.0) - 15.767*umu0[b10] +4.8211)*ade[b10] + b11 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.5591) & (umu0<=0.6427) + Tddp[b11] = (-37.48*np.power(umu0[b11],2.0) + 44.388*umu0[b11] -12.141)*ade[b11] + b12 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.6427) & (umu0<=0.7431) + Tddp[b12] = (0.3501*np.power(umu0[b12],2.0) - 0.1634*umu0[b12] +0.9385)*ade[b12] + b13 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.7431) & (umu0<=0.8290) + Tddp[b13] = (-10.237*np.power(umu0[b13],2.0) + 16.165*umu0[b13] -5.3782)*ade[b13] + b14 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8290) & (umu0<=0.8829) + Tddp[b14] = (-145.49*np.power(umu0[b14],2.0) + 247.15*umu0[b14] -104.0)*ade[b14] + b15 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8829) & (umu0<=0.9271) + Tddp[b15] = (-174.18*np.power(umu0[b15],2.0) + 311.61*umu0[b15] -138.42)*ade[b15] + b16 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9271) & (umu0<=0.9612) + Tddp[b16] = (-147.45*np.power(umu0[b16],2.0) + 275.26*umu0[b16] -127.36)*ade[b16] + b17 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9612) & (umu0<=0.9902) + Tddp[b17] = (25.643*np.power(umu0[b17],2.0) - 53.74*umu0[b17] +29.027)*ade[b17] + b18 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9902) + Tddp[b18] = (1294.4*np.power(umu0[b18],2.0) - 2611.5*umu0[b18] +1318.0)*ade[b18] + + bde = 0.0000166*np.power(De,2.0) + 0.00411*De + 0.352 + b19 = (umu0<0.999) & (De>30.0) & (umu0<=0.2079) + Tddp[b19] = (-8.4358*np.power(umu0[b19],2.0) + 0.6676*umu0[b19] +1.0565)*bde[b19] + b20 = (umu0<0.999) & (De>30.0) & (umu0>0.2079) & (umu0<=0.3420) + Tddp[b20] = (-48.564*np.power(umu0[b20],2.0) + 24.929*umu0[b20] -2.1551)*bde[b20] + b21 = (umu0<0.999) & (De>30.0) & (umu0>0.3420) & (umu0<=0.4383) + Tddp[b21] = (56.902*np.power(umu0[b21],2.0) - 44.46*umu0[b21] +9.59)*bde[b21] + b22 = (umu0<0.999) & (De>30.0) & (umu0>0.4383) & (umu0<=0.5591) + Tddp[b22] = (59.618*np.power(umu0[b22],2.0) - 56.882*umu0[b22] +14.45)*bde[b22] + b23 = (umu0<0.999) & (De>30.0) & (umu0>0.5591) & (umu0<=0.6427) + Tddp[b23] = (-225.52*np.power(umu0[b23],2.0) + 265.66*umu0[b23] +77.136)*bde[b23] + b24 = (umu0<0.999) & (De>30.0) & (umu0>0.6427) & (umu0<=0.7431) + Tddp[b24] = (8.6548*np.power(umu0[b24],2.0) + 11.085*umu0[b24] +4.5026)*bde[b24] + b25 = (umu0<0.999) & (De>30.0) & (umu0>0.7431) & (umu0<=0.8290) + Tddp[b25] = (-50.917*np.power(umu0[b25],2.0) + 80.953*umu0[b25] -31.094)*bde[b25] + b26 = (umu0<0.999) & (De>30.0) & (umu0>0.8290) & (umu0<=0.8829) + Tddp[b26] = (-434.92*np.power(umu0[b26],2.0) + 739.75*umu0[b26] -313.63)*bde[b26] + b27 = (umu0<0.999) & (De>30.0) & (umu0>0.8829) & (umu0<=0.9271) + Tddp[b27] = (-392.67*np.power(umu0[b27],2.0) + 702.16*umu0[b27] -312.95)*bde[b27] + b28 = (umu0<0.999) & (De>30.0) & (umu0>0.9271) & (umu0<=0.9612) + Tddp[b28] = (-281.4*np.power(umu0[b28],2.0) + 528.53*umu0[b28] -247.08)*bde[b28] + b29 = (umu0<0.999) & (De>30.0) & (umu0>0.9612) & (umu0<=0.9902) + Tddp[b29] = (467.5*np.power(umu0[b29],2.0) - 915.28*umu0[b29] +449.03)*bde[b29] + b30 = (umu0<0.999) & (De>30.0) & (umu0>0.9902) + Tddp[b30] = (3872.1*np.power(umu0[b30],2.0) - 7746.4*umu0[b30] +3875.3)*bde[b30] + + +###Tddcld + a = 1.8099*np.power(umu0,-0.824) + b = 7.1094*np.power(umu0,1.7436) + + Tddcld = np.zeros_like(Z) + a1 = tau<=0.9*taup + Tddcld[a1] = Tddp[a1]*np.tanh(a[a1]*tau[a1]) + a2 = (tau>0.9*taup) & (tau=taup + Tddcld[a3] = Tddp[a3]*np.tanh(b[a3]/np.power(tau[a3],2.0)) + + return Tddcld + + +#aa = Pwater(np.array([30.0]), np.array([5.0]), np.array([10.0]) ) +#aa = Pwater(np.arange(10)*8.0, np.arange(10), (np.arange(10)+1)*10 ) +aa = Pice(np.arange(10)*8.0, np.arange(10), (np.arange(10)+1)*10 ) +print(aa) + + +def farms_dni(F0, tau, solar_zenith_angle, De, phase1, phase2, Tddclr, Ftotal, Tddcld0, Tddcld1, Fd2 ): + + + Fd0 = solar_zenith_angle*F0*Tddcld*Tddclr + + + return Fd, dni + + + + From 1aa4b0ff288a18ee75e35b278257a1e7120d6e35 Mon Sep 17 00:00:00 2001 From: bnb32 Date: Thu, 9 Mar 2023 14:16:04 -0700 Subject: [PATCH 03/55] linting fix --- .github/workflows/linter.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 4b78645..29835fc 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -16,11 +16,13 @@ jobs: fetch-depth: 0 - name: Lint Code Base - uses: github/super-linter@v3 + uses: docker://ghcr.io/github/super-linter:slim-v4 env: VALIDATE_ALL_CODEBASE: false VALIDATE_PYTHON_BLACK: false VALIDATE_PYTHON_ISORT: false + VALIDATE_PYTHON_MYPY: false + VALIDATE_DOCKERFILE_HADOLINT: false VALIDATE_JSCPD: false VALIDATE_JSON: false VALIDATE_MARKDOWN: false From ebe7b2adc5da682749b4f10c7d16e1d0ab0b5fd4 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Mon, 20 Mar 2023 14:33:24 -0600 Subject: [PATCH 04/55] fix a mistake in TDD2 --- farms/farms_dni.py | 50 ++----- farms/old/farms_dni.py | 287 +++++++++++++++++++++++------------------ 2 files changed, 176 insertions(+), 161 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index c2067fc..a07de3c 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -1,7 +1,6 @@ """ Created on March 1, 2022 FARMS-DNI model developed by Yu Xie (yu.xie@nrel.gov) -Must have Interomega.dat to compute DNI Literature [1] Yu Xie, Manajit Sengupta, Yangang Liu, Hai Long, Qilong Min, Weijia Liu, Aron Habte, @@ -17,37 +16,19 @@ import pandas as pd -def Read_Two_Column_File(file_name): - with open(file_name, 'r') as data: - x = [] - y = [] - for line in data: - p = line.split() - x.append(float(p[0])) - y.append(float(p[1])) - - return x, y - -def find_nearest(array, value): - array = np.asarray(array) - idx = (np.abs(array - value)).argmin() - return array[idx], idx - - - def TDD2(Z, Ftotal, F1): - + # compute surface reflection that falls in the circumsolar region. A parameterization of Eq. (S4) in Xie et al (2020) is used. a = 5.94991536e-03 b = 5.42116600e-01 c = 331280.9859904468 - muomega = np.exp(-np.power(Z-b, 3.0)/c ) + muomega = a*np.exp(-np.power(Z-b, 3.0)/c ) Fd2 = np.cos( Z*np.pi/180.0 )*(Ftotal - F1)*muomega/np.pi return Fd2 def TDDP(Z, tau, De, phase1, phase2): - + # compute cloud transmittance of DNI for water and ice clouds Tddcld = np.zeros_like(tau) Tddcld[phase1] = Pwater( Z[phase1],tau[phase1], De[phase1] ) Tddcld[phase2] = Pice( Z[phase2],tau[phase2], De[phase2] ) @@ -55,11 +36,10 @@ def TDDP(Z, tau, De, phase1, phase2): return Tddcld - def Pwater(Z, tau, De): umu0 = np.cos( Z*np.pi/180.0 ) -### taup +### taup Eq.(3) in Yang et al. (2022) taup = np.zeros_like(Z) taup[(De<10.0) & (umu0<0.1391)] = 0.1 taup[(De<10.0) & (umu0>=0.1391) & (umu0<0.2419)] = 0.2 @@ -75,7 +55,7 @@ def Pwater(Z, tau, De): taup[(De>=10.0) & (umu0>=0.3746) & (umu0<0.6156)] = 0.5 taup[(De>=10.0) & (umu0>=0.6156)] = 1.0 -###Tddp +###Tddp Eq(4) in Yang et al. (2022) h = 0.005553*np.log(De) + 0.002503 h[De==0] = 0.0 Tddp = np.zeros_like(Z) @@ -96,9 +76,11 @@ def Pwater(Z, tau, De): a8 = umu0>=0.999 Tddp[a8] = 0.76*h[a8] + # Eq.(6) in Yang et al. (2022) a = 2.0339*np.power( umu0, -0.927 ) b = 6.6421*np.power( umu0, 2.0672 ) + # compute Tddcld using Eq.(5) in Yang et al. (2022) Tddcld = np.zeros_like(Z) a1 = tau<=0.9*taup Tddcld[a1] = Tddp[a1]*np.tanh(a[a1]*tau[a1]) @@ -108,16 +90,13 @@ def Pwater(Z, tau, De): a3 = tau>=taup Tddcld[a3] = Tddp[a3]*np.tanh(b[a3]/np.power(tau[a3],2.0)) - return Tddcld - - def Pice(Z, tau, De): umu0 = np.cos( Z*np.pi/180.0 ) -### taup +### taup Eq.(3) in Yang et al. (2022) taup = np.zeros_like(Z) a1 = (De>=5.0) & (De<14.0) & (umu0<0.1391) taup[a1] = 0.1 @@ -164,7 +143,7 @@ def Pice(Z, tau, De): a21 = (De>=50.0) & (umu0>=-0.0006*De+1.0367) taup[a21] = 2.0 -###Tddp +###Tddp Eq(4) in Yang et al. (2022) Tddp = np.zeros_like(Z) b1 = (umu0>=0.9994) & (De<=10.0) Tddp[b1] = 0.12269 @@ -180,7 +159,6 @@ def Pice(Z, tau, De): b6 = (umu0>=0.9945) & (umu0<0.9994) & (De<=10.0) Tddp[b6] = 298.45*np.power(umu0[b6],2.0) - 601.33*umu0[b6] + 303.04 - ade = -0.000232338*np.power(De,2.0) + 0.012748726*De + 0.046745083 b7 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0<=0.2419) Tddp[b7] = (-8.454*np.power(umu0[b7],2.0) + 2.4095*umu0[b7] +0.8425)*ade[b7] @@ -233,7 +211,7 @@ def Pice(Z, tau, De): b30 = (umu0<0.999) & (De>30.0) & (umu0>0.9945) Tddp[b30] = (6309.63*np.power(umu0[b30],2.0) - 12654.78*umu0[b30] +6346.15)*bde[b30] -###Tddcld +###compute Tddcld using Eq.(5) in Yang et al. (2022) a = 1.7686*np.power(umu0,-0.95) b = 7.117*np.power(umu0,1.9658) @@ -249,12 +227,9 @@ def Pice(Z, tau, De): return Tddcld - - - def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1): - ############### scale tau + ############### scale tau for the computation of DNI. See Eqs. (3a and 3b) in Xie et al. (2020), iScience. taudni = np.zeros_like(tau) a1 = np.where( (phase == 1) & (tau<8.0) ) @@ -270,16 +245,19 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ft taudni[b2] = 0.2*np.power(tau[b2]-8.0, 1.5) + 2.91345 ############### + # compute DNI in the narrow beam. Eq.(S2) in Xie et al. (2020), iScience. Z = np.arccos(solar_zenith_angle)*180.0/np.pi dni0 = F0*Tddclr*np.exp(-tau/solar_zenith_angle) Tddcld0 = np.exp(-taudni/solar_zenith_angle) Fd0 = solar_zenith_angle*F0*Tddcld0*Tddclr + # compute scattered radiation in the circumsolar region. Eq.(S3 and S4) in Xie et al. (2020), iScience. Tddcld1 = TDDP(Z, taudni, De, phase1, phase2) Fd1 = solar_zenith_angle*F0*Tddclr*Tddcld1 Fd2 = TDD2(Z, Ftotal, F1 ) + # compute DNI using the three components. Eq.(S1) in Xie et al. (2020), iScience. Fd = Fd0 + Fd1 + Fd2 dni_farmsdni = Fd/solar_zenith_angle diff --git a/farms/old/farms_dni.py b/farms/old/farms_dni.py index 52fa8d7..c2067fc 100644 --- a/farms/old/farms_dni.py +++ b/farms/old/farms_dni.py @@ -35,20 +35,22 @@ def find_nearest(array, value): -def TDD2(Z, Ftotal, Fd1 ): +def TDD2(Z, Ftotal, F1): - theta0, mmuomega = Read_Two_Column_File('Interomega.dat') - theta00, idx = find_nearest(theta0, Z) - muomega = mmuomega[idx] - Fd2 = (Ftotal - Fd1)*muomega/np.pi -# print( theta00, idx, muomega ) + a = 5.94991536e-03 + b = 5.42116600e-01 + c = 331280.9859904468 + muomega = np.exp(-np.power(Z-b, 3.0)/c ) + + Fd2 = np.cos( Z*np.pi/180.0 )*(Ftotal - F1)*muomega/np.pi return Fd2 -def TDDP(Z, tau, De, phase): +def TDDP(Z, tau, De, phase1, phase2): -# Tddcld[phase1] = pwater( Z[phase1],tau[phase1], De[phase1] ) -# Tddcld[phase2] = pice( Z[phase1],tau[phase1], De[phase1] ) + Tddcld = np.zeros_like(tau) + Tddcld[phase1] = Pwater( Z[phase1],tau[phase1], De[phase1] ) + Tddcld[phase2] = Pice( Z[phase2],tau[phase2], De[phase2] ) return Tddcld @@ -59,30 +61,43 @@ def Pwater(Z, tau, De): umu0 = np.cos( Z*np.pi/180.0 ) ### taup taup = np.zeros_like(Z) - taup[umu0<0.1391] = 0.1 - taup[(umu0>=0.1391) & (umu0<0.2419)] = 0.2 - taup[(umu0>=0.2419) & (umu0<0.3090)] = 0.3 - taup[(umu0>=0.3090) & (umu0<0.4067)] = 0.4 - taup[(umu0>=0.4067) & (umu0<0.6156)] = 0.5 - taup[umu0>=0.6156] = 1.0 + taup[(De<10.0) & (umu0<0.1391)] = 0.1 + taup[(De<10.0) & (umu0>=0.1391) & (umu0<0.2419)] = 0.2 + taup[(De<10.0) & (umu0>=0.2419) & (umu0<0.3090)] = 0.3 + taup[(De<10.0) & (umu0>=0.3090) & (umu0<0.4067)] = 0.4 + taup[(De<10.0) & (umu0>=0.4067) & (umu0<0.6156)] = 0.5 + taup[(De<10.0) & (umu0>=0.6156)] = 1.0 + + taup[(De>=10.0) & (umu0<0.1391)] = 0.1 + taup[(De>=10.0) & (umu0>=0.1391) & (umu0<0.2079)] = 0.2 + taup[(De>=10.0) & (umu0>=0.2079) & (umu0<0.3090)] = 0.3 + taup[(De>=10.0) & (umu0>=0.3090) & (umu0<0.3746)] = 0.4 + taup[(De>=10.0) & (umu0>=0.3746) & (umu0<0.6156)] = 0.5 + taup[(De>=10.0) & (umu0>=0.6156)] = 1.0 ###Tddp + h = 0.005553*np.log(De) + 0.002503 + h[De==0] = 0.0 Tddp = np.zeros_like(Z) - a1 = (umu0>=0.0) & (umu0<0.45) - Tddp[a1] = 0.00628502*( np.log(De[a1]) + 0.035 ) - a2 = (umu0>=0.45) & (umu0<0.88) - Tddp[a2] = 0.00609272*( np.log(De[a2]) + 0.035 ) - a3 = (umu0>=0.88) & (umu0<0.92) - Tddp[a3] = ( -0.0128*umu0[a3] + 0.0175 )*( np.log(De[a3]) + 0.035 ) - a4 = (umu0>=0.92) & (umu0<0.99) - Tddp[a4] = ( -0.0103*umu0[a4] + 0.0163 )*( np.log(De[a4]) + 0.035 ) - a5 = (umu0>=0.99) & (umu0<0.999) - Tddp[a5] = ( -0.0326*umu0[a5] + 0.0392 )*( np.log(De[a5]) + 0.035 ) - a6 = umu0>=0.999 - Tddp[a6] = 0.0042*np.log(De[a6]) + 0.002 - - a = 2.0461*np.power( umu0, -0.816 ) - b = 6.5257*np.power( umu0, 1.819 ) + a1 = (umu0>=0.0) & (umu0<0.342) + Tddp[a1] = h[a1]*(-0.1787*umu0[a1]*umu0[a1] + 0.2207*umu0[a1] + 0.977) + a2 = (umu0>=0.342) & (umu0<0.4694) + Tddp[a2] = h[a2] + a3 = (umu0>=0.4694) & (umu0<0.7193) + Tddp[a3] = h[a3]*( 2.6399*umu0[a3]*umu0[a3] - 3.2111*umu0[a3] + 1.9434 ) + a4 = (umu0>=0.7193) & (umu0<0.8829) + Tddp[a4] = h[a4]*( -0.224*umu0[a4]*umu0[a4] + 0.0835*umu0[a4] + 1.056 ) + a5 = (umu0>=0.8829) & (umu0<0.9396) + Tddp[a5] = h[a5]*( -94.381*umu0[a5]*umu0[a5] + 170.32*umu0[a5] - 75.843 ) + a6 = (umu0>=0.9396) & (umu0<0.9945) + Tddp[a6] = h[a6]*( -12.794*umu0[a6]*umu0[a6] + 22.686*umu0[a6] - 8.9392 ) + a7 = (umu0>=0.9945) & (umu0<0.999) + Tddp[a7] = h[a7]*( 11248.61*umu0[a7]*umu0[a7] - 22441.07*umu0[a7] + 11193.59 ) + a8 = umu0>=0.999 + Tddp[a8] = 0.76*h[a8] + + a = 2.0339*np.power( umu0, -0.927 ) + b = 6.6421*np.power( umu0, 2.0672 ) Tddcld = np.zeros_like(Z) a1 = tau<=0.9*taup @@ -93,6 +108,7 @@ def Pwater(Z, tau, De): a3 = tau>=taup Tddcld[a3] = Tddp[a3]*np.tanh(b[a3]/np.power(tau[a3],2.0)) + return Tddcld @@ -103,124 +119,123 @@ def Pice(Z, tau, De): umu0 = np.cos( Z*np.pi/180.0 ) ### taup taup = np.zeros_like(Z) - a1 = (De>=5.0) & (De<14.0) & (umu0<0.1045) + a1 = (De>=5.0) & (De<14.0) & (umu0<0.1391) taup[a1] = 0.1 - a2 = (De>=5.0) & (De<14.0) & (umu0>=0.1045) & (umu0<0.1736) + a2 = (De>=5.0) & (De<14.0) & (umu0>=0.1391) & (umu0<0.2079) taup[a2] = 0.2 - a3 = (De>=5.0) & (De<14.0) & (umu0>=0.1736) & (umu0<0.2756) + a3 = (De>=5.0) & (De<14.0) & (umu0>=0.2079) & (umu0<0.3090) taup[a3] = 0.3 - a4 = (De>=5.0) & (De<14.0) & (umu0>=0.2756) & (umu0<0.3420) + a4 = (De>=5.0) & (De<14.0) & (umu0>=0.3090) & (umu0<0.3746) taup[a4] = 0.4 - a5 = (De>=5.0) & (De<14.0) & (umu0>=0.3420) & (umu0<0.5877) + a5 = (De>=5.0) & (De<14.0) & (umu0>=0.3746) & (umu0<0.6156) taup[a5] = 0.5 - a6 = (De>=5.0) & (De<14.0) & (umu0>=0.5877) & (umu0<0.9993) + a6 = (De>=5.0) & (De<14.0) & (umu0>=0.6156) & (umu0<0.9994) taup[a6] = 1.0 - a7 = (De>=5.0) & (De<14.0) & (umu0>=0.9993) + a7 = (De>=5.0) & (De<14.0) & (umu0>=0.9994) taup[a7] = 1.5 - a8 = (De>=14.0) & (De<50.0) & (umu0<0.10453) + a8 = (De>=14.0) & (De<50.0) & (umu0<0.139173) taup[a8] = 0.1 - a9 = (De>=14.0) & (De<50.0) & (umu0>=0.10453) & (umu0<-0.0011*De+0.1966) + a9 = (De>=14.0) & (De<50.0) & (umu0>=0.139173) & (umu0<-0.0011*De+0.2307) taup[a9] = 0.2 - a10 = (De>=14.0) & (De<50.0) & (umu0>=-0.0011*De+0.1966) & (umu0<-0.0022*De+0.3009) + a10 = (De>=14.0) & (De<50.0) & (umu0>=-0.0011*De+0.2307) & (umu0<-0.0022*De+0.3340) taup[a10] = 0.3 - a11 = (De>=14.0) & (De<50.0) & (umu0>=-0.0022*De+0.3009) & (umu0<-0.0021*De+0.3774) + a11 = (De>=14.0) & (De<50.0) & (umu0>=-0.0022*De+0.3340) & (umu0<-0.0020*De+0.4096) taup[a11] = 0.4 - a12 = (De>=14.0) & (De<50.0) & (umu0>=-0.0021*De+0.3774) & (umu0<-0.0034*De+0.6188) + a12 = (De>=14.0) & (De<50.0) & (umu0>=-0.0020*De+0.4096) & (umu0<-0.0033*De+0.6461) taup[a12] = 0.5 - a13 = (De>=14.0) & (De<50.0) & (umu0>=-0.0034*De+0.6188) & (umu0<-0.0054*De+1.0743) + a13 = (De>=14.0) & (De<50.0) & (umu0>=-0.0033*De+0.6461) & (umu0<-0.0049*De+1.0713) taup[a13] = 1.0 - a14 = (De>=14.0) & (De<50.0) & (umu0>=-0.0054*De+1.0743) + a14 = (De>=14.0) & (De<50.0) & (umu0>=-0.0049*De+1.0713) taup[a14] = 1.5 - a15 = (De>=50.0) & (umu0<-0.0006*De+0.1766) + a15 = (De>=50.0) & (umu0<-0.0006*De+0.2109) taup[a15] = 0.2 - a16 = (De>=50.0) & (umu0>=-0.0006*De+0.1766) & (umu0<-0.0005*De+0.2242) + a16 = (De>=50.0) & (umu0>=-0.0006*De+0.2109) & (umu0<-0.0005*De+0.2581) taup[a16] = 0.3 - a17 = (De>=50.0) & (umu0>=-0.0005*De+0.2242) & (umu0<-0.0011*De+0.3583) + a17 = (De>=50.0) & (umu0>=-0.0005*De+0.2581) & (umu0<-0.0010*De+0.3907) taup[a17] = 0.4 - a18 = (De>=50.0) & (umu0>=-0.0011*De+0.3583) & (umu0<-0.0008*De+0.4592) + a18 = (De>=50.0) & (umu0>=-0.0010*De+0.3907) & (umu0<-0.0008*De+0.4900) taup[a18] = 0.5 - a19 = (De>=50.0) & (umu0>=-0.0008*De+0.4592) & (umu0<-0.0018*De+0.8521) + a19 = (De>=50.0) & (umu0>=-0.0008*De+0.4900) & (umu0<-0.0017*De+0.8708) taup[a19] = 1.0 - a20 = (De>=50.0) & (umu0>=-0.0018*De+0.8521) & (umu0<-0.0007*De+1.0455) + a20 = (De>=50.0) & (umu0>=-0.0017*De+0.8708) & (umu0<-0.0006*De+1.0367) taup[a20] = 1.5 - a21 = (De>=50.0) & (umu0>=-0.0007*De+1.0455) + a21 = (De>=50.0) & (umu0>=-0.0006*De+1.0367) taup[a21] = 2.0 - +###Tddp Tddp = np.zeros_like(Z) - b1 = (umu0>=0.999) & (De<=10.0) + b1 = (umu0>=0.9994) & (De<=10.0) Tddp[b1] = 0.12269 - b2 = (umu0>=0.999) & (De>10.0) & (De<=16.0) + b2 = (umu0>=0.9994) & (De>10.0) & (De<=16.0) Tddp[b2] = 0.0015*De[b2] + 0.1078 - b3 = (umu0>=0.999) & (De>16.0) + b3 = (umu0>=0.9994) & (De>16.0) Tddp[b3] = 0.1621*np.exp(-0.016*De[b3]) - b4 = (umu0<0.9271) & (De<=10.0) - Tddp[b4] = 0.1499 - b5 = (umu0<0.9902) & (umu0>=0.9271) & (De<=10.0) - Tddp[b5] = -3.1476*np.power(De[b5],2.0) + 5.6543*De[b5] - 2.3682 - b6 = (umu0>=0.9902) & (umu0<0.999) & (De<=10.0) - Tddp[b6] = 226.5*np.power(De[b6],2.0) - 454.41*De[b6] - 228.07 - - - ade = -0.000232338*np.power(De,2.0) + 0.012749*De + 0.046745 - b7 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0<=0.2079) - Tddp[b7] = (-8.3642*np.power(umu0[b7],2.0) + 1.8051*umu0[b7] +0.9168)*ade[b7] - b8 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.2079) & (umu0<=0.3420) - Tddp[b8] = (-13.253*np.power(umu0[b8],2.0) + 6.7924*umu0[b8] +0.1436)*ade[b8] - b9 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.3420) & (umu0<=0.4383) - Tddp[b9] = (18.976*np.power(umu0[b9],2.0) - 14.82*umu0[b9] +3.87)*ade[b9] - b10 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.4383) & (umu0<=0.5591) - Tddp[b10] = (16.078*np.power(umu0[b10],2.0) - 15.767*umu0[b10] +4.8211)*ade[b10] - b11 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.5591) & (umu0<=0.6427) - Tddp[b11] = (-37.48*np.power(umu0[b11],2.0) + 44.388*umu0[b11] -12.141)*ade[b11] - b12 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.6427) & (umu0<=0.7431) - Tddp[b12] = (0.3501*np.power(umu0[b12],2.0) - 0.1634*umu0[b12] +0.9385)*ade[b12] - b13 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.7431) & (umu0<=0.8290) - Tddp[b13] = (-10.237*np.power(umu0[b13],2.0) + 16.165*umu0[b13] -5.3782)*ade[b13] - b14 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8290) & (umu0<=0.8829) - Tddp[b14] = (-145.49*np.power(umu0[b14],2.0) + 247.15*umu0[b14] -104.0)*ade[b14] - b15 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8829) & (umu0<=0.9271) - Tddp[b15] = (-174.18*np.power(umu0[b15],2.0) + 311.61*umu0[b15] -138.42)*ade[b15] - b16 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9271) & (umu0<=0.9612) - Tddp[b16] = (-147.45*np.power(umu0[b16],2.0) + 275.26*umu0[b16] -127.36)*ade[b16] - b17 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9612) & (umu0<=0.9902) - Tddp[b17] = (25.643*np.power(umu0[b17],2.0) - 53.74*umu0[b17] +29.027)*ade[b17] - b18 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9902) - Tddp[b18] = (1294.4*np.power(umu0[b18],2.0) - 2611.5*umu0[b18] +1318.0)*ade[b18] - - bde = 0.0000166*np.power(De,2.0) + 0.00411*De + 0.352 - b19 = (umu0<0.999) & (De>30.0) & (umu0<=0.2079) - Tddp[b19] = (-8.4358*np.power(umu0[b19],2.0) + 0.6676*umu0[b19] +1.0565)*bde[b19] - b20 = (umu0<0.999) & (De>30.0) & (umu0>0.2079) & (umu0<=0.3420) - Tddp[b20] = (-48.564*np.power(umu0[b20],2.0) + 24.929*umu0[b20] -2.1551)*bde[b20] - b21 = (umu0<0.999) & (De>30.0) & (umu0>0.3420) & (umu0<=0.4383) - Tddp[b21] = (56.902*np.power(umu0[b21],2.0) - 44.46*umu0[b21] +9.59)*bde[b21] - b22 = (umu0<0.999) & (De>30.0) & (umu0>0.4383) & (umu0<=0.5591) - Tddp[b22] = (59.618*np.power(umu0[b22],2.0) - 56.882*umu0[b22] +14.45)*bde[b22] - b23 = (umu0<0.999) & (De>30.0) & (umu0>0.5591) & (umu0<=0.6427) - Tddp[b23] = (-225.52*np.power(umu0[b23],2.0) + 265.66*umu0[b23] +77.136)*bde[b23] - b24 = (umu0<0.999) & (De>30.0) & (umu0>0.6427) & (umu0<=0.7431) - Tddp[b24] = (8.6548*np.power(umu0[b24],2.0) + 11.085*umu0[b24] +4.5026)*bde[b24] - b25 = (umu0<0.999) & (De>30.0) & (umu0>0.7431) & (umu0<=0.8290) - Tddp[b25] = (-50.917*np.power(umu0[b25],2.0) + 80.953*umu0[b25] -31.094)*bde[b25] - b26 = (umu0<0.999) & (De>30.0) & (umu0>0.8290) & (umu0<=0.8829) - Tddp[b26] = (-434.92*np.power(umu0[b26],2.0) + 739.75*umu0[b26] -313.63)*bde[b26] - b27 = (umu0<0.999) & (De>30.0) & (umu0>0.8829) & (umu0<=0.9271) - Tddp[b27] = (-392.67*np.power(umu0[b27],2.0) + 702.16*umu0[b27] -312.95)*bde[b27] - b28 = (umu0<0.999) & (De>30.0) & (umu0>0.9271) & (umu0<=0.9612) - Tddp[b28] = (-281.4*np.power(umu0[b28],2.0) + 528.53*umu0[b28] -247.08)*bde[b28] - b29 = (umu0<0.999) & (De>30.0) & (umu0>0.9612) & (umu0<=0.9902) - Tddp[b29] = (467.5*np.power(umu0[b29],2.0) - 915.28*umu0[b29] +449.03)*bde[b29] - b30 = (umu0<0.999) & (De>30.0) & (umu0>0.9902) - Tddp[b30] = (3872.1*np.power(umu0[b30],2.0) - 7746.4*umu0[b30] +3875.3)*bde[b30] - + b4 = (umu0<0.9396) & (De<=10.0) + Tddp[b4] = 0.14991 + b5 = (umu0<0.9945) & (umu0>=0.9396) & (De<=10.0) + Tddp[b5] = -4.5171*np.power(umu0[b5],2.0) + 8.3056*umu0[b5] - 3.6476 + b6 = (umu0>=0.9945) & (umu0<0.9994) & (De<=10.0) + Tddp[b6] = 298.45*np.power(umu0[b6],2.0) - 601.33*umu0[b6] + 303.04 + + + ade = -0.000232338*np.power(De,2.0) + 0.012748726*De + 0.046745083 + b7 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0<=0.2419) + Tddp[b7] = (-8.454*np.power(umu0[b7],2.0) + 2.4095*umu0[b7] +0.8425)*ade[b7] + b8 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.2419) & (umu0<=0.3746) + Tddp[b8] = (-13.528*np.power(umu0[b8],2.0) + 7.8403*umu0[b8] -0.1221)*ade[b8] + b9 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.3746) & (umu0<=0.4694) + Tddp[b9] = (19.524*np.power(umu0[b9],2.0) - 16.5*umu0[b9] +4.4612)*ade[b9] + b10 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.4694) & (umu0<=0.5877) + Tddp[b10] = (16.737*np.power(umu0[b10],2.0) - 17.419*umu0[b10] +5.4881)*ade[b10] + b11 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.5877) & (umu0<=0.6691) + Tddp[b11] = (-39.493*np.power(umu0[b11],2.0) + 48.963*umu0[b11] -14.175)*ade[b11] + b12 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.6691) & (umu0<=0.7660) + Tddp[b12] = (0.4017*np.power(umu0[b12],2.0) - 0.243*umu0[b12] +0.9609)*ade[b12] + b13 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.7660) & (umu0<=0.8480) + Tddp[b13] = (-11.183*np.power(umu0[b13],2.0) + 18.126*umu0[b13] -6.3417)*ade[b13] + b14 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8480) & (umu0<=0.8987) + Tddp[b14] = (-163.36*np.power(umu0[b14],2.0) + 283.35*umu0[b14] -121.91)*ade[b14] + b15 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8987) & (umu0<=0.9396) + Tddp[b15] = (-202.72*np.power(umu0[b15],2.0) + 368.75*umu0[b15] -166.75)*ade[b15] + b16 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9396) & (umu0<=0.9702) + Tddp[b16] = (-181.72*np.power(umu0[b16],2.0) + 343.59*umu0[b16] -161.3)*ade[b16] + b17 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9702) & (umu0<=0.9945) + Tddp[b17] = (127.66*np.power(umu0[b17],2.0) - 255.73*umu0[b17] +129.03)*ade[b17] + b18 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9945) + Tddp[b18] = (908.66*np.power(umu0[b18],2.0) - 1869.3*umu0[b18] +961.63)*ade[b18] + + bde = 0.0000166112*np.power(De,2.0) - 0.00410998*De + 0.352026619 + b19 = (umu0<0.999) & (De>30.0) & (umu0<=0.2419) + Tddp[b19] = (-4.362*np.power(umu0[b19],2.0) - 0.0878*umu0[b19] +1.1218)*bde[b19] + b20 = (umu0<0.999) & (De>30.0) & (umu0>0.2419) & (umu0<=0.3746) + Tddp[b20] = (-49.566*np.power(umu0[b20],2.0) + 28.767*umu0[b20] -3.1299)*bde[b20] + b21 = (umu0<0.999) & (De>30.0) & (umu0>0.3746) & (umu0<=0.4694) + Tddp[b21] = (58.572*np.power(umu0[b21],2.0) - 49.5*umu0[b21] +11.363)*bde[b21] + b22 = (umu0<0.999) & (De>30.0) & (umu0>0.4694) & (umu0<=0.5877) + Tddp[b22] = (62.118*np.power(umu0[b22],2.0) - 63.037*umu0[b22] +16.875)*bde[b22] + b23 = (umu0<0.999) & (De>30.0) & (umu0>0.5877) & (umu0<=0.6691) + Tddp[b23] = (-237.68*np.power(umu0[b23],2.0) + 293.21*umu0[b23] -89.328)*bde[b23] + b24 = (umu0<0.999) & (De>30.0) & (umu0>0.6691) & (umu0<=0.7660) + Tddp[b24] = (1.2051*np.power(umu0[b24],2.0) - 0.7291*umu0[b24] +0.8826)*bde[b24] + b25 = (umu0<0.999) & (De>30.0) & (umu0>0.7660) & (umu0<=0.8480) + Tddp[b25] = (-55.6*np.power(umu0[b25],2.0) + 90.698*umu0[b25] -35.905)*bde[b25] + b26 = (umu0<0.999) & (De>30.0) & (umu0>0.8480) & (umu0<=0.8987) + Tddp[b26] = (-422.36*np.power(umu0[b26],2.0) + 733.97*umu0[b26] -317.89)*bde[b26] + b27 = (umu0<0.999) & (De>30.0) & (umu0>0.8987) & (umu0<=0.9396) + Tddp[b27] = (-457.09*np.power(umu0[b27],2.0) + 831.11*umu0[b27] -376.85)*bde[b27] + b28 = (umu0<0.999) & (De>30.0) & (umu0>0.9396) & (umu0<=0.9702) + Tddp[b28] = (-344.91*np.power(umu0[b28],2.0) + 655.67*umu0[b28] -310.5)*bde[b28] + b29 = (umu0<0.999) & (De>30.0) & (umu0>0.9702) & (umu0<=0.9945) + Tddp[b29] = (622.85*np.power(umu0[b29],2.0) - 1227.6*umu0[b29] +605.97)*bde[b29] + b30 = (umu0<0.999) & (De>30.0) & (umu0>0.9945) + Tddp[b30] = (6309.63*np.power(umu0[b30],2.0) - 12654.78*umu0[b30] +6346.15)*bde[b30] ###Tddcld - a = 1.8099*np.power(umu0,-0.824) - b = 7.1094*np.power(umu0,1.7436) + a = 1.7686*np.power(umu0,-0.95) + b = 7.117*np.power(umu0,1.9658) Tddcld = np.zeros_like(Z) a1 = tau<=0.9*taup @@ -234,19 +249,41 @@ def Pice(Z, tau, De): return Tddcld -#aa = Pwater(np.array([30.0]), np.array([5.0]), np.array([10.0]) ) -#aa = Pwater(np.arange(10)*8.0, np.arange(10), (np.arange(10)+1)*10 ) -aa = Pice(np.arange(10)*8.0, np.arange(10), (np.arange(10)+1)*10 ) -print(aa) -def farms_dni(F0, tau, solar_zenith_angle, De, phase1, phase2, Tddclr, Ftotal, Tddcld0, Tddcld1, Fd2 ): - - Fd0 = solar_zenith_angle*F0*Tddcld*Tddclr +def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1): + + ############### scale tau + taudni = np.zeros_like(tau) + + a1 = np.where( (phase == 1) & (tau<8.0) ) + a2 = np.where( (phase == 1) & (tau>=8.0) ) + taudni[a1] = ( 0.254825*tau[a1] - 0.00232717*np.power(tau[a1], 2.0) \ + + (5.19320e-06)*np.power(tau[a1], 3.0) )*(1.0+(8.0-tau[a1])*0.07) + taudni[a2] = 0.2*np.power(tau[a2]-8.0, 1.5) + 2.10871 + + b1 = np.where( (phase == 2) & (tau<8.0) ) + b2 = np.where( (phase == 2) & (tau>=8.0) ) + taudni[b1] = 0.345353*tau[b1] - 0.00244671*np.power(tau[b1], 2.0) \ + + (4.74263E-06)*np.power(tau[b1], 3.0) + taudni[b2] = 0.2*np.power(tau[b2]-8.0, 1.5) + 2.91345 + ############### + + Z = np.arccos(solar_zenith_angle)*180.0/np.pi + dni0 = F0*Tddclr*np.exp(-tau/solar_zenith_angle) + + Tddcld0 = np.exp(-taudni/solar_zenith_angle) + Fd0 = solar_zenith_angle*F0*Tddcld0*Tddclr + + Tddcld1 = TDDP(Z, taudni, De, phase1, phase2) + Fd1 = solar_zenith_angle*F0*Tddclr*Tddcld1 + Fd2 = TDD2(Z, Ftotal, F1 ) + Fd = Fd0 + Fd1 + Fd2 + dni_farmsdni = Fd/solar_zenith_angle - return Fd, dni + return Fd, dni_farmsdni, dni0 From 528bf0e2c96d0b32830ee1bfdddb8dd1d0ca3044 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 21 Mar 2023 16:55:43 -0600 Subject: [PATCH 05/55] Test FARMS-DNI --- farms/Interomega.dat | 841 ------------------------------------------- farms/farms_dni.py | 28 ++ tests/testfarms.py | 33 ++ 3 files changed, 61 insertions(+), 841 deletions(-) delete mode 100644 farms/Interomega.dat create mode 100644 tests/testfarms.py diff --git a/farms/Interomega.dat b/farms/Interomega.dat deleted file mode 100644 index 7e6b3c5..0000000 --- a/farms/Interomega.dat +++ /dev/null @@ -1,841 +0,0 @@ - 0.00000 0.00590483 - 0.100000 0.00590620 - 0.200000 0.00590758 - 0.300000 0.00590895 - 0.400000 0.00591032 - 0.500000 0.00591169 - 0.600000 0.00591306 - 0.700000 0.00591444 - 0.800000 0.00591581 - 0.900000 0.00591718 - 1.00000 0.00591855 - 1.10000 0.00591993 - 1.20000 0.00592130 - 1.30000 0.00592267 - 1.40000 0.00592405 - 1.50000 0.00592542 - 1.60000 0.00592679 - 1.70000 0.00592816 - 1.80000 0.00592953 - 1.90000 0.00593091 - 2.00000 0.00593228 - 2.10000 0.00593590 - 2.20000 0.00593952 - 2.30000 0.00594314 - 2.40000 0.00594675 - 2.50000 0.00595037 - 2.60000 0.00595399 - 2.70000 0.00595761 - 2.80000 0.00596123 - 2.90000 0.00596485 - 3.00000 0.00596847 - 3.10000 0.00597208 - 3.20000 0.00597570 - 3.30000 0.00597932 - 3.40000 0.00598294 - 3.50000 0.00598656 - 3.60000 0.00599018 - 3.70000 0.00599379 - 3.80000 0.00599741 - 3.90000 0.00600103 - 4.00000 0.00600465 - 4.10000 0.00600483 - 4.20000 0.00600501 - 4.30000 0.00600519 - 4.40000 0.00600537 - 4.50000 0.00600555 - 4.60000 0.00600573 - 4.70000 0.00600591 - 4.80000 0.00600609 - 4.90000 0.00600627 - 5.00000 0.00600644 - 5.10000 0.00600662 - 5.20000 0.00600680 - 5.30000 0.00600698 - 5.40000 0.00600716 - 5.50000 0.00600734 - 5.60000 0.00600752 - 5.70000 0.00600770 - 5.80000 0.00600788 - 5.90000 0.00600806 - 6.00000 0.00600824 - 6.10000 0.00600801 - 6.20000 0.00600777 - 6.30000 0.00600754 - 6.40000 0.00600731 - 6.50000 0.00600708 - 6.60000 0.00600684 - 6.70000 0.00600661 - 6.80000 0.00600638 - 6.90000 0.00600615 - 7.00000 0.00600591 - 7.10000 0.00600568 - 7.20000 0.00600545 - 7.30000 0.00600522 - 7.40000 0.00600498 - 7.50000 0.00600475 - 7.60000 0.00600452 - 7.70000 0.00600429 - 7.80000 0.00600406 - 7.90000 0.00600382 - 8.00000 0.00600359 - 8.10000 0.00600320 - 8.20000 0.00600280 - 8.30000 0.00600241 - 8.40000 0.00600201 - 8.50000 0.00600162 - 8.60000 0.00600122 - 8.70000 0.00600083 - 8.80000 0.00600043 - 8.90000 0.00600004 - 9.00000 0.00599965 - 9.10000 0.00599925 - 9.20000 0.00599886 - 9.30000 0.00599846 - 9.40000 0.00599807 - 9.50000 0.00599767 - 9.60000 0.00599728 - 9.70000 0.00599688 - 9.80000 0.00599649 - 9.90000 0.00599609 - 10.0000 0.00599570 - 10.1000 0.00599476 - 10.2000 0.00599382 - 10.3000 0.00599288 - 10.4000 0.00599194 - 10.5000 0.00599100 - 10.6000 0.00599005 - 10.7000 0.00598911 - 10.8000 0.00598817 - 10.9000 0.00598723 - 11.0000 0.00598629 - 11.1000 0.00598535 - 11.2000 0.00598441 - 11.3000 0.00598347 - 11.4000 0.00598253 - 11.5000 0.00598159 - 11.6000 0.00598064 - 11.7000 0.00597970 - 11.8000 0.00597876 - 11.9000 0.00597782 - 12.0000 0.00597688 - 12.1000 0.00597445 - 12.2000 0.00597202 - 12.3000 0.00596960 - 12.4000 0.00596717 - 12.5000 0.00596474 - 12.6000 0.00596231 - 12.7000 0.00595988 - 12.8000 0.00595746 - 12.9000 0.00595503 - 13.0000 0.00595260 - 13.1000 0.00595017 - 13.2000 0.00594774 - 13.3000 0.00594532 - 13.4000 0.00594289 - 13.5000 0.00594046 - 13.6000 0.00593803 - 13.7000 0.00593560 - 13.8000 0.00593318 - 13.9000 0.00593075 - 14.0000 0.00592832 - 14.1000 0.00592701 - 14.2000 0.00592570 - 14.3000 0.00592439 - 14.4000 0.00592308 - 14.5000 0.00592177 - 14.6000 0.00592046 - 14.7000 0.00591915 - 14.8000 0.00591784 - 14.9000 0.00591653 - 15.0000 0.00591523 - 15.1000 0.00591392 - 15.2000 0.00591261 - 15.3000 0.00591130 - 15.4000 0.00590999 - 15.5000 0.00590868 - 15.6000 0.00590737 - 15.7000 0.00590606 - 15.8000 0.00590475 - 15.9000 0.00590344 - 16.0000 0.00590213 - 16.1000 0.00590074 - 16.2000 0.00589934 - 16.3000 0.00589795 - 16.4000 0.00589655 - 16.5000 0.00589516 - 16.6000 0.00589376 - 16.7000 0.00589237 - 16.8000 0.00589097 - 16.9000 0.00588958 - 17.0000 0.00588818 - 17.1000 0.00588679 - 17.2000 0.00588540 - 17.3000 0.00588400 - 17.4000 0.00588261 - 17.5000 0.00588121 - 17.6000 0.00587982 - 17.7000 0.00587842 - 17.8000 0.00587703 - 17.9000 0.00587563 - 18.0000 0.00587424 - 18.1000 0.00587173 - 18.2000 0.00586921 - 18.3000 0.00586670 - 18.4000 0.00586419 - 18.5000 0.00586167 - 18.6000 0.00585916 - 18.7000 0.00585665 - 18.8000 0.00585413 - 18.9000 0.00585162 - 19.0000 0.00584910 - 19.1000 0.00584659 - 19.2000 0.00584408 - 19.3000 0.00584156 - 19.4000 0.00583905 - 19.5000 0.00583654 - 19.6000 0.00583402 - 19.7000 0.00583151 - 19.8000 0.00582900 - 19.9000 0.00582648 - 20.0000 0.00582397 - 20.1000 0.00582024 - 20.2000 0.00581650 - 20.3000 0.00581277 - 20.4000 0.00580903 - 20.5000 0.00580530 - 20.6000 0.00580157 - 20.7000 0.00579783 - 20.8000 0.00579410 - 20.9000 0.00579036 - 21.0000 0.00578663 - 21.1000 0.00578290 - 21.2000 0.00577916 - 21.3000 0.00577543 - 21.4000 0.00577169 - 21.5000 0.00576796 - 21.6000 0.00576423 - 21.7000 0.00576049 - 21.8000 0.00575676 - 21.9000 0.00575302 - 22.0000 0.00574929 - 22.1000 0.00574687 - 22.2000 0.00574445 - 22.3000 0.00574203 - 22.4000 0.00573961 - 22.5000 0.00573719 - 22.6000 0.00573477 - 22.7000 0.00573235 - 22.8000 0.00572993 - 22.9000 0.00572751 - 23.0000 0.00572510 - 23.1000 0.00572268 - 23.2000 0.00572026 - 23.3000 0.00571784 - 23.4000 0.00571542 - 23.5000 0.00571300 - 23.6000 0.00571058 - 23.7000 0.00570816 - 23.8000 0.00570574 - 23.9000 0.00570332 - 24.0000 0.00570090 - 24.1000 0.00569727 - 24.2000 0.00569363 - 24.3000 0.00569000 - 24.4000 0.00568637 - 24.5000 0.00568274 - 24.6000 0.00567910 - 24.7000 0.00567547 - 24.8000 0.00567184 - 24.9000 0.00566821 - 25.0000 0.00566457 - 25.1000 0.00566094 - 25.2000 0.00565731 - 25.3000 0.00565368 - 25.4000 0.00565005 - 25.5000 0.00564641 - 25.6000 0.00564278 - 25.7000 0.00563915 - 25.8000 0.00563551 - 25.9000 0.00563188 - 26.0000 0.00562825 - 26.1000 0.00562424 - 26.2000 0.00562022 - 26.3000 0.00561621 - 26.4000 0.00561219 - 26.5000 0.00560818 - 26.6000 0.00560416 - 26.7000 0.00560015 - 26.8000 0.00559613 - 26.9000 0.00559212 - 27.0000 0.00558810 - 27.1000 0.00558409 - 27.2000 0.00558008 - 27.3000 0.00557606 - 27.4000 0.00557205 - 27.5000 0.00556803 - 27.6000 0.00556402 - 27.7000 0.00556000 - 27.8000 0.00555599 - 27.9000 0.00555197 - 28.0000 0.00554796 - 28.1000 0.00554317 - 28.2000 0.00553839 - 28.3000 0.00553360 - 28.4000 0.00552881 - 28.5000 0.00552403 - 28.6000 0.00551924 - 28.7000 0.00551445 - 28.8000 0.00550967 - 28.9000 0.00550488 - 29.0000 0.00550009 - 29.1000 0.00549531 - 29.2000 0.00549052 - 29.3000 0.00548574 - 29.4000 0.00548095 - 29.5000 0.00547616 - 29.6000 0.00547138 - 29.7000 0.00546659 - 29.8000 0.00546180 - 29.9000 0.00545702 - 30.0000 0.00545223 - 30.1000 0.00544585 - 30.2000 0.00543946 - 30.3000 0.00543308 - 30.4000 0.00542670 - 30.5000 0.00542031 - 30.6000 0.00541393 - 30.7000 0.00540755 - 30.8000 0.00540116 - 30.9000 0.00539478 - 31.0000 0.00538839 - 31.1000 0.00538201 - 31.2000 0.00537563 - 31.3000 0.00536924 - 31.4000 0.00536286 - 31.5000 0.00535648 - 31.6000 0.00535009 - 31.7000 0.00534371 - 31.8000 0.00533733 - 31.9000 0.00533094 - 32.0000 0.00532456 - 32.1000 0.00532113 - 32.2000 0.00531770 - 32.3000 0.00531426 - 32.4000 0.00531083 - 32.5000 0.00530740 - 32.6000 0.00530397 - 32.7000 0.00530054 - 32.8000 0.00529710 - 32.9000 0.00529367 - 33.0000 0.00529024 - 33.1000 0.00528681 - 33.2000 0.00528338 - 33.3000 0.00527994 - 33.4000 0.00527651 - 33.5000 0.00527308 - 33.6000 0.00526965 - 33.7000 0.00526622 - 33.8000 0.00526278 - 33.9000 0.00525935 - 34.0000 0.00525592 - 34.1000 0.00524949 - 34.2000 0.00524307 - 34.3000 0.00523664 - 34.4000 0.00523022 - 34.5000 0.00522379 - 34.6000 0.00521736 - 34.7000 0.00521094 - 34.8000 0.00520451 - 34.9000 0.00519809 - 35.0000 0.00519166 - 35.1000 0.00518523 - 35.2000 0.00517881 - 35.3000 0.00517238 - 35.4000 0.00516596 - 35.5000 0.00515953 - 35.6000 0.00515310 - 35.7000 0.00514668 - 35.8000 0.00514025 - 35.9000 0.00513383 - 36.0000 0.00512740 - 36.1000 0.00512218 - 36.2000 0.00511697 - 36.3000 0.00511175 - 36.4000 0.00510653 - 36.5000 0.00510132 - 36.6000 0.00509610 - 36.7000 0.00509088 - 36.8000 0.00508567 - 36.9000 0.00508045 - 37.0000 0.00507523 - 37.1000 0.00507002 - 37.2000 0.00506480 - 37.3000 0.00505959 - 37.4000 0.00505437 - 37.5000 0.00504915 - 37.6000 0.00504394 - 37.7000 0.00503872 - 37.8000 0.00503350 - 37.9000 0.00502829 - 38.0000 0.00502307 - 38.1000 0.00501537 - 38.2000 0.00500767 - 38.3000 0.00499998 - 38.4000 0.00499228 - 38.5000 0.00498458 - 38.6000 0.00497688 - 38.7000 0.00496919 - 38.8000 0.00496149 - 38.9000 0.00495379 - 39.0000 0.00494609 - 39.1000 0.00493840 - 39.2000 0.00493070 - 39.3000 0.00492300 - 39.4000 0.00491530 - 39.5000 0.00490761 - 39.6000 0.00489991 - 39.7000 0.00489221 - 39.8000 0.00488452 - 39.9000 0.00487682 - 40.0000 0.00486912 - 40.1000 0.00486418 - 40.2000 0.00485924 - 40.3000 0.00485430 - 40.4000 0.00484935 - 40.5000 0.00484441 - 40.6000 0.00483947 - 40.7000 0.00483453 - 40.8000 0.00482959 - 40.9000 0.00482465 - 41.0000 0.00481971 - 41.1000 0.00481476 - 41.2000 0.00480982 - 41.3000 0.00480488 - 41.4000 0.00479994 - 41.5000 0.00479500 - 41.6000 0.00479006 - 41.7000 0.00478511 - 41.8000 0.00478017 - 41.9000 0.00477523 - 42.0000 0.00477029 - 42.1000 0.00475930 - 42.2000 0.00474832 - 42.3000 0.00473733 - 42.4000 0.00472634 - 42.5000 0.00471535 - 42.6000 0.00470436 - 42.7000 0.00469338 - 42.8000 0.00468239 - 42.9000 0.00467140 - 43.0000 0.00466041 - 43.1000 0.00464943 - 43.2000 0.00463844 - 43.3000 0.00462745 - 43.4000 0.00461646 - 43.5000 0.00460548 - 43.6000 0.00459449 - 43.7000 0.00458350 - 43.8000 0.00457251 - 43.9000 0.00456153 - 44.0000 0.00455054 - 44.1000 0.00454559 - 44.2000 0.00454063 - 44.3000 0.00453568 - 44.4000 0.00453072 - 44.5000 0.00452577 - 44.6000 0.00452081 - 44.7000 0.00451586 - 44.8000 0.00451090 - 44.9000 0.00450595 - 45.0000 0.00450099 - 45.1000 0.00449604 - 45.2000 0.00449109 - 45.3000 0.00448613 - 45.4000 0.00448118 - 45.5000 0.00447622 - 45.6000 0.00447127 - 45.7000 0.00446631 - 45.8000 0.00446136 - 45.9000 0.00445640 - 46.0000 0.00445145 - 46.1000 0.00444520 - 46.2000 0.00443896 - 46.3000 0.00443271 - 46.4000 0.00442647 - 46.5000 0.00442022 - 46.6000 0.00441397 - 46.7000 0.00440773 - 46.8000 0.00440148 - 46.9000 0.00439524 - 47.0000 0.00438899 - 47.1000 0.00438274 - 47.2000 0.00437650 - 47.3000 0.00437025 - 47.4000 0.00436401 - 47.5000 0.00435776 - 47.6000 0.00435151 - 47.7000 0.00434527 - 47.8000 0.00433902 - 47.9000 0.00433278 - 48.0000 0.00432653 - 48.1000 0.00431831 - 48.2000 0.00431009 - 48.3000 0.00430187 - 48.4000 0.00429365 - 48.5000 0.00428543 - 48.6000 0.00427721 - 48.7000 0.00426899 - 48.8000 0.00426077 - 48.9000 0.00425255 - 49.0000 0.00424433 - 49.1000 0.00423612 - 49.2000 0.00422790 - 49.3000 0.00421968 - 49.4000 0.00421146 - 49.5000 0.00420324 - 49.6000 0.00419502 - 49.7000 0.00418680 - 49.8000 0.00417858 - 49.9000 0.00417036 - 50.0000 0.00416214 - 50.1000 0.00415042 - 50.2000 0.00413870 - 50.3000 0.00412699 - 50.4000 0.00411527 - 50.5000 0.00410355 - 50.6000 0.00409183 - 50.7000 0.00408011 - 50.8000 0.00406840 - 50.9000 0.00405668 - 51.0000 0.00404496 - 51.1000 0.00403324 - 51.2000 0.00402152 - 51.3000 0.00400981 - 51.4000 0.00399809 - 51.5000 0.00398637 - 51.6000 0.00397465 - 51.7000 0.00396293 - 51.8000 0.00395122 - 51.9000 0.00393950 - 52.0000 0.00392778 - 52.1000 0.00392101 - 52.2000 0.00391423 - 52.3000 0.00390746 - 52.4000 0.00390068 - 52.5000 0.00389391 - 52.6000 0.00388714 - 52.7000 0.00388036 - 52.8000 0.00387359 - 52.9000 0.00386681 - 53.0000 0.00386004 - 53.1000 0.00385327 - 53.2000 0.00384649 - 53.3000 0.00383972 - 53.4000 0.00383294 - 53.5000 0.00382617 - 53.6000 0.00381940 - 53.7000 0.00381262 - 53.8000 0.00380585 - 53.9000 0.00379907 - 54.0000 0.00379230 - 54.1000 0.00378461 - 54.2000 0.00377692 - 54.3000 0.00376922 - 54.4000 0.00376153 - 54.5000 0.00375384 - 54.6000 0.00374615 - 54.7000 0.00373846 - 54.8000 0.00373076 - 54.9000 0.00372307 - 55.0000 0.00371538 - 55.1000 0.00370769 - 55.2000 0.00370000 - 55.3000 0.00369230 - 55.4000 0.00368461 - 55.5000 0.00367692 - 55.6000 0.00366923 - 55.7000 0.00366154 - 55.8000 0.00365384 - 55.9000 0.00364615 - 56.0000 0.00363846 - 56.1000 0.00362986 - 56.2000 0.00362126 - 56.3000 0.00361266 - 56.4000 0.00360407 - 56.5000 0.00359547 - 56.6000 0.00358687 - 56.7000 0.00357827 - 56.8000 0.00356967 - 56.9000 0.00356107 - 57.0000 0.00355248 - 57.1000 0.00354388 - 57.2000 0.00353528 - 57.3000 0.00352668 - 57.4000 0.00351808 - 57.5000 0.00350948 - 57.6000 0.00350088 - 57.7000 0.00349229 - 57.8000 0.00348369 - 57.9000 0.00347509 - 58.0000 0.00346649 - 58.1000 0.00345696 - 58.2000 0.00344743 - 58.3000 0.00343791 - 58.4000 0.00342838 - 58.5000 0.00341885 - 58.6000 0.00340932 - 58.7000 0.00339980 - 58.8000 0.00339027 - 58.9000 0.00338074 - 59.0000 0.00337121 - 59.1000 0.00336169 - 59.2000 0.00335216 - 59.3000 0.00334263 - 59.4000 0.00333310 - 59.5000 0.00332358 - 59.6000 0.00331405 - 59.7000 0.00330452 - 59.8000 0.00329500 - 59.9000 0.00328547 - 60.0000 0.00327594 - 60.1000 0.00326526 - 60.2000 0.00325458 - 60.3000 0.00324391 - 60.4000 0.00323323 - 60.5000 0.00322255 - 60.6000 0.00321187 - 60.7000 0.00320120 - 60.8000 0.00319052 - 60.9000 0.00317984 - 61.0000 0.00316916 - 61.1000 0.00315849 - 61.2000 0.00314781 - 61.3000 0.00313713 - 61.4000 0.00312645 - 61.5000 0.00311578 - 61.6000 0.00310510 - 61.7000 0.00309442 - 61.8000 0.00308375 - 61.9000 0.00307307 - 62.0000 0.00306239 - 62.1000 0.00305003 - 62.2000 0.00303768 - 62.3000 0.00302532 - 62.4000 0.00301297 - 62.5000 0.00300061 - 62.6000 0.00298826 - 62.7000 0.00297590 - 62.8000 0.00296355 - 62.9000 0.00295119 - 63.0000 0.00293883 - 63.1000 0.00292648 - 63.2000 0.00291412 - 63.3000 0.00290177 - 63.4000 0.00288941 - 63.5000 0.00287706 - 63.6000 0.00286470 - 63.7000 0.00285235 - 63.8000 0.00283999 - 63.9000 0.00282764 - 64.0000 0.00281528 - 64.1000 0.00280613 - 64.2000 0.00279699 - 64.3000 0.00278784 - 64.4000 0.00277870 - 64.5000 0.00276955 - 64.6000 0.00276040 - 64.7000 0.00275126 - 64.8000 0.00274211 - 64.9000 0.00273297 - 65.0000 0.00272382 - 65.1000 0.00271467 - 65.2000 0.00270553 - 65.3000 0.00269638 - 65.4000 0.00268724 - 65.5000 0.00267809 - 65.6000 0.00266894 - 65.7000 0.00265980 - 65.8000 0.00265065 - 65.9000 0.00264151 - 66.0000 0.00263236 - 66.1000 0.00262276 - 66.2000 0.00261315 - 66.3000 0.00260355 - 66.4000 0.00259395 - 66.5000 0.00258435 - 66.6000 0.00257475 - 66.7000 0.00256514 - 66.8000 0.00255554 - 66.9000 0.00254594 - 67.0000 0.00253634 - 67.1000 0.00252673 - 67.2000 0.00251713 - 67.3000 0.00250753 - 67.4000 0.00249792 - 67.5000 0.00248832 - 67.6000 0.00247872 - 67.7000 0.00246912 - 67.8000 0.00245951 - 67.9000 0.00244991 - 68.0000 0.00244031 - 68.1000 0.00243031 - 68.2000 0.00242031 - 68.3000 0.00241031 - 68.4000 0.00240030 - 68.5000 0.00239030 - 68.6000 0.00238030 - 68.7000 0.00237030 - 68.8000 0.00236030 - 68.9000 0.00235030 - 69.0000 0.00234029 - 69.1000 0.00233029 - 69.2000 0.00232029 - 69.3000 0.00231029 - 69.4000 0.00230029 - 69.5000 0.00229029 - 69.6000 0.00228029 - 69.7000 0.00227028 - 69.8000 0.00226028 - 69.9000 0.00225028 - 70.0000 0.00224028 - 70.1000 0.00222992 - 70.2000 0.00221956 - 70.3000 0.00220919 - 70.4000 0.00219883 - 70.5000 0.00218847 - 70.6000 0.00217811 - 70.7000 0.00216775 - 70.8000 0.00215738 - 70.9000 0.00214702 - 71.0000 0.00213666 - 71.1000 0.00212630 - 71.2000 0.00211594 - 71.3000 0.00210557 - 71.4000 0.00209521 - 71.5000 0.00208485 - 71.6000 0.00207449 - 71.7000 0.00206413 - 71.8000 0.00205376 - 71.9000 0.00204340 - 72.0000 0.00203304 - 72.1000 0.00202236 - 72.2000 0.00201167 - 72.3000 0.00200099 - 72.4000 0.00199031 - 72.5000 0.00197963 - 72.6000 0.00196895 - 72.7000 0.00195826 - 72.8000 0.00194758 - 72.9000 0.00193690 - 73.0000 0.00192621 - 73.1000 0.00191553 - 73.2000 0.00190485 - 73.3000 0.00189417 - 73.4000 0.00188348 - 73.5000 0.00187280 - 73.6000 0.00186212 - 73.7000 0.00185144 - 73.8000 0.00184075 - 73.9000 0.00183007 - 74.0000 0.00181939 - 74.1000 0.00180847 - 74.2000 0.00179755 - 74.3000 0.00178664 - 74.4000 0.00177572 - 74.5000 0.00176480 - 74.6000 0.00175389 - 74.7000 0.00174297 - 74.8000 0.00173205 - 74.9000 0.00172113 - 75.0000 0.00171022 - 75.1000 0.00169930 - 75.2000 0.00168838 - 75.3000 0.00167746 - 75.4000 0.00166654 - 75.5000 0.00165563 - 75.6000 0.00164471 - 75.7000 0.00163379 - 75.8000 0.00162287 - 75.9000 0.00161196 - 76.0000 0.00160104 - 76.1000 0.00158991 - 76.2000 0.00157878 - 76.3000 0.00156765 - 76.4000 0.00155653 - 76.5000 0.00154540 - 76.6000 0.00153427 - 76.7000 0.00152314 - 76.8000 0.00151201 - 76.9000 0.00150088 - 77.0000 0.00148975 - 77.1000 0.00147863 - 77.2000 0.00146750 - 77.3000 0.00145637 - 77.4000 0.00144524 - 77.5000 0.00143411 - 77.6000 0.00142298 - 77.7000 0.00141185 - 77.8000 0.00140073 - 77.9000 0.00138960 - 78.0000 0.00137847 - 78.1000 0.00136718 - 78.2000 0.00135590 - 78.3000 0.00134461 - 78.4000 0.00133333 - 78.5000 0.00132204 - 78.6000 0.00131075 - 78.7000 0.00129947 - 78.8000 0.00128818 - 78.9000 0.00127690 - 79.0000 0.00126561 - 79.1000 0.00125432 - 79.2000 0.00124304 - 79.3000 0.00123175 - 79.4000 0.00122047 - 79.5000 0.00120918 - 79.6000 0.00119789 - 79.7000 0.00118661 - 79.8000 0.00117532 - 79.9000 0.00116404 - 80.0000 0.00115275 - 80.1000 0.00114134 - 80.2000 0.00112992 - 80.3000 0.00111851 - 80.4000 0.00110709 - 80.5000 0.00109568 - 80.6000 0.00108426 - 80.7000 0.00107285 - 80.8000 0.00106144 - 80.9000 0.00105002 - 81.0000 0.00103861 - 81.1000 0.00102719 - 81.2000 0.00101578 - 81.3000 0.00100437 - 81.4000 0.000992951 - 81.5000 0.000981537 - 81.6000 0.000970123 - 81.7000 0.000958708 - 81.8000 0.000947294 - 81.9000 0.000935880 - 82.0000 0.000924466 - 82.1000 0.000912979 - 82.2000 0.000901491 - 82.3000 0.000890005 - 82.4000 0.000878518 - 82.5000 0.000867031 - 82.6000 0.000855544 - 82.7000 0.000844056 - 82.8000 0.000832570 - 82.9000 0.000821083 - 83.0000 0.000809596 - 83.1000 0.000798109 - 83.2000 0.000786621 - 83.3000 0.000775135 - 83.4000 0.000763648 - 83.5000 0.000752161 - 83.6000 0.000740674 - 83.7000 0.000729186 - 83.8000 0.000717700 - 83.9000 0.000706213 - 84.0000 0.000694726 diff --git a/farms/farms_dni.py b/farms/farms_dni.py index a07de3c..de8b1b3 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -15,6 +15,34 @@ import sys import pandas as pd +''' +Fast All-sky Radiation Model for solar applications with direct normal irradiance (FARMS-DNI) + +References +----------- +Xie, Y., Sengupta, M., Dudhia, J., 2016. A Fast All-sky Radiation Model for Solar applications (FARMS): Algorithm and performance evaluation. Sol. Energy 135, 435-445. +Xie, Y., Sengupta, M., Liu, Y., Long, H., Min, Q., Liu, W., Habte, A., 2020. A physics-based DNI model assessing all-sky circumsolar radiation. iScience 22, doi.org/10.1016/j.isci.2020.100893. +Yang, J., Xie, Y., Sengupta, M., Liu, Y., Long, H., 2022. Parameterization of cloud transmittance for expeditious assessment and forecasting of all-sky DNI. J. Renewable Sustainable Energy 14, 063703. + +Input data +----------- +F0: np.ndarray +extraterrestrial solar radiation (Wm-2). +F1: np.ndarray + First order solar radiation given in FARMS (Wm-2). See Xie et al. (2016) for more details. + +Output data +----------- +Fd: np.ndarray + Direct radiation in the downwelling direction (Wm-2). It includes the narrow beam and the scattered radiation in the circumsolar region. + +dni_farmsdni: np.ndarray + DNI computed by FARMS-DNI (Wm-2). +dni0: np.ndarray + DNI computed by the Lambert law (Wm-2). It only includes the narrow beam in the circumsolar region. +''' + + def TDD2(Z, Ftotal, F1): # compute surface reflection that falls in the circumsolar region. A parameterization of Eq. (S4) in Xie et al (2020) is used. diff --git a/tests/testfarms.py b/tests/testfarms.py new file mode 100644 index 0000000..e894a27 --- /dev/null +++ b/tests/testfarms.py @@ -0,0 +1,33 @@ + +import numpy as np +from farms import farms_dni +import sys + +def sunearth(juday): + b = 2.0*np.pi*juday/365.0 + R1 = 1.00011 + 0.034221*np.cos(b) + 0.001280*np.sin(b) + 0.000719*np.cos(2.0*b) +0.000077*np.sin(2.0*b) + R = np.power(R1, -0.5) + return R + + +f = open( '/projects/pxs/yxie/forecast/FARMS-DNI/test/ppdata/SRRL/datawater/input.dat', 'r') +n = 100 +F0 = np.arange(n) +F0[:] = 1360.0 +tau = np.arange(n)*0.1 +sza = np.arange(n)*0.85 +solar_zenith_angle = np.cos( sza*np.pi/180.0 ) +De = np.arange(n)+10.0 +phase = np.arange(n) +phase[:50] = 1 +phase[50:] = 2 +phase1 = np.where(phase == 1) +phase2 = np.where(phase == 2) +Tddclr = ( np.arange(n)+100 )*0.005 +Ftotal = np.flip( np.arange(n) + 900.0) +F1 = Ftotal*0.7 + +Fd, dni_farmsdni, dni0 = farms_dni.farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1) + +print( dni_farmsdni) +print( dni0 ) From f8bc8e46e0bd618bee70fec9e08148a547aba25f Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 21 Mar 2023 17:09:28 -0600 Subject: [PATCH 06/55] update FARMS-DNI --- farms/farms_dni.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index de8b1b3..07e0be0 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -1,23 +1,10 @@ """ +Fast All-sky Radiation Model for solar applications with direct normal irradiance (FARMS-DNI) + Created on March 1, 2022 +Upgraded on March 21, 2023 FARMS-DNI model developed by Yu Xie (yu.xie@nrel.gov) -Literature -[1] Yu Xie, Manajit Sengupta, Yangang Liu, Hai Long, Qilong Min, Weijia Liu, Aron Habte, - A physics-based DNI model assessing all-sky circumsolar radiation, iScience -[2] Yu Xie, Jaemo Yang, Manajit Sengupta, Yangang Liu, Xin Zhou, - Improving the prediction of DNI with physics-based representation of all-sky circumsolar radaition, Solar Energy -[3] Jaemo Yang, Yu Xie, Manajit Sengupta, Yangang Liu, Hai Long, - Parameterization of cloud transmittance for expeditious assessment and forecasting of all-sky DNI, Solar Energy - -""" -import numpy as np -import sys -import pandas as pd - -''' -Fast All-sky Radiation Model for solar applications with direct normal irradiance (FARMS-DNI) - References ----------- Xie, Y., Sengupta, M., Dudhia, J., 2016. A Fast All-sky Radiation Model for Solar applications (FARMS): Algorithm and performance evaluation. Sol. Energy 135, 435-445. @@ -40,7 +27,11 @@ DNI computed by FARMS-DNI (Wm-2). dni0: np.ndarray DNI computed by the Lambert law (Wm-2). It only includes the narrow beam in the circumsolar region. -''' + +""" +import numpy as np +import sys +import pandas as pd From 25c335482cb7fc8e688bb6ecaad83998d12f7111 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Thu, 23 Mar 2023 16:27:03 -0600 Subject: [PATCH 07/55] update FARMS-DNI --- farms/farms_dni.py | 22 ++++++++++++++++++++-- tests/testfarms.py | 33 --------------------------------- 2 files changed, 20 insertions(+), 35 deletions(-) delete mode 100644 tests/testfarms.py diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 07e0be0..430ab5e 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -14,7 +14,26 @@ Input data ----------- F0: np.ndarray -extraterrestrial solar radiation (Wm-2). + extraterrestrial solar radiation (Wm-2). +tau : np.ndarray + Cloud optical thickness (cld_opd_dcomp) (unitless). +solar_zenith_angle : np.ndarray + Solar zenith angle (degrees). Must represent the average value over the + integration period (e.g. hourly) under scrutiny. +De: np.ndarray + Effective cloud particle size (diameter, micron). +phase: np.ndarray + Cloud thermodynamic phase (water:1, ice:2) +phase1: np.ndarray + np.where( phase==1 ) +phase2: np.ndarray + np.where( phase==2 ) +Tddclr : np.ndarray + Calculated in REST2. Transmittance of the clear-sky atmosphere for + direct incident and direct outgoing fluxes (dd). + Tddclr = dni / etdirn +Ftotal: np.ndarray + GHI (Wm-2) F1: np.ndarray First order solar radiation given in FARMS (Wm-2). See Xie et al. (2016) for more details. @@ -22,7 +41,6 @@ ----------- Fd: np.ndarray Direct radiation in the downwelling direction (Wm-2). It includes the narrow beam and the scattered radiation in the circumsolar region. - dni_farmsdni: np.ndarray DNI computed by FARMS-DNI (Wm-2). dni0: np.ndarray diff --git a/tests/testfarms.py b/tests/testfarms.py deleted file mode 100644 index e894a27..0000000 --- a/tests/testfarms.py +++ /dev/null @@ -1,33 +0,0 @@ - -import numpy as np -from farms import farms_dni -import sys - -def sunearth(juday): - b = 2.0*np.pi*juday/365.0 - R1 = 1.00011 + 0.034221*np.cos(b) + 0.001280*np.sin(b) + 0.000719*np.cos(2.0*b) +0.000077*np.sin(2.0*b) - R = np.power(R1, -0.5) - return R - - -f = open( '/projects/pxs/yxie/forecast/FARMS-DNI/test/ppdata/SRRL/datawater/input.dat', 'r') -n = 100 -F0 = np.arange(n) -F0[:] = 1360.0 -tau = np.arange(n)*0.1 -sza = np.arange(n)*0.85 -solar_zenith_angle = np.cos( sza*np.pi/180.0 ) -De = np.arange(n)+10.0 -phase = np.arange(n) -phase[:50] = 1 -phase[50:] = 2 -phase1 = np.where(phase == 1) -phase2 = np.where(phase == 2) -Tddclr = ( np.arange(n)+100 )*0.005 -Ftotal = np.flip( np.arange(n) + 900.0) -F1 = Ftotal*0.7 - -Fd, dni_farmsdni, dni0 = farms_dni.farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1) - -print( dni_farmsdni) -print( dni0 ) From 84c3210020bd3d9d150c658bcde7df6e06621c17 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Thu, 23 Mar 2023 18:16:34 -0600 Subject: [PATCH 08/55] new test --- tests/test_farmsdni.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/test_farmsdni.py diff --git a/tests/test_farmsdni.py b/tests/test_farmsdni.py new file mode 100644 index 0000000..6145155 --- /dev/null +++ b/tests/test_farmsdni.py @@ -0,0 +1,38 @@ + +import numpy as np +from farms import farms_dni +import sys + + +def test_farmsdni(): + + n = 100 + F0 = np.arange(n) + F0[:] = 1360.0 + tau = np.arange(n)*0.1 + sza = np.arange(n)*0.85 + solar_zenith_angle = np.cos( sza*np.pi/180.0 ) + De = np.arange(n)+10.0 + phase = np.arange(n) + phase[:50] = 1 + phase[50:] = 2 + phase1 = np.where(phase == 1) + phase2 = np.where(phase == 2) + Tddclr = ( np.arange(n)+100 )*0.005 + Ftotal = np.flip( np.arange(n) + 900.0) + F1 = Ftotal*0.7 + + Fd, dni_farmsdni, dni0 = farms_dni.farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1) + + cond1 = [x for x in dni_farmsdni if x<0] + cond2 = [x for x in dni_farmsdni if x>=1400] + cond3 = [i for i in range(dni_farmsdni.shape[0]) if dni_farmsdni[i] < dni0[i] ] + + wrong_num = np.size(cond1+cond2+cond3) + assert wrong_num == 0 + + + +if __name__ == '__main__': + execute_pytest() + From 2f85ca4eb45198705d9bce52ef4ea47cc2eab395 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Thu, 23 Mar 2023 18:22:15 -0600 Subject: [PATCH 09/55] test code for Lint code base --- tests/test_farmsdni1.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test_farmsdni1.py diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py new file mode 100644 index 0000000..9e8b85e --- /dev/null +++ b/tests/test_farmsdni1.py @@ -0,0 +1,33 @@ +import numpy as np +from farms import farms_dni + + +def test_farmsdni(): + n = 100 + F0 = np.full(n, 1360.0) + tau = np.arange(n) * 0.1 + sza = np.arange(n) * 0.85 + solar_zenith_angle = np.cos(sza * np.pi / 180.0) + De = np.arange(n) + 10.0 + phase = np.full(n, 2) + phase[:50] = 1 + phase1 = np.where(phase == 1)[0] + phase2 = np.where(phase == 2)[0] + Tddclr = (np.arange(n) + 100) * 0.005 + Ftotal = np.flip(np.arange(n) + 900.0) + F1 = Ftotal * 0.7 + + Fd, dni_farmsdni, dni0 = farms_dni.farms_dni( + F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1 + ) + + cond1 = dni_farmsdni[dni_farmsdni < 0] + cond2 = dni_farmsdni[dni_farmsdni >= 1400] + cond3 = np.where(dni_farmsdni < dni0)[0] + + wrong_num = len(cond1) + len(cond2) + len(cond3) + assert wrong_num == 0 + + +if __name__ == "__main__": + test_farmsdni() From cec9d2f2d8548396807905cde26494764104d484 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 12:43:37 -0600 Subject: [PATCH 10/55] test code for Linting --- tests/test_farmsdni1.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 9e8b85e..5623213 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -1,8 +1,18 @@ +""" +PyTest file for FARMS-DNI + +Created on 03/24/2023 + +@author: Yu Xie +""" + import numpy as np from farms import farms_dni def test_farmsdni(): + '''Test FARMS-DNI with typical input variables ''' + n = 100 F0 = np.full(n, 1360.0) tau = np.arange(n) * 0.1 @@ -18,7 +28,8 @@ def test_farmsdni(): F1 = Ftotal * 0.7 Fd, dni_farmsdni, dni0 = farms_dni.farms_dni( - F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1 + F0, tau, solar_zenith_angle, De, phase, phase1, phase2, + Tddclr, Ftotal, F1 ) cond1 = dni_farmsdni[dni_farmsdni < 0] From 7d18f0a8801339000103c31bd110debfb154c93c Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 12:49:19 -0600 Subject: [PATCH 11/55] test code for Linting --- tests/test_farmsdni1.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 5623213..1906df7 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -36,6 +36,8 @@ def test_farmsdni(): cond2 = dni_farmsdni[dni_farmsdni >= 1400] cond3 = np.where(dni_farmsdni < dni0)[0] + Fd = 0.0 #Set this to pass the Linting + wrong_num = len(cond1) + len(cond2) + len(cond3) assert wrong_num == 0 From 04c16a5f9050cd52dda6817116baf782f74847ea Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 12:56:11 -0600 Subject: [PATCH 12/55] test code for Linting --- tests/test_farmsdni1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 1906df7..3a69c2a 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -36,7 +36,7 @@ def test_farmsdni(): cond2 = dni_farmsdni[dni_farmsdni >= 1400] cond3 = np.where(dni_farmsdni < dni0)[0] - Fd = 0.0 #Set this to pass the Linting + useless = Fd #Set this to pass the Linting wrong_num = len(cond1) + len(cond2) + len(cond3) assert wrong_num == 0 From be29c2928d412016b588437ff2e8fcd2743823d9 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 13:02:22 -0600 Subject: [PATCH 13/55] test code for Linting --- tests/test_farmsdni1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 3a69c2a..0a9e7c1 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -36,7 +36,7 @@ def test_farmsdni(): cond2 = dni_farmsdni[dni_farmsdni >= 1400] cond3 = np.where(dni_farmsdni < dni0)[0] - useless = Fd #Set this to pass the Linting + print(Fd) #Set this to pass the Linting wrong_num = len(cond1) + len(cond2) + len(cond3) assert wrong_num == 0 From d3132843ab4454cf3f253faa6b4648a86f03025b Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 13:07:59 -0600 Subject: [PATCH 14/55] test code for Linting --- tests/test_farmsdni1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 0a9e7c1..18d785b 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -36,7 +36,7 @@ def test_farmsdni(): cond2 = dni_farmsdni[dni_farmsdni >= 1400] cond3 = np.where(dni_farmsdni < dni0)[0] - print(Fd) #Set this to pass the Linting + print(Fd) # Set this to pass the Linting wrong_num = len(cond1) + len(cond2) + len(cond3) assert wrong_num == 0 From d4b96fb203cdf611387cd42e0511d4e3b23b52cf Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 14:07:07 -0600 Subject: [PATCH 15/55] test code for Linting --- tests/test_farmsdni1.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 18d785b..09042dd 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -11,7 +11,10 @@ def test_farmsdni(): - '''Test FARMS-DNI with typical input variables ''' + '''Test FARMS-DNI with typical input variables + Check if the DNI computation is between 0 and 1400, + and larger than the DNI in the narrow beam. + ''' n = 100 F0 = np.full(n, 1360.0) From 0b636e5597050cedde36b44d1c99e6cbc4395fe8 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 15:11:17 -0600 Subject: [PATCH 16/55] test code for Linting --- farms/farms_dni.py | 372 ++++++++++++++++++++++++---------------- tests/test_farmsdni1.py | 3 +- 2 files changed, 221 insertions(+), 154 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 430ab5e..c59f1dc 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -1,71 +1,45 @@ """ -Fast All-sky Radiation Model for solar applications with direct normal irradiance (FARMS-DNI) - Created on March 1, 2022 Upgraded on March 21, 2023 FARMS-DNI model developed by Yu Xie (yu.xie@nrel.gov) References ----------- -Xie, Y., Sengupta, M., Dudhia, J., 2016. A Fast All-sky Radiation Model for Solar applications (FARMS): Algorithm and performance evaluation. Sol. Energy 135, 435-445. -Xie, Y., Sengupta, M., Liu, Y., Long, H., Min, Q., Liu, W., Habte, A., 2020. A physics-based DNI model assessing all-sky circumsolar radiation. iScience 22, doi.org/10.1016/j.isci.2020.100893. -Yang, J., Xie, Y., Sengupta, M., Liu, Y., Long, H., 2022. Parameterization of cloud transmittance for expeditious assessment and forecasting of all-sky DNI. J. Renewable Sustainable Energy 14, 063703. - -Input data ------------ -F0: np.ndarray - extraterrestrial solar radiation (Wm-2). -tau : np.ndarray - Cloud optical thickness (cld_opd_dcomp) (unitless). -solar_zenith_angle : np.ndarray - Solar zenith angle (degrees). Must represent the average value over the - integration period (e.g. hourly) under scrutiny. -De: np.ndarray - Effective cloud particle size (diameter, micron). -phase: np.ndarray - Cloud thermodynamic phase (water:1, ice:2) -phase1: np.ndarray - np.where( phase==1 ) -phase2: np.ndarray - np.where( phase==2 ) -Tddclr : np.ndarray - Calculated in REST2. Transmittance of the clear-sky atmosphere for - direct incident and direct outgoing fluxes (dd). - Tddclr = dni / etdirn -Ftotal: np.ndarray - GHI (Wm-2) -F1: np.ndarray - First order solar radiation given in FARMS (Wm-2). See Xie et al. (2016) for more details. - -Output data ------------ -Fd: np.ndarray - Direct radiation in the downwelling direction (Wm-2). It includes the narrow beam and the scattered radiation in the circumsolar region. -dni_farmsdni: np.ndarray - DNI computed by FARMS-DNI (Wm-2). -dni0: np.ndarray - DNI computed by the Lambert law (Wm-2). It only includes the narrow beam in the circumsolar region. - +Xie, Y., Sengupta, M., Dudhia, J., 2016. A Fast All-sky Radiation Model for +Solar applications (FARMS): Algorithm and performance evaluation. Sol. Energy + 135, 435-445. +Xie, Y., Sengupta, M., Liu, Y., Long, H., Min, Q., Liu, W., Habte, A., 2020. +A physics-based DNI model assessing all-sky circumsolar radiation. iScience 22, + doi.org/10.1016/j.isci.2020.100893. +Yang, J., Xie, Y., Sengupta, M., Liu, Y., Long, H., 2022. Parameterization of +cloud transmittance for expeditious assessment and forecasting of all-sky DNI. +J. Renewable Sustainable Energy 14, 063703. """ + import numpy as np import sys import pandas as pd - def TDD2(Z, Ftotal, F1): - # compute surface reflection that falls in the circumsolar region. A parameterization of Eq. (S4) in Xie et al (2020) is used. + ''' + Compute surface reflection that falls in the circumsolar region. + A parameterization of Eq. (S4) in Xie et al (2020) is used. + ''' + # compute the integration of the solid angle a = 5.94991536e-03 b = 5.42116600e-01 c = 331280.9859904468 - muomega = a*np.exp(-np.power(Z-b, 3.0)/c ) + muomega = a * np.exp( -np.power(Z-b, 3.0)/c ) - Fd2 = np.cos( Z*np.pi/180.0 )*(Ftotal - F1)*muomega/np.pi + Fd2 = np.cos(Z * np.pi / 180.0) * (Ftotal - F1) * muomega / np.pi return Fd2 def TDDP(Z, tau, De, phase1, phase2): - # compute cloud transmittance of DNI for water and ice clouds + ''' + compute cloud transmittance of DNI for water and ice clouds + ''' Tddcld = np.zeros_like(tau) Tddcld[phase1] = Pwater( Z[phase1],tau[phase1], De[phase1] ) Tddcld[phase2] = Pice( Z[phase2],tau[phase2], De[phase2] ) @@ -74,153 +48,190 @@ def TDDP(Z, tau, De, phase1, phase2): def Pwater(Z, tau, De): - - umu0 = np.cos( Z*np.pi/180.0 ) -### taup Eq.(3) in Yang et al. (2022) + ''' + Compute cloud transmittance for water clouds + ''' + umu0 = np.cos( Z * np.pi / 180.0 ) + # taup Eq.(3) in Yang et al. (2022) taup = np.zeros_like(Z) - taup[(De<10.0) & (umu0<0.1391)] = 0.1 - taup[(De<10.0) & (umu0>=0.1391) & (umu0<0.2419)] = 0.2 - taup[(De<10.0) & (umu0>=0.2419) & (umu0<0.3090)] = 0.3 - taup[(De<10.0) & (umu0>=0.3090) & (umu0<0.4067)] = 0.4 - taup[(De<10.0) & (umu0>=0.4067) & (umu0<0.6156)] = 0.5 - taup[(De<10.0) & (umu0>=0.6156)] = 1.0 - - taup[(De>=10.0) & (umu0<0.1391)] = 0.1 - taup[(De>=10.0) & (umu0>=0.1391) & (umu0<0.2079)] = 0.2 - taup[(De>=10.0) & (umu0>=0.2079) & (umu0<0.3090)] = 0.3 - taup[(De>=10.0) & (umu0>=0.3090) & (umu0<0.3746)] = 0.4 - taup[(De>=10.0) & (umu0>=0.3746) & (umu0<0.6156)] = 0.5 - taup[(De>=10.0) & (umu0>=0.6156)] = 1.0 - -###Tddp Eq(4) in Yang et al. (2022) - h = 0.005553*np.log(De) + 0.002503 - h[De==0] = 0.0 + taup[(De < 10.0) & (umu0 < 0.1391)] = 0.1 + taup[(De < 10.0) & (umu0 >= 0.1391) & (umu0 < 0.2419)] = 0.2 + taup[(De < 10.0) & (umu0 >= 0.2419) & (umu0 < 0.3090)] = 0.3 + taup[(De < 10.0) & (umu0 >= 0.3090) & (umu0 < 0.4067)] = 0.4 + taup[(De < 10.0) & (umu0 >= 0.4067) & (umu0 < 0.6156)] = 0.5 + taup[(De < 10.0) & (umu0 >= 0.6156)] = 1.0 + + taup[(De >= 10.0) & (umu0 < 0.1391)] = 0.1 + taup[(De >= 10.0) & (umu0 >= 0.1391) & (umu0 < 0.2079)] = 0.2 + taup[(De >= 10.0) & (umu0 >= 0.2079) & (umu0 < 0.3090)] = 0.3 + taup[(De >= 10.0) & (umu0 >= 0.3090) & (umu0 < 0.3746)] = 0.4 + taup[(De >= 10.0) & (umu0 >= 0.3746) & (umu0 < 0.6156)] = 0.5 + taup[(De >= 10.0) & (umu0 >= 0.6156)] = 1.0 + + # Tddp Eq(4) in Yang et al. (2022) + h = 0.005553 * np.log(De) + 0.002503 + h[De == 0] = 0.0 Tddp = np.zeros_like(Z) - a1 = (umu0>=0.0) & (umu0<0.342) - Tddp[a1] = h[a1]*(-0.1787*umu0[a1]*umu0[a1] + 0.2207*umu0[a1] + 0.977) - a2 = (umu0>=0.342) & (umu0<0.4694) + a1 = (umu0 >= 0.0) & (umu0 < 0.342) + Tddp[a1] = h[a1] * (-0.1787 * umu0[a1] * umu0[a1] + 0.2207 * umu0[a1] + 0.977) + a2 = (umu0 >= 0.342) & (umu0 < 0.4694) Tddp[a2] = h[a2] - a3 = (umu0>=0.4694) & (umu0<0.7193) - Tddp[a3] = h[a3]*( 2.6399*umu0[a3]*umu0[a3] - 3.2111*umu0[a3] + 1.9434 ) - a4 = (umu0>=0.7193) & (umu0<0.8829) - Tddp[a4] = h[a4]*( -0.224*umu0[a4]*umu0[a4] + 0.0835*umu0[a4] + 1.056 ) - a5 = (umu0>=0.8829) & (umu0<0.9396) - Tddp[a5] = h[a5]*( -94.381*umu0[a5]*umu0[a5] + 170.32*umu0[a5] - 75.843 ) - a6 = (umu0>=0.9396) & (umu0<0.9945) - Tddp[a6] = h[a6]*( -12.794*umu0[a6]*umu0[a6] + 22.686*umu0[a6] - 8.9392 ) - a7 = (umu0>=0.9945) & (umu0<0.999) - Tddp[a7] = h[a7]*( 11248.61*umu0[a7]*umu0[a7] - 22441.07*umu0[a7] + 11193.59 ) - a8 = umu0>=0.999 - Tddp[a8] = 0.76*h[a8] + a3 = (umu0 >= 0.4694) & (umu0 < 0.7193) + Tddp[a3] = h[a3] * (2.6399 * umu0[a3] * umu0[a3] - 3.2111 * umu0[a3] + 1.9434) + a4 = (umu0 >= 0.7193) & (umu0 < 0.8829) + Tddp[a4] = h[a4] * (-0.224 * umu0[a4] * umu0[a4] + 0.0835 * umu0[a4] + 1.056) + a5 = (umu0 >= 0.8829) & (umu0 < 0.9396) + Tddp[a5] = h[a5] * (-94.381 * umu0[a5] * umu0[a5] + 170.32 * umu0[a5] - 75.843) + a6 = (umu0 >= 0.9396) & (umu0 < 0.9945) + Tddp[a6] = h[a6] * (-12.794 * umu0[a6] * umu0[a6] + 22.686 * umu0[a6] - 8.9392) + a7 = (umu0 >= 0.9945) & (umu0 < 0.999) + Tddp[a7] = h[a7]*(11248.61 * umu0[a7] * umu0[a7] - 22441.07 * umu0[a7] + 11193.59) + a8 = umu0 >= 0.999 + Tddp[a8] = 0.76 * h[a8] # Eq.(6) in Yang et al. (2022) - a = 2.0339*np.power( umu0, -0.927 ) - b = 6.6421*np.power( umu0, 2.0672 ) + a = 2.0339 * np.power( umu0, -0.927 ) + b = 6.6421 * np.power( umu0, 2.0672 ) # compute Tddcld using Eq.(5) in Yang et al. (2022) Tddcld = np.zeros_like(Z) - a1 = tau<=0.9*taup - Tddcld[a1] = Tddp[a1]*np.tanh(a[a1]*tau[a1]) - a2 = (tau>0.9*taup) & (tau=taup - Tddcld[a3] = Tddp[a3]*np.tanh(b[a3]/np.power(tau[a3],2.0)) + a1 = tau <= 0.9 * taup + Tddcld[a1] = Tddp[a1] * np.tanh(a[a1] * tau[a1]) + a2 = (tau > 0.9 * taup) & (tau < taup) + Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + + Tddp[a2] * (np.tanh(b[a2] / np.power(taup[a2],2.0)) + - np.tanh(0.9 * a[a2] * taup[a2])) * + (tau[a2] - 0.9 * taup[a2])/(0.1 * taup[a2]) + a3 = tau >= taup + Tddcld[a3] = Tddp[a3] * np.tanh(b[a3] / np.power(tau[a3],2.0)) return Tddcld def Pice(Z, tau, De): - - umu0 = np.cos( Z*np.pi/180.0 ) -### taup Eq.(3) in Yang et al. (2022) + ''' + Compute cloud transmittance for ice clouds + ''' + umu0 = np.cos( Z * np.pi / 180.0 ) + # taup Eq.(3) in Yang et al. (2022) taup = np.zeros_like(Z) - a1 = (De>=5.0) & (De<14.0) & (umu0<0.1391) + a1 = (De >= 5.0) & (De < 14.0) & (umu0 < 0.1391) taup[a1] = 0.1 - a2 = (De>=5.0) & (De<14.0) & (umu0>=0.1391) & (umu0<0.2079) + a2 = (De >= 5.0) & (De < 14.0) & (umu0 >= 0.1391) & (umu0 < 0.2079) taup[a2] = 0.2 - a3 = (De>=5.0) & (De<14.0) & (umu0>=0.2079) & (umu0<0.3090) + a3 = (De >= 5.0) & (De < 14.0) & (umu0 >= 0.2079) & (umu0 < 0.3090) taup[a3] = 0.3 - a4 = (De>=5.0) & (De<14.0) & (umu0>=0.3090) & (umu0<0.3746) + a4 = (De >= 5.0) & (De < 14.0) & (umu0 >= 0.3090) & (umu0 < 0.3746) taup[a4] = 0.4 - a5 = (De>=5.0) & (De<14.0) & (umu0>=0.3746) & (umu0<0.6156) + a5 = (De >= 5.0) & (De < 14.0) & (umu0 >= 0.3746) & (umu0 < 0.6156) taup[a5] = 0.5 - a6 = (De>=5.0) & (De<14.0) & (umu0>=0.6156) & (umu0<0.9994) + a6 = (De >= 5.0) & (De < 14.0) & (umu0 >= 0.6156) & (umu0 < 0.9994) taup[a6] = 1.0 - a7 = (De>=5.0) & (De<14.0) & (umu0>=0.9994) + a7 = (De >= 5.0) & (De < 14.0) & (umu0 >= 0.9994) taup[a7] = 1.5 - a8 = (De>=14.0) & (De<50.0) & (umu0<0.139173) + a8 = (De >= 14.0) & (De < 50.0) & (umu0 < 0.139173) taup[a8] = 0.1 - a9 = (De>=14.0) & (De<50.0) & (umu0>=0.139173) & (umu0<-0.0011*De+0.2307) + a9 = (De >= 14.0) & (De < 50.0) & (umu0 >= 0.139173) & + (umu0 < -0.0011 * De + 0.2307) taup[a9] = 0.2 - a10 = (De>=14.0) & (De<50.0) & (umu0>=-0.0011*De+0.2307) & (umu0<-0.0022*De+0.3340) + a10 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0011 * De + 0.2307) & + (umu0 < -0.0022 * De + 0.3340) taup[a10] = 0.3 - a11 = (De>=14.0) & (De<50.0) & (umu0>=-0.0022*De+0.3340) & (umu0<-0.0020*De+0.4096) + a11 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0022 * De + 0.3340) & + (umu0<-0.0020*De+0.4096) taup[a11] = 0.4 - a12 = (De>=14.0) & (De<50.0) & (umu0>=-0.0020*De+0.4096) & (umu0<-0.0033*De+0.6461) + a12 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0020 * De + 0.4096) & + (umu0 < -0.0033 * De + 0.6461) taup[a12] = 0.5 - a13 = (De>=14.0) & (De<50.0) & (umu0>=-0.0033*De+0.6461) & (umu0<-0.0049*De+1.0713) + a13 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0033 * De + 0.6461) & + (umu0 < -0.0049 * De + 1.0713) taup[a13] = 1.0 - a14 = (De>=14.0) & (De<50.0) & (umu0>=-0.0049*De+1.0713) + a14 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0049 * De + 1.0713) taup[a14] = 1.5 - - a15 = (De>=50.0) & (umu0<-0.0006*De+0.2109) + a15 = (De >= 50.0) & (umu0 < -0.0006 * De + 0.2109) taup[a15] = 0.2 - a16 = (De>=50.0) & (umu0>=-0.0006*De+0.2109) & (umu0<-0.0005*De+0.2581) + a16 = (De >= 50.0) & (umu0 >= -0.0006 * De + 0.2109) & + (umu0 < -0.0005 * De + 0.2581) taup[a16] = 0.3 - a17 = (De>=50.0) & (umu0>=-0.0005*De+0.2581) & (umu0<-0.0010*De+0.3907) + a17 = (De >= 50.0) & (umu0 >= -0.0005 * De + 0.2581) & + (umu0 < -0.0010 * De + 0.3907) taup[a17] = 0.4 - a18 = (De>=50.0) & (umu0>=-0.0010*De+0.3907) & (umu0<-0.0008*De+0.4900) + a18 = (De >= 50.0) & (umu0 >= -0.0010 * De + 0.3907) & + (umu0 < -0.0008 * De + 0.4900) taup[a18] = 0.5 - a19 = (De>=50.0) & (umu0>=-0.0008*De+0.4900) & (umu0<-0.0017*De+0.8708) + a19 = (De >= 50.0) & (umu0 >= -0.0008 * De + 0.4900) & + (umu0 < -0.0017 * De + 0.8708) taup[a19] = 1.0 - a20 = (De>=50.0) & (umu0>=-0.0017*De+0.8708) & (umu0<-0.0006*De+1.0367) + a20 = (De >= 50.0) & (umu0 >= -0.0017 * De + 0.8708) & + (umu0 < -0.0006 * De + 1.0367) taup[a20] = 1.5 - a21 = (De>=50.0) & (umu0>=-0.0006*De+1.0367) + a21 = (De >= 50.0) & (umu0 >= -0.0006 * De + 1.0367) taup[a21] = 2.0 -###Tddp Eq(4) in Yang et al. (2022) + # Tddp Eq(4) in Yang et al. (2022) Tddp = np.zeros_like(Z) - b1 = (umu0>=0.9994) & (De<=10.0) + b1 = (umu0 >= 0.9994) & (De <= 10.0) Tddp[b1] = 0.12269 - b2 = (umu0>=0.9994) & (De>10.0) & (De<=16.0) - Tddp[b2] = 0.0015*De[b2] + 0.1078 - b3 = (umu0>=0.9994) & (De>16.0) - Tddp[b3] = 0.1621*np.exp(-0.016*De[b3]) + b2 = (umu0 >= 0.9994) & (De > 10.0) & (De <= 16.0) + Tddp[b2] = 0.0015 * De[b2] + 0.1078 + b3 = (umu0 >= 0.9994) & (De > 16.0) + Tddp[b3] = 0.1621 * np.exp(-0.016 * De[b3]) - b4 = (umu0<0.9396) & (De<=10.0) + b4 = (umu0 < 0.9396) & (De <= 10.0) Tddp[b4] = 0.14991 - b5 = (umu0<0.9945) & (umu0>=0.9396) & (De<=10.0) - Tddp[b5] = -4.5171*np.power(umu0[b5],2.0) + 8.3056*umu0[b5] - 3.6476 - b6 = (umu0>=0.9945) & (umu0<0.9994) & (De<=10.0) - Tddp[b6] = 298.45*np.power(umu0[b6],2.0) - 601.33*umu0[b6] + 303.04 - - ade = -0.000232338*np.power(De,2.0) + 0.012748726*De + 0.046745083 - b7 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0<=0.2419) - Tddp[b7] = (-8.454*np.power(umu0[b7],2.0) + 2.4095*umu0[b7] +0.8425)*ade[b7] - b8 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.2419) & (umu0<=0.3746) - Tddp[b8] = (-13.528*np.power(umu0[b8],2.0) + 7.8403*umu0[b8] -0.1221)*ade[b8] - b9 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.3746) & (umu0<=0.4694) - Tddp[b9] = (19.524*np.power(umu0[b9],2.0) - 16.5*umu0[b9] +4.4612)*ade[b9] - b10 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.4694) & (umu0<=0.5877) - Tddp[b10] = (16.737*np.power(umu0[b10],2.0) - 17.419*umu0[b10] +5.4881)*ade[b10] - b11 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.5877) & (umu0<=0.6691) - Tddp[b11] = (-39.493*np.power(umu0[b11],2.0) + 48.963*umu0[b11] -14.175)*ade[b11] - b12 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.6691) & (umu0<=0.7660) - Tddp[b12] = (0.4017*np.power(umu0[b12],2.0) - 0.243*umu0[b12] +0.9609)*ade[b12] - b13 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.7660) & (umu0<=0.8480) - Tddp[b13] = (-11.183*np.power(umu0[b13],2.0) + 18.126*umu0[b13] -6.3417)*ade[b13] - b14 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8480) & (umu0<=0.8987) - Tddp[b14] = (-163.36*np.power(umu0[b14],2.0) + 283.35*umu0[b14] -121.91)*ade[b14] - b15 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8987) & (umu0<=0.9396) - Tddp[b15] = (-202.72*np.power(umu0[b15],2.0) + 368.75*umu0[b15] -166.75)*ade[b15] - b16 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9396) & (umu0<=0.9702) - Tddp[b16] = (-181.72*np.power(umu0[b16],2.0) + 343.59*umu0[b16] -161.3)*ade[b16] - b17 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9702) & (umu0<=0.9945) - Tddp[b17] = (127.66*np.power(umu0[b17],2.0) - 255.73*umu0[b17] +129.03)*ade[b17] - b18 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9945) - Tddp[b18] = (908.66*np.power(umu0[b18],2.0) - 1869.3*umu0[b18] +961.63)*ade[b18] + b5 = (umu0 < 0.9945) & (umu0 >= 0.9396) & (De <= 10.0) + Tddp[b5] = -4.5171 * np.power(umu0[b5],2.0) + 8.3056 * umu0[b5] - 3.6476 + b6 = (umu0 >= 0.9945) & (umu0 < 0.9994) & (De <= 10.0) + Tddp[b6] = 298.45 * np.power(umu0[b6],2.0) - 601.33 * umu0[b6] + 303.04 + + ade = -0.000232338 * np.power(De,2.0) + 0.012748726 * De + 0.046745083 + b7 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 <= 0.2419) + Tddp[b7] = (-8.454 * np.power(umu0[b7],2.0) + 2.4095 * umu0[b7] + 0.8425) * + ade[b7] + b8 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.2419) & + (umu0 <= 0.3746) + Tddp[b8] = (-13.528 * np.power(umu0[b8],2.0) + 7.8403 * umu0[b8] -0.1221) + * ade[b8] + b9 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.3746) & + (umu0 <= 0.4694) + Tddp[b9] = (19.524 * np.power(umu0[b9],2.0) - 16.5 * umu0[b9] + 4.4612) * + ade[b9] + b10 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.4694) & + (umu0 <= 0.5877) + Tddp[b10] = (16.737 * np.power(umu0[b10],2.0) - 17.419 * umu0[b10] + 5.4881) + * ade[b10] + b11 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.5877) & + (umu0 <= 0.6691) + Tddp[b11] = (-39.493 * np.power(umu0[b11],2.0) + 48.963 * umu0[b11] -14.175) + * ade[b11] + b12 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.6691) & + (umu0 <= 0.7660) + Tddp[b12] = (0.4017 * np.power(umu0[b12],2.0) - 0.243 * umu0[b12] + 0.9609) + *ade[b12] + b13 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.7660) & + (umu0 <= 0.8480) + Tddp[b13] = (-11.183 * np.power(umu0[b13],2.0) + 18.126 * umu0[b13] - + 6.3417)*ade[b13] + b14 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8480) & + (umu0 <= 0.8987) + Tddp[b14] = (-163.36 * np.power(umu0[b14],2.0) + 283.35 * umu0[b14] + - 121.91) * ade[b14] + b15 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8987) + & (umu0 <= 0.9396) + Tddp[b15] = (-202.72 * np.power(umu0[b15],2.0) + 368.75 * umu0[b15] + - 166.75) * ade[b15] + b16 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9396) + & (umu0 <= 0.9702) + Tddp[b16] = (-181.72 * np.power(umu0[b16],2.0) + 343.59 * umu0[b16] + - 161.3)*ade[b16] + b17 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9702) + & (umu0 <= 0.9945) + Tddp[b17] = (127.66 * np.power(umu0[b17],2.0) - 255.73 * umu0[b17] + + 129.03) * ade[b17] + b18 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9945) + Tddp[b18] = (908.66 * np.power(umu0[b18],2.0) - 1869.3 * umu0[b18] + + 961.63) * ade[b18] bde = 0.0000166112*np.power(De,2.0) - 0.00410998*De + 0.352026619 b19 = (umu0<0.999) & (De>30.0) & (umu0<=0.2419) @@ -266,6 +277,63 @@ def Pice(Z, tau, De): def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1): +''' +Fast All-sky Radiation Model for solar applications with direct normal +irradiance (FARMS-DNI) + +References +----------- +Xie, Y., Sengupta, M., Dudhia, J., 2016. A Fast All-sky Radiation Model for +Solar applications (FARMS): Algorithm and performance evaluation. Sol. Energy + 135, 435-445. +Xie, Y., Sengupta, M., Liu, Y., Long, H., Min, Q., Liu, W., Habte, A., 2020. +A physics-based DNI model assessing all-sky circumsolar radiation. iScience 22, + doi.org/10.1016/j.isci.2020.100893. +Yang, J., Xie, Y., Sengupta, M., Liu, Y., Long, H., 2022. Parameterization of +cloud transmittance for expeditious assessment and forecasting of all-sky DNI. +J. Renewable Sustainable Energy 14, 063703. + +Input data +----------- +F0: np.ndarray + extraterrestrial solar radiation (Wm-2). +tau : np.ndarray + Cloud optical thickness (cld_opd_dcomp) (unitless). +solar_zenith_angle : np.ndarray + Solar zenith angle (degrees). Must represent the average value over the + integration period (e.g. hourly) under scrutiny. +De: np.ndarray + Effective cloud particle size (diameter, micron). +phase: np.ndarray + Cloud thermodynamic phase (water:1, ice:2) +phase1: np.ndarray + np.where( phase==1 ) +phase2: np.ndarray + np.where( phase==2 ) +Tddclr : np.ndarray + Calculated in REST2. Transmittance of the clear-sky atmosphere for + direct incident and direct outgoing fluxes (dd). + Tddclr = dni / etdirn +Ftotal: np.ndarray + GHI (Wm-2) +F1: np.ndarray + First order solar radiation given in FARMS (Wm-2). See Xie et al. (2016) + for more details. + +Output data +----------- +Fd: np.ndarray + Direct radiation in the downwelling direction (Wm-2). It includes the + narrow beam and the scattered radiation in the circumsolar region. +dni_farmsdni: np.ndarray + DNI computed by FARMS-DNI (Wm-2). +dni0: np.ndarray + DNI computed by the Lambert law (Wm-2). It only includes the narrow beam + in the circumsolar region. +''' + + + ############### scale tau for the computation of DNI. See Eqs. (3a and 3b) in Xie et al. (2020), iScience. taudni = np.zeros_like(tau) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 09042dd..612394c 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -9,10 +9,9 @@ import numpy as np from farms import farms_dni - def test_farmsdni(): '''Test FARMS-DNI with typical input variables - Check if the DNI computation is between 0 and 1400, + Check if the DNI computation is between 0 and 1400, and larger than the DNI in the narrow beam. ''' From a95e307f9c0f2bae527b8a9b8ccd6275d83754a0 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 15:22:43 -0600 Subject: [PATCH 17/55] test code for Linting --- farms/farms_dni.py | 59 ++++++++++++++++++++++++----------------- tests/test_farmsdni1.py | 7 ++--- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index c59f1dc..f3956dc 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -233,31 +233,42 @@ def Pice(Z, tau, De): Tddp[b18] = (908.66 * np.power(umu0[b18],2.0) - 1869.3 * umu0[b18] + 961.63) * ade[b18] - bde = 0.0000166112*np.power(De,2.0) - 0.00410998*De + 0.352026619 - b19 = (umu0<0.999) & (De>30.0) & (umu0<=0.2419) - Tddp[b19] = (-4.362*np.power(umu0[b19],2.0) - 0.0878*umu0[b19] +1.1218)*bde[b19] - b20 = (umu0<0.999) & (De>30.0) & (umu0>0.2419) & (umu0<=0.3746) - Tddp[b20] = (-49.566*np.power(umu0[b20],2.0) + 28.767*umu0[b20] -3.1299)*bde[b20] - b21 = (umu0<0.999) & (De>30.0) & (umu0>0.3746) & (umu0<=0.4694) - Tddp[b21] = (58.572*np.power(umu0[b21],2.0) - 49.5*umu0[b21] +11.363)*bde[b21] - b22 = (umu0<0.999) & (De>30.0) & (umu0>0.4694) & (umu0<=0.5877) - Tddp[b22] = (62.118*np.power(umu0[b22],2.0) - 63.037*umu0[b22] +16.875)*bde[b22] - b23 = (umu0<0.999) & (De>30.0) & (umu0>0.5877) & (umu0<=0.6691) - Tddp[b23] = (-237.68*np.power(umu0[b23],2.0) + 293.21*umu0[b23] -89.328)*bde[b23] - b24 = (umu0<0.999) & (De>30.0) & (umu0>0.6691) & (umu0<=0.7660) - Tddp[b24] = (1.2051*np.power(umu0[b24],2.0) - 0.7291*umu0[b24] +0.8826)*bde[b24] - b25 = (umu0<0.999) & (De>30.0) & (umu0>0.7660) & (umu0<=0.8480) - Tddp[b25] = (-55.6*np.power(umu0[b25],2.0) + 90.698*umu0[b25] -35.905)*bde[b25] - b26 = (umu0<0.999) & (De>30.0) & (umu0>0.8480) & (umu0<=0.8987) - Tddp[b26] = (-422.36*np.power(umu0[b26],2.0) + 733.97*umu0[b26] -317.89)*bde[b26] - b27 = (umu0<0.999) & (De>30.0) & (umu0>0.8987) & (umu0<=0.9396) - Tddp[b27] = (-457.09*np.power(umu0[b27],2.0) + 831.11*umu0[b27] -376.85)*bde[b27] - b28 = (umu0<0.999) & (De>30.0) & (umu0>0.9396) & (umu0<=0.9702) - Tddp[b28] = (-344.91*np.power(umu0[b28],2.0) + 655.67*umu0[b28] -310.5)*bde[b28] - b29 = (umu0<0.999) & (De>30.0) & (umu0>0.9702) & (umu0<=0.9945) + bde = 0.0000166112 * np.power(De,2.0) - 0.00410998 * De + 0.352026619 + b19 = (umu0 < 0.999) & (De > 30.0) & (umu0 <= 0.2419) + Tddp[b19] = (-4.362 * np.power(umu0[b19],2.0) - 0.0878 * umu0[b19] + + 1.1218) * bde[b19] + b20 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.2419) & (umu0 <= 0.3746) + Tddp[b20] = (-49.566 * np.power(umu0[b20],2.0) + 28.767 * umu0[b20] + - 3.1299) * bde[b20] + b21 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.3746) & (umu0 <= 0.4694) + Tddp[b21] = (58.572 * np.power(umu0[b21],2.0) - 49.5 * umu0[b21] + + 11.363) * bde[b21] + b22 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.4694) & (umu0 <= 0.5877) + Tddp[b22] = (62.118 * np.power(umu0[b22],2.0) - 63.037 * umu0[b22] + + 16.875) * bde[b22] + b23 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.5877) & (umu0 <= 0.6691) + Tddp[b23] = (-237.68 * np.power(umu0[b23],2.0) + 293.21 * umu0[b23] + - 89.328) * bde[b23] + b24 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.6691) & (umu0 <= 0.7660) + Tddp[b24] = (1.2051 * np.power(umu0[b24],2.0) - 0.7291 * umu0[b24] + + 0.8826) * bde[b24] + b25 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.7660) & (umu0 <= 0.8480) + Tddp[b25] = (-55.6 * np.power(umu0[b25],2.0) + 90.698 * umu0[b25] + - 35.905) * bde[b25] + b26 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.8480) & (umu0 <= 0.8987) + Tddp[b26] = (-422.36 * np.power(umu0[b26],2.0) + 733.97 * umu0[b26] + - 317.89) * bde[b26] + b27 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.8987) & (umu0 <= 0.9396) + Tddp[b27] = (-457.09 * np.power(umu0[b27],2.0) + 831.11 * umu0[b27] + - 376.85) * bde[b27] + b28 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9396) & (umu0 <= 0.9702) + Tddp[b28] = (-344.91 * np.power(umu0[b28],2.0) + 655.67 * umu0[b28] + -310.5) * bde[b28] + b29 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9702) & (umu0 <= 0.9945) Tddp[b29] = (622.85*np.power(umu0[b29],2.0) - 1227.6*umu0[b29] +605.97)*bde[b29] - b30 = (umu0<0.999) & (De>30.0) & (umu0>0.9945) - Tddp[b30] = (6309.63*np.power(umu0[b30],2.0) - 12654.78*umu0[b30] +6346.15)*bde[b30] + b30 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9945) + Tddp[b30] = (6309.63 * np.power(umu0[b30],2.0) - 12654.78 * umu0[b30] + + 6346.15) * bde[b30] ###compute Tddcld using Eq.(5) in Yang et al. (2022) a = 1.7686*np.power(umu0,-0.95) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 612394c..34df24c 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -10,9 +10,10 @@ from farms import farms_dni def test_farmsdni(): - '''Test FARMS-DNI with typical input variables - Check if the DNI computation is between 0 and 1400, - and larger than the DNI in the narrow beam. + ''' + Test FARMS-DNI with typical input variables + Check if the DNI computation is between 0 and 1400, + and larger than the DNI in the narrow beam. ''' n = 100 From 3366ad074b4d18e089db4cce1425b380eeb4ba64 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 15:26:08 -0600 Subject: [PATCH 18/55] test code for Linting --- tests/test_farmsdni1.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 34df24c..8577621 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -1,3 +1,5 @@ + + """ PyTest file for FARMS-DNI From c5d90424cf559b5119703086836409e23e9f6f3d Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 15:36:26 -0600 Subject: [PATCH 19/55] test code for Linting --- tests/test_farmsdni1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 8577621..3694699 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -12,6 +12,7 @@ from farms import farms_dni def test_farmsdni(): + ''' Test FARMS-DNI with typical input variables Check if the DNI computation is between 0 and 1400, From 78baf0871a7dbd497b966e86487e7ee0aba510da Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 15:38:51 -0600 Subject: [PATCH 20/55] test code for Linting --- tests/test_farmsdni1.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 3694699..5b75bf7 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -11,14 +11,13 @@ import numpy as np from farms import farms_dni -def test_farmsdni(): +def test_farmsdni(): ''' Test FARMS-DNI with typical input variables Check if the DNI computation is between 0 and 1400, and larger than the DNI in the narrow beam. ''' - n = 100 F0 = np.full(n, 1360.0) tau = np.arange(n) * 0.1 From 9f8b9ccfce05891dd815a01096e7a1175bbf0e53 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 16:48:42 -0600 Subject: [PATCH 21/55] farms_dni for Linting check --- farms/farms_dni.py | 248 ++++++++++++++++++++-------------------- tests/test_farmsdni.py | 11 +- tests/test_farmsdni1.py | 2 - 3 files changed, 132 insertions(+), 129 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index f3956dc..63abbe2 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -98,9 +98,9 @@ def Pwater(Z, tau, De): a1 = tau <= 0.9 * taup Tddcld[a1] = Tddp[a1] * np.tanh(a[a1] * tau[a1]) a2 = (tau > 0.9 * taup) & (tau < taup) - Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + - Tddp[a2] * (np.tanh(b[a2] / np.power(taup[a2],2.0)) - - np.tanh(0.9 * a[a2] * taup[a2])) * + Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + \ + Tddp[a2] * (np.tanh(b[a2] / np.power(taup[a2],2.0)) \ + - np.tanh(0.9 * a[a2] * taup[a2])) * \ (tau[a2] - 0.9 * taup[a2])/(0.1 * taup[a2]) a3 = tau >= taup Tddcld[a3] = Tddp[a3] * np.tanh(b[a3] / np.power(tau[a3],2.0)) @@ -132,38 +132,38 @@ def Pice(Z, tau, De): a8 = (De >= 14.0) & (De < 50.0) & (umu0 < 0.139173) taup[a8] = 0.1 - a9 = (De >= 14.0) & (De < 50.0) & (umu0 >= 0.139173) & + a9 = (De >= 14.0) & (De < 50.0) & (umu0 >= 0.139173) & \ (umu0 < -0.0011 * De + 0.2307) taup[a9] = 0.2 - a10 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0011 * De + 0.2307) & + a10 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0011 * De + 0.2307) & \ (umu0 < -0.0022 * De + 0.3340) taup[a10] = 0.3 - a11 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0022 * De + 0.3340) & + a11 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0022 * De + 0.3340) & \ (umu0<-0.0020*De+0.4096) taup[a11] = 0.4 - a12 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0020 * De + 0.4096) & + a12 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0020 * De + 0.4096) & \ (umu0 < -0.0033 * De + 0.6461) taup[a12] = 0.5 - a13 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0033 * De + 0.6461) & + a13 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0033 * De + 0.6461) & \ (umu0 < -0.0049 * De + 1.0713) taup[a13] = 1.0 a14 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0049 * De + 1.0713) taup[a14] = 1.5 a15 = (De >= 50.0) & (umu0 < -0.0006 * De + 0.2109) taup[a15] = 0.2 - a16 = (De >= 50.0) & (umu0 >= -0.0006 * De + 0.2109) & + a16 = (De >= 50.0) & (umu0 >= -0.0006 * De + 0.2109) & \ (umu0 < -0.0005 * De + 0.2581) taup[a16] = 0.3 - a17 = (De >= 50.0) & (umu0 >= -0.0005 * De + 0.2581) & + a17 = (De >= 50.0) & (umu0 >= -0.0005 * De + 0.2581) & \ (umu0 < -0.0010 * De + 0.3907) taup[a17] = 0.4 - a18 = (De >= 50.0) & (umu0 >= -0.0010 * De + 0.3907) & + a18 = (De >= 50.0) & (umu0 >= -0.0010 * De + 0.3907) & \ (umu0 < -0.0008 * De + 0.4900) taup[a18] = 0.5 - a19 = (De >= 50.0) & (umu0 >= -0.0008 * De + 0.4900) & + a19 = (De >= 50.0) & (umu0 >= -0.0008 * De + 0.4900) & \ (umu0 < -0.0017 * De + 0.8708) taup[a19] = 1.0 - a20 = (De >= 50.0) & (umu0 >= -0.0017 * De + 0.8708) & + a20 = (De >= 50.0) & (umu0 >= -0.0017 * De + 0.8708) & \ (umu0 < -0.0006 * De + 1.0367) taup[a20] = 1.5 a21 = (De >= 50.0) & (umu0 >= -0.0006 * De + 1.0367) @@ -171,7 +171,7 @@ def Pice(Z, tau, De): # Tddp Eq(4) in Yang et al. (2022) Tddp = np.zeros_like(Z) - b1 = (umu0 >= 0.9994) & (De <= 10.0) + b1 = (umu0 >= 0.9994) & (De <= 10.0) Tddp[b1] = 0.12269 b2 = (umu0 >= 0.9994) & (De > 10.0) & (De <= 16.0) Tddp[b2] = 0.0015 * De[b2] + 0.1078 @@ -187,61 +187,61 @@ def Pice(Z, tau, De): ade = -0.000232338 * np.power(De,2.0) + 0.012748726 * De + 0.046745083 b7 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 <= 0.2419) - Tddp[b7] = (-8.454 * np.power(umu0[b7],2.0) + 2.4095 * umu0[b7] + 0.8425) * + Tddp[b7] = (-8.454 * np.power(umu0[b7],2.0) + 2.4095 * umu0[b7] + 0.8425) *\ ade[b7] - b8 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.2419) & + b8 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.2419) &\ (umu0 <= 0.3746) - Tddp[b8] = (-13.528 * np.power(umu0[b8],2.0) + 7.8403 * umu0[b8] -0.1221) + Tddp[b8] = (-13.528 * np.power(umu0[b8],2.0) + 7.8403 * umu0[b8] -0.1221)\ * ade[b8] - b9 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.3746) & + b9 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.3746) &\ (umu0 <= 0.4694) - Tddp[b9] = (19.524 * np.power(umu0[b9],2.0) - 16.5 * umu0[b9] + 4.4612) * + Tddp[b9] = (19.524 * np.power(umu0[b9],2.0) - 16.5 * umu0[b9] + 4.4612) *\ ade[b9] - b10 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.4694) & + b10 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.4694) &\ (umu0 <= 0.5877) - Tddp[b10] = (16.737 * np.power(umu0[b10],2.0) - 17.419 * umu0[b10] + 5.4881) + Tddp[b10] = (16.737 * np.power(umu0[b10],2.0) - 17.419 * umu0[b10] + 5.4881)\ * ade[b10] - b11 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.5877) & + b11 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.5877) &\ (umu0 <= 0.6691) - Tddp[b11] = (-39.493 * np.power(umu0[b11],2.0) + 48.963 * umu0[b11] -14.175) + Tddp[b11] = (-39.493 * np.power(umu0[b11],2.0) + 48.963 * umu0[b11] -14.175)\ * ade[b11] - b12 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.6691) & + b12 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.6691) &\ (umu0 <= 0.7660) - Tddp[b12] = (0.4017 * np.power(umu0[b12],2.0) - 0.243 * umu0[b12] + 0.9609) + Tddp[b12] = (0.4017 * np.power(umu0[b12],2.0) - 0.243 * umu0[b12] + 0.9609)\ *ade[b12] - b13 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.7660) & + b13 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.7660) &\ (umu0 <= 0.8480) - Tddp[b13] = (-11.183 * np.power(umu0[b13],2.0) + 18.126 * umu0[b13] - + Tddp[b13] = (-11.183 * np.power(umu0[b13],2.0) + 18.126 * umu0[b13] - \ 6.3417)*ade[b13] - b14 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8480) & + b14 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8480) & \ (umu0 <= 0.8987) - Tddp[b14] = (-163.36 * np.power(umu0[b14],2.0) + 283.35 * umu0[b14] + Tddp[b14] = (-163.36 * np.power(umu0[b14],2.0) + 283.35 * umu0[b14] \ - 121.91) * ade[b14] - b15 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8987) + b15 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8987) \ & (umu0 <= 0.9396) - Tddp[b15] = (-202.72 * np.power(umu0[b15],2.0) + 368.75 * umu0[b15] + Tddp[b15] = (-202.72 * np.power(umu0[b15],2.0) + 368.75 * umu0[b15] \ - 166.75) * ade[b15] - b16 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9396) + b16 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9396) \ & (umu0 <= 0.9702) - Tddp[b16] = (-181.72 * np.power(umu0[b16],2.0) + 343.59 * umu0[b16] + Tddp[b16] = (-181.72 * np.power(umu0[b16],2.0) + 343.59 * umu0[b16] \ - 161.3)*ade[b16] - b17 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9702) + b17 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9702) \ & (umu0 <= 0.9945) - Tddp[b17] = (127.66 * np.power(umu0[b17],2.0) - 255.73 * umu0[b17] + Tddp[b17] = (127.66 * np.power(umu0[b17],2.0) - 255.73 * umu0[b17] \ + 129.03) * ade[b17] b18 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9945) - Tddp[b18] = (908.66 * np.power(umu0[b18],2.0) - 1869.3 * umu0[b18] + Tddp[b18] = (908.66 * np.power(umu0[b18],2.0) - 1869.3 * umu0[b18] \ + 961.63) * ade[b18] bde = 0.0000166112 * np.power(De,2.0) - 0.00410998 * De + 0.352026619 b19 = (umu0 < 0.999) & (De > 30.0) & (umu0 <= 0.2419) - Tddp[b19] = (-4.362 * np.power(umu0[b19],2.0) - 0.0878 * umu0[b19] + Tddp[b19] = (-4.362 * np.power(umu0[b19],2.0) - 0.0878 * umu0[b19] \ + 1.1218) * bde[b19] b20 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.2419) & (umu0 <= 0.3746) - Tddp[b20] = (-49.566 * np.power(umu0[b20],2.0) + 28.767 * umu0[b20] + Tddp[b20] = (-49.566 * np.power(umu0[b20],2.0) + 28.767 * umu0[b20] \ - 3.1299) * bde[b20] b21 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.3746) & (umu0 <= 0.4694) - Tddp[b21] = (58.572 * np.power(umu0[b21],2.0) - 49.5 * umu0[b21] + Tddp[b21] = (58.572 * np.power(umu0[b21],2.0) - 49.5 * umu0[b21] \ + 11.363) * bde[b21] b22 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.4694) & (umu0 <= 0.5877) Tddp[b22] = (62.118 * np.power(umu0[b22],2.0) - 63.037 * umu0[b22] @@ -265,117 +265,117 @@ def Pice(Z, tau, De): Tddp[b28] = (-344.91 * np.power(umu0[b28],2.0) + 655.67 * umu0[b28] -310.5) * bde[b28] b29 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9702) & (umu0 <= 0.9945) - Tddp[b29] = (622.85*np.power(umu0[b29],2.0) - 1227.6*umu0[b29] +605.97)*bde[b29] + Tddp[b29] = (622.85*np.power(umu0[b29],2.0) - 1227.6*umu0[b29] + +605.97)*bde[b29] b30 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9945) Tddp[b30] = (6309.63 * np.power(umu0[b30],2.0) - 12654.78 * umu0[b30] + 6346.15) * bde[b30] ###compute Tddcld using Eq.(5) in Yang et al. (2022) - a = 1.7686*np.power(umu0,-0.95) - b = 7.117*np.power(umu0,1.9658) + a = 1.7686 * np.power(umu0,-0.95) + b = 7.117 * np.power(umu0,1.9658) Tddcld = np.zeros_like(Z) - a1 = tau<=0.9*taup - Tddcld[a1] = Tddp[a1]*np.tanh(a[a1]*tau[a1]) - a2 = (tau>0.9*taup) & (tau=taup - Tddcld[a3] = Tddp[a3]*np.tanh(b[a3]/np.power(tau[a3],2.0)) + a1 = tau <= 0.9 * taup + Tddcld[a1] = Tddp[a1] * np.tanh(a[a1] * tau[a1]) + a2 = (tau > 0.9 * taup) & (tau < taup) + Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + \ + Tddp[a2] * (np.tanh(b[a2] / np.power(taup[a2],2.0)) \ + - np.tanh(0.9 * a[a2] * taup[a2])) * \ + (tau[a2] - 0.9 * taup[a2]) / (0.1 * taup[a2]) + a3 = tau >= taup + Tddcld[a3] = Tddp[a3] * np.tanh(b[a3] / np.power(tau[a3],2.0)) return Tddcld def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1): + ''' + Fast All-sky Radiation Model for solar applications with direct normal + irradiance (FARMS-DNI) + + References + ----------- + Xie, Y., Sengupta, M., Dudhia, J., 2016. A Fast All-sky Radiation Model for + Solar applications (FARMS): Algorithm and performance evaluation. Sol. Energy + 135, 435-445. + Xie, Y., Sengupta, M., Liu, Y., Long, H., Min, Q., Liu, W., Habte, A., 2020. + A physics-based DNI model assessing all-sky circumsolar radiation. iScience 22, + doi.org/10.1016/j.isci.2020.100893. + Yang, J., Xie, Y., Sengupta, M., Liu, Y., Long, H., 2022. Parameterization of + cloud transmittance for expeditious assessment and forecasting of all-sky DNI. + J. Renewable Sustainable Energy 14, 063703. + + Input data + ----------- + F0: np.ndarray + extraterrestrial solar radiation (Wm-2). + tau : np.ndarray + Cloud optical thickness (cld_opd_dcomp) (unitless). + solar_zenith_angle : np.ndarray + Solar zenith angle (degrees). Must represent the average value over the + integration period (e.g. hourly) under scrutiny. + De: np.ndarray + Effective cloud particle size (diameter, micron). + phase: np.ndarray + Cloud thermodynamic phase (water:1, ice:2) + phase1: np.ndarray + np.where( phase==1 ) + phase2: np.ndarray + np.where( phase==2 ) + Tddclr : np.ndarray + Calculated in REST2. Transmittance of the clear-sky atmosphere for + direct incident and direct outgoing fluxes (dd). + Tddclr = dni / etdirn + Ftotal: np.ndarray + GHI (Wm-2) + F1: np.ndarray + First order solar radiation given in FARMS (Wm-2). See Xie et al. (2016) + for more details. + + Output data + ----------- + Fd: np.ndarray + Direct radiation in the downwelling direction (Wm-2). It includes the + narrow beam and the scattered radiation in the circumsolar region. + dni_farmsdni: np.ndarray + DNI computed by FARMS-DNI (Wm-2). + dni0: np.ndarray + DNI computed by the Lambert law (Wm-2). It only includes the narrow beam + in the circumsolar region. + ''' -''' -Fast All-sky Radiation Model for solar applications with direct normal -irradiance (FARMS-DNI) - -References ------------ -Xie, Y., Sengupta, M., Dudhia, J., 2016. A Fast All-sky Radiation Model for -Solar applications (FARMS): Algorithm and performance evaluation. Sol. Energy - 135, 435-445. -Xie, Y., Sengupta, M., Liu, Y., Long, H., Min, Q., Liu, W., Habte, A., 2020. -A physics-based DNI model assessing all-sky circumsolar radiation. iScience 22, - doi.org/10.1016/j.isci.2020.100893. -Yang, J., Xie, Y., Sengupta, M., Liu, Y., Long, H., 2022. Parameterization of -cloud transmittance for expeditious assessment and forecasting of all-sky DNI. -J. Renewable Sustainable Energy 14, 063703. - -Input data ------------ -F0: np.ndarray - extraterrestrial solar radiation (Wm-2). -tau : np.ndarray - Cloud optical thickness (cld_opd_dcomp) (unitless). -solar_zenith_angle : np.ndarray - Solar zenith angle (degrees). Must represent the average value over the - integration period (e.g. hourly) under scrutiny. -De: np.ndarray - Effective cloud particle size (diameter, micron). -phase: np.ndarray - Cloud thermodynamic phase (water:1, ice:2) -phase1: np.ndarray - np.where( phase==1 ) -phase2: np.ndarray - np.where( phase==2 ) -Tddclr : np.ndarray - Calculated in REST2. Transmittance of the clear-sky atmosphere for - direct incident and direct outgoing fluxes (dd). - Tddclr = dni / etdirn -Ftotal: np.ndarray - GHI (Wm-2) -F1: np.ndarray - First order solar radiation given in FARMS (Wm-2). See Xie et al. (2016) - for more details. - -Output data ------------ -Fd: np.ndarray - Direct radiation in the downwelling direction (Wm-2). It includes the - narrow beam and the scattered radiation in the circumsolar region. -dni_farmsdni: np.ndarray - DNI computed by FARMS-DNI (Wm-2). -dni0: np.ndarray - DNI computed by the Lambert law (Wm-2). It only includes the narrow beam - in the circumsolar region. -''' - - - - ############### scale tau for the computation of DNI. See Eqs. (3a and 3b) in Xie et al. (2020), iScience. + # scale tau for the computation of DNI. See Eqs. (3a and 3b) in Xie et al. (2020), iScience. taudni = np.zeros_like(tau) - a1 = np.where( (phase == 1) & (tau<8.0) ) - a2 = np.where( (phase == 1) & (tau>=8.0) ) - taudni[a1] = ( 0.254825*tau[a1] - 0.00232717*np.power(tau[a1], 2.0) \ - + (5.19320e-06)*np.power(tau[a1], 3.0) )*(1.0+(8.0-tau[a1])*0.07) - taudni[a2] = 0.2*np.power(tau[a2]-8.0, 1.5) + 2.10871 + a1 = np.where( (phase == 1) & (tau < 8.0) ) + a2 = np.where( (phase == 1) & (tau >= 8.0) ) + taudni[a1] = ( 0.254825 * tau[a1] - 0.00232717 * np.power(tau[a1], 2.0) \ + + (5.19320e-06) * np.power(tau[a1], 3.0) ) * \ + (1.0 + (8.0 - tau[a1]) * 0.07) + taudni[a2] = 0.2 * np.power(tau[a2] - 8.0, 1.5) + 2.10871 - b1 = np.where( (phase == 2) & (tau<8.0) ) - b2 = np.where( (phase == 2) & (tau>=8.0) ) - taudni[b1] = 0.345353*tau[b1] - 0.00244671*np.power(tau[b1], 2.0) \ - + (4.74263E-06)*np.power(tau[b1], 3.0) - taudni[b2] = 0.2*np.power(tau[b2]-8.0, 1.5) + 2.91345 - ############### + b1 = np.where( (phase == 2) & (tau < 8.0) ) + b2 = np.where( (phase == 2) & (tau >= 8.0) ) + taudni[b1] = 0.345353 * tau[b1] - 0.00244671 * np.power(tau[b1], 2.0) \ + + (4.74263E-06) * np.power(tau[b1], 3.0) + taudni[b2] = 0.2 * np.power(tau[b2] - 8.0, 1.5) + 2.91345 # compute DNI in the narrow beam. Eq.(S2) in Xie et al. (2020), iScience. - Z = np.arccos(solar_zenith_angle)*180.0/np.pi - dni0 = F0*Tddclr*np.exp(-tau/solar_zenith_angle) + Z = np.arccos(solar_zenith_angle) * 180.0 / np.pi + dni0 = F0 * Tddclr * np.exp(-tau / solar_zenith_angle) - Tddcld0 = np.exp(-taudni/solar_zenith_angle) - Fd0 = solar_zenith_angle*F0*Tddcld0*Tddclr + Tddcld0 = np.exp(-taudni / solar_zenith_angle) + Fd0 = solar_zenith_angle * F0 * Tddcld0 * Tddclr # compute scattered radiation in the circumsolar region. Eq.(S3 and S4) in Xie et al. (2020), iScience. Tddcld1 = TDDP(Z, taudni, De, phase1, phase2) - Fd1 = solar_zenith_angle*F0*Tddclr*Tddcld1 + Fd1 = solar_zenith_angle * F0 * Tddclr * Tddcld1 Fd2 = TDD2(Z, Ftotal, F1 ) # compute DNI using the three components. Eq.(S1) in Xie et al. (2020), iScience. Fd = Fd0 + Fd1 + Fd2 - dni_farmsdni = Fd/solar_zenith_angle + dni_farmsdni = Fd / solar_zenith_angle return Fd, dni_farmsdni, dni0 diff --git a/tests/test_farmsdni.py b/tests/test_farmsdni.py index 6145155..329cdbe 100644 --- a/tests/test_farmsdni.py +++ b/tests/test_farmsdni.py @@ -23,16 +23,21 @@ def test_farmsdni(): F1 = Ftotal*0.7 Fd, dni_farmsdni, dni0 = farms_dni.farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1) + print( dni_farmsdni ) cond1 = [x for x in dni_farmsdni if x<0] cond2 = [x for x in dni_farmsdni if x>=1400] cond3 = [i for i in range(dni_farmsdni.shape[0]) if dni_farmsdni[i] < dni0[i] ] wrong_num = np.size(cond1+cond2+cond3) - assert wrong_num == 0 - - +# assert wrong_num == 0 + return +''' if __name__ == '__main__': execute_pytest() +''' + +test_farmsdni() + diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py index 5b75bf7..4488909 100644 --- a/tests/test_farmsdni1.py +++ b/tests/test_farmsdni1.py @@ -1,5 +1,3 @@ - - """ PyTest file for FARMS-DNI From 38c47983442cc28192f787e03589aa97dd402553 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 17:00:00 -0600 Subject: [PATCH 22/55] farms_dni for Linting check --- farms/farms_dni.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 63abbe2..c20c072 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -23,14 +23,14 @@ def TDD2(Z, Ftotal, F1): ''' - Compute surface reflection that falls in the circumsolar region. + Compute surface reflection that falls in the circumsolar region. A parameterization of Eq. (S4) in Xie et al (2020) is used. ''' # compute the integration of the solid angle a = 5.94991536e-03 b = 5.42116600e-01 c = 331280.9859904468 - muomega = a * np.exp( -np.power(Z-b, 3.0)/c ) + muomega = a * np.exp( -np.power(Z - b, 3.0)/c ) Fd2 = np.cos(Z * np.pi / 180.0) * (Ftotal - F1) * muomega / np.pi return Fd2 @@ -41,8 +41,8 @@ def TDDP(Z, tau, De, phase1, phase2): compute cloud transmittance of DNI for water and ice clouds ''' Tddcld = np.zeros_like(tau) - Tddcld[phase1] = Pwater( Z[phase1],tau[phase1], De[phase1] ) - Tddcld[phase2] = Pice( Z[phase2],tau[phase2], De[phase2] ) + Tddcld[phase1] = Pwater(Z[phase1], tau[phase1], De[phase1]) + Tddcld[phase2] = Pice(Z[phase2], tau[phase2], De[phase2]) return Tddcld @@ -51,7 +51,7 @@ def Pwater(Z, tau, De): ''' Compute cloud transmittance for water clouds ''' - umu0 = np.cos( Z * np.pi / 180.0 ) + umu0 = np.cos(Z * np.pi / 180.0) # taup Eq.(3) in Yang et al. (2022) taup = np.zeros_like(Z) taup[(De < 10.0) & (umu0 < 0.1391)] = 0.1 @@ -73,9 +73,10 @@ def Pwater(Z, tau, De): h[De == 0] = 0.0 Tddp = np.zeros_like(Z) a1 = (umu0 >= 0.0) & (umu0 < 0.342) - Tddp[a1] = h[a1] * (-0.1787 * umu0[a1] * umu0[a1] + 0.2207 * umu0[a1] + 0.977) + Tddp[a1] = h[a1] * (-0.1787 * umu0[a1] * umu0[a1] + 0.2207 * umu0[a1] \ + + 0.977) a2 = (umu0 >= 0.342) & (umu0 < 0.4694) - Tddp[a2] = h[a2] + Tddp[a2] = h[a2] a3 = (umu0 >= 0.4694) & (umu0 < 0.7193) Tddp[a3] = h[a3] * (2.6399 * umu0[a3] * umu0[a3] - 3.2111 * umu0[a3] + 1.9434) a4 = (umu0 >= 0.7193) & (umu0 < 0.8829) From e646c0b34f134ff094f67857ab292890eb3f3b0d Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 17:11:22 -0600 Subject: [PATCH 23/55] farms_dni for Linting check --- farms/farms_dni.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index c20c072..b9ea24f 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -30,7 +30,7 @@ def TDD2(Z, Ftotal, F1): a = 5.94991536e-03 b = 5.42116600e-01 c = 331280.9859904468 - muomega = a * np.exp( -np.power(Z - b, 3.0)/c ) + muomega = a * np.exp(-np.power(Z - b, 3.0) / c) Fd2 = np.cos(Z * np.pi / 180.0) * (Ftotal - F1) * muomega / np.pi return Fd2 @@ -73,8 +73,8 @@ def Pwater(Z, tau, De): h[De == 0] = 0.0 Tddp = np.zeros_like(Z) a1 = (umu0 >= 0.0) & (umu0 < 0.342) - Tddp[a1] = h[a1] * (-0.1787 * umu0[a1] * umu0[a1] + 0.2207 * umu0[a1] \ - + 0.977) + Tddp[a1] = h[a1] * \ + (-0.1787 * umu0[a1] * umu0[a1] + 0.2207 * umu0[a1] + 0.977) a2 = (umu0 >= 0.342) & (umu0 < 0.4694) Tddp[a2] = h[a2] a3 = (umu0 >= 0.4694) & (umu0 < 0.7193) From ee5c4f7af6b3a122c8311715bd5c031bf40050da Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 17:17:20 -0600 Subject: [PATCH 24/55] farms_dni for Linting check --- farms/farms_dni.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index b9ea24f..77d5c78 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -78,15 +78,20 @@ def Pwater(Z, tau, De): a2 = (umu0 >= 0.342) & (umu0 < 0.4694) Tddp[a2] = h[a2] a3 = (umu0 >= 0.4694) & (umu0 < 0.7193) - Tddp[a3] = h[a3] * (2.6399 * umu0[a3] * umu0[a3] - 3.2111 * umu0[a3] + 1.9434) + Tddp[a3] = h[a3] * \ + (2.6399 * umu0[a3] * umu0[a3] - 3.2111 * umu0[a3] + 1.9434) a4 = (umu0 >= 0.7193) & (umu0 < 0.8829) - Tddp[a4] = h[a4] * (-0.224 * umu0[a4] * umu0[a4] + 0.0835 * umu0[a4] + 1.056) + Tddp[a4] = h[a4] * \ + (-0.224 * umu0[a4] * umu0[a4] + 0.0835 * umu0[a4] + 1.056) a5 = (umu0 >= 0.8829) & (umu0 < 0.9396) - Tddp[a5] = h[a5] * (-94.381 * umu0[a5] * umu0[a5] + 170.32 * umu0[a5] - 75.843) + Tddp[a5] = h[a5] * \ + (-94.381 * umu0[a5] * umu0[a5] + 170.32 * umu0[a5] - 75.843) a6 = (umu0 >= 0.9396) & (umu0 < 0.9945) - Tddp[a6] = h[a6] * (-12.794 * umu0[a6] * umu0[a6] + 22.686 * umu0[a6] - 8.9392) + Tddp[a6] = h[a6] * \ + (-12.794 * umu0[a6] * umu0[a6] + 22.686 * umu0[a6] - 8.9392) a7 = (umu0 >= 0.9945) & (umu0 < 0.999) - Tddp[a7] = h[a7]*(11248.61 * umu0[a7] * umu0[a7] - 22441.07 * umu0[a7] + 11193.59) + Tddp[a7] = h[a7] * \ + (11248.61 * umu0[a7] * umu0[a7] - 22441.07 * umu0[a7] + 11193.59) a8 = umu0 >= 0.999 Tddp[a8] = 0.76 * h[a8] @@ -99,10 +104,9 @@ def Pwater(Z, tau, De): a1 = tau <= 0.9 * taup Tddcld[a1] = Tddp[a1] * np.tanh(a[a1] * tau[a1]) a2 = (tau > 0.9 * taup) & (tau < taup) - Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + \ - Tddp[a2] * (np.tanh(b[a2] / np.power(taup[a2],2.0)) \ - - np.tanh(0.9 * a[a2] * taup[a2])) * \ - (tau[a2] - 0.9 * taup[a2])/(0.1 * taup[a2]) + Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + Tddp[a2] * \ + (np.tanh(b[a2] / np.power(taup[a2],2.0)) - np.tanh(0.9 * a[a2] * taup[a2]))\ + * (tau[a2] - 0.9 * taup[a2])/(0.1 * taup[a2]) a3 = tau >= taup Tddcld[a3] = Tddp[a3] * np.tanh(b[a3] / np.power(tau[a3],2.0)) From 100a5160d7fa52821c60cfd1a85d019c184c3639 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 17:27:17 -0600 Subject: [PATCH 25/55] farms_dni for Linting check --- farms/farms_dni.py | 70 +++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 77d5c78..e4eba86 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -96,19 +96,19 @@ def Pwater(Z, tau, De): Tddp[a8] = 0.76 * h[a8] # Eq.(6) in Yang et al. (2022) - a = 2.0339 * np.power( umu0, -0.927 ) - b = 6.6421 * np.power( umu0, 2.0672 ) + a = 2.0339 * np.power(umu0, -0.927) + b = 6.6421 * np.power(umu0, 2.0672) # compute Tddcld using Eq.(5) in Yang et al. (2022) Tddcld = np.zeros_like(Z) a1 = tau <= 0.9 * taup Tddcld[a1] = Tddp[a1] * np.tanh(a[a1] * tau[a1]) a2 = (tau > 0.9 * taup) & (tau < taup) + temp = np.tanh(b[a2] / np.power(taup[a2],2.0)) - np.tanh(0.9 * a[a2] * taup[a2]) Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + Tddp[a2] * \ - (np.tanh(b[a2] / np.power(taup[a2],2.0)) - np.tanh(0.9 * a[a2] * taup[a2]))\ - * (tau[a2] - 0.9 * taup[a2])/(0.1 * taup[a2]) + temp * (tau[a2] - 0.9 * taup[a2])/(0.1 * taup[a2]) a3 = tau >= taup - Tddcld[a3] = Tddp[a3] * np.tanh(b[a3] / np.power(tau[a3],2.0)) + Tddcld[a3] = Tddp[a3] * np.tanh(b[a3] / np.power(tau[a3], 2.0)) return Tddcld @@ -117,7 +117,7 @@ def Pice(Z, tau, De): ''' Compute cloud transmittance for ice clouds ''' - umu0 = np.cos( Z * np.pi / 180.0 ) + umu0 = np.cos(Z * np.pi / 180.0) # taup Eq.(3) in Yang et al. (2022) taup = np.zeros_like(Z) a1 = (De >= 5.0) & (De < 14.0) & (umu0 < 0.1391) @@ -144,7 +144,7 @@ def Pice(Z, tau, De): (umu0 < -0.0022 * De + 0.3340) taup[a10] = 0.3 a11 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0022 * De + 0.3340) & \ - (umu0<-0.0020*De+0.4096) + (umu0 < -0.0020 * De + 0.4096) taup[a11] = 0.4 a12 = (De >= 14.0) & (De < 50.0) & (umu0 >= -0.0020 * De + 0.4096) & \ (umu0 < -0.0033 * De + 0.6461) @@ -186,94 +186,94 @@ def Pice(Z, tau, De): b4 = (umu0 < 0.9396) & (De <= 10.0) Tddp[b4] = 0.14991 b5 = (umu0 < 0.9945) & (umu0 >= 0.9396) & (De <= 10.0) - Tddp[b5] = -4.5171 * np.power(umu0[b5],2.0) + 8.3056 * umu0[b5] - 3.6476 + Tddp[b5] = -4.5171 * np.power(umu0[b5], 2.0) + 8.3056 * umu0[b5] - 3.6476 b6 = (umu0 >= 0.9945) & (umu0 < 0.9994) & (De <= 10.0) - Tddp[b6] = 298.45 * np.power(umu0[b6],2.0) - 601.33 * umu0[b6] + 303.04 + Tddp[b6] = 298.45 * np.power(umu0[b6], 2.0) - 601.33 * umu0[b6] + 303.04 - ade = -0.000232338 * np.power(De,2.0) + 0.012748726 * De + 0.046745083 + ade = -0.000232338 * np.power(De, 2.0) + 0.012748726 * De + 0.046745083 b7 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 <= 0.2419) - Tddp[b7] = (-8.454 * np.power(umu0[b7],2.0) + 2.4095 * umu0[b7] + 0.8425) *\ + Tddp[b7] = (-8.454 * np.power(umu0[b7], 2.0) + 2.4095 * umu0[b7] + 0.8425) *\ ade[b7] b8 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.2419) &\ (umu0 <= 0.3746) - Tddp[b8] = (-13.528 * np.power(umu0[b8],2.0) + 7.8403 * umu0[b8] -0.1221)\ + Tddp[b8] = (-13.528 * np.power(umu0[b8], 2.0) + 7.8403 * umu0[b8] -0.1221)\ * ade[b8] b9 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.3746) &\ (umu0 <= 0.4694) - Tddp[b9] = (19.524 * np.power(umu0[b9],2.0) - 16.5 * umu0[b9] + 4.4612) *\ + Tddp[b9] = (19.524 * np.power(umu0[b9], 2.0) - 16.5 * umu0[b9] + 4.4612) *\ ade[b9] b10 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.4694) &\ (umu0 <= 0.5877) - Tddp[b10] = (16.737 * np.power(umu0[b10],2.0) - 17.419 * umu0[b10] + 5.4881)\ + Tddp[b10] = (16.737 * np.power(umu0[b10], 2.0) - 17.419 * umu0[b10] + 5.4881)\ * ade[b10] b11 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.5877) &\ (umu0 <= 0.6691) - Tddp[b11] = (-39.493 * np.power(umu0[b11],2.0) + 48.963 * umu0[b11] -14.175)\ + Tddp[b11] = (-39.493 * np.power(umu0[b11], 2.0) + 48.963 * umu0[b11] -14.175)\ * ade[b11] b12 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.6691) &\ (umu0 <= 0.7660) - Tddp[b12] = (0.4017 * np.power(umu0[b12],2.0) - 0.243 * umu0[b12] + 0.9609)\ + Tddp[b12] = (0.4017 * np.power(umu0[b12], 2.0) - 0.243 * umu0[b12] + 0.9609)\ *ade[b12] b13 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.7660) &\ (umu0 <= 0.8480) - Tddp[b13] = (-11.183 * np.power(umu0[b13],2.0) + 18.126 * umu0[b13] - \ + Tddp[b13] = (-11.183 * np.power(umu0[b13], 2.0) + 18.126 * umu0[b13] - \ 6.3417)*ade[b13] b14 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8480) & \ (umu0 <= 0.8987) - Tddp[b14] = (-163.36 * np.power(umu0[b14],2.0) + 283.35 * umu0[b14] \ + Tddp[b14] = (-163.36 * np.power(umu0[b14], 2.0) + 283.35 * umu0[b14] \ - 121.91) * ade[b14] b15 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8987) \ & (umu0 <= 0.9396) - Tddp[b15] = (-202.72 * np.power(umu0[b15],2.0) + 368.75 * umu0[b15] \ + Tddp[b15] = (-202.72 * np.power(umu0[b15], 2.0) + 368.75 * umu0[b15] \ - 166.75) * ade[b15] b16 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9396) \ & (umu0 <= 0.9702) - Tddp[b16] = (-181.72 * np.power(umu0[b16],2.0) + 343.59 * umu0[b16] \ + Tddp[b16] = (-181.72 * np.power(umu0[b16], 2.0) + 343.59 * umu0[b16] \ - 161.3)*ade[b16] b17 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9702) \ & (umu0 <= 0.9945) - Tddp[b17] = (127.66 * np.power(umu0[b17],2.0) - 255.73 * umu0[b17] \ + Tddp[b17] = (127.66 * np.power(umu0[b17], 2.0) - 255.73 * umu0[b17] \ + 129.03) * ade[b17] b18 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9945) - Tddp[b18] = (908.66 * np.power(umu0[b18],2.0) - 1869.3 * umu0[b18] \ + Tddp[b18] = (908.66 * np.power(umu0[b18], 2.0) - 1869.3 * umu0[b18] \ + 961.63) * ade[b18] - bde = 0.0000166112 * np.power(De,2.0) - 0.00410998 * De + 0.352026619 + bde = 0.0000166112 * np.power(De, 2.0) - 0.00410998 * De + 0.352026619 b19 = (umu0 < 0.999) & (De > 30.0) & (umu0 <= 0.2419) - Tddp[b19] = (-4.362 * np.power(umu0[b19],2.0) - 0.0878 * umu0[b19] \ + Tddp[b19] = (-4.362 * np.power(umu0[b19], 2.0) - 0.0878 * umu0[b19] \ + 1.1218) * bde[b19] b20 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.2419) & (umu0 <= 0.3746) - Tddp[b20] = (-49.566 * np.power(umu0[b20],2.0) + 28.767 * umu0[b20] \ + Tddp[b20] = (-49.566 * np.power(umu0[b20], 2.0) + 28.767 * umu0[b20] \ - 3.1299) * bde[b20] b21 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.3746) & (umu0 <= 0.4694) - Tddp[b21] = (58.572 * np.power(umu0[b21],2.0) - 49.5 * umu0[b21] \ + Tddp[b21] = (58.572 * np.power(umu0[b21], 2.0) - 49.5 * umu0[b21] \ + 11.363) * bde[b21] b22 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.4694) & (umu0 <= 0.5877) - Tddp[b22] = (62.118 * np.power(umu0[b22],2.0) - 63.037 * umu0[b22] + Tddp[b22] = (62.118 * np.power(umu0[b22], 2.0) - 63.037 * umu0[b22] + 16.875) * bde[b22] b23 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.5877) & (umu0 <= 0.6691) - Tddp[b23] = (-237.68 * np.power(umu0[b23],2.0) + 293.21 * umu0[b23] + Tddp[b23] = (-237.68 * np.power(umu0[b23], 2.0) + 293.21 * umu0[b23] - 89.328) * bde[b23] b24 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.6691) & (umu0 <= 0.7660) - Tddp[b24] = (1.2051 * np.power(umu0[b24],2.0) - 0.7291 * umu0[b24] + Tddp[b24] = (1.2051 * np.power(umu0[b24], 2.0) - 0.7291 * umu0[b24] + 0.8826) * bde[b24] b25 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.7660) & (umu0 <= 0.8480) - Tddp[b25] = (-55.6 * np.power(umu0[b25],2.0) + 90.698 * umu0[b25] + Tddp[b25] = (-55.6 * np.power(umu0[b25], 2.0) + 90.698 * umu0[b25] - 35.905) * bde[b25] b26 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.8480) & (umu0 <= 0.8987) - Tddp[b26] = (-422.36 * np.power(umu0[b26],2.0) + 733.97 * umu0[b26] + Tddp[b26] = (-422.36 * np.power(umu0[b26], 2.0) + 733.97 * umu0[b26] - 317.89) * bde[b26] b27 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.8987) & (umu0 <= 0.9396) - Tddp[b27] = (-457.09 * np.power(umu0[b27],2.0) + 831.11 * umu0[b27] + Tddp[b27] = (-457.09 * np.power(umu0[b27], 2.0) + 831.11 * umu0[b27] - 376.85) * bde[b27] b28 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9396) & (umu0 <= 0.9702) - Tddp[b28] = (-344.91 * np.power(umu0[b28],2.0) + 655.67 * umu0[b28] + Tddp[b28] = (-344.91 * np.power(umu0[b28], 2.0) + 655.67 * umu0[b28] -310.5) * bde[b28] b29 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9702) & (umu0 <= 0.9945) - Tddp[b29] = (622.85*np.power(umu0[b29],2.0) - 1227.6*umu0[b29] + Tddp[b29] = (622.85*np.power(umu0[b29], 2.0) - 1227.6*umu0[b29] +605.97)*bde[b29] b30 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9945) - Tddp[b30] = (6309.63 * np.power(umu0[b30],2.0) - 12654.78 * umu0[b30] + Tddp[b30] = (6309.63 * np.power(umu0[b30], 2.0) - 12654.78 * umu0[b30] + 6346.15) * bde[b30] ###compute Tddcld using Eq.(5) in Yang et al. (2022) From 5fa403cec1bc3ab0e376c161d8b8ee0eb0a2da57 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 17:40:14 -0600 Subject: [PATCH 26/55] farms_dni for Linting check --- farms/farms_dni.py | 116 +++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 51 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index e4eba86..b2401e2 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -104,9 +104,10 @@ def Pwater(Z, tau, De): a1 = tau <= 0.9 * taup Tddcld[a1] = Tddp[a1] * np.tanh(a[a1] * tau[a1]) a2 = (tau > 0.9 * taup) & (tau < taup) - temp = np.tanh(b[a2] / np.power(taup[a2],2.0)) - np.tanh(0.9 * a[a2] * taup[a2]) + temp = np.tanh(b[a2] / np.power(taup[a2], 2.0)) - \ + np.tanh(0.9 * a[a2] * taup[a2]) Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + Tddp[a2] * \ - temp * (tau[a2] - 0.9 * taup[a2])/(0.1 * taup[a2]) + temp * (tau[a2] - 0.9 * taup[a2]) / (0.1 * taup[a2]) a3 = tau >= taup Tddcld[a3] = Tddp[a3] * np.tanh(b[a3] / np.power(tau[a3], 2.0)) @@ -191,94 +192,107 @@ def Pice(Z, tau, De): Tddp[b6] = 298.45 * np.power(umu0[b6], 2.0) - 601.33 * umu0[b6] + 303.04 ade = -0.000232338 * np.power(De, 2.0) + 0.012748726 * De + 0.046745083 - b7 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 <= 0.2419) + b7 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & \ + (umu0 <= 0.2419) Tddp[b7] = (-8.454 * np.power(umu0[b7], 2.0) + 2.4095 * umu0[b7] + 0.8425) *\ - ade[b7] + ade[b7] b8 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.2419) &\ - (umu0 <= 0.3746) + (umu0 <= 0.3746) Tddp[b8] = (-13.528 * np.power(umu0[b8], 2.0) + 7.8403 * umu0[b8] -0.1221)\ - * ade[b8] + * ade[b8] b9 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.3746) &\ - (umu0 <= 0.4694) + (umu0 <= 0.4694) Tddp[b9] = (19.524 * np.power(umu0[b9], 2.0) - 16.5 * umu0[b9] + 4.4612) *\ - ade[b9] + ade[b9] b10 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.4694) &\ - (umu0 <= 0.5877) + (umu0 <= 0.5877) Tddp[b10] = (16.737 * np.power(umu0[b10], 2.0) - 17.419 * umu0[b10] + 5.4881)\ - * ade[b10] + * ade[b10] b11 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.5877) &\ - (umu0 <= 0.6691) + (umu0 <= 0.6691) Tddp[b11] = (-39.493 * np.power(umu0[b11], 2.0) + 48.963 * umu0[b11] -14.175)\ - * ade[b11] + * ade[b11] b12 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.6691) &\ - (umu0 <= 0.7660) + (umu0 <= 0.7660) Tddp[b12] = (0.4017 * np.power(umu0[b12], 2.0) - 0.243 * umu0[b12] + 0.9609)\ - *ade[b12] + *ade[b12] b13 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.7660) &\ - (umu0 <= 0.8480) + (umu0 <= 0.8480) Tddp[b13] = (-11.183 * np.power(umu0[b13], 2.0) + 18.126 * umu0[b13] - \ - 6.3417)*ade[b13] + 6.3417)*ade[b13] b14 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8480) & \ - (umu0 <= 0.8987) + (umu0 <= 0.8987) Tddp[b14] = (-163.36 * np.power(umu0[b14], 2.0) + 283.35 * umu0[b14] \ - - 121.91) * ade[b14] + - 121.91) * ade[b14] b15 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8987) \ - & (umu0 <= 0.9396) + & (umu0 <= 0.9396) Tddp[b15] = (-202.72 * np.power(umu0[b15], 2.0) + 368.75 * umu0[b15] \ - - 166.75) * ade[b15] + - 166.75) * ade[b15] b16 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9396) \ - & (umu0 <= 0.9702) + & (umu0 <= 0.9702) Tddp[b16] = (-181.72 * np.power(umu0[b16], 2.0) + 343.59 * umu0[b16] \ - - 161.3)*ade[b16] + - 161.3)*ade[b16] b17 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9702) \ - & (umu0 <= 0.9945) + & (umu0 <= 0.9945) Tddp[b17] = (127.66 * np.power(umu0[b17], 2.0) - 255.73 * umu0[b17] \ - + 129.03) * ade[b17] + + 129.03) * ade[b17] b18 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9945) Tddp[b18] = (908.66 * np.power(umu0[b18], 2.0) - 1869.3 * umu0[b18] \ - + 961.63) * ade[b18] + + 961.63) * ade[b18] bde = 0.0000166112 * np.power(De, 2.0) - 0.00410998 * De + 0.352026619 b19 = (umu0 < 0.999) & (De > 30.0) & (umu0 <= 0.2419) - Tddp[b19] = (-4.362 * np.power(umu0[b19], 2.0) - 0.0878 * umu0[b19] \ - + 1.1218) * bde[b19] + Tddp[b19] = \ + (-4.362 * np.power(umu0[b19], 2.0) - 0.0878 * umu0[b19] + 1.1218) *\ + bde[b19] b20 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.2419) & (umu0 <= 0.3746) - Tddp[b20] = (-49.566 * np.power(umu0[b20], 2.0) + 28.767 * umu0[b20] \ - - 3.1299) * bde[b20] + Tddp[b20] = \ + (-49.566 * np.power(umu0[b20], 2.0) + 28.767 * umu0[b20] - 3.1299) *\ + bde[b20] b21 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.3746) & (umu0 <= 0.4694) - Tddp[b21] = (58.572 * np.power(umu0[b21], 2.0) - 49.5 * umu0[b21] \ - + 11.363) * bde[b21] + Tddp[b21] = \ + (58.572 * np.power(umu0[b21], 2.0) - 49.5 * umu0[b21] + 11.363) *\ + bde[b21] b22 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.4694) & (umu0 <= 0.5877) - Tddp[b22] = (62.118 * np.power(umu0[b22], 2.0) - 63.037 * umu0[b22] - + 16.875) * bde[b22] + Tddp[b22] = \ + (62.118 * np.power(umu0[b22], 2.0) - 63.037 * umu0[b22] + 16.875) *\ + bde[b22] b23 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.5877) & (umu0 <= 0.6691) - Tddp[b23] = (-237.68 * np.power(umu0[b23], 2.0) + 293.21 * umu0[b23] - - 89.328) * bde[b23] + Tddp[b23] = \ + (-237.68 * np.power(umu0[b23], 2.0) + 293.21 * umu0[b23] - 89.328) *\ + bde[b23] b24 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.6691) & (umu0 <= 0.7660) - Tddp[b24] = (1.2051 * np.power(umu0[b24], 2.0) - 0.7291 * umu0[b24] - + 0.8826) * bde[b24] + Tddp[b24] = \ + (1.2051 * np.power(umu0[b24], 2.0) - 0.7291 * umu0[b24] + 0.8826) *\ + bde[b24] b25 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.7660) & (umu0 <= 0.8480) - Tddp[b25] = (-55.6 * np.power(umu0[b25], 2.0) + 90.698 * umu0[b25] - - 35.905) * bde[b25] + Tddp[b25] = \ + (-55.6 * np.power(umu0[b25], 2.0) + 90.698 * umu0[b25] - 35.905) *\ + bde[b25] b26 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.8480) & (umu0 <= 0.8987) - Tddp[b26] = (-422.36 * np.power(umu0[b26], 2.0) + 733.97 * umu0[b26] - - 317.89) * bde[b26] + Tddp[b26] = \ + (-422.36 * np.power(umu0[b26], 2.0) + 733.97 * umu0[b26] - 317.89) *\ + bde[b26] b27 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.8987) & (umu0 <= 0.9396) - Tddp[b27] = (-457.09 * np.power(umu0[b27], 2.0) + 831.11 * umu0[b27] - - 376.85) * bde[b27] + Tddp[b27] = \ + (-457.09 * np.power(umu0[b27], 2.0) + 831.11 * umu0[b27] - 376.85) *\ + bde[b27] b28 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9396) & (umu0 <= 0.9702) - Tddp[b28] = (-344.91 * np.power(umu0[b28], 2.0) + 655.67 * umu0[b28] - -310.5) * bde[b28] + Tddp[b28] = \ + (-344.91 * np.power(umu0[b28], 2.0) + 655.67 * umu0[b28] -310.5) *\ + bde[b28] b29 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9702) & (umu0 <= 0.9945) - Tddp[b29] = (622.85*np.power(umu0[b29], 2.0) - 1227.6*umu0[b29] - +605.97)*bde[b29] + Tddp[b29] = \ + (622.85*np.power(umu0[b29], 2.0) - 1227.6*umu0[b29] +605.97) *\ + bde[b29] b30 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9945) - Tddp[b30] = (6309.63 * np.power(umu0[b30], 2.0) - 12654.78 * umu0[b30] - + 6346.15) * bde[b30] + Tddp[b30] = \ + (6309.63 * np.power(umu0[b30], 2.0) - 12654.78 * umu0[b30] + 6346.15) *\ + bde[b30] ###compute Tddcld using Eq.(5) in Yang et al. (2022) - a = 1.7686 * np.power(umu0,-0.95) - b = 7.117 * np.power(umu0,1.9658) + a = 1.7686 * np.power(umu0, -0.95) + b = 7.117 * np.power(umu0, 1.9658) Tddcld = np.zeros_like(Z) a1 = tau <= 0.9 * taup From 7837fb82e9c8341f1cadeb6ed18af75ea35e335a Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 18:09:59 -0600 Subject: [PATCH 27/55] farms_dni for Linting check --- farms/farms_dni.py | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index b2401e2..3e0d481 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -194,11 +194,13 @@ def Pice(Z, tau, De): ade = -0.000232338 * np.power(De, 2.0) + 0.012748726 * De + 0.046745083 b7 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & \ (umu0 <= 0.2419) - Tddp[b7] = (-8.454 * np.power(umu0[b7], 2.0) + 2.4095 * umu0[b7] + 0.8425) *\ + Tddp[b7] = \ + (-8.454 * np.power(umu0[b7], 2.0) + 2.4095 * umu0[b7] + 0.8425) *\ ade[b7] b8 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.2419) &\ (umu0 <= 0.3746) - Tddp[b8] = (-13.528 * np.power(umu0[b8], 2.0) + 7.8403 * umu0[b8] -0.1221)\ + Tddp[b8] = \ + (-13.528 * np.power(umu0[b8], 2.0) + 7.8403 * umu0[b8] -0.1221)\ * ade[b8] b9 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.3746) &\ (umu0 <= 0.4694) @@ -206,39 +208,48 @@ def Pice(Z, tau, De): ade[b9] b10 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.4694) &\ (umu0 <= 0.5877) - Tddp[b10] = (16.737 * np.power(umu0[b10], 2.0) - 17.419 * umu0[b10] + 5.4881)\ + Tddp[b10] = \ + (16.737 * np.power(umu0[b10], 2.0) - 17.419 * umu0[b10] + 5.4881)\ * ade[b10] b11 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.5877) &\ (umu0 <= 0.6691) - Tddp[b11] = (-39.493 * np.power(umu0[b11], 2.0) + 48.963 * umu0[b11] -14.175)\ + Tddp[b11] = \ + (-39.493 * np.power(umu0[b11], 2.0) + 48.963 * umu0[b11] -14.175)\ * ade[b11] b12 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.6691) &\ (umu0 <= 0.7660) - Tddp[b12] = (0.4017 * np.power(umu0[b12], 2.0) - 0.243 * umu0[b12] + 0.9609)\ + Tddp[b12] = \ + (0.4017 * np.power(umu0[b12], 2.0) - 0.243 * umu0[b12] + 0.9609)\ *ade[b12] b13 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.7660) &\ (umu0 <= 0.8480) - Tddp[b13] = (-11.183 * np.power(umu0[b13], 2.0) + 18.126 * umu0[b13] - \ - 6.3417)*ade[b13] + Tddp[b13] = \ + (-11.183 * np.power(umu0[b13], 2.0) + 18.126 * umu0[b13] - 6.3417) *\ + ade[b13] b14 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8480) & \ (umu0 <= 0.8987) - Tddp[b14] = (-163.36 * np.power(umu0[b14], 2.0) + 283.35 * umu0[b14] \ - - 121.91) * ade[b14] + Tddp[b14] = \ + (-163.36 * np.power(umu0[b14], 2.0) + 283.35 * umu0[b14] - 121.91) *\ + ade[b14] b15 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8987) \ & (umu0 <= 0.9396) - Tddp[b15] = (-202.72 * np.power(umu0[b15], 2.0) + 368.75 * umu0[b15] \ - - 166.75) * ade[b15] + Tddp[b15] = \ + (-202.72 * np.power(umu0[b15], 2.0) + 368.75 * umu0[b15] - 166.75) *\ + ade[b15] b16 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9396) \ & (umu0 <= 0.9702) - Tddp[b16] = (-181.72 * np.power(umu0[b16], 2.0) + 343.59 * umu0[b16] \ - - 161.3)*ade[b16] + Tddp[b16] = \ + (-181.72 * np.power(umu0[b16], 2.0) + 343.59 * umu0[b16] - 161.3) *\ + ade[b16] b17 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9702) \ & (umu0 <= 0.9945) - Tddp[b17] = (127.66 * np.power(umu0[b17], 2.0) - 255.73 * umu0[b17] \ - + 129.03) * ade[b17] + Tddp[b17] = \ + (127.66 * np.power(umu0[b17], 2.0) - 255.73 * umu0[b17] + 129.03) *\ + ade[b17] b18 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9945) - Tddp[b18] = (908.66 * np.power(umu0[b18], 2.0) - 1869.3 * umu0[b18] \ - + 961.63) * ade[b18] + Tddp[b18] = \ + (908.66 * np.power(umu0[b18], 2.0) - 1869.3 * umu0[b18] + 961.63) *\ + ade[b18] bde = 0.0000166112 * np.power(De, 2.0) - 0.00410998 * De + 0.352026619 b19 = (umu0 < 0.999) & (De > 30.0) & (umu0 <= 0.2419) From 9bb4df801b832c3ac20f9bb15591090c01a3f9b8 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 18:19:03 -0600 Subject: [PATCH 28/55] farms_dni for Linting check --- farms/farms_dni.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 3e0d481..71073c9 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -200,7 +200,7 @@ def Pice(Z, tau, De): b8 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.2419) &\ (umu0 <= 0.3746) Tddp[b8] = \ - (-13.528 * np.power(umu0[b8], 2.0) + 7.8403 * umu0[b8] -0.1221)\ + (-13.528 * np.power(umu0[b8], 2.0) + 7.8403 * umu0[b8] - 0.1221) \ * ade[b8] b9 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.3746) &\ (umu0 <= 0.4694) @@ -214,13 +214,13 @@ def Pice(Z, tau, De): b11 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.5877) &\ (umu0 <= 0.6691) Tddp[b11] = \ - (-39.493 * np.power(umu0[b11], 2.0) + 48.963 * umu0[b11] -14.175)\ + (-39.493 * np.power(umu0[b11], 2.0) + 48.963 * umu0[b11] - 14.175)\ * ade[b11] b12 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.6691) &\ (umu0 <= 0.7660) Tddp[b12] = \ (0.4017 * np.power(umu0[b12], 2.0) - 0.243 * umu0[b12] + 0.9609)\ - *ade[b12] + * ade[b12] b13 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.7660) &\ (umu0 <= 0.8480) Tddp[b13] = \ @@ -229,13 +229,13 @@ def Pice(Z, tau, De): b14 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8480) & \ (umu0 <= 0.8987) Tddp[b14] = \ - (-163.36 * np.power(umu0[b14], 2.0) + 283.35 * umu0[b14] - 121.91) *\ - ade[b14] + (-163.36 * np.power(umu0[b14], 2.0) + 283.35 * umu0[b14] - 121.91)\ + * ade[b14] b15 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8987) \ & (umu0 <= 0.9396) Tddp[b15] = \ - (-202.72 * np.power(umu0[b15], 2.0) + 368.75 * umu0[b15] - 166.75) *\ - ade[b15] + (-202.72 * np.power(umu0[b15], 2.0) + 368.75 * umu0[b15] - 166.75) \ + * ade[b15] b16 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9396) \ & (umu0 <= 0.9702) Tddp[b16] = \ @@ -245,17 +245,17 @@ def Pice(Z, tau, De): & (umu0 <= 0.9945) Tddp[b17] = \ (127.66 * np.power(umu0[b17], 2.0) - 255.73 * umu0[b17] + 129.03) *\ - ade[b17] + ade[b17] b18 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9945) Tddp[b18] = \ (908.66 * np.power(umu0[b18], 2.0) - 1869.3 * umu0[b18] + 961.63) *\ - ade[b18] + ade[b18] bde = 0.0000166112 * np.power(De, 2.0) - 0.00410998 * De + 0.352026619 b19 = (umu0 < 0.999) & (De > 30.0) & (umu0 <= 0.2419) Tddp[b19] = \ (-4.362 * np.power(umu0[b19], 2.0) - 0.0878 * umu0[b19] + 1.1218) *\ - bde[b19] + bde[b19] b20 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.2419) & (umu0 <= 0.3746) Tddp[b20] = \ (-49.566 * np.power(umu0[b20], 2.0) + 28.767 * umu0[b20] - 3.1299) *\ From 8e46284e4ea71cf5f5079bee598e23284742708a Mon Sep 17 00:00:00 2001 From: xieyupku Date: Fri, 24 Mar 2023 18:24:12 -0600 Subject: [PATCH 29/55] farms_dni for Linting check --- farms/farms_dni.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 71073c9..4dd3afd 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -229,13 +229,13 @@ def Pice(Z, tau, De): b14 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8480) & \ (umu0 <= 0.8987) Tddp[b14] = \ - (-163.36 * np.power(umu0[b14], 2.0) + 283.35 * umu0[b14] - 121.91)\ - * ade[b14] + (-163.36 * np.power(umu0[b14], 2.0) + 283.35 * umu0[b14] - 121.91) *\ + ade[b14] b15 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8987) \ & (umu0 <= 0.9396) Tddp[b15] = \ - (-202.72 * np.power(umu0[b15], 2.0) + 368.75 * umu0[b15] - 166.75) \ - * ade[b15] + (-202.72 * np.power(umu0[b15], 2.0) + 368.75 * umu0[b15] - 166.75) *\ + ade[b15] b16 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9396) \ & (umu0 <= 0.9702) Tddp[b16] = \ @@ -259,31 +259,31 @@ def Pice(Z, tau, De): b20 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.2419) & (umu0 <= 0.3746) Tddp[b20] = \ (-49.566 * np.power(umu0[b20], 2.0) + 28.767 * umu0[b20] - 3.1299) *\ - bde[b20] + bde[b20] b21 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.3746) & (umu0 <= 0.4694) Tddp[b21] = \ (58.572 * np.power(umu0[b21], 2.0) - 49.5 * umu0[b21] + 11.363) *\ - bde[b21] + bde[b21] b22 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.4694) & (umu0 <= 0.5877) Tddp[b22] = \ (62.118 * np.power(umu0[b22], 2.0) - 63.037 * umu0[b22] + 16.875) *\ - bde[b22] + bde[b22] b23 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.5877) & (umu0 <= 0.6691) Tddp[b23] = \ (-237.68 * np.power(umu0[b23], 2.0) + 293.21 * umu0[b23] - 89.328) *\ - bde[b23] + bde[b23] b24 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.6691) & (umu0 <= 0.7660) Tddp[b24] = \ (1.2051 * np.power(umu0[b24], 2.0) - 0.7291 * umu0[b24] + 0.8826) *\ - bde[b24] + bde[b24] b25 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.7660) & (umu0 <= 0.8480) Tddp[b25] = \ (-55.6 * np.power(umu0[b25], 2.0) + 90.698 * umu0[b25] - 35.905) *\ - bde[b25] + bde[b25] b26 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.8480) & (umu0 <= 0.8987) Tddp[b26] = \ (-422.36 * np.power(umu0[b26], 2.0) + 733.97 * umu0[b26] - 317.89) *\ - bde[b26] + bde[b26] b27 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.8987) & (umu0 <= 0.9396) Tddp[b27] = \ (-457.09 * np.power(umu0[b27], 2.0) + 831.11 * umu0[b27] - 376.85) *\ From 0cf341452537e1a4a1e525a59eb5b084ab1adebc Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 08:51:37 -0600 Subject: [PATCH 30/55] FARMS-DNI for Linting --- farms/farms_dni.py | 56 ++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 4dd3afd..3a7e332 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -230,12 +230,12 @@ def Pice(Z, tau, De): (umu0 <= 0.8987) Tddp[b14] = \ (-163.36 * np.power(umu0[b14], 2.0) + 283.35 * umu0[b14] - 121.91) *\ - ade[b14] + ade[b14] b15 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.8987) \ & (umu0 <= 0.9396) Tddp[b15] = \ (-202.72 * np.power(umu0[b15], 2.0) + 368.75 * umu0[b15] - 166.75) *\ - ade[b15] + ade[b15] b16 = (umu0 < 0.999) & (De > 10.0) & (De <= 30.0) & (umu0 > 0.9396) \ & (umu0 <= 0.9702) Tddp[b16] = \ @@ -287,21 +287,21 @@ def Pice(Z, tau, De): b27 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.8987) & (umu0 <= 0.9396) Tddp[b27] = \ (-457.09 * np.power(umu0[b27], 2.0) + 831.11 * umu0[b27] - 376.85) *\ - bde[b27] + bde[b27] b28 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9396) & (umu0 <= 0.9702) Tddp[b28] = \ (-344.91 * np.power(umu0[b28], 2.0) + 655.67 * umu0[b28] -310.5) *\ - bde[b28] + bde[b28] b29 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9702) & (umu0 <= 0.9945) Tddp[b29] = \ - (622.85*np.power(umu0[b29], 2.0) - 1227.6*umu0[b29] +605.97) *\ + (622.85 * np.power(umu0[b29], 2.0) - 1227.6 * umu0[b29] + 605.97) *\ bde[b29] b30 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9945) Tddp[b30] = \ - (6309.63 * np.power(umu0[b30], 2.0) - 12654.78 * umu0[b30] + 6346.15) *\ - bde[b30] + (6309.63 * np.power(umu0[b30], 2.0) - 12654.78 * umu0[b30] + 6346.15)\ + * bde[b30] -###compute Tddcld using Eq.(5) in Yang et al. (2022) + # compute Tddcld using Eq.(5) in Yang et al. (2022) a = 1.7686 * np.power(umu0, -0.95) b = 7.117 * np.power(umu0, 1.9658) @@ -310,31 +310,32 @@ def Pice(Z, tau, De): Tddcld[a1] = Tddp[a1] * np.tanh(a[a1] * tau[a1]) a2 = (tau > 0.9 * taup) & (tau < taup) Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + \ - Tddp[a2] * (np.tanh(b[a2] / np.power(taup[a2],2.0)) \ - - np.tanh(0.9 * a[a2] * taup[a2])) * \ - (tau[a2] - 0.9 * taup[a2]) / (0.1 * taup[a2]) + Tddp[a2] * (np.tanh(b[a2] / np.power(taup[a2], 2.0)) \ + - np.tanh(0.9 * a[a2] * taup[a2])) * \ + (tau[a2] - 0.9 * taup[a2]) / (0.1 * taup[a2]) a3 = tau >= taup - Tddcld[a3] = Tddp[a3] * np.tanh(b[a3] / np.power(tau[a3],2.0)) + Tddcld[a3] = Tddp[a3] * np.tanh(b[a3] / np.power(tau[a3], 2.0)) return Tddcld -def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1): +def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, \ + Tddclr, Ftotal, F1): ''' Fast All-sky Radiation Model for solar applications with direct normal irradiance (FARMS-DNI) References ----------- - Xie, Y., Sengupta, M., Dudhia, J., 2016. A Fast All-sky Radiation Model for - Solar applications (FARMS): Algorithm and performance evaluation. Sol. Energy - 135, 435-445. - Xie, Y., Sengupta, M., Liu, Y., Long, H., Min, Q., Liu, W., Habte, A., 2020. - A physics-based DNI model assessing all-sky circumsolar radiation. iScience 22, - doi.org/10.1016/j.isci.2020.100893. - Yang, J., Xie, Y., Sengupta, M., Liu, Y., Long, H., 2022. Parameterization of - cloud transmittance for expeditious assessment and forecasting of all-sky DNI. - J. Renewable Sustainable Energy 14, 063703. + Xie, Y., Sengupta, M., Dudhia, J., 2016. A Fast All-sky Radiation Model + for Solar applications (FARMS): Algorithm and performance evaluation. + Sol. Energy 135, 435-445. + Xie, Y., Sengupta, M., Liu, Y., Long, H., Min, Q., Liu, W., Habte, A., + 2020. A physics-based DNI model assessing all-sky circumsolar radiation. + iScience 22, doi.org/10.1016/j.isci.2020.100893. + Yang, J., Xie, Y., Sengupta, M., Liu, Y., Long, H., 2022. Parameterization + of cloud transmittance for expeditious assessment and forecasting of + all-sky DNI. J. Renewable Sustainable Energy 14, 063703. Input data ----------- @@ -360,8 +361,8 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ft Ftotal: np.ndarray GHI (Wm-2) F1: np.ndarray - First order solar radiation given in FARMS (Wm-2). See Xie et al. (2016) - for more details. + First order solar radiation given in FARMS (Wm-2). + See Xie et al. (2016) for more details. Output data ----------- @@ -371,11 +372,12 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ft dni_farmsdni: np.ndarray DNI computed by FARMS-DNI (Wm-2). dni0: np.ndarray - DNI computed by the Lambert law (Wm-2). It only includes the narrow beam - in the circumsolar region. + DNI computed by the Lambert law (Wm-2). It only includes the narrow + beam in the circumsolar region. ''' - # scale tau for the computation of DNI. See Eqs. (3a and 3b) in Xie et al. (2020), iScience. + # scale tau for the computation of DNI. See Eqs. (3a and 3b) in + # Xie et al. (2020), iScience. taudni = np.zeros_like(tau) a1 = np.where( (phase == 1) & (tau < 8.0) ) From 4c21982655bf411df5b1d5163c5364ad620aa077 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 09:08:06 -0600 Subject: [PATCH 31/55] FARMS-DNI for Linting --- farms/farms_dni.py | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 3a7e332..ebad460 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -290,7 +290,7 @@ def Pice(Z, tau, De): bde[b27] b28 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9396) & (umu0 <= 0.9702) Tddp[b28] = \ - (-344.91 * np.power(umu0[b28], 2.0) + 655.67 * umu0[b28] -310.5) *\ + (-344.91 * np.power(umu0[b28], 2.0) + 655.67 * umu0[b28] - 310.5) *\ bde[b28] b29 = (umu0 < 0.999) & (De > 30.0) & (umu0 > 0.9702) & (umu0 <= 0.9945) Tddp[b29] = \ @@ -309,9 +309,8 @@ def Pice(Z, tau, De): a1 = tau <= 0.9 * taup Tddcld[a1] = Tddp[a1] * np.tanh(a[a1] * tau[a1]) a2 = (tau > 0.9 * taup) & (tau < taup) - Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + \ - Tddp[a2] * (np.tanh(b[a2] / np.power(taup[a2], 2.0)) \ - - np.tanh(0.9 * a[a2] * taup[a2])) * \ + Tddcld[a2] = Tddp[a2] * np.tanh(0.9 * a[a2] * taup[a2]) + Tddp[a2] *\ + (np.tanh(b[a2] / taup[a2]**2.0) - np.tanh(0.9 * a[a2] * taup[a2])) *\ (tau[a2] - 0.9 * taup[a2]) / (0.1 * taup[a2]) a3 = tau >= taup Tddcld[a3] = Tddp[a3] * np.tanh(b[a3] / np.power(tau[a3], 2.0)) @@ -320,7 +319,7 @@ def Pice(Z, tau, De): def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, \ - Tddclr, Ftotal, F1): + Tddclr, Ftotal, F1): ''' Fast All-sky Radiation Model for solar applications with direct normal irradiance (FARMS-DNI) @@ -379,18 +378,17 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, \ # scale tau for the computation of DNI. See Eqs. (3a and 3b) in # Xie et al. (2020), iScience. taudni = np.zeros_like(tau) - - a1 = np.where( (phase == 1) & (tau < 8.0) ) - a2 = np.where( (phase == 1) & (tau >= 8.0) ) + a1 = np.where((phase == 1) & (tau < 8.0)) + a2 = np.where((phase == 1) & (tau >= 8.0)) taudni[a1] = ( 0.254825 * tau[a1] - 0.00232717 * np.power(tau[a1], 2.0) \ + (5.19320e-06) * np.power(tau[a1], 3.0) ) * \ (1.0 + (8.0 - tau[a1]) * 0.07) taudni[a2] = 0.2 * np.power(tau[a2] - 8.0, 1.5) + 2.10871 - b1 = np.where( (phase == 2) & (tau < 8.0) ) - b2 = np.where( (phase == 2) & (tau >= 8.0) ) + b1 = np.where((phase == 2) & (tau < 8.0)) + b2 = np.where((phase == 2) & (tau >= 8.0)) taudni[b1] = 0.345353 * tau[b1] - 0.00244671 * np.power(tau[b1], 2.0) \ - + (4.74263E-06) * np.power(tau[b1], 3.0) + + (4.74263E-06) * np.power(tau[b1], 3.0) taudni[b2] = 0.2 * np.power(tau[b2] - 8.0, 1.5) + 2.91345 # compute DNI in the narrow beam. Eq.(S2) in Xie et al. (2020), iScience. @@ -400,17 +398,15 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, \ Tddcld0 = np.exp(-taudni / solar_zenith_angle) Fd0 = solar_zenith_angle * F0 * Tddcld0 * Tddclr - # compute scattered radiation in the circumsolar region. Eq.(S3 and S4) in Xie et al. (2020), iScience. + # compute scattered radiation in the circumsolar region. Eq.(S3 and S4) + # in Xie et al. (2020), iScience. Tddcld1 = TDDP(Z, taudni, De, phase1, phase2) Fd1 = solar_zenith_angle * F0 * Tddclr * Tddcld1 - Fd2 = TDD2(Z, Ftotal, F1 ) + Fd2 = TDD2(Z, Ftotal, F1) - # compute DNI using the three components. Eq.(S1) in Xie et al. (2020), iScience. + # compute DNI using the three components. Eq.(S1) in + # Xie et al. (2020), iScience. Fd = Fd0 + Fd1 + Fd2 dni_farmsdni = Fd / solar_zenith_angle return Fd, dni_farmsdni, dni0 - - - - From 60da2a2964eeb31a84ccd5dc6191d3737ea3ddfc Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 10:29:54 -0600 Subject: [PATCH 32/55] FARMS-DNI for Linting --- farms/farms_dni.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index ebad460..a4ac11f 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -318,8 +318,8 @@ def Pice(Z, tau, De): return Tddcld -def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, \ - Tddclr, Ftotal, F1): +def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, + Tddclr, Ftotal, F1): ''' Fast All-sky Radiation Model for solar applications with direct normal irradiance (FARMS-DNI) @@ -375,14 +375,14 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, \ beam in the circumsolar region. ''' - # scale tau for the computation of DNI. See Eqs. (3a and 3b) in + # scale tau for the computation of DNI. See Eqs. (3a and 3b) in # Xie et al. (2020), iScience. taudni = np.zeros_like(tau) a1 = np.where((phase == 1) & (tau < 8.0)) a2 = np.where((phase == 1) & (tau >= 8.0)) - taudni[a1] = ( 0.254825 * tau[a1] - 0.00232717 * np.power(tau[a1], 2.0) \ - + (5.19320e-06) * np.power(tau[a1], 3.0) ) * \ - (1.0 + (8.0 - tau[a1]) * 0.07) + taudni[a1] = (0.254825 * tau[a1] - 0.00232717 * np.power(tau[a1], 2.0) \ + + (5.19320e-06) * np.power(tau[a1], 3.0)) * \ + (1.0 + (8.0 - tau[a1]) * 0.07) taudni[a2] = 0.2 * np.power(tau[a2] - 8.0, 1.5) + 2.10871 b1 = np.where((phase == 2) & (tau < 8.0)) @@ -398,13 +398,13 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, \ Tddcld0 = np.exp(-taudni / solar_zenith_angle) Fd0 = solar_zenith_angle * F0 * Tddcld0 * Tddclr - # compute scattered radiation in the circumsolar region. Eq.(S3 and S4) + # compute scattered radiation in the circumsolar region. Eq.(S3 and S4) # in Xie et al. (2020), iScience. Tddcld1 = TDDP(Z, taudni, De, phase1, phase2) Fd1 = solar_zenith_angle * F0 * Tddclr * Tddcld1 Fd2 = TDD2(Z, Ftotal, F1) - # compute DNI using the three components. Eq.(S1) in + # compute DNI using the three components. Eq.(S1) in # Xie et al. (2020), iScience. Fd = Fd0 + Fd1 + Fd2 dni_farmsdni = Fd / solar_zenith_angle From c340c80a53ffb1f6e948c714bab9b37623351444 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 10:38:09 -0600 Subject: [PATCH 33/55] FARMS-DNI for Linting --- farms/farms_dni.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index a4ac11f..4e006c0 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -319,7 +319,7 @@ def Pice(Z, tau, De): def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, - Tddclr, Ftotal, F1): + Tddclr, Ftotal, F1): ''' Fast All-sky Radiation Model for solar applications with direct normal irradiance (FARMS-DNI) @@ -380,9 +380,9 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, taudni = np.zeros_like(tau) a1 = np.where((phase == 1) & (tau < 8.0)) a2 = np.where((phase == 1) & (tau >= 8.0)) - taudni[a1] = (0.254825 * tau[a1] - 0.00232717 * np.power(tau[a1], 2.0) \ - + (5.19320e-06) * np.power(tau[a1], 3.0)) * \ - (1.0 + (8.0 - tau[a1]) * 0.07) + temp1 = 0.254825 * tau[a1] - 0.00232717 * tau[a1]**2.0 + \ + 5.19320e-06 * tau[a1]**3.0 + taudni[a1] = temp1 * (1.0 + (8.0 - tau[a1]) * 0.07) taudni[a2] = 0.2 * np.power(tau[a2] - 8.0, 1.5) + 2.10871 b1 = np.where((phase == 2) & (tau < 8.0)) From 00f8cd9a9e266307ae7855d4e77c5cdfd335bf5f Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 10:45:38 -0600 Subject: [PATCH 34/55] FARMS-DNI for Linting --- farms/farms_dni.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 4e006c0..d8d520f 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -319,7 +319,7 @@ def Pice(Z, tau, De): def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, - Tddclr, Ftotal, F1): + Tddclr, Ftotal, F1): ''' Fast All-sky Radiation Model for solar applications with direct normal irradiance (FARMS-DNI) From 4f0d42b05e59c81e12c2d9e07cf9ad066b53203f Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 10:52:07 -0600 Subject: [PATCH 35/55] FARMS-DNI for Linting --- farms/farms_dni.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index d8d520f..b1c5e49 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -319,7 +319,7 @@ def Pice(Z, tau, De): def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, - Tddclr, Ftotal, F1): + Tddclr, Ftotal, F1): ''' Fast All-sky Radiation Model for solar applications with direct normal irradiance (FARMS-DNI) From e235202da9bf762303c5ebd66286f08f812abded Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 10:59:33 -0600 Subject: [PATCH 36/55] FARMS-DNI for Linting --- farms/farms_dni.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index b1c5e49..c70675a 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -17,8 +17,6 @@ """ import numpy as np -import sys -import pandas as pd def TDD2(Z, Ftotal, F1): From 22450e1cf68973d8fcf2dd2be1eecfb4a119b1f1 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 11:16:38 -0600 Subject: [PATCH 37/55] update with FARMS-DNI --- farms/farms.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/farms/farms.py b/farms/farms.py index dcd4dd9..7ac0462 100644 --- a/farms/farms.py +++ b/farms/farms.py @@ -209,7 +209,9 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, dni = Fd / solar_zenith_angle # eq 2b from [1] dhi = ghi - Fd # eq 7 from [1] - Fd, dni_farmsdni, dni0 = farms_dni.farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, ghi, F1) + Fd, dni_farmsdni, dni0 = \ + farms_dni.farms_dni(F0, tau, solar_zenith_angle, De, phase, + phase1, phase2, Tddclr, ghi, F1) clear_mask = np.in1d(cloud_type, CLEAR_TYPES).reshape(cloud_type.shape) if debug: @@ -227,5 +229,7 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, return fast_data else: # return only GHI - return np.where(clear_mask, np.nan, ghi), np.where(clear_mask, np.nan, dni_farmsdni), np.where(clear_mask, np.nan, dni0) + return np.where(clear_mask, np.nan, ghi), + np.where(clear_mask, np.nan, dni_farmsdni), + np.where(clear_mask, np.nan, dni0) # print( theta00, idx, muomega ) From 421e87afea3c24d6199528881ebeb2c8be3281f2 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 11:19:55 -0600 Subject: [PATCH 38/55] update with FARMS-DNI --- farms/farms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/farms/farms.py b/farms/farms.py index 7ac0462..e8989d1 100644 --- a/farms/farms.py +++ b/farms/farms.py @@ -230,6 +230,6 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, else: # return only GHI return np.where(clear_mask, np.nan, ghi), - np.where(clear_mask, np.nan, dni_farmsdni), - np.where(clear_mask, np.nan, dni0) + np.where(clear_mask, np.nan, dni_farmsdni), + np.where(clear_mask, np.nan, dni0) # print( theta00, idx, muomega ) From c80080eefe530c528a00cbe1db513116cf0f766e Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 11:22:31 -0600 Subject: [PATCH 39/55] update with FARMS-DNI --- farms/farms.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/farms/farms.py b/farms/farms.py index e8989d1..2a95867 100644 --- a/farms/farms.py +++ b/farms/farms.py @@ -229,7 +229,5 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, return fast_data else: # return only GHI - return np.where(clear_mask, np.nan, ghi), - np.where(clear_mask, np.nan, dni_farmsdni), - np.where(clear_mask, np.nan, dni0) + return np.where(clear_mask, np.nan, ghi), np.where(clear_mask, np.nan, dni_farmsdni), np.where(clear_mask, np.nan, dni0) # print( theta00, idx, muomega ) From a6a37e2848c9f796760ea872df47bb4d5d4332d8 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 11:23:49 -0600 Subject: [PATCH 40/55] update with FARMS-DNI --- farms/farms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/farms/farms.py b/farms/farms.py index 2a95867..594d23e 100644 --- a/farms/farms.py +++ b/farms/farms.py @@ -230,4 +230,4 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, else: # return only GHI return np.where(clear_mask, np.nan, ghi), np.where(clear_mask, np.nan, dni_farmsdni), np.where(clear_mask, np.nan, dni0) -# print( theta00, idx, muomega ) + # print( theta00, idx, muomega ) From 58800e5009b75a2bce66e5f88535ddc181aabb5e Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 11:32:17 -0600 Subject: [PATCH 41/55] update with FARMS-DNI --- farms/farms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/farms/farms.py b/farms/farms.py index 594d23e..019f0f9 100644 --- a/farms/farms.py +++ b/farms/farms.py @@ -229,5 +229,7 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, return fast_data else: # return only GHI - return np.where(clear_mask, np.nan, ghi), np.where(clear_mask, np.nan, dni_farmsdni), np.where(clear_mask, np.nan, dni0) + return np.where(clear_mask, np.nan, ghi), + np.where(clear_mask, np.nan, dni_farmsdni), + np.where(clear_mask, np.nan, dni0) # print( theta00, idx, muomega ) From 48c0b4727c132220f6c25a215646199676b7958b Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 11:37:09 -0600 Subject: [PATCH 42/55] update with FARMS-DNI --- farms/farms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/farms/farms.py b/farms/farms.py index 019f0f9..ba4ab6c 100644 --- a/farms/farms.py +++ b/farms/farms.py @@ -229,7 +229,7 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, return fast_data else: # return only GHI - return np.where(clear_mask, np.nan, ghi), - np.where(clear_mask, np.nan, dni_farmsdni), + return np.where(clear_mask, np.nan, ghi),\ + np.where(clear_mask, np.nan, dni_farmsdni),\ np.where(clear_mask, np.nan, dni0) # print( theta00, idx, muomega ) From c0e68ab5c3b366091f109d0dbbe6a05aa8fd94e6 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 11:40:47 -0600 Subject: [PATCH 43/55] update with FARMS-DNI --- farms/farms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/farms/farms.py b/farms/farms.py index ba4ab6c..1fcbadc 100644 --- a/farms/farms.py +++ b/farms/farms.py @@ -230,6 +230,6 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, else: # return only GHI return np.where(clear_mask, np.nan, ghi),\ - np.where(clear_mask, np.nan, dni_farmsdni),\ - np.where(clear_mask, np.nan, dni0) + np.where(clear_mask, np.nan, dni_farmsdni),\ + np.where(clear_mask, np.nan, dni0) # print( theta00, idx, muomega ) From 69a84a9c8f9d103cf6545c3de393b12fa12e9b3e Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 11:52:03 -0600 Subject: [PATCH 44/55] FARMS-DNI for improving the DNI computation --- farms/farms_dni.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index c70675a..c4f79d8 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -1,4 +1,9 @@ """ +This model updates the computation of DNI used for FARMS. +The orignal FARMS use DISC model to compute cloudy-sky DNI. +This new model uses a physics-based algorithm to solve the direct +and scattered beam in the circumsolar region. + Created on March 1, 2022 Upgraded on March 21, 2023 FARMS-DNI model developed by Yu Xie (yu.xie@nrel.gov) @@ -36,7 +41,8 @@ def TDD2(Z, Ftotal, F1): def TDDP(Z, tau, De, phase1, phase2): ''' - compute cloud transmittance of DNI for water and ice clouds + Compute cloud transmittance of DNI for water and ice clouds + More details can be found in Xie et al. (2020) ''' Tddcld = np.zeros_like(tau) Tddcld[phase1] = Pwater(Z[phase1], tau[phase1], De[phase1]) @@ -48,6 +54,7 @@ def TDDP(Z, tau, De, phase1, phase2): def Pwater(Z, tau, De): ''' Compute cloud transmittance for water clouds + More details can be found in Xie et al. (2020) ''' umu0 = np.cos(Z * np.pi / 180.0) # taup Eq.(3) in Yang et al. (2022) @@ -115,6 +122,7 @@ def Pwater(Z, tau, De): def Pice(Z, tau, De): ''' Compute cloud transmittance for ice clouds + More details can be found in Xie et al. (2020) ''' umu0 = np.cos(Z * np.pi / 180.0) # taup Eq.(3) in Yang et al. (2022) From 2c00e7ad604bd27f20db0d31ef333d5704c40760 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 11:58:27 -0600 Subject: [PATCH 45/55] FARMS-DNI for improving the DNI computation --- farms/farms_dni.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index c4f79d8..1a39d43 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -2,7 +2,7 @@ This model updates the computation of DNI used for FARMS. The orignal FARMS use DISC model to compute cloudy-sky DNI. This new model uses a physics-based algorithm to solve the direct -and scattered beam in the circumsolar region. +and scattered beam in the circumsolar region. Created on March 1, 2022 Upgraded on March 21, 2023 @@ -54,7 +54,9 @@ def TDDP(Z, tau, De, phase1, phase2): def Pwater(Z, tau, De): ''' Compute cloud transmittance for water clouds - More details can be found in Xie et al. (2020) + The defination and use of the transmittance can be found in + Xie et al. (2020) + The cloud transmittance is parameterized by Yang et al. (2022) ''' umu0 = np.cos(Z * np.pi / 180.0) # taup Eq.(3) in Yang et al. (2022) @@ -122,7 +124,9 @@ def Pwater(Z, tau, De): def Pice(Z, tau, De): ''' Compute cloud transmittance for ice clouds - More details can be found in Xie et al. (2020) + The defination and use of the transmittance can be found in + Xie et al. (2020) + The cloud transmittance is parameterized by Yang et al. (2022) ''' umu0 = np.cos(Z * np.pi / 180.0) # taup Eq.(3) in Yang et al. (2022) From fa438291af9c1a2db7f1d9c2e61840aa59d2ad12 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 13:07:08 -0600 Subject: [PATCH 46/55] FARMS-DNI for improving the DNI computation --- farms/farms_dni.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 1a39d43..b1ddeb4 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -346,7 +346,7 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, of cloud transmittance for expeditious assessment and forecasting of all-sky DNI. J. Renewable Sustainable Energy 14, 063703. - Input data + Parameters ----------- F0: np.ndarray extraterrestrial solar radiation (Wm-2). @@ -373,7 +373,7 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, First order solar radiation given in FARMS (Wm-2). See Xie et al. (2016) for more details. - Output data + Returns ----------- Fd: np.ndarray Direct radiation in the downwelling direction (Wm-2). It includes the From 5ca6c4312dc44d6fc89b848362530bad45bed7aa Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 13:25:06 -0600 Subject: [PATCH 47/55] FARMS-DNI for improving the DNI computation --- farms/farms_dni.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index b1ddeb4..64cf724 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -28,6 +28,22 @@ def TDD2(Z, Ftotal, F1): ''' Compute surface reflection that falls in the circumsolar region. A parameterization of Eq. (S4) in Xie et al (2020) is used. + + Parameters + ----------- + Z: np.ndarray + solar zenith angle (degree). + Ftotal: np.ndarray + GHI (Wm-2) + F1: np.ndarray + First order solar radiation given in FARMS (Wm-2). + See Xie et al. (2016) for more details. + + Returns + ----------- + Fd2: np.ndarray + Direct radiation caused by the reflection between + surface and cloud (Wm-2). ''' # compute the integration of the solid angle a = 5.94991536e-03 @@ -43,6 +59,26 @@ def TDDP(Z, tau, De, phase1, phase2): ''' Compute cloud transmittance of DNI for water and ice clouds More details can be found in Xie et al. (2020) + + Parameters + ----------- + Z: np.ndarray + solar zenith angle (degree). + tau : np.ndarray + Cloud optical thickness (cld_opd_dcomp) (unitless). + De: np.ndarray + Effective cloud particle size (diameter, micron). + phase: np.ndarray + Cloud thermodynamic phase (water:1, ice:2) + phase1: np.ndarray + np.where( phase==1 ) + phase2: np.ndarray + np.where( phase==2 ) + + Returns + ----------- + Tddcld: np.ndarray + Cloud transmittance of DNI for the cloud ''' Tddcld = np.zeros_like(tau) Tddcld[phase1] = Pwater(Z[phase1], tau[phase1], De[phase1]) @@ -57,6 +93,20 @@ def Pwater(Z, tau, De): The defination and use of the transmittance can be found in Xie et al. (2020) The cloud transmittance is parameterized by Yang et al. (2022) + + Parameters + ----------- + Z: np.ndarray + solar zenith angle (degree). + tau : np.ndarray + Cloud optical thickness (cld_opd_dcomp) (unitless). + De: np.ndarray + Effective cloud particle size (diameter, micron). + + Returns + ----------- + Tddcld: np.ndarray + Cloud transmittance of DNI for the cloud ''' umu0 = np.cos(Z * np.pi / 180.0) # taup Eq.(3) in Yang et al. (2022) @@ -127,6 +177,20 @@ def Pice(Z, tau, De): The defination and use of the transmittance can be found in Xie et al. (2020) The cloud transmittance is parameterized by Yang et al. (2022) + + Parameters + ----------- + Z: np.ndarray + solar zenith angle (degree). + tau : np.ndarray + Cloud optical thickness (cld_opd_dcomp) (unitless). + De: np.ndarray + Effective cloud particle size (diameter, micron). + + Returns + ----------- + Tddcld: np.ndarray + Cloud transmittance of DNI for the cloud ''' umu0 = np.cos(Z * np.pi / 180.0) # taup Eq.(3) in Yang et al. (2022) From 65d3c24ca3da93eda00c7ea65e8fef75198c4a0a Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 14:05:32 -0600 Subject: [PATCH 48/55] test FARMS-DNI --- farms/farms_dni.py | 1 + tests/test_farmsdni.py | 64 ++++++++++++++++++++++------------------- tests/test_farmsdni1.py | 49 ------------------------------- 3 files changed, 36 insertions(+), 78 deletions(-) delete mode 100644 tests/test_farmsdni1.py diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 64cf724..ae4df34 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -33,6 +33,7 @@ def TDD2(Z, Ftotal, F1): ----------- Z: np.ndarray solar zenith angle (degree). + Array shape is (n_time, n_sites). Ftotal: np.ndarray GHI (Wm-2) F1: np.ndarray diff --git a/tests/test_farmsdni.py b/tests/test_farmsdni.py index 329cdbe..4488909 100644 --- a/tests/test_farmsdni.py +++ b/tests/test_farmsdni.py @@ -1,43 +1,49 @@ +""" +PyTest file for FARMS-DNI + +Created on 03/24/2023 + +@author: Yu Xie +""" import numpy as np from farms import farms_dni -import sys def test_farmsdni(): - + ''' + Test FARMS-DNI with typical input variables + Check if the DNI computation is between 0 and 1400, + and larger than the DNI in the narrow beam. + ''' n = 100 - F0 = np.arange(n) - F0[:] = 1360.0 - tau = np.arange(n)*0.1 - sza = np.arange(n)*0.85 - solar_zenith_angle = np.cos( sza*np.pi/180.0 ) - De = np.arange(n)+10.0 - phase = np.arange(n) + F0 = np.full(n, 1360.0) + tau = np.arange(n) * 0.1 + sza = np.arange(n) * 0.85 + solar_zenith_angle = np.cos(sza * np.pi / 180.0) + De = np.arange(n) + 10.0 + phase = np.full(n, 2) phase[:50] = 1 - phase[50:] = 2 - phase1 = np.where(phase == 1) - phase2 = np.where(phase == 2) - Tddclr = ( np.arange(n)+100 )*0.005 - Ftotal = np.flip( np.arange(n) + 900.0) - F1 = Ftotal*0.7 - - Fd, dni_farmsdni, dni0 = farms_dni.farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1) - print( dni_farmsdni ) + phase1 = np.where(phase == 1)[0] + phase2 = np.where(phase == 2)[0] + Tddclr = (np.arange(n) + 100) * 0.005 + Ftotal = np.flip(np.arange(n) + 900.0) + F1 = Ftotal * 0.7 - cond1 = [x for x in dni_farmsdni if x<0] - cond2 = [x for x in dni_farmsdni if x>=1400] - cond3 = [i for i in range(dni_farmsdni.shape[0]) if dni_farmsdni[i] < dni0[i] ] + Fd, dni_farmsdni, dni0 = farms_dni.farms_dni( + F0, tau, solar_zenith_angle, De, phase, phase1, phase2, + Tddclr, Ftotal, F1 + ) - wrong_num = np.size(cond1+cond2+cond3) -# assert wrong_num == 0 - return + cond1 = dni_farmsdni[dni_farmsdni < 0] + cond2 = dni_farmsdni[dni_farmsdni >= 1400] + cond3 = np.where(dni_farmsdni < dni0)[0] -''' -if __name__ == '__main__': - execute_pytest() -''' + print(Fd) # Set this to pass the Linting -test_farmsdni() + wrong_num = len(cond1) + len(cond2) + len(cond3) + assert wrong_num == 0 +if __name__ == "__main__": + test_farmsdni() diff --git a/tests/test_farmsdni1.py b/tests/test_farmsdni1.py deleted file mode 100644 index 4488909..0000000 --- a/tests/test_farmsdni1.py +++ /dev/null @@ -1,49 +0,0 @@ -""" -PyTest file for FARMS-DNI - -Created on 03/24/2023 - -@author: Yu Xie -""" - -import numpy as np -from farms import farms_dni - - -def test_farmsdni(): - ''' - Test FARMS-DNI with typical input variables - Check if the DNI computation is between 0 and 1400, - and larger than the DNI in the narrow beam. - ''' - n = 100 - F0 = np.full(n, 1360.0) - tau = np.arange(n) * 0.1 - sza = np.arange(n) * 0.85 - solar_zenith_angle = np.cos(sza * np.pi / 180.0) - De = np.arange(n) + 10.0 - phase = np.full(n, 2) - phase[:50] = 1 - phase1 = np.where(phase == 1)[0] - phase2 = np.where(phase == 2)[0] - Tddclr = (np.arange(n) + 100) * 0.005 - Ftotal = np.flip(np.arange(n) + 900.0) - F1 = Ftotal * 0.7 - - Fd, dni_farmsdni, dni0 = farms_dni.farms_dni( - F0, tau, solar_zenith_angle, De, phase, phase1, phase2, - Tddclr, Ftotal, F1 - ) - - cond1 = dni_farmsdni[dni_farmsdni < 0] - cond2 = dni_farmsdni[dni_farmsdni >= 1400] - cond3 = np.where(dni_farmsdni < dni0)[0] - - print(Fd) # Set this to pass the Linting - - wrong_num = len(cond1) + len(cond2) + len(cond3) - assert wrong_num == 0 - - -if __name__ == "__main__": - test_farmsdni() From 5e25a9f3ce6e430c4bbc66bf4c979398b2cc32c3 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 14:07:30 -0600 Subject: [PATCH 49/55] FARMS-DNI --- farms/farms_dni.py | 1 - 1 file changed, 1 deletion(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index ae4df34..64cf724 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -33,7 +33,6 @@ def TDD2(Z, Ftotal, F1): ----------- Z: np.ndarray solar zenith angle (degree). - Array shape is (n_time, n_sites). Ftotal: np.ndarray GHI (Wm-2) F1: np.ndarray From 720d1fe2fdb6b845f009ac0eccc15b47bb70883a Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 14:38:44 -0600 Subject: [PATCH 50/55] FARMS-DNI --- farms/farms_dni.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 64cf724..b193db6 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -29,6 +29,8 @@ def TDD2(Z, Ftotal, F1): Compute surface reflection that falls in the circumsolar region. A parameterization of Eq. (S4) in Xie et al (2020) is used. + All arrays should have the same shape (n_times) or (ntime, nlats, nlons) + Parameters ----------- Z: np.ndarray @@ -60,6 +62,8 @@ def TDDP(Z, tau, De, phase1, phase2): Compute cloud transmittance of DNI for water and ice clouds More details can be found in Xie et al. (2020) + All arrays should have the same shape (n_times) or (ntime, nlats, nlons) + Parameters ----------- Z: np.ndarray @@ -68,12 +72,12 @@ def TDDP(Z, tau, De, phase1, phase2): Cloud optical thickness (cld_opd_dcomp) (unitless). De: np.ndarray Effective cloud particle size (diameter, micron). - phase: np.ndarray - Cloud thermodynamic phase (water:1, ice:2) phase1: np.ndarray np.where( phase==1 ) + phase is cloud thermodynamic phase (water:1, ice:2) phase2: np.ndarray np.where( phase==2 ) + phase is cloud thermodynamic phase (water:1, ice:2) Returns ----------- @@ -94,6 +98,8 @@ def Pwater(Z, tau, De): Xie et al. (2020) The cloud transmittance is parameterized by Yang et al. (2022) + All arrays should have the same shape (n_times) or (ntime, nlats, nlons) + Parameters ----------- Z: np.ndarray @@ -178,6 +184,8 @@ def Pice(Z, tau, De): Xie et al. (2020) The cloud transmittance is parameterized by Yang et al. (2022) + All arrays should have the same shape (n_times) or (ntime, nlats, nlons) + Parameters ----------- Z: np.ndarray @@ -410,6 +418,8 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, of cloud transmittance for expeditious assessment and forecasting of all-sky DNI. J. Renewable Sustainable Energy 14, 063703. + All arrays should have the same shape (n_times) or (ntime, nlats, nlons) + Parameters ----------- F0: np.ndarray From 8f0f6c96c14147add91610c738a5b97c5bc4a2b2 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 14:42:42 -0600 Subject: [PATCH 51/55] FARMS-DNI --- farms/farms_dni.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index b193db6..0880a53 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -29,7 +29,7 @@ def TDD2(Z, Ftotal, F1): Compute surface reflection that falls in the circumsolar region. A parameterization of Eq. (S4) in Xie et al (2020) is used. - All arrays should have the same shape (n_times) or (ntime, nlats, nlons) + All arrays should have the same shape (n_times) or (ntimes, nlats, nlons) Parameters ----------- @@ -62,7 +62,7 @@ def TDDP(Z, tau, De, phase1, phase2): Compute cloud transmittance of DNI for water and ice clouds More details can be found in Xie et al. (2020) - All arrays should have the same shape (n_times) or (ntime, nlats, nlons) + All arrays should have the same shape (n_times) or (ntimes, nlats, nlons) Parameters ----------- @@ -98,7 +98,7 @@ def Pwater(Z, tau, De): Xie et al. (2020) The cloud transmittance is parameterized by Yang et al. (2022) - All arrays should have the same shape (n_times) or (ntime, nlats, nlons) + All arrays should have the same shape (n_times) or (ntimes, nlats, nlons) Parameters ----------- @@ -184,7 +184,7 @@ def Pice(Z, tau, De): Xie et al. (2020) The cloud transmittance is parameterized by Yang et al. (2022) - All arrays should have the same shape (n_times) or (ntime, nlats, nlons) + All arrays should have the same shape (n_times) or (ntimes, nlats, nlons) Parameters ----------- @@ -418,7 +418,7 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, of cloud transmittance for expeditious assessment and forecasting of all-sky DNI. J. Renewable Sustainable Energy 14, 063703. - All arrays should have the same shape (n_times) or (ntime, nlats, nlons) + All arrays should have the same shape (n_times) or (ntimes, nlats, nlons) Parameters ----------- From bb61547c77ed35365ad86b12b29b8cdb47b00402 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 14:50:32 -0600 Subject: [PATCH 52/55] FARMS-DNI --- farms/farms_dni.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 0880a53..69fe628 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -29,7 +29,8 @@ def TDD2(Z, Ftotal, F1): Compute surface reflection that falls in the circumsolar region. A parameterization of Eq. (S4) in Xie et al (2020) is used. - All arrays should have the same shape (n_times) or (ntimes, nlats, nlons) + All arrays should have the same shape (n_times) or + (n_times,n_lats,n_lons) Parameters ----------- @@ -62,7 +63,8 @@ def TDDP(Z, tau, De, phase1, phase2): Compute cloud transmittance of DNI for water and ice clouds More details can be found in Xie et al. (2020) - All arrays should have the same shape (n_times) or (ntimes, nlats, nlons) + All arrays should have the same shape (n_times) or + (n_times,n_lats,n_lons) Parameters ----------- @@ -98,7 +100,8 @@ def Pwater(Z, tau, De): Xie et al. (2020) The cloud transmittance is parameterized by Yang et al. (2022) - All arrays should have the same shape (n_times) or (ntimes, nlats, nlons) + All arrays should have the same shape (n_times) or + (n_times,n_lats,n_lons) Parameters ----------- @@ -184,7 +187,8 @@ def Pice(Z, tau, De): Xie et al. (2020) The cloud transmittance is parameterized by Yang et al. (2022) - All arrays should have the same shape (n_times) or (ntimes, nlats, nlons) + All arrays should have the same shape (n_times) or + (n_times, n_lats, n_lons) Parameters ----------- @@ -418,7 +422,8 @@ def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, of cloud transmittance for expeditious assessment and forecasting of all-sky DNI. J. Renewable Sustainable Energy 14, 063703. - All arrays should have the same shape (n_times) or (ntimes, nlats, nlons) + All arrays should have the same shape (n_times) or + (n_times, n_lats, n_lons) Parameters ----------- From f604b551050dea707796d9f075be06286861f193 Mon Sep 17 00:00:00 2001 From: xieyupku Date: Tue, 28 Mar 2023 14:57:20 -0600 Subject: [PATCH 53/55] FARMS-DNI --- farms/farms_dni.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/farms/farms_dni.py b/farms/farms_dni.py index 69fe628..2628f09 100644 --- a/farms/farms_dni.py +++ b/farms/farms_dni.py @@ -30,7 +30,7 @@ def TDD2(Z, Ftotal, F1): A parameterization of Eq. (S4) in Xie et al (2020) is used. All arrays should have the same shape (n_times) or - (n_times,n_lats,n_lons) + (n_times, n_lats, n_lons) Parameters ----------- @@ -64,7 +64,7 @@ def TDDP(Z, tau, De, phase1, phase2): More details can be found in Xie et al. (2020) All arrays should have the same shape (n_times) or - (n_times,n_lats,n_lons) + (n_times, n_lats, n_lons) Parameters ----------- @@ -101,7 +101,7 @@ def Pwater(Z, tau, De): The cloud transmittance is parameterized by Yang et al. (2022) All arrays should have the same shape (n_times) or - (n_times,n_lats,n_lons) + (n_times, n_lats, n_lons) Parameters ----------- From 51ff4015c9956014511b6dd333575ba1f740d22a Mon Sep 17 00:00:00 2001 From: bnb32 Date: Thu, 13 Apr 2023 15:42:36 -0600 Subject: [PATCH 54/55] version increment. old directory removed --- farms/old/farms_dni.py | 290 ----------------------------------------- farms/version.py | 2 +- 2 files changed, 1 insertion(+), 291 deletions(-) delete mode 100644 farms/old/farms_dni.py diff --git a/farms/old/farms_dni.py b/farms/old/farms_dni.py deleted file mode 100644 index c2067fc..0000000 --- a/farms/old/farms_dni.py +++ /dev/null @@ -1,290 +0,0 @@ -""" -Created on March 1, 2022 -FARMS-DNI model developed by Yu Xie (yu.xie@nrel.gov) -Must have Interomega.dat to compute DNI - -Literature -[1] Yu Xie, Manajit Sengupta, Yangang Liu, Hai Long, Qilong Min, Weijia Liu, Aron Habte, - A physics-based DNI model assessing all-sky circumsolar radiation, iScience -[2] Yu Xie, Jaemo Yang, Manajit Sengupta, Yangang Liu, Xin Zhou, - Improving the prediction of DNI with physics-based representation of all-sky circumsolar radaition, Solar Energy -[3] Jaemo Yang, Yu Xie, Manajit Sengupta, Yangang Liu, Hai Long, - Parameterization of cloud transmittance for expeditious assessment and forecasting of all-sky DNI, Solar Energy - -""" -import numpy as np -import sys -import pandas as pd - - -def Read_Two_Column_File(file_name): - with open(file_name, 'r') as data: - x = [] - y = [] - for line in data: - p = line.split() - x.append(float(p[0])) - y.append(float(p[1])) - - return x, y - -def find_nearest(array, value): - array = np.asarray(array) - idx = (np.abs(array - value)).argmin() - return array[idx], idx - - - -def TDD2(Z, Ftotal, F1): - - a = 5.94991536e-03 - b = 5.42116600e-01 - c = 331280.9859904468 - muomega = np.exp(-np.power(Z-b, 3.0)/c ) - - Fd2 = np.cos( Z*np.pi/180.0 )*(Ftotal - F1)*muomega/np.pi - return Fd2 - - -def TDDP(Z, tau, De, phase1, phase2): - - Tddcld = np.zeros_like(tau) - Tddcld[phase1] = Pwater( Z[phase1],tau[phase1], De[phase1] ) - Tddcld[phase2] = Pice( Z[phase2],tau[phase2], De[phase2] ) - - return Tddcld - - - -def Pwater(Z, tau, De): - - umu0 = np.cos( Z*np.pi/180.0 ) -### taup - taup = np.zeros_like(Z) - taup[(De<10.0) & (umu0<0.1391)] = 0.1 - taup[(De<10.0) & (umu0>=0.1391) & (umu0<0.2419)] = 0.2 - taup[(De<10.0) & (umu0>=0.2419) & (umu0<0.3090)] = 0.3 - taup[(De<10.0) & (umu0>=0.3090) & (umu0<0.4067)] = 0.4 - taup[(De<10.0) & (umu0>=0.4067) & (umu0<0.6156)] = 0.5 - taup[(De<10.0) & (umu0>=0.6156)] = 1.0 - - taup[(De>=10.0) & (umu0<0.1391)] = 0.1 - taup[(De>=10.0) & (umu0>=0.1391) & (umu0<0.2079)] = 0.2 - taup[(De>=10.0) & (umu0>=0.2079) & (umu0<0.3090)] = 0.3 - taup[(De>=10.0) & (umu0>=0.3090) & (umu0<0.3746)] = 0.4 - taup[(De>=10.0) & (umu0>=0.3746) & (umu0<0.6156)] = 0.5 - taup[(De>=10.0) & (umu0>=0.6156)] = 1.0 - -###Tddp - h = 0.005553*np.log(De) + 0.002503 - h[De==0] = 0.0 - Tddp = np.zeros_like(Z) - a1 = (umu0>=0.0) & (umu0<0.342) - Tddp[a1] = h[a1]*(-0.1787*umu0[a1]*umu0[a1] + 0.2207*umu0[a1] + 0.977) - a2 = (umu0>=0.342) & (umu0<0.4694) - Tddp[a2] = h[a2] - a3 = (umu0>=0.4694) & (umu0<0.7193) - Tddp[a3] = h[a3]*( 2.6399*umu0[a3]*umu0[a3] - 3.2111*umu0[a3] + 1.9434 ) - a4 = (umu0>=0.7193) & (umu0<0.8829) - Tddp[a4] = h[a4]*( -0.224*umu0[a4]*umu0[a4] + 0.0835*umu0[a4] + 1.056 ) - a5 = (umu0>=0.8829) & (umu0<0.9396) - Tddp[a5] = h[a5]*( -94.381*umu0[a5]*umu0[a5] + 170.32*umu0[a5] - 75.843 ) - a6 = (umu0>=0.9396) & (umu0<0.9945) - Tddp[a6] = h[a6]*( -12.794*umu0[a6]*umu0[a6] + 22.686*umu0[a6] - 8.9392 ) - a7 = (umu0>=0.9945) & (umu0<0.999) - Tddp[a7] = h[a7]*( 11248.61*umu0[a7]*umu0[a7] - 22441.07*umu0[a7] + 11193.59 ) - a8 = umu0>=0.999 - Tddp[a8] = 0.76*h[a8] - - a = 2.0339*np.power( umu0, -0.927 ) - b = 6.6421*np.power( umu0, 2.0672 ) - - Tddcld = np.zeros_like(Z) - a1 = tau<=0.9*taup - Tddcld[a1] = Tddp[a1]*np.tanh(a[a1]*tau[a1]) - a2 = (tau>0.9*taup) & (tau=taup - Tddcld[a3] = Tddp[a3]*np.tanh(b[a3]/np.power(tau[a3],2.0)) - - - return Tddcld - - - - -def Pice(Z, tau, De): - - umu0 = np.cos( Z*np.pi/180.0 ) -### taup - taup = np.zeros_like(Z) - a1 = (De>=5.0) & (De<14.0) & (umu0<0.1391) - taup[a1] = 0.1 - a2 = (De>=5.0) & (De<14.0) & (umu0>=0.1391) & (umu0<0.2079) - taup[a2] = 0.2 - a3 = (De>=5.0) & (De<14.0) & (umu0>=0.2079) & (umu0<0.3090) - taup[a3] = 0.3 - a4 = (De>=5.0) & (De<14.0) & (umu0>=0.3090) & (umu0<0.3746) - taup[a4] = 0.4 - a5 = (De>=5.0) & (De<14.0) & (umu0>=0.3746) & (umu0<0.6156) - taup[a5] = 0.5 - a6 = (De>=5.0) & (De<14.0) & (umu0>=0.6156) & (umu0<0.9994) - taup[a6] = 1.0 - a7 = (De>=5.0) & (De<14.0) & (umu0>=0.9994) - taup[a7] = 1.5 - - a8 = (De>=14.0) & (De<50.0) & (umu0<0.139173) - taup[a8] = 0.1 - a9 = (De>=14.0) & (De<50.0) & (umu0>=0.139173) & (umu0<-0.0011*De+0.2307) - taup[a9] = 0.2 - a10 = (De>=14.0) & (De<50.0) & (umu0>=-0.0011*De+0.2307) & (umu0<-0.0022*De+0.3340) - taup[a10] = 0.3 - a11 = (De>=14.0) & (De<50.0) & (umu0>=-0.0022*De+0.3340) & (umu0<-0.0020*De+0.4096) - taup[a11] = 0.4 - a12 = (De>=14.0) & (De<50.0) & (umu0>=-0.0020*De+0.4096) & (umu0<-0.0033*De+0.6461) - taup[a12] = 0.5 - a13 = (De>=14.0) & (De<50.0) & (umu0>=-0.0033*De+0.6461) & (umu0<-0.0049*De+1.0713) - taup[a13] = 1.0 - a14 = (De>=14.0) & (De<50.0) & (umu0>=-0.0049*De+1.0713) - taup[a14] = 1.5 - - a15 = (De>=50.0) & (umu0<-0.0006*De+0.2109) - taup[a15] = 0.2 - a16 = (De>=50.0) & (umu0>=-0.0006*De+0.2109) & (umu0<-0.0005*De+0.2581) - taup[a16] = 0.3 - a17 = (De>=50.0) & (umu0>=-0.0005*De+0.2581) & (umu0<-0.0010*De+0.3907) - taup[a17] = 0.4 - a18 = (De>=50.0) & (umu0>=-0.0010*De+0.3907) & (umu0<-0.0008*De+0.4900) - taup[a18] = 0.5 - a19 = (De>=50.0) & (umu0>=-0.0008*De+0.4900) & (umu0<-0.0017*De+0.8708) - taup[a19] = 1.0 - a20 = (De>=50.0) & (umu0>=-0.0017*De+0.8708) & (umu0<-0.0006*De+1.0367) - taup[a20] = 1.5 - a21 = (De>=50.0) & (umu0>=-0.0006*De+1.0367) - taup[a21] = 2.0 - -###Tddp - Tddp = np.zeros_like(Z) - b1 = (umu0>=0.9994) & (De<=10.0) - Tddp[b1] = 0.12269 - b2 = (umu0>=0.9994) & (De>10.0) & (De<=16.0) - Tddp[b2] = 0.0015*De[b2] + 0.1078 - b3 = (umu0>=0.9994) & (De>16.0) - Tddp[b3] = 0.1621*np.exp(-0.016*De[b3]) - - b4 = (umu0<0.9396) & (De<=10.0) - Tddp[b4] = 0.14991 - b5 = (umu0<0.9945) & (umu0>=0.9396) & (De<=10.0) - Tddp[b5] = -4.5171*np.power(umu0[b5],2.0) + 8.3056*umu0[b5] - 3.6476 - b6 = (umu0>=0.9945) & (umu0<0.9994) & (De<=10.0) - Tddp[b6] = 298.45*np.power(umu0[b6],2.0) - 601.33*umu0[b6] + 303.04 - - - ade = -0.000232338*np.power(De,2.0) + 0.012748726*De + 0.046745083 - b7 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0<=0.2419) - Tddp[b7] = (-8.454*np.power(umu0[b7],2.0) + 2.4095*umu0[b7] +0.8425)*ade[b7] - b8 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.2419) & (umu0<=0.3746) - Tddp[b8] = (-13.528*np.power(umu0[b8],2.0) + 7.8403*umu0[b8] -0.1221)*ade[b8] - b9 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.3746) & (umu0<=0.4694) - Tddp[b9] = (19.524*np.power(umu0[b9],2.0) - 16.5*umu0[b9] +4.4612)*ade[b9] - b10 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.4694) & (umu0<=0.5877) - Tddp[b10] = (16.737*np.power(umu0[b10],2.0) - 17.419*umu0[b10] +5.4881)*ade[b10] - b11 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.5877) & (umu0<=0.6691) - Tddp[b11] = (-39.493*np.power(umu0[b11],2.0) + 48.963*umu0[b11] -14.175)*ade[b11] - b12 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.6691) & (umu0<=0.7660) - Tddp[b12] = (0.4017*np.power(umu0[b12],2.0) - 0.243*umu0[b12] +0.9609)*ade[b12] - b13 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.7660) & (umu0<=0.8480) - Tddp[b13] = (-11.183*np.power(umu0[b13],2.0) + 18.126*umu0[b13] -6.3417)*ade[b13] - b14 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8480) & (umu0<=0.8987) - Tddp[b14] = (-163.36*np.power(umu0[b14],2.0) + 283.35*umu0[b14] -121.91)*ade[b14] - b15 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.8987) & (umu0<=0.9396) - Tddp[b15] = (-202.72*np.power(umu0[b15],2.0) + 368.75*umu0[b15] -166.75)*ade[b15] - b16 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9396) & (umu0<=0.9702) - Tddp[b16] = (-181.72*np.power(umu0[b16],2.0) + 343.59*umu0[b16] -161.3)*ade[b16] - b17 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9702) & (umu0<=0.9945) - Tddp[b17] = (127.66*np.power(umu0[b17],2.0) - 255.73*umu0[b17] +129.03)*ade[b17] - b18 = (umu0<0.999) & (De>10.0) & (De<=30.0) & (umu0>0.9945) - Tddp[b18] = (908.66*np.power(umu0[b18],2.0) - 1869.3*umu0[b18] +961.63)*ade[b18] - - bde = 0.0000166112*np.power(De,2.0) - 0.00410998*De + 0.352026619 - b19 = (umu0<0.999) & (De>30.0) & (umu0<=0.2419) - Tddp[b19] = (-4.362*np.power(umu0[b19],2.0) - 0.0878*umu0[b19] +1.1218)*bde[b19] - b20 = (umu0<0.999) & (De>30.0) & (umu0>0.2419) & (umu0<=0.3746) - Tddp[b20] = (-49.566*np.power(umu0[b20],2.0) + 28.767*umu0[b20] -3.1299)*bde[b20] - b21 = (umu0<0.999) & (De>30.0) & (umu0>0.3746) & (umu0<=0.4694) - Tddp[b21] = (58.572*np.power(umu0[b21],2.0) - 49.5*umu0[b21] +11.363)*bde[b21] - b22 = (umu0<0.999) & (De>30.0) & (umu0>0.4694) & (umu0<=0.5877) - Tddp[b22] = (62.118*np.power(umu0[b22],2.0) - 63.037*umu0[b22] +16.875)*bde[b22] - b23 = (umu0<0.999) & (De>30.0) & (umu0>0.5877) & (umu0<=0.6691) - Tddp[b23] = (-237.68*np.power(umu0[b23],2.0) + 293.21*umu0[b23] -89.328)*bde[b23] - b24 = (umu0<0.999) & (De>30.0) & (umu0>0.6691) & (umu0<=0.7660) - Tddp[b24] = (1.2051*np.power(umu0[b24],2.0) - 0.7291*umu0[b24] +0.8826)*bde[b24] - b25 = (umu0<0.999) & (De>30.0) & (umu0>0.7660) & (umu0<=0.8480) - Tddp[b25] = (-55.6*np.power(umu0[b25],2.0) + 90.698*umu0[b25] -35.905)*bde[b25] - b26 = (umu0<0.999) & (De>30.0) & (umu0>0.8480) & (umu0<=0.8987) - Tddp[b26] = (-422.36*np.power(umu0[b26],2.0) + 733.97*umu0[b26] -317.89)*bde[b26] - b27 = (umu0<0.999) & (De>30.0) & (umu0>0.8987) & (umu0<=0.9396) - Tddp[b27] = (-457.09*np.power(umu0[b27],2.0) + 831.11*umu0[b27] -376.85)*bde[b27] - b28 = (umu0<0.999) & (De>30.0) & (umu0>0.9396) & (umu0<=0.9702) - Tddp[b28] = (-344.91*np.power(umu0[b28],2.0) + 655.67*umu0[b28] -310.5)*bde[b28] - b29 = (umu0<0.999) & (De>30.0) & (umu0>0.9702) & (umu0<=0.9945) - Tddp[b29] = (622.85*np.power(umu0[b29],2.0) - 1227.6*umu0[b29] +605.97)*bde[b29] - b30 = (umu0<0.999) & (De>30.0) & (umu0>0.9945) - Tddp[b30] = (6309.63*np.power(umu0[b30],2.0) - 12654.78*umu0[b30] +6346.15)*bde[b30] - -###Tddcld - a = 1.7686*np.power(umu0,-0.95) - b = 7.117*np.power(umu0,1.9658) - - Tddcld = np.zeros_like(Z) - a1 = tau<=0.9*taup - Tddcld[a1] = Tddp[a1]*np.tanh(a[a1]*tau[a1]) - a2 = (tau>0.9*taup) & (tau=taup - Tddcld[a3] = Tddp[a3]*np.tanh(b[a3]/np.power(tau[a3],2.0)) - - return Tddcld - - - - - -def farms_dni(F0, tau, solar_zenith_angle, De, phase, phase1, phase2, Tddclr, Ftotal, F1): - - ############### scale tau - taudni = np.zeros_like(tau) - - a1 = np.where( (phase == 1) & (tau<8.0) ) - a2 = np.where( (phase == 1) & (tau>=8.0) ) - taudni[a1] = ( 0.254825*tau[a1] - 0.00232717*np.power(tau[a1], 2.0) \ - + (5.19320e-06)*np.power(tau[a1], 3.0) )*(1.0+(8.0-tau[a1])*0.07) - taudni[a2] = 0.2*np.power(tau[a2]-8.0, 1.5) + 2.10871 - - b1 = np.where( (phase == 2) & (tau<8.0) ) - b2 = np.where( (phase == 2) & (tau>=8.0) ) - taudni[b1] = 0.345353*tau[b1] - 0.00244671*np.power(tau[b1], 2.0) \ - + (4.74263E-06)*np.power(tau[b1], 3.0) - taudni[b2] = 0.2*np.power(tau[b2]-8.0, 1.5) + 2.91345 - ############### - - Z = np.arccos(solar_zenith_angle)*180.0/np.pi - dni0 = F0*Tddclr*np.exp(-tau/solar_zenith_angle) - - Tddcld0 = np.exp(-taudni/solar_zenith_angle) - Fd0 = solar_zenith_angle*F0*Tddcld0*Tddclr - - Tddcld1 = TDDP(Z, taudni, De, phase1, phase2) - Fd1 = solar_zenith_angle*F0*Tddclr*Tddcld1 - Fd2 = TDD2(Z, Ftotal, F1 ) - - Fd = Fd0 + Fd1 + Fd2 - dni_farmsdni = Fd/solar_zenith_angle - - return Fd, dni_farmsdni, dni0 - - - - diff --git a/farms/version.py b/farms/version.py index 51fee2b..0d95eab 100644 --- a/farms/version.py +++ b/farms/version.py @@ -2,4 +2,4 @@ FARMS version number """ -__version__ = "1.0.4" +__version__ = "1.0.5" From 0d9baf6b5e7d189a7d7d4d53c347ab538686179f Mon Sep 17 00:00:00 2001 From: bnb32 Date: Thu, 13 Apr 2023 16:42:54 -0600 Subject: [PATCH 55/55] updated docstring for farms outputs --- farms/farms.py | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/farms/farms.py b/farms/farms.py index 1fcbadc..48824dd 100644 --- a/farms/farms.py +++ b/farms/farms.py @@ -158,14 +158,32 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, Returns ------- - ghi : np.ndarray - FARMS GHI values (this is the only output if debug is False). - fast_data : collections.namedtuple - Additional debugging variables if debug is True. - Named tuple with irradiance data. Attributes: - ghi : global horizontal irradiance (w/m2) - dni : direct normal irradiance (w/m2) - dhi : diffuse horizontal irradiance (w/m2) + If debug == True: + fast_data : collections.namedtuple + Named tuple with irradiance data with the following attributes: + ghi : np.ndarray + global horizontal irradiance (W/m2) + dni : np.ndarray + direct normal irradiance (W/m2) + dhi : np.ndarray + diffuse horizontal irradiance (W/m2) + Ruucld : np.ndarray + Aerosol reflectance for diffuse fluxes for cloudy + atmosphere. + Tddcld : np.ndarray + Transmittance of the cloudy atmosphere for direct incident + and direct outgoing fluxes (dd). + Tducld : np.ndarray + Transmittance of the cloudy atmosphere for direct incident + and diffuse outgoing fluxes (du). + else: + ghi: np.ndarray + Global horizontal irradiance (W/m2) + dni_farmsdni: np.ndarray + DNI computed by FARMS-DNI (W/m2). + dni0: np.ndarray + DNI computed by the Lambert law (W/m2). It only includes the narrow + beam in the circumsolar region. """ # disable divide by zero warnings np.seterr(divide='ignore') @@ -209,9 +227,9 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, dni = Fd / solar_zenith_angle # eq 2b from [1] dhi = ghi - Fd # eq 7 from [1] - Fd, dni_farmsdni, dni0 = \ - farms_dni.farms_dni(F0, tau, solar_zenith_angle, De, phase, - phase1, phase2, Tddclr, ghi, F1) + Fd, dni_farmsdni, dni0 = farms_dni.farms_dni(F0, tau, solar_zenith_angle, + De, phase, phase1, phase2, + Tddclr, ghi, F1) clear_mask = np.in1d(cloud_type, CLEAR_TYPES).reshape(cloud_type.shape) if debug: @@ -228,8 +246,7 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle, return fast_data else: - # return only GHI - return np.where(clear_mask, np.nan, ghi),\ - np.where(clear_mask, np.nan, dni_farmsdni),\ - np.where(clear_mask, np.nan, dni0) - # print( theta00, idx, muomega ) + out = (np.where(clear_mask, np.nan, ghi), + np.where(clear_mask, np.nan, dni_farmsdni), + np.where(clear_mask, np.nan, dni0)) + return out