The Science

From Photon
to Prayer Time

Follow sunlight through 100 km of atmosphere, scattered, absorbed, and refracted, until the moment it becomes visible to an observer on the ground.

Step 1

Real-Time Atmospheric Data

We gather data from multiple weather services to build an accurate model of today's sky

Cloud Coverage

Multi-layer cloud data including low, mid, and high altitude coverage with optical depth estimation

Source: Met.no Weather API

Atmospheric Profile

Temperature, pressure, and humidity at 19 altitude levels from surface to 23km

Source: GFS via Open-Meteo

Aerosols & Dust

Pollution levels, desert dust concentration, and aerosol optical depth at 550nm

Source: CAMS Satellite Data

Terrain Elevation

Precise observer height above sea level for accurate horizon calculations

Source: SRTM via Open-Meteo

Snow Coverage

Surface reflectivity mapping. Snow reflects twilight back into the sky, changing visibility

Source: IMS/NOAA Satellite

Solar Position

Precise sun location computed using NASA Jet Propulsion Laboratory planetary ephemeris

Source: NASA JPL DE440
Step 2

Intelligent Cloud Modeling

Combining multiple data sources to build an accurate 3D cloud structure

Stratosphere 22+ km High Ice Clouds · OD: 2.5
Upper Troposphere 7–8 km Mid-Level Clouds · OD: 7.5
Lower Troposphere 3–4 km Low Stratus Clouds · OD: 20
Ground Level Observer

What is Optical Depth?

Optical depth (OD) measures how much light a medium blocks. An OD of 1 blocks 63% of light. An OD of 30 (heavy overcast) blocks 99.9999999999% of direct light. The tiny fraction that survives, scattered multiple times, is what creates the faint twilight glow you see.

More clouds = less glow = later visible Fajr

Step 3

Monte Carlo Radiative Transfer

Reverse-tracing 40 billion+ photons from observer to sun

0 Photons Simulated
0 Sun Angles
0 Wavelengths
GPU Accelerated

We reverse-trace over 40 billion virtual photons from observer to sun through the atmosphere, 20 million for each of 41 wavelengths and 49 sun angles. Each photon can scatter off air molecules, interact with cloud droplets, pass through aerosols, or reflect off the ground. By tracing their paths backwards for efficiency, we calculate exactly how bright the sky appears at each sun angle.

Rayleigh Scattering

Photons scatter off air molecules. Blue light scatters more, which is why the sky is blue and why twilight has its characteristic color gradient.

Cloud Interaction

Cloud droplets scatter light in all directions (Mie scattering). They block direct paths but create diffuse glow. Ice crystals behave differently than water droplets.

Aerosol Effects

Dust, pollution, and haze particles absorb and scatter light based on their size and composition. Desert dust scatters differently than urban smog.

Ozone Absorption

The ozone layer absorbs certain wavelengths, affecting the color and intensity of scattered twilight light passing through the stratosphere.

Surface Reflection

Ground reflects light back up. Snow reflects 80% (making twilight brighter), dark forest only 10%. This affects overall sky brightness.

Human Vision Model

We weight the spectrum by mesopic (twilight) human eye sensitivity, centered at 530nm. This gives us the brightness you would actually perceive.

Understanding Twilight

The Phases of Dawn

As the sun descends, twilight progresses through distinct phases

Civil Twilight

0° – 6° below

Bright enough to read outdoors

Nautical Twilight

6° – 12° below

Horizon still visible at sea

Astronomical Twilight

12° – 18° below

Sky nearly dark, stars visible

True Fajr (Takbir)

~14° – 16° typically

White thread of dawn becomes visible

Our simulation calculates the actual sky brightness at each sun position, then finds precisely when it crosses the human visibility threshold.

The Atmosphere

Layers of the Sky

Each atmospheric layer affects light differently

Mesosphere

50–85 km

Negligible scattering

Stratosphere

12–50 km

Ozone absorption, Rayleigh scattering

Upper Troposphere

6–12 km

Ice cloud scattering, temperature inversion

Lower Troposphere

2–6 km

Water cloud scattering, main absorption zone

Boundary Layer

0–2 km

Aerosols, pollution, surface reflection

The Complete Pipeline

From Location to Fajr Time

Eight steps from your coordinates to a physics-accurate prayer time

Step 1

Input Location & Date

Your latitude, longitude, and the date you want to calculate.

Step 2

Fetch Atmospheric Data

Gather real-time cloud coverage, temperature profiles, aerosols, elevation, and snow cover from meteorological satellites.

Step 3

Build Cloud Model

Detect cloud layers using humidity profiles and verify against satellite observations. Apply hybrid GFS + Met.no strategy.

Step 4

Construct Atmosphere

Create a virtual atmosphere with real-time temperature, pressure, and humidity up to 23km altitude.

Step 5

Run Monte Carlo Simulation

Reverse-trace 40 billion+ photons from observer to sun, 20 million per each of 49 sun angles × 41 wavelengths, using GPU acceleration.

Step 6

Process Spectra

Calculate human-perceivable brightness at each sun angle using mesopic vision response curves.

Step 7

Build Twilight Curve

Create smooth interpolation of brightness vs. sun angle using PCHIP splines for sub-degree precision.

Step 8

Find Threshold Crossing

Use Brent's root-finding algorithm to locate the exact moment when brightness equals the visibility threshold.

A first-of-its-kind physics-based approach to Islamic prayer time calculation, honoring both the Quranic definition and modern atmospheric science.

← Back to Home