Antoine, Pidou.
I'll try to explain the reason I go trough all this trouble calculating expexted energy.
This might not be as important closer to the equator, but here the length of the day changes soo much over the year. In summer we have midnight sun, and winter no sun at all. If I set my sunshine criteria to 100 w/m2 it's obviously not valid for each day of the year. In winter it barely reaches this amount on a sunny day, due to the sun beeing so close to the horizon. And ofcourse in summer the energy seen by the detector is far above this amount even with skies covering the sun.
Midsummer my sunny criteria will be >500W/m2 with sun at zenith and >20 w/m2 before it sets at 11pm.
Remember, I try to accurately count every second of detected sun to have a database with hours of sunshine.
Another thing not taken into account in my code, is that it assumes a flat horizon. Another part is needed in addition to compensate for obstructions (ie. forest, mountains, buildings). To get this absolutely perfect yo'd have to measure the horizon with a 'Teodolitt' and come up with a compensating algorithm. (Don't know the english word so I'm posting an image).
Pièce jointe:
teodolitt.jpg
My experince is that setting the criteria to 55% of expected radiation you get a cutoff when the sun doesn't cast distinct shadows anymore. If you want to elaboarte on this you could do all sorts of 'binning' of these data, monitoring different thresholds. Clear, Haze, Light overcast, Heavy overcast. Monitor for broken clouds and so further (I'm not there yet
)
This way I always have an accurate percentage of sunshine compared to the length of the day. So far today It's been sunny 70% of the time
Hope this explanation is worth something to somebody.
Regards
Audun
http://vindkast.no