Function to fit solar radiation data I have ground-level radiation data of solar incoming radiation from a radiometer (cosine collector) measured along the day. In the following plot you can see PAR irradiance (ie visible light) in Watts per square meter versus time of day (local time). AS usual for this type of sensor, radiation intensity varies with the Sun's angle with respect to the ground level.

As you can see it doesn't look perfectly smooth, rather it has some 'chopped' sections (most notably after maximum at noon) due to the presence of transient, passing-by clouds. I would like to use these data points to fit a model and obtain the ideal radiation curve as if it was a clear-sky day, ie perfect, continuous curve. 
As you can see it is not a gaussian curve... I've heard before that the appropriate model is the Rayleigh distribution, but I'm not sure... 
What do you think? is that the correct one or should I use another distribution? I don't want just to fit any equation, rather I want to use the appropriate one which is suitable for investigating ant testing the corresponding parameters. Thanks!
 A: You'll need two things, the solar zenith angle $\theta$ and the air mass $AM$. The zenith angle is given by $$\cos\theta = \cos\phi \cos \delta + \sin\phi \sin\delta \sin h$$ where


*

*$\phi$ is your latitude,

*$\delta$ is the declination of the Sun, and

*$h$ is the hour angle.


You should know your own latitude. The declination of the Sun can be found on a number of websites. For example, http://www.esrl.noaa.gov/gmd/grad/solcalc. Finally, the hour angle is zero at solar noon and moves at 15 degrees per hour. The above site also tells when solar noon occurs.
A simplified formula for air mass is $$AM = \frac 1{\cos \theta}$$ This doesn't quite apply at low zenith angles. (You can see quite nicely at sunrise and sunset. This simple expression says you can't.) You can find more detailed formulae for air mass at the wikipedia article on air mass.
Once you have the air mass you calculate the solar radiance via $$I = I_0\, 0.7^{{AM}^{0.678}}$$
where $I_0$ is the radiance at the top of the atmosphere, 1.353 kW/m2. If you want to account for the clear sky radiance, multiply by 1.1. Once again, see the wiki air mass article for details.
Note that the irradiance most definitely is not a linear function of zenith angle.
A: Your curve has two components in it:


*

*Actual solar intensity per unit area (affected by atmospheric conditions, that is the probability that the sunlight is not scattered or absorbed on its path through the atmosphere)

*The projection of the sunlight onto your collector: if your collector is facing in a particular direction, the angle of the normal of the collector to the incident light will change, and give rise to a cosine relationship.


The second of these is relatively easy to calculate; the first can be harder, as it depends on atmospheric conditions (see my recent answer on Why is the sun brighter in Australia for some more details about that) as well as the actual path length (a function of the height of observation, the latitude, and the position of the sun). But you might decide to set an arbitrary attenuation coefficient $\alpha$ of the atmosphere (units of $/km$, perhaps) after which you can write an expression for the second term based on a model with a constant thickness atmosphere, using just the angle of the sun to compute the approximate path length.
One note about fitting the data: you will want to ignore (or give low weight) to any points that fall below the expected curve, since these are likely caused by clouds as you say; on the other hand your fit should not go above the data, as this is unphysical. That makes the fitting routine itself a little bit unusual - but you can address this by constructing your own penalty function rather than relying on a conventional RMS error metric.
