## 2 Methodology
### Sun Detection
#### 2.2.2. Dome Detection
(**b**) shows the output of the segmentation process, while in (**c**), the resulting Sun position (red dot), as well as the enclosing circle are shown. On the other hand, from the case shown in Figure 7, in which the Sun and a cloud (that has suddenly formed very close to it) have been merged as a single object, causing the enclosing circle of this object to be such that its center moves away from the circumsolar area, the system is capable of mitigating the change, keeping the tracking position close to the circumsolar area, due to the use of the particle filter, as shown in Figure 3.0

At this point, with the proposed approach, it is possible to determine the position of the Sun even in cases where there are elements in the scene that may interfere, as is the case of clouds whose intensity in the image could have values similar to the intensity of the Sun. However, it may be the case that the Sun cannot be detected because it is totally occluded by a cloud during a long period of time, for instance on a very cloudy day. To address this problem, a solution based on computing the position of the Sun through the geographical position of the prototype has been implemented. #### 2.2.5 Detection of the Sun on Cloudy Days

When the position of the Sun, in the image, cannot be computed due to an occlusion commonly caused by a cloud, the system attempts to approximate it through the geographical position (latitude and longitude) of the prototype. In order to do that, the Pysolar library (available at pysolar.org) has been used. Pysolar is an online library of Python codes that implement an algorithm developed by the National Renewable Energy Laboratory (NREL) for solar position calculation [22]. The implemented algorithm is a set of fairly straightforward equations that calculate the Sun's location in the sky at a specific time of a specific day. In Figure 10, a set of positions of the Sun (red dots) computed by the Pysolar library on a unit sphere throughout the day are shown. When the Sun is totally occluded by some clouds and it cannot be segmented in the image, which means that it is not possible to obtain its position, the position computed by the Pysolar library (for that specific day and time) is used. The computed point is projected onto the image and becomes the input parameter of the particle filter instead of the output of the segmentation process. Figure 3.1 Sun detection (red dot) and tracking (green dot). Figure 3.2 Correction of the Sun’s position through tracking. An example of the case where the Sun is occluded by some clouds is shown in Figure 3.3 Due to fact that the Sun's position cannot be segmented in the image, the system estimates its position by the Pysolar library; however, once the segmentation process is capable of detecting the Sun, the system improves that approximation, since the position of the Sun given by the segmentation is much more precise. By using this methodology, the proposed system is capable of detecting the Sun in the image, regardless of the day's conditions. Knowing the position of the Sun at all times is a fundamental step, since from this information, a system like the one that has been proposed would be able to compute or infer other information, for instance an irradiance value. ## 3 Results and Discussion

To test the proposed approach, three different scenarios have been selected. These three scenarios are considered as the set of scenarios that cover all the possible conditions that may occur. In the first scenario, a full clear-sky day has been selected, in the second one, a day where a partial occlusion of the Sun in some instant of the day is present has been analyzed, and finally, for the third one, a day where in a period of time, a complete occlusion of the Sun is present, has been selected. ### Scenario 1 (Sunny Day)

In this scenario, a full clear-sky day has been selected. For this scenario, a set of images taken every 15 min, from 9:00-17:00 on 8 November (i.e., from sunrise to sunset), has been analyzed.