Maarten Laureyssen.
Sunsethue•

The Sunset Forecasting Problem: An Overview

An overview of sunset quality forecasting, from simple heuristics to ray-based and machine-learning approaches.

Context

Predicting the quality of a sunrise or sunset is a niche problem at the intersection of meteorology, computation and optics. With the increasing popularity of landscape photography and tourist destinations marketing their sunrise or sunset spots, the problem has gained importance over the last decade.

It has been known for a long time that the quality of a sunset can be predictive of the weather to come. Take, for example, the saying: “red sky at night, shepherd's delight”. A red sky at night (colourful sunset) indicates that the skies are clear to the west, which is the prevailing direction of movement of weather systems in the mid-latitudes.

But with today's increasingly accurate weather forecasts, the opposite problem has become more interesting: predicting the quality of a sunrise or sunset given the expected weather. Historically, this problem has been approached using common sense and some basic principles applied to weather forecasts. General rules like “30–70% cloud cover and low humidity” are not that helpful. Analyzing weather charts can work well for some, but for untrained people, making their own predictions based on weather forecasts is difficult.

That’s where automated methods come in. Here, I will define the problem of sunset quality forecasting and discuss some methods to solve it.

Goal

The quality of a sunset is not binary (it is not simply good or bad, but rather falls on a scale). The goal of a sunset forecast is to predict the quality of a sunset, not the probability of a good sunset (although the two are sometimes confused by mainstream predictors, including Sunsethue).

First, the meaning of sunset quality needs to be defined. This is, of course, difficult, as quality is highly subjective and there are multiple dimensions to a sunset. I typically define the quality of a sunset as a combination of the following factors:

  • Color: the color or vibrancy of the sunset
  • Expanse: the extent of the colors across the sky
  • Duration: the time from the first appearance of colors to the last

More information with some examples can be found here: https://sunsethue.com/guide

Sunset quality is not a directly measurable physical quantity. There is no natural unit for it; instead, it is typically represented by a composite score that attempts to capture the different factors described above in a single value.

A poor, mediocre and good sunset shown from left to right
Figure 1. a poor, mediocre and good sunset (left to right)

As such, the goal of a sunset forecast is to inform end users about the quality of an upcoming sunset. There are two important parts to this:

  1. Determining a score that captures the important factors that make a sunset good. From now on, I will call this the sunset quality.
  2. Communicating the score in a simple yet nuanced way to inform users as accurately as possible about the forecast (but also its limitations).

Both are difficult problems, and in some ways, the second is even more difficult than the first. However, this article will focus on the first problem: how to determine a sunset quality score from weather data.

Problem Formulation

The goal can be formalized in an abstract manner by defining the predicted quality of a sunset at a given location and time as:

q^(lat,lon,t)=f(lat,lon,t,Xt),\hat{q}(\mathrm{lat},\mathrm{lon},t)=f(\mathrm{lat},\mathrm{lon},t,X_t),

where tt is the time of sunset and XtX_t is the relevant weather data surrounding the location (lat,lon)(\mathrm{lat},\mathrm{lon}) at time tt.

The goal is to find a function ff that predicts sunset quality as closely as possible to the actual observed quality q(lat,lon,t)q(\mathrm{lat},\mathrm{lon},t) across all locations and times. This can be expressed as an optimization problem:

min⁡f∑(lat,lon,t)∈DL ⁣(q(lat,lon,t),f(lat,lon,t,Xt))\min_f \sum_{(\mathrm{lat},\mathrm{lon},t)\in D} L\!\left(q(\mathrm{lat},\mathrm{lon},t),f(\mathrm{lat},\mathrm{lon},t,X_t)\right)

Where DD is some dataset of observed sunsets and LL is a loss function measuring the difference between predicted and observed.

Writing the problem as an optimization problem might suggest that it has to be solved using some (gradient-based) machine learning method. However, the most important choice is the function ff itself, which can be constructed using physical principles or heuristics rather than necessarily relying on data-driven or machine learning methods.

Methodologies

The naive method

The first, very simple approach to solving this problem is to restrict the weather data XtX_t to a set of manually selected weather variables:

Xt=[x1,…,xn].X_t=[x_1,\ldots,x_n].

These variables can then be combined as a linear combination to produce a naive quality score.

q^(lat,lon,t)=∑i=1nwixi+b\hat{q}(\mathrm{lat},\mathrm{lon},t)=\sum_{i=1}^{n} w_i x_i+b

The weights can be manually tuned based on which variables are typically most important (in practice, this often comes down to the variables describing cloud cover at different altitude levels).

A very simple example could be something like this:

q^(x,y,t)=−0.5xlow-clouds,x,y,t+0.3xmid-clouds,x,y,t+0.9xhigh-clouds,x,y,t\hat{q}(x,y,t)=-0.5x_{\mathrm{low\text{-}clouds},x,y,t}+0.3x_{\mathrm{mid\text{-}clouds},x,y,t}+0.9x_{\mathrm{high\text{-}clouds},x,y,t}
A naive sunset quality calculation using cloud data from three altitude layers
Figure 2. a simple example of this naive approach applied on cloud data with three altitude layers

These types of simple rules are equivalent to the advice you might find on photography websites for predicting the quality of an upcoming sunset yourself. Optionally, they can also be combined with some conditional checks to introduce non-linearity into the predictions.

I suspect this is the most common approach used by the many vibe-coded sunset predictors that have appeared lately. My best guess is that bigger and more established players like SunsetWX and SkyFire, which have been around since about 2015, also use a similar methodology with more complex rules.

As you might already have guessed, this method does not tend to work very well. Consider this simple failure case: the high clouds are beautifully illuminated by the setting sun, but they are obscured by a thick layer of low clouds. Since none of the colour is visible to the observer, the quality score should be low, but this type of simple model might still score it relatively high.

Being tactical about what is visible

In the previous example, the vivid high clouds would not be visible because they would be blocked by the low clouds. These types of failure cases can be avoided by being a bit more tactical about what is visible when determining the quality score.

When limiting the weather data to cloud cover in a single cell, we can conceptually look straight up within that cell and keep track of the cumulative cloud cover along the way. This can then be used to scale the contribution of clouds appearing above it.

The biggest advantage of this approach is that it is very simple, not only conceptually but also computationally. It can also be calculated purely from weather data for a single location, which makes it very easy to build on top of a weather API and enables on-demand computation of the quality score.

total_clouds = 0
quality = 0
for level = 0, 1, …, L
    hypothetical_quality = cloud_cover_factor(clouds[level]) * altitude_factor(level)
    quality += (1 - total_clouds) * hypothetical_quality
    total_clouds += clouds[level]

In other words, each cloud layer contributes to the score in proportion to how visible it remains after accounting for the cloud cover below it.

A visibility-aware sunset quality calculation using cloud data from three altitude layers
Figure 3. a simple example of this naive approach applied on cloud data with three altitude layers

The first version of the Sunsethue algorithm essentially came down to this. It used cloud cover at 10 different altitude levels and weighted the contribution of clouds based on their visibility from the ground (using the summed total cloud cover value).

This method amounts to tracing a single ray straight up within a single cell and does not account for whether sunlight is actually hitting those clouds. This approach still has some failure cases, the two most important being: (1) that the model assumes the colour of the clouds depends only on altitude and cloud cover fraction, and (2) that only the conditions at that exact location (or, in practice, the weather model cell) matter.

An example failure case for the first is when there are widespread high clouds, but they do not become colourful because other clouds are blocking the incoming light. An example of the second failure case is when there are no clouds overhead, but there are many colourful clouds slightly closer to the direction of sunset.

Two failure cases involving blocked sunlight and visible clouds outside the observer's grid cell
Figure 4. visualisation of both failure cases

Ray-based approach

To solve the first failure case, the algorithm should determine whether there are any clouds between the sun and a given cloud around sunset. To accomplish this, more data is needed than just the cloud cover overhead. Instead, cloud cover data for a whole region around the given location is required.

Xt=C∈Rlat,lon,altX_t=C\in\mathbb{R}^{\mathrm{lat},\mathrm{lon},\mathrm{alt}}

The algorithm can then sample the cloud cover along the ray between the sun and a given cloud, and aggregate it to determine whether sunlight will be able to reach the underside of that cloud at position (lat,lon,alt)(\mathrm{lat},\mathrm{lon},\mathrm{alt}).

total_cloudslat,lon,alt,ϕ=∑(i,j,k)∈ray⁡(lat,lon,alt,ϕ)Ci,j,k\mathrm{total\_clouds}_{\mathrm{lat},\mathrm{lon},\mathrm{alt},\phi} =\sum_{(i,j,k)\in\operatorname{ray}(\mathrm{lat},\mathrm{lon},\mathrm{alt},\phi)} C_{i,j,k}

Since the sun is not static, and sunlight can reach these clouds both before and after sunset, multiple rays have to be sampled at different angles ϕ\phi. The total cloud cover along each ray can then be combined into a metric that I call the reflection potential of a cloud.

reflection_potentiallat,lon,alt=mean⁡ϕ ⁣(1−total_cloudslat,lon,alt,ϕ)\mathrm{reflection\_potential}_{\mathrm{lat},\mathrm{lon},\mathrm{alt}} =\operatorname{mean}_{\phi}\!\left(1-\mathrm{total\_clouds}_{\mathrm{lat},\mathrm{lon},\mathrm{alt},\phi}\right)

This process can be performed for every potential cloud position (lat,lon,ϕ)(\mathrm{lat},\mathrm{lon},\phi). In practice, in the Sunsethue V3 algorithm, this is done in parallel for the entire grid at once.

To fix the second failure case, the model also needs to account for clouds that are visible to an observer at a given location (lat,lon)(\mathrm{lat},\mathrm{lon}), but are not in that exact grid cell. For this, we can apply a similar ray-based approach, but this time from the perspective of the observer rather than the sun. This is done using an algorithm very similar to the one in the previous section, but with the reflection potential replacing the manually defined transformations of cloud fraction and altitude. Averaging the results over all rays gives the final quality forecast.

Sun-to-cloud and observer-to-cloud rays used to avoid the two failure cases
Figure 5. using a ray-based approach to avoid the two failure cases

This ray-based approach is how the Sunsethue forecasts are made. More information on Sunsethue’s ray-based methodology can be found in the Sunsethue whitepaper https://sunsethue.com/whitepaper.

This approach accounts for the three main dimensions of a sunset:

  1. Color: accounted for through the ability of clouds to reflect sunlight around sunset.
  2. Expanse: approximated by casting multiple rays from the observer and taking their mean (in practice, these should be weighted by the size of the skybox region they approximate).
  3. Duration: included by sampling multiple solar angles in the reflection potential step, accounting for different positions of the sun around sunset.

Nevertheless, this approach is not perfect. Color is not solely determined by clouds, but also by atmospheric scattering, which can be influenced by other variables (humidity, aerosols, …). Besides this, some approximations have to be made to keep the computational complexity at manageable levels, which somewhat affects the expanse and duration aspects.

Machine Learning

As discussed in the formal problem statement, it is possible to view the problem of sunset quality prediction as a relatively simple optimization problem. Assuming there is a labeled dataset (Xt,q)(X_t,q), you can apply your favourite regression-based machine learning algorithm to train a model f:Xt→q^f:X_t\rightarrow\hat{q} in a supervised manner. However, there are two major concerns I have with this approach.

Data and subjectivity

To my knowledge, no sufficiently large labeled dataset (Xt,q)(X_t,q) currently exists, and constructing such a dataset would be the hardest part of this approach. For one, the input features for the algorithm XtX_t should include data from a sufficiently large area around the location, as discussed before. A simple set of 10–100 features is unlikely to suffice.

Besides this, determining the quality of a sunset is difficult. If the quality scores are based on user reports, they are subject to a lot of subjectivity and different interpretations. Another approach is to base the scores on photos. This introduces the problem of converting a photo into a quality score. Even if this is somehow possible, we’re still not accounting for the duration aspect of a sunset, and likely only partially capturing colour and expanse (because of cropping and differences in photo quality). For both approaches, an additional challenge is that collecting a balanced dataset is difficult, because poor sunrises and sunsets generally don't get reported or shared.

Model architecture

A simple MLP or decision tree is unlikely to fully capture the rather complex dynamics of sunset quality forecasting. Since clouds over 300 km away can affect the sunset, it is not unthinkable that the model would have to take tens of thousands of input features, if not more. However, these input features are not independent, and the inherent spatial connections between different cells are not exploited by a simple MLP.

In weather forecasting, this issue is addressed by employing ML models that can capture these spatial connections more easily (while keeping the models efficient), such as Graph Neural Networks, specialised Transformers or Convolutional Neural Networks. However, for sunset forecasting, the relationships between relevant cells are not necessarily determined by spatial proximity, but by the geometry of sunlight and visibility. These relationships can be complex and nonlinear, potentially making them difficult to learn even for these more sophisticated models.

Maybe the model should limit the input to exactly those cells that lie along the paths that light can travel between the sun, the clouds and the observer, making it easier for the model to learn? At this point, we’ve come full circle and arrived at the conclusion that a ray-based approach is probably the more practical option, at least given the current limitations in available training data.

The case for ML

That being said, I don’t think machine learning is completely useless when it comes to sunset forecasting. In the implementation of the Sunsethue ray-based algorithm, there are a handful of hyperparameters and constants that have to be set manually to generate realistic and meaningful forecasts. Ideally, these should be determined based on an actual dataset rather than manual tuning.

In the future, machine learning could also be used to adjust forecasts based on satellite imagery, improve uncertainty quantification and improve model verification, among other things.

Difficulties

In the end, forecasting the quality of a sunrise or sunset is a form of weather prediction. All algorithms and methods discussed here rely on some form of cloud data. To make forecasts for the future, this data is provided by a weather model. But as with all weather predictions, these forecasts are not perfect. This is especially relevant for sunset quality prediction, since the forecasts are very sensitive to the exact positioning of clouds. A small error in cloud positioning can result in wildly different quality forecasts.

Based on reports from Sunsethue users, the accuracy of Sunsethue’s predictions is about 61% (as of November 2026). However, when excluding forecasts for which users reported inaccurate cloud cover predictions, this figure jumps to 76% https://sunsethue.com/accuracy.

Lastly, the fact that the quality of a sunrise or sunset is subjective makes it very difficult to capture in a single value. As discussed earlier in this article, defining what makes a good sunset and communicating this effectively to a varied audience is probably harder than actually designing algorithms for skillful sunset predictions.

← Back to all notes