You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A .NET library for astronomical calculations — from Julian dates to sunsets, planetary positions to eclipses.
✨ Overview
Ephemeris implements classical computational astronomy formulas in a modern, strongly-typed, immutable .NET library. Every algorithm is referenced to its original source and verified against published almanac data.
usingEphemeris.Core;usingEphemeris.SolarSystem;usingEphemeris.Time;// 🌅 Calculate sunrise and sunset for Rome, Italyvarrome=GeographicCoordinate.FromDms(41,54,0,12,29,0,37);varresult=SunriseSunset.Calculate(2026,3,8,rome);var(hRise,mRise)=SunriseSunset.ToHoursMinutes(result.Sunrise);var(hSet,mSet)=SunriseSunset.ToHoursMinutes(result.Sunset);Console.WriteLine($"Sunrise: {hRise}:{mRise:D2} UT");Console.WriteLine($"Sunset: {hSet}:{mSet:D2} UT");// 🌙 Moon positionvarjd=JulianDate.FromCalendar(2026,3,8);varmoon=LunarPosition.Calculate(jd);Console.WriteLine($"Moon: λ={moon.Position.Longitude.Degrees:F2}°, distance={moon.DistanceKm:F0} km");// 🔭 Can I see M42 tonight?varreport=VisibilityPlanner.CheckMessier(42,2026,1,15,rome,telescopeApertureMm:200);Console.WriteLine(report);// ✅ M42: EXCELLENT — alt 41°, Moon 120° away
💾 The Origin Story
This project has roots that go way back. As a teenager, my very first program — written in GW-BASIC and saved on a 3.5″ floppy disk — calculated the sunrise and sunset times. I still remember my father patiently dictating the code listing while I typed it, line by line, on my Olivetti M80.
Since that day, I've always had the itch to build my own astronomy library, fueled by all those books on computational astronomy I'd collected over the years — Meeus, Smart, the USNO Almanac… But life got in the way, and those books gathered dust on the shelf for a long time.
Now, finally, that small dream is fulfilled. Ephemeris is the result of a passion that was born on a floppy disk and grew through decades of curiosity. From GW-BASIC to .NET 10 — the journey was long, but the stars were always there, waiting. 🔭
📦 Project structure
Ephemeris/
├── 📐 src/Ephemeris/
│ ├── Core/ # Foundation types: Angle, GeographicCoordinate, SexagesimalConverter
│ ├── Time/ # Julian dates, sidereal time, Easter date
│ ├── Coordinates/ # Coordinate systems and transformations
│ ├── Corrections/ # Precession, nutation, aberration, refraction, parallax
│ ├── SolarSystem/ # Sun, Moon, planets, Jovian moons, Saturn rings, comets
│ ├── Phenomena/ # Eclipses, conjunctions, oppositions, Moon phase info
│ ├── Optics/ # Telescope calculations, visual magnitude, Bortle scale
│ └── Observation/ # Observing session planning, rise/transit/set, dark sky windows
│
└── 🧪 tests/Ephemeris.Tests/ # 127 xUnit tests verified against almanac data
🧮 Namespaces and classes
Ephemeris.Core — Foundation types
Class
Description
Angle
Immutable value type: degrees, radians, DMS, HMS with arithmetic operators and trigonometry
GeographicCoordinate
Observer latitude, longitude and elevation
SexagesimalConverter
Sexagesimal ↔ decimal conversions
Ephemeris.Time — Calendar and time
Class
Description
JulianDate
Julian Day Number ↔ calendar conversions (Gregorian reform handled)
SiderealTime
Greenwich and local mean sidereal time
Easter
Easter date computation (Meeus Ch.9)
Ephemeris.Coordinates — Celestial coordinates
Class
Description
EquatorialCoordinate
Right ascension and declination
EclipticCoordinate
Ecliptic longitude and latitude
HorizontalCoordinate
Azimuth and altitude
GalacticCoordinate
Galactic coordinates (l, b)
CoordinateTransform
Transformations between all coordinate systems
Ephemeris.Corrections — Atmospheric and geometric corrections
# Clone the repository
git clone https://github.com/robgrame/Ephemeris.git
cd Ephemeris
# Build
dotnet build
# Run all tests
dotnet test# Run a single test
dotnet test --filter "MathcadExample_MmtObservatory_19880115"
Use in your project
# Add as a project reference
dotnet add reference path/to/Ephemeris.csproj
📚 References
The implemented formulas come from four classical texts in computational astronomy:
📖 Jean Meeus — Astronomical Formulae for Calculators (3rd ed., Willmann-Bell, 1985)
The primary reference for most algorithms. Chapters used:
Chapter
Topic
Ephemeris class
Ch. 7
Julian Day Number
JulianDate
Ch. 9
Easter date
Easter
Ch. 12
Sidereal time
SiderealTime
Ch. 13
Coordinate transformations
CoordinateTransform
Ch. 16
Atmospheric refraction
Refraction
Ch. 17
Angular separation
CoordinateTransform.AngularSeparation
Ch. 21
Precession
Precession
Ch. 22
Nutation
Nutation
Ch. 23
Aberration
Aberration
Ch. 25
Solar coordinates
SolarPosition
Ch. 31–36
Planetary positions
PlanetaryPosition
Ch. 33–34
Comet positions from orbital elements
CometPosition
Ch. 40
Parallax
Parallax
Ch. 41
Planetary visual magnitudes
PlanetaryMagnitude
Ch. 47
Lunar position
LunarPosition
Ch. 48
Lunar phase
LunarPosition.Phase
Ch. 49
Lunar phases (new/full moon)
Eclipse
Ch. 54
Eclipses
Eclipse
Ch. 44
Galilean satellite positions
JovianMoons
Ch. 45
Saturn ring geometry
SaturnRings
📖 U.S. Naval Observatory — Almanac for Computers
Algorithm for computing sunrise, sunset and twilight times. Implemented via a Mathcad worksheet (Ch. 3 — Astronomical Phenomena) that includes a verified worked example:
MMT Observatory, Arizona — 31°41'18" N, 110°53'06" W, 2608 m Date: January 15, 1988
Computes sunrise, sunset and all three twilight types with observer elevation correction.
📖 W.M. Smart — Textbook on Spherical Astronomy (6th ed., Cambridge University Press, 1977)
Reference for spherical trigonometry and coordinate system transformations: