pingswept / pysolar

Pysolar is a collection of Python libraries for simulating the irradiation of any point on earth by the sun. It includes code for extremely precise ephemeris calculations.
http://pysolar.org
GNU General Public License v3.0
372 stars 125 forks source link

global_irradiance_clear vs get_radiation_direct #116

Closed trondkr closed 3 years ago

trondkr commented 4 years ago

Hi, I am trying to calculate the total incoming solar irradiation at a specific location and time using pysolar, but I have some trouble figuring out which functions to use. I used 'radiation.get_radiation_direct' which seems to give reasonable values (W/m2). But looking at the code for function 'global_irradiance_clear' it seems like a much more robust approach to doing this calculation taking into account diffuse and direct irradiation and properties of the atmosphere. But when I use the function I get weird values.

Is there something I am doing wrong here - or alternative approach better suited? I appreciate your help in understanding best how to use pysolar. Thanks for your help. T

latitude_deg=37.77
longitude_deg=-122.41 
d = datetime.datetime.now(datetime.timezone(offset=datetime.timedelta(hours=-8)))
thirty_minutes = datetime.timedelta(hours = 2)
for _ in range(48):
     timestamp = d.ctime()
     altitude_deg = get_altitude(latitude_deg, longitude_deg, d)
     azimuth_deg = get_azimuth(latitude_deg, longitude_deg, d)
     power = radiation.get_radiation_direct(d, altitude_deg)

     test3=pysolar.util.global_irradiance_clear(latitude_deg, longitude_deg, d)
     #if (altitude_deg > 0):
     print(timestamp, "PST: ", power,test3)
     d = d + thirty_minutes

which gives: Thu Jan 2 15:02:03 2020 PST: 779.66 -230238050145218428928.00 Thu Jan 2 17:02:03 2020 PST: 0.00 -46187714474826194944.00 Thu Jan 2 19:02:03 2020 PST: 0.00 178007895035033321472.00 Thu Jan 2 21:02:03 2020 PST: 0.00 -109928677071960883200.00 Thu Jan 2 23:02:03 2020 PST: 0.00 104739133866417717248.00 Fri Jan 3 01:02:03 2020 PST: 0.00 -84009954411344871424.00 Fri Jan 3 03:02:03 2020 PST: 0.00 -161044782726617726976.00 Fri Jan 3 05:02:03 2020 PST: 0.00 -141336583624569978880.00 Fri Jan 3 07:02:03 2020 PST: 0.00 205425159211368087552.00 Fri Jan 3 09:02:03 2020 PST: 709.71 192161756740812963840.00 Fri Jan 3 11:02:03 2020 PST: 910.15 191023236926092902400.00 Fri Jan 3 13:02:03 2020 PST: 921.74 -27916580034010144768.00 Fri Jan 3 15:02:03 2020 PST: 782.51 -186157673811934117888.00 Fri Jan 3 17:02:03 2020 PST: 0.00 -18285685307843796992.00 Fri Jan 3 19:02:03 2020 PST: 0.00 136243274237641441280.00 Fri Jan 3 21:02:03 2020 PST: 0.00 -113743511259885207552.00 Fri Jan 3 23:02:03 2020 PST: 0.00 110078234459507671040.00

pingswept commented 3 years ago

Nobody seems to want to spend the time to sort out what’s going on here, so I’m closing this for now. Feel free to re-open if it’s an ongoing issue.