Astro binding radiation not matching website sonnenverlauf.de

Hi, I included the astro binding quite some time ago and forgot about it. Now I had a look again and found these odd observations:

Maximum radiation today (december):
direct: 85 W/m²
total: 180 W/m²

Maximum radiation in june:
direct: 675 W/m²
total: 800 W/m²

I thought that was too little as I expected a peak around 1000W/m² in germany, but maybe I remember this wrong or mix things up…

But then I compared with this site’s irradiance (german Strahlungsstärke):

It states 750 W/m² peak for today and 1020 W/m² in june.

The definition is:
“Irradiance is the term for the theoretical total power of incoming electromagnetic energy that strikes a surface of the earth (excluding clouds and other air pollution, including the altitude of the location)”

I found nowhere whats the definition for the astro binding.

Anyone got a better understanding of what’s going on here?

Thank you

Edit:
For everyone wondering what’s going on at the website:

<!DOCTYPE html>
<html lang="de">
<head>
    <title>SoMo test</title>
</head>
<body>
	<script src="https://www.sonnenverlauf.de/scripts/somotools.min.js?v=1.4"></script> 
	<script>
		var date = new Date('2024-12-11T12:00:00');
		var longitude = 50.6319;
		var latitude = 10.7438;
		var height = 405 / 1000;
		var l = 60;
        var result = SoMo.getSunSecInfo(date, longitude, latitude, l, 'de', height);
		console.log(result);
	</script>
</body>
</html>

Radiation calculation is done here

Thank you for this information.
I did some research, but I’m really no astronomer and those formulas give me headaches…
But here are my results so far:

Our astro binding has a comment that says:
// all the following methods are translated to java based on the javascript calculations of http://www.suncalc.net

But suncalc.net doesn’t even output this data. Instead I found an englisch version of earlier mentioned https://www.sonnenverlauf.de/ here:
https://www.suncalc.org
This looks much more where I would copy the formulas from…

Here are some explanations for different irradiances:

suncalc.org seems to calculate the “Global normal irradiance (GNI)”.
Normal means the plane where the irradiance is calculated is pependicular to the irradiance. I verified with this calculator that shows more details:
Solar spectrum calculator

But I still haven’t figured out what our astro binding calculates. I guess the values are for the horizontal plane and not perpendicular to the radiation. This reduces the irradiation by cos(zenith angle) which is quite a lot in winter but the values from the astro binding are still too small…

Here I created a running example with the code of the astro binding:
https://onlinegdb.com/PvlxYxRRl
You can just “run” it or click “fork this” and then you can alter the code

This is true for a part of it - espacially stated for lines below #284
The radiation part has been added later (in this PR).

This code comes from anadaptation of a LUA script (I think it was this this); apparently based on this article.

If you find enhancements; please feel free to open an issue and or push a PR with your findings.

Thanks again, I did a comparison and found out:

The solar flux at the entrance to the atmosphere (in Astro binding rOut and at suncalc.org SC - solar constant) are pretty much identical and the zenith angle and the airmass m are pretty identical too. I’ve compared values over a year.

The difference comes solely from the calculation of the irradiance itself:
astro binding:

// Direct radiation after atmospheric layer
// 0.6 = Coefficient de transmissivité
double rDir = rOut * Math.pow(0.6, m) * sinAlpha;
// Diffuse Radiation
double rDiff = rOut * (0.271 - 0.294 * Math.pow(0.6, m)) * sinAlpha;
double rTot = rDir + rDiff;

suncalc.org:

Irradiance = 1.1 * SolarConstant * [(1 - height / 7.1) * Math.pow(0.7, Math.pow(Airmass, 0.678)) + height / 7.1];

This is a very interresting discussion.
Did you recalculate the irradiance in a openhab rule?

No, I’ve used the code from astro binding and put it in an online java compiler.
I’ve already linked it above, but here is the example with the loop over one year:

Edit:
Here is the reference from suncalc:

Copied both to excel and compared there:

The difference is pretty small, but the diff sc has a weird pattern…

I had a look where this comes from and found that the astro binding somehow doesn’t produce continuous values. You can see a graph of the delta with the previous value here:

The zeros are twice the same value:

1.3.24 12:00	1390,24
2.3.24 12:00	1390,24

Don’t know if I can motivate myself to dive even deeper into this…

Yes, the diff equals zero on each second day of an odd month (1/3/5/7/9/11).
Got it. The culprit is :

double rOut = (elevation > 3) ? SC * (0.034 * Math.cos(DEG2RAD * (360 * dayOfYear / daysInYear)) + 1) : 0;

should be:
double rOut = (elevation > 3) ? SC * (0.034 * Math.cos(DEG2RAD * (360.0 * dayOfYear / daysInYear)) + 1) : 0;

Nice, the new code is here (Memory for myself :wink: ):

and the difference to suncalc now looks like this:

I’m not specialist enough, so I asked to ChatGPT :

Difference Between Total Radiation and Irradiance

Total radiation and irradiance are related concepts in the context of light or electromagnetic energy, but they differ in their definitions and applications:


1. Total Radiation

  • Definition: Total radiation is the sum of direct radiation (coming directly from the sun) and diffuse radiation (scattered by the atmosphere, such as by clouds or particles).
  • Unit: It is expressed in joules per square meter (J/m2\text{J/m}^2J/m2) over a specific time period, often used to measure cumulative energy (e.g., daily or monthly totals).
  • Time Context: It refers to energy received over a defined period.

2. Irradiance

  • Definition: Irradiance is the power of radiation received per unit area at a given moment. It measures the instantaneous energy intensity of solar radiation or other types of radiation.
  • Unit: It is expressed in watts per square meter (W/m2\text{W/m}^2W/m2), where 1 W/m2=1 J/s/m21 , \text{W/m}^2 = 1 , \text{J/s/m}^21W/m2=1J/s/m2.
  • Time Context: It refers to a point-in-time measurement, without cumulative energy.

Summary

Criteria Total Radiation Irradiance
Nature Cumulative energy Instantaneous intensity
Unit J/m2\text{J/m}^2J/m2 W/m2\text{W/m}^2W/m2
Time Frame Measured over a time period Measured at a specific moment
Application Assessment of energy received Analysis of energy intensity

Example

  • Measuring solar energy at a specific moment gives you the irradiance.
  • Accumulating these measurements over an entire day results in the daily total radiation.

I doubt the AI is right here.

The astro binding code states that the direct radiation is calculated in W/m².
The total means the combination of diffuse and direct.
Something radiates (the sun) and something else is then hit with irradiance (area on earth). Both are momentary values. This is what we try to calculate.

On the other hand, when time comes into play, it’s called insolation which should be the integral of irradiance over time. Joule = Ws

I found some models that explain how to calculate irradiance, but although they state those are simple models it’s quite complex for me…
You can find them here:

and here:

https://www.researchgate.net/publication/236314775_SMARTS2_a_simple_model_of_the_atmospheric_radiative_transfer_of_sunshine_algorithms_and_performance_assessment

Both are sources of the already posted online calculator here:

https://www2.pvlighthouse.com.au/calculators/solar%20spectrum%20calculator/solar%20spectrum%20calculator.aspx

They use power density for the irradiance and call it perpendicular instead of normal irradiance. But it should be the same. Astro binding calculates horizontal (which they call 0°)

Unfortunately their code is not javascript but a server calculation with a quite complex POST request. I was annoyed of this and quickly gave up trying to iterate over a year with their calculator. But i guess I will go back there and try to do that again…

Astro binding:
DirectRadiation = SolarConstant * 0.6 ^ Airmass ** sin(Angle)*

If we get rid of the angle for the horizontal plane, we should get the formula for DNI (direct normal irradiance)

In wikipedia

there is a link to the DNI, but once clicked the name of the page is “Direct insolation”.

I think a lot on this page is wrong. The title should be “direct normal irradiance” and the page says “Direct insolation is measured in (W/m2)” which is definitely wrong!

What a fuck up.

Buuuut, there is a formula on this page (I tried to find a better source for this but couldn’t…):
DirectInsolation = SolarConstant * 0.7 ^ Airmass ^ 0.678

Ok, we’ve found a similarity.
The relevant factor in astro binding is 0.6 ^ AM and in Wikipedia it is 0.7 ^ AM ^ 0.678

I did a visualization for airmass from 0 to 10:

Compared with above calculator, the wiki one seems better to me.
Now it would be nice to find a valid source for this formula.

I wrote an email to the author of the astro binding source

asking if he got a clue.

2 Likes

Maybe another source of information, I’ll try to investigate : Code search results · GitHub