AstroCalc 0.9.6

dotnet add package AstroCalc --version 0.9.6
                    
NuGet\Install-Package AstroCalc -Version 0.9.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AstroCalc" Version="0.9.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AstroCalc" Version="0.9.6" />
                    
Directory.Packages.props
<PackageReference Include="AstroCalc" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AstroCalc --version 0.9.6
                    
#r "nuget: AstroCalc, 0.9.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AstroCalc@0.9.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AstroCalc&version=0.9.6
                    
Install as a Cake Addin
#tool nuget:?package=AstroCalc&version=0.9.6
                    
Install as a Cake Tool

๐Ÿ”ญ AstroCalc

A .NET 9 library for astronomical calculations โ€” from Julian dates to sunsets, planetary positions to eclipses.

.NET xUnit License Built with GitHub Copilot CLI


โœจ Overview

AstroCalc 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.

using AstroCalc.Core;
using AstroCalc.SolarSystem;
using AstroCalc.Time;

// ๐ŸŒ… Calculate sunrise and sunset for Rome, Italy
var rome = GeographicCoordinate.FromDms(41, 54, 0, 12, 29, 0, 37);
var result = 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 position
var jd = JulianDate.FromCalendar(2026, 3, 8);
var moon = LunarPosition.Calculate(jd);
Console.WriteLine($"Moon: ฮป={moon.Position.Longitude.Degrees:F2}ยฐ, distance={moon.DistanceKm:F0} km");

// ๐Ÿ”ญ Can I see M42 tonight?
var report = VisibilityPlanner.CheckMessier(42, 2026, 1, 15, rome, telescopeApertureMm: 200);
Console.WriteLine(report); // โœ… M42: EXCELLENT โ€” alt 41ยฐ, Moon 120ยฐ away

๐Ÿ“ฆ Project structure

AstroCalc/
โ”œโ”€โ”€ ๐Ÿ“ src/AstroCalc/
โ”‚   โ”œโ”€โ”€ 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/AstroCalc.Tests/  # 127 xUnit tests verified against almanac data

๐Ÿงฎ Namespaces and classes

AstroCalc.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

AstroCalc.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)

AstroCalc.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

AstroCalc.Corrections โ€” Atmospheric and geometric corrections

Class Description
Precession Precession of the equinoxes (Lieske 1979)
Nutation Nutation in longitude and obliquity
Aberration Annual aberration of starlight
Refraction Atmospheric refraction (Sรฆmundsson/Bennett formula)
Parallax Geocentric โ†’ topocentric parallax correction

AstroCalc.SolarSystem โ€” Sun, Moon and planets

Class Description
SolarPosition Solar coordinates (low and medium precision), equation of time
SunriseSunset Sunrise, sunset, twilight (civil, nautical, astronomical)
LunarPosition Lunar position and phase
PlanetaryPosition Geocentric positions for all planets (Mercuryโ€“Neptune)
PlanetaryMagnitude Visual magnitude of planets from phase angle and distance
JovianMoons Positions of Galilean satellites (Io, Europa, Ganymede, Callisto)
SaturnRings Ring tilt, position angle, and apparent dimensions
CometPosition Position from parabolic, elliptical, or hyperbolic orbital elements

AstroCalc.Phenomena โ€” Observable events

Class Description
Eclipse Solar and lunar eclipse prediction
PlanetaryPhenomena Elongations, oppositions, conjunctions
MoonPhaseInfo Phase name, lunar age, illumination, next phase dates

AstroCalc.Optics โ€” Telescope and visual calculations ๐Ÿ”ฌ

Class Description
Telescope Magnification, exit pupil, FOV, limiting magnitude, Dawes/Rayleigh limits, light-gathering power
VisualMagnitude Pogson's law, combined magnitudes, airmass, atmospheric extinction, surface brightness, Bortle scale

AstroCalc.Observation โ€” Observing session planning ๐ŸŒŒ

Class Description
RiseTransitSet Rise, transit, and set times for any celestial object, the Sun, or Moon
ObservingWindow Dark sky window, Moon interference assessment, sky quality rating
VisibilityPlanner "Can I See It Tonight?" โ€” combines horizon, darkness, Moon, airmass, and telescope limits
MonthlyPlanner Best objects for any month โ€” deep-sky, doubles, meteor showers, and lunar features

AstroCalc.Catalogs โ€” Built-in object databases ๐Ÿ“‹

Class Description
MessierCatalog All 110 Messier objects with coordinates, magnitude, size, type, and constellation
BrightStarCatalog 50 brightest named stars with J2000.0 coordinates and proper motion
DoubleStarCatalog 36 notable double/multiple stars with separation, PA, magnitudes, and color notes
MeteorShowerCatalog 16 major meteor showers with radiant coords, ZHR, active periods, parent bodies
LunarFeatureCatalog 45 lunar features (craters, maria, mountains, rilles) with selenographic coordinates
ConstellationIdentifier Identify constellation from RA/Dec; all 88 IAU constellations with names and meanings

AstroCalc.Coordinates โ€” Additional features

Class Description
EpochConverter Proper motion correction and epoch conversion (J2000.0 โ†’ any date)

AstroCalc.Time โ€” Additional features

Class Description
TimeZoneHelper UT โ†” local time conversion with DST support for US and EU

๐Ÿš€ Quick start

Prerequisites

Build and test

# Clone the repository
git clone https://github.com/<your-username>/AstroCalc.git
cd AstroCalc

# 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/AstroCalc.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 AstroCalc 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:

  • Ch. 2โ€“3: Equatorial โ†” ecliptic โ†” horizontal โ†” galactic transformations
  • Ch. 4: Precession of the equinoxes
  • Ch. 5: Annual and diurnal aberration

๐Ÿ“– H. Karttunen et al. โ€” Fundamental Astronomy (3rd ed., Springer, 2003)

Supporting reference for modern theory and updated astronomical constants.


๐Ÿ› ๏ธ Technology stack

Technology Role
.NET 9 Target framework
C# 13 Language (record structs, pattern matching, primary constructors)
xUnit Test framework (127 tests)
GitHub Copilot CLI AI assistant for code and test generation

๐Ÿค– Built with GitHub Copilot CLI

This project was entirely designed and implemented with GitHub Copilot CLI (powered by Claude), which:

  • ๐Ÿ“ Analyzed the astronomy textbook PDFs to extract formulas and algorithms
  • ๐Ÿ—๏ธ Designed the library architecture (6 namespaces, 24 classes)
  • ๐Ÿ’ป Generated all source code and tests
  • โœ… Verified results against published almanac data
  • ๐Ÿ”„ Iterated to fix compilation errors and failing tests

๐Ÿ“Š Accuracy

Calculation Typical accuracy Method
Julian dates Exact Meeus Ch.7
Solar coordinates (low) ~1' USNO
Solar coordinates (medium) ~0.01ยฐ Meeus Ch.25
Sunrise/sunset ยฑ2 min USNO Almanac
Lunar position ~10' lon, ~3' lat Meeus Ch.47 (simplified)
Planetary positions ~1โ€“2' Truncated VSOP87
Coordinate transforms ~0.01ยฐ Rigorous spherical trigonometry

๐ŸŽฏ Design principles

  • Immutability โ€” all value types are readonly struct or record struct
  • Pure functions โ€” no side effects, easy to test
  • Strong typing โ€” Angle instead of double to prevent degree/radian confusion
  • Fully referenced โ€” every algorithm cites the chapter and equation from the original source
  • double precision โ€” sufficient for arc-second accuracy

๐Ÿ“„ License

This project is licensed under the MIT License.


๐Ÿ™ Acknowledgements

  • Jean Meeus for his foundational collections of astronomical algorithms
  • U.S. Naval Observatory for the sunrise/sunset algorithm
  • GitHub Copilot CLI for assistance in design and implementation

<p align="center"> <i>โญ If you find this library useful, please give it a star!</i> </p>

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.6 99 3/8/2026
0.9.5 87 3/8/2026

v0.9.5 โ€” Initial public preview
โ€ข Core: Angle, GeographicCoordinate, SexagesimalConverter
โ€ข Time: JulianDate, SiderealTime, Easter, TimeZoneHelper
โ€ข Coordinates: Equatorial/Ecliptic/Horizontal/Galactic transforms, EpochConverter
โ€ข Corrections: Precession, Nutation, Aberration, Refraction, Parallax
โ€ข SolarSystem: Sun, Moon, 8 planets, comets, Jovian moons, Saturn rings, magnitudes
โ€ข Phenomena: Eclipses, Moon phases, planetary elongations
โ€ข Optics: Telescope calculations, visual magnitude, Bortle scale
โ€ข Observation: Rise/Transit/Set, ObservingWindow, VisibilityPlanner, MonthlyPlanner
โ€ข Catalogs: 110 Messier, 50 bright stars, 36 double stars, 16 meteor showers, 45 lunar features, 88 constellations
โ€ข 186 unit tests