(Not exactly Radiance, but I have nowhere else to ask.)

I’ve got fixtures for which the manufacturer refuses to divulge photometric data. It is, unfortunately, a poor country, and the vendor is the only one I can find, so I’m trying to generate one based on data about fixture geometry and output. I have then run into a second problem: I seem unable to correctly go from an array of proportionate candela values to a valid IES file; my attempts at integrating the candela values in existing IES files lead to total lumen outputs of about 1.7-1.8 times the correct value. I suspect I am missing a factor of √π somewhere. My procedure (in Julia) is the following. Anyone have any thoughts on what is going wrong here?

```
cv = pho.candelavalues
va = pho.verticalangles
ha = pho.horizontalangles
rows,cols = size(cv)
total = 0
for i = 1:rows-1
for j = 1:cols-1
Iᵥ = sum(cv[i,j] + cv[i+1,j] + cv[i,j+1] + cv[i+1,j+1]) / 4
Ω = 4 * asin(
sind((ha[i+1]-ha[i])/2) *
sind((va[j+1]-va[j])/2))
total += Iᵥ * Ω
end
end
total
```

Hi Randolph,

this looks familiar, and I think I once ran down that rabbit hole too.

The solid angle calculation is more involved, as it requires calculating the *spherical excess* of the quadrilateral spanned by the cv array entries:

```
Ω = ∑ α_i - 2π
```

where α_i is the angle (in radians) between the two adjacent planes passing through the hemisphere’s origin and the i-th and ((i+1) mod 4)-th quadrilateral edge. There’s a nice illustration here for a spherical triangle: Spherical trigonometry - Wikipedia

Incidentally, *evalglare* does the same calculation under the hood for pixels.

Hope this helps. Let me know if you need hints calculating the plane normals. I wrote this stuff in Python a few years back.

–Roland

1 Like

Ouch! Thanks. Yes, I certainly got that wrong. To be continued…

BTW, I have put in a request to have equation support added to the Radiance Discourse server. This is one of those “Duh” things that seems to have been overlooked.

Hi Randolph,

no worries. Been there, done that. Of course I’m not ruling out other issues with the calculation, but the spherical excess is a common issue here.

I do agree equation support would be very helpful here. Punching in Unicodes is no fun. Had to revert to TeX notation with the subscripts.

–Roland

1 Like

Lo! I have found it!

Turns out that the horizontal angles in type C photometry describe great circles - lines of longitude, but the vertical angles describe circles in planes perpendicular to the axis of horizontal angles, which are *not* great circles - lines of latitude. With that in hand, and a formula found in Wikipedia’s “Solid Angles” article, this code produces a total approximating the total lumen output of the luminaire.

Thank you for the advice.

```
cv = pho.candelavalues
va = pho.verticalangles
ha = pho.horizontalangles
rows,cols = size(cv)
total = 0
for i = 1:rows-1
for j = 1:cols-1
Iᵥ = (cv[i,j] + cv[i+1,j] + cv[i,j+1] + cv[i+1,j+1]) / 4
Ω = (sind(va[j+1]-90) - sind(va[j]-90)) * (deg2rad(ha[i+1]) - deg2rad(ha[i]))
total += Iᵥ * Ω
end
end
total
```