# Need to write a function that computes the UV index

I have found a lot of people talking about how to compute the UV index, but have not found an example that shows the actual equations, so I could adapt them into an algorithm.

Probably the closest is this example here.

The most confusing part of the process is why there are so many cases that present hypothetical data rather than a real example. For instance, here is the EPA's explanation. They seem to compute a real number. But they say the weighing factors are fake.

-

This is a part answer in regards to the weighing factors:

According to the Smithsonian Environmental Research Centre's page "How is the UV-Index Calculated?", the weighing factor are not so much made up, but is

weighted according to how human skin responds to each wavelength; it is more important to protect people from wavelengths that harm skin than from wavelengths that do not damage people's skin.

This weighting function is based on the McKinlay-Diffey Erythema action spectrum, defined in this NOAA article "Instantaneous UV Index and Daily UV Dose Calculations" and is wavelength dependent, with the weighting for wavelengths (note, the NOAA article has a step by step mathematical procedure).

• less than 298nm = 1.

• between 298nm and 328nm weighted by $10^{0.094(298-\lambda)}$

• between 328nm and 400nm weighted as $10^{0.015(139-\lambda)}$

• for wavelengths 400nm and above, they are weighted as 0

Giving the action spectra as:

Image source: "Solar ultraviolet radiation effects on biological systems" (Diffey, 1991).

-
I hadn't looked at this in a long time. Not sure why I checked this answer. I up voted it and that was deserved, but this is not an answer. –  Rob May 28 '14 at 2:34