Skip to content

Implementation of algorithms from "Practical Astronomy with your Calculator or Spreadsheet"

Notifications You must be signed in to change notification settings

jfcarr/practical-astronomy-dotnet

Repository files navigation

practical-astronomy-dotnet

Main

Algorithms from "Practical Astronomy with your Calculator or Spreadsheet" by Peter Duffett-Smith, implemented in .NET 6.

If you're interested in this topic, please buy the book! It provides far more detail and context.

Getting Started (for clients)

Create a console application:

dotnet new console -o PAConsoleTest

cd PAConsoleTest

Using the NuGet package is the easiest way to consume the library in a client application. Add a NuGet reference for the Practical Astronomy library, following the directions here.

Open Program.cs, and make a few changes. First, add a using statement for Practical Astronomy:

using PALib;

Then, replace the 'Hello World' boilerplate with this:

// Coordinates test (angle degrees to decimal degrees)
var paCoordinates = new PALib.PACoordinates();

var decimalDegrees = Math.Round(paCoordinates.AngleToDecimalDegrees(182, 31, 27), 3);

Console.WriteLine($"Decimal degrees value is {decimalDegrees}");

// Moon test (approximate moon phase)
var paMoon = new PALib.PAMoon();

var (moonPhase, brightLimbDegrees) = paMoon.MoonPhase(0, 0, 0, false, 0, 1, 9, 2003, PAAccuracyLevel.Approximate);

Console.WriteLine($"Moon phase value is {moonPhase}, bright limb degrees value is {brightLimbDegrees}");

When you run, you should see this:

Decimal degrees value is 182.524
Moon phase value is 0.22, bright limb degrees value is -71.58

Library Functions - Status

Date/Time

  • Calculate -> Date of Easter
  • Convert -> Civil Date to Day Number
  • Convert -> Civil Time <-> Decimal Hours
  • Extract -> Hour, Minutes, and Seconds parts of Decimal Hours
  • Convert -> Local Civil Time <-> Universal Time
  • Convert -> Universal Time <-> Greenwich Sidereal Time
  • Convert -> Greenwich Sidereal Time <-> Local Sidereal Time

Coordinates

  • Convert -> Angle <-> Decimal Degrees
  • Convert -> Right Ascension <-> Hour Angle
  • Convert -> Equatorial Coordinates <-> Horizon Coordinates
  • Calculate -> Obliquity of the Ecliptic
  • Convert -> Ecliptic Coordinates <-> Equatorial Coordinates
  • Convert -> Equatorial Coordinates <-> Galactic Coordinates
  • Calculate -> Angle between two objects
  • Calculate -> Rising and Setting times for an object
  • Calculate -> Precession (corrected coordinates between two epochs)
  • Calculate -> Nutation (in ecliptic longitude and obliquity) for a Greenwich date
  • Calculate -> Effects of aberration for ecliptic coordinates
  • Calculate -> RA and Declination values, corrected for atmospheric refraction
  • Calculate -> RA and Declination values, corrected for geocentric parallax
  • Calculate -> Heliographic coordinates
  • Calculate -> Carrington rotation number
  • Calculate -> Selenographic (lunar) coordinates (sub-Earth and sub-Solar)

The Sun

  • Calculate -> Approximate and precise positions of the Sun
  • Calculate -> Sun's distance and angular size
  • Calculate -> Local sunrise and sunset
  • Calculate -> Morning and evening twilight
  • Calculate -> Equation of time
  • Calculate -> Solar elongation

Planets

  • Calculate -> Approximate position of planet
  • Calculate -> Precise position of planet
  • Calculate -> Visual aspects of planet (distance, angular diameter, phase, light time, position angle of bright limb, and apparent magnitude)
  • Calculate -> Position of comet (elliptical and parabolic)
  • Calculate -> Binary star orbit data

The Moon

  • Calculate -> Approximate and precise position of Moon
  • Calculate -> Moon phase and position angle of bright limb
  • Calculate -> Times of new Moon and full Moon
  • Calculate -> Moon's distance, angular diameter, and horizontal parallax
  • Calculate -> Local moonrise and moonset

Eclipses

  • Calculate -> Lunar eclipse occurrence and circumstances
  • Calculate -> Solar eclipse occurrence and circumstances

About

Implementation of algorithms from "Practical Astronomy with your Calculator or Spreadsheet"

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages