In this article we want to explain how, using two mathematical tools with more than two centuries of history, known as the Saros cycle and Besselian elements, and combining them with an open source astronomy library, you can build your own eclipse calculator with just a few lines of code. That way, you can determine precisely where and when eclipses will occur anywhere on the planet.
How free software and Python make the James Webb telescope images possible
The problem: predicting where the Moon's shadow will fall
Predicting a total solar eclipse is not magic, nor something impossible and supernatural as our primitive ancestors believed; it is simple celestial mechanics. Let us first remember that an eclipse occurs when the Moon comes between the Earth and the Sun, and its shadow (the umbra, in the centre, and the penumbra, more diffuse) sweeps across the Earth's surface.
The problem is that the three bodies (Sun-Earth-Moon) do not move in perfect circular orbits or in the same plane: the lunar orbit is inclined about five degrees relative to the ecliptic, the plane of the Earth's orbit. That is why eclipses do not occur every month; instead, the Moon must roughly coincide with its passage through one of its nodes, the two points where its orbit crosses the ecliptic.
Moreover, the path of the umbra across the Earth is narrow and capricious. This 2026 eclipse, for example, reached its maximum in the middle of the North Atlantic, at coordinates 65°12'N, 25°12'W, with a maximum totality of 2 minutes and 18 seconds. When the shadow reached the Galician coast, totality had shrunk to just under a minute and a half, and the Sun was almost glued to the horizon, a few degrees above the sea.
So knowing the approximate day and time of an eclipse is relatively easy; knowing where and for how many seconds the shadow will fall is another level of difficulty. For that, there are the two methods we are going to explain and use in this small technological experiment.

The Saros Cycle: the arithmetic of the Babylonian astronomers
The oldest way to anticipate eclipses needs no computer: it is the Saros Cycle, known since Mesopotamian antiquity. It works because the Sun-Moon-Earth geometry repeats almost exactly every 223 synodic months, that is, every 18 years, 11 days and 8 hours, or about 6,585.3 days.
After that interval, the Moon is again at the same node, at roughly the same distance from the Earth and with the Sun in an almost identical position in the sky. The result is that eclipses are grouped into numbered families: each Saros Series produces an eclipse every 18 years, and each one is the "sibling" of the previous one.
So we can say that the eclipse of 12 August 2026 belongs to Saros 126, specifically its 48th member out of a total of 72. The series began with a partial eclipse on 10 March 1179 and will end with another partial one on 3 May 2459: almost 1,280 years of history, 72 eclipses, all following the same family. If you do the arithmetic, 18 years and 11 days after 12 August 2026, you get 23 August 2044, which is exactly member 49 of the series. The series works, and you don't need a computer to calculate it.
Almost perfect
However, there is a crucial nuance: the 8 hours of the Saros mean that the Earth rotates a third of a turn more than in the previous eclipse, so each new member of the series shifts about 120 degrees west. Member 47, of 1 August 2008, crossed Russia and China. The 2026 one crossed Iceland and Spain.
As you can see, those 120 degrees are no small thing; they are thousands of kilometres of displacement across the Earth's surface. It is the difference between being able to see it and not even noticing it. For example, the next Saros in 2044 will fall over Greenland, Canada and the northern United States. We will not see it in Spain.
And that is the great limitation of the Saros Cycle: it tells us when it will happen, but not where it will be visible. For the latter, we need the second method.
The 4 major scientific projects driven by free software
Besselian elements: the exact geometry for calculating eclipses
In 1824, the Prussian mathematician and astronomer Friedrich Bessel proposed a method to predict the path of the lunar shadow with all the precision geometry allowed. His idea was to change the frame of reference: instead of calculating the positions of the Sun and the Moon relative to the centre of the Earth, calculate the path of the axis of the lunar shadow on an imaginary plane that passes through the centre of the Earth and is perpendicular to that axis. It is called the fundamental plane, and on it the shadow always projects a perfect circle, without perspective distortions.
The mathematics reduces to eight parameters, the Besselian elements: the coordinates x and y of the shadow axis on the fundamental plane (in units of Earth radius), the radii L1 and L2 of the penumbral and umbral shadows, the declination d and the hour angle µ of the shadow axis, and the angles f1 and f2 that the shadow cones make with their axis.
Reaching the highest precision
With those eight values, tabulated hourly or expressed as third-degree polynomials, it is possible to calculate, for any point on Earth, when each of the four contacts of the eclipse occurs (start of partiality, start of totality, end of totality and end of partiality) and at what altitude the Sun will be at that moment.
There is an additional detail that makes this method honest: the Earth does not rotate at a constant rate, and that slowing, measured by the parameter ΔT, must be incorporated into the predictions. For the 2026 eclipse, NASA's tables use a ΔT of about 72 seconds, a correction that makes the difference between predicting an eclipse decades in advance and getting the exact second right. Today, NASA and Fred Espenak publish the Besselian elements of every eclipse of the millennium, and anyone can download them.

Astronomy Engine: pocket ephemerides, MIT license
So far, two centuries of mathematics. Now comes the free software part. Astronomy Engine is an astronomy library written and maintained by Don Cross, published under the MIT license, which calculates the position of the Sun, the Moon and the planets and predicts events such as lunar phases, solstices, transits and, of course, eclipses. It is available in C, C#, Python, Kotlin and JavaScript/TypeScript, with a consistent API across all languages.
The interesting part is how it is built. NASA and JPL use full ephemerides, such as DE405, which require hundreds of megabytes of precalculated data, and that is too much for a browser. Cross solved the problem by truncating the trigonometric series of the VSOP87 model from the French Bureau des Longitudes until the entire library fit on a web page without exceeding an error of one arcminute in the calculated positions.
One arcminute is an imperceptible error for an amateur (by comparison, the Sun measures about 30 arcminutes in diameter) and enough to know whether your city will be inside a 294-kilometre shadow strip. The predictions are systematically validated against the NOVAS library of the United States Naval Observatory operating on DE405 and against the JPL Horizons service. That is: an open source library, with no external dependencies, that runs in the browser and reproduces NASA's ephemeris results with more than enough precision for the general public.
Let's get to work: build your calculator
The rest is standard web programming. For the example we will use a Vite project with React and TypeScript, styled with Tailwind CSS, which is the stack we used for this calculator. Explaining the whole process is complex, but to make it easier for you, we have uploaded the calculator's code to this GitHub, with comments and documentation in Spanish, explaining step by step how the calculator works.
You can also see the calculator in action if you follow this link, and you can use it in your browser at any time.

Science in the browser
The most surprising thing about this whole exercise is how little is needed: an MIT library that fits on a web page, based on a truncated astronomical model from 1987 and mathematics from 1824, reproduces predictions that for decades were the privilege of NASA's catalogues. And it is not an isolated case. Astronomy Engine is the spearhead of a "science in the browser" movement.
What free software is and how it transformed technology and finance
Now, for Spain, the wait will be long: after the August 2026 eclipse, the next total eclipse visible from the territory will have to be sought with patience. But now, with the calculator working, the answer no longer depends on consulting someone else's tables: it is a question your own software can answer, in seconds, for any coordinate on the planet. The Saros Cycle gives the cadence, the Besselian elements give the precision, and free software puts both in your pocket.