Sunsethue logo

Sunsethue Whitepaper

Sunsethue’s sunrise and sunset forecasts are made using Sunsethue’s ray-based algorithm. The model tries to capture reality using simple mathematical and physical concepts. This page tries to conceptually explain how the Sunsethue ray-based model works, and how it is able to predict the quality of upcoming sunrises and sunsets.

TECHNICAL DETAILS

Figure 1

A conceptual overview

A conceptual overview

Let the blue dot on the surface of the Earth be an observer (figure 1), this could be you at your preferred sunrise or sunset spotting location. The concept is simple, a set of rays is cast from the observer’s position in the direction of sunrise or sunset. Let’s consider one of these rays, the blue ray in the figure.

We walk over the hypothetical blue ray from the observer’s position on the Earth’s surface up into the sky. We keep walking until we encounter a cloud. At the base of the cloud we stop and cast a new ray towards the sunrise or sunset (i.e. the ray reflects off the cloud). Let’s consider the red ray in the figure.

If there are no clouds between the base of the cloud (where the red and blue ray meet) and the sun, it means that sunlight can reach said cloud during sunrise or sunset, and reflect towards our observer. To determine this, we walk over the red ray and keep track of the clouds we pass until exiting the troposphere.

With this information, we now know if sunlight can be reflected off a cloud to the observer’s position at sunset. In this very simplistic example, we can now assign a score to the sunset depending on if the red ray is blocked, and the height of the cloud (because it plays a role in the duration and colours during a sunset). In very simple terms, this is what the Sunsethue quality metric is.

Figure 2

A more realistic example

A more realistic example

The situation in figure 1 only consists of one cloud and two rays, it is a really simplified version of reality. Consider a more realistic example, where multiple rays are cast from the observer. Each of these rays can hit clouds, although some of them might not. When clouds are hit by a blue ray, a new set of red rays are cast in the direction of the sun. Some of them might be blocked by clouds in the distance, even if they are not visible for the observer.

Even this is a simplified example, since the blue rays are actually cast in all three dimensions, and some clouds might not block all light. The latter means that the blue rays could in some cases pass partially through a cloud, resulting in even more red rays.

The algorithm in two steps

In actuality these calculations are done in parallel for each location in two main phases. In the first phase, the model calculates if the sun can hit a cell. Together with the cloud cover of the given cell, the reflection potential is calculated (i.e. does this cell have any potential to reflect light towards the observer at sunrise or sunset).

In a second phase, rays are cast from the observer (from all cells on the surface of the Earth). Based on the cells it encounters along the way, and their reflection potential, as well as the total cloud cover on the ray, the actual sunrise or sunset quality metric is calculated.

Figure 3

Reflection potential

Reflection potential

The lowest layer of the atmosphere, called the troposphere is where all clouds reside. In weather models, the troposphere is divided in a number of vertical layers. For every location on Earth, and for every vertical level, the reflection potential is calculated.

To do this, rays are cast in various directions towards sunrise or sunset (figure 3). The total cloud cover on these rays are calculated. If there are a lot of clear rays, the hypothetical reflection potential is high, if most rays are blocked, it is low. In essence, the hypothetical reflection potential is a number between 0% and 100%, where 0% means that all incoming rays are fully blocked, and 100% means none of the rays are blocked by any other clouds.

The hypothetical reflection potential of a cell is thus solely determined by how much sunlight can reach said cell during sunrise and sunset. Accounting for the cloud cover in every cell, and the height above Earth’s surface of the cell, the actual reflection potential is calculated.

Middle high and high clouds receive a higher reflection potential because they are more potent at reflecting light during sunrise or sunset. Meanwhile, if there are no clouds that can reflect the light back to the observer in the cell, the reflection potential is low.

Figure 4

Quality score

Quality score

To calculate the actual metric we’re after: the quality score for every location on Earth, we start by casting a bunch of rays from every location on Earth’s surface. This time, the rays are cast in the general direction of sunrise or sunset (figure 4).

For every ray, a value is kept with the total cloud cover of the ray. We start from the observer and sum up the reflection potential of all cells on the ray. If the total cloud cover of the ray becomes saturated, we know that the clouds above it won’t be visible anymore from the observer’s position, so the reflection potential of the cells above is affected by the ray’s running cumulative cloud cover.

Finally, an average is taken of all rays that are cast from the observer. This average value is the base sunrise or sunset quality metric. Until this stage in the algorithm, only the cloud cover has had an impact on the quality of the sunrise or sunset. Cloud cover is the main variable used in Sunsethue’s model, but some post-processing is done on the quality after the main algorithm.

Post-processing

The last step in the calculation of the sunrise and sunset quality metric that is available on the Sunsethue website and in the API, is to do some post processing. The quality metric is slightly adjusted by the humidity at the surface. A high humidity correlates with less visibility, which results in a lower probability of a good sunrise or sunset.

Besides this, the quality metric is also slightly skewed based on the duration of the sunset (i.e. the duration of golden hour), which varies by latitude and time of year. In summer and winter, the longer sunsets up north and south result in a higher score for these regions than the regions near the equator.

Extensions

Due to the nature of the ray-based model, some other metrics regarding the sunrise or sunset are theoretically possible to calculate. These metrics can help us understand an upcoming sunrise or sunset even better than a single composite index, like the quality metric.

Figure 5

Highlight time metric

Highlight time metric

One of these features, which is currently in an experimental phase, is the highlight metric. The highlight time tries to determine when the best colors will occur relative to the time of sunrise or sunset. Together with this, the highlight quality is calculated (but not yet available on Sunsethue). The highlight value will tell you how good the best moment of a sunrise or sunset will be.

The highlight time is determined by saving the angle of the ray (angle B in figure 5) with the least light being blocked in the reflection potential phase for each cell. In the sunset quality phase, a similar thing is done. The angle of the ray which contains the cloud with the highest reflection potential for that location is stored (angle A in figure 5). With A and B you can determine angle C, which tells you how much the sun is above/below the horizon during the highlight. Angle C can then be used to determine the highlight time (relative to the sunrise or sunset).

Other extensions

This is just one of the (theoretically) possible extensions that could be developed. Some other potential extensions include (in order of how difficult it will be to implement them, from easy to hard):
- Sunset quality and (visible) cloud cover per cloud level (low, middle, high clouds)
- Separate before and after sunset quality metrics
- Skybox location of the best colors
- Color or color gradient of the sunrise or sunset
- Duration and time range of colors during sunrise or sunset

These extensions do require more research and testing to verify if they are practically feasible to implement, and accurate enough to be used on a day-to-day basis. The structure of the rays-based model does facilitate these extensions, but deriving the math for these extensions will take time.

Points for improvement

The main chunk of the algorithm is based on the geographical and physical reality, but nevertheless there do remain some tweakable values and formulas. Take for example the impact of cloud height on reflection potential or the humidity post-processing.

The values for these tweakable values have been chosen and tweaked to represent the real world as accurately as possible, but nevertheless they can be wrong on some occasions. Ideally the impact of these values should be minimized, and the actual values should be determined more scientifically.

Besides that, more post-processing variables could be introduced, like for example visibility at the Earth’s surface, the presence of fog, air pollution or smoke from forest fires. Before doing so, the effects of these parameters on the sunrise or sunset should be more accurately studied.

Lastly, technical improvements could be made to the actual execution of the model. Currently, some corners are cut in calculating the quality metric to save costs on computation. Ideally, the horizontal and vertical resolution and number of runs per day should be increased.

Uncertainty

I’d like to end this overview by addressing two points which have been quite difficult to handle in the process of creating the Sunsethue model. First off, Sunsethue uses the raw output from a weather model to perform the calculations. Weather forecasts are inherently uncertain, because the atmosphere cannot be perfectly modelled and forecasted.

This has an impact on Sunsethue’s model, especially for forecasts for multiple days in the future. To combat this uncertainty, I chose a weather model that has quite accurate cloud cover forecasts. But this model does lack in some other areas. Ideally, smaller scale regional models could be used for more accurate forecasts, but this requires more computational capacity.

Before the new ray-based model was deployed, Sunsethue had an uncertainty metric, which indicated how uncertain a forecast was deemed to be. This is one of the things I’d like to bring back, to make it easier to make decisions based on Sunsethue’s forecasts.

MORE ON UNCERTAINTY

Subjectivity

What does the quality of a sunrise or sunset mean? The answer to this question may be different for everyone. A sunrise or sunset is an experience, which cannot be objectively determined, it is different for every individual. Some people may rate a sunset as excellent, while others think it is quite average, because of their previous experiences and/or personal preferences.

Trying to reflect something this subjective in a single value is really difficult. That’s why the sunrise or sunset quality is accompanied by some more textual information on Sunsethue’s website. But at last, users can interpret the quality metric based on their own experiences with using Sunsethue, and using the quality interpreting guide.

INTERPRETING GUIDE

Questions and feedback

If you have questions or feedback on one of the subjects touched upon in this write-up, or if you have general questions about Sunsethue and its model, please hit me up at tropoflow@gmail.com.