| Crates.io | pracstro |
| lib.rs | pracstro |
| version | 1.0.0 |
| created_at | 2025-03-15 02:09:49.843076+00 |
| updated_at | 2025-04-07 02:19:04.206347+00 |
| description | A simplistic library for astronomy |
| homepage | |
| repository | https://github.com/oliverkwebb/pracstro |
| max_upload_size | |
| id | 1593020 |
| size | 61,295 |
pracstro is an astronomy library made from a collection of other algorithms that is compact, principled, and easy to understand. It's made for calculating properties of celestial objects, such as the moon, sun, planets, and stars.
use pracstro::*;
let now_date = time::Date::from_calendar(2025, 4, 16.0);
let now_time = time::Period::from_clock(19, 41, 11.0);
let my_latitude = time::Period::from_degrees(30.5);
let my_longitude = time::Period::from_degrees(-110.0);
sol::VENUS.location(now_date).horizon(now_date, now_time, my_latitude, my_longitude); // Get the horizontal coordinates of Venus
moon::MOON.phase(now_date).0; // The illuminated fraction of the moons surface
time::Period::from_degrees(120.0).clock(); // 16h00m00s
This library contains 4 primary modules, which build upon the ones before them:
time for the conversion and representation of times, dates, and angles.coord for the conversion and representation of coordinates.sol for the calculation of properties of planets and the sun.moon for the calculation of properties of the moon.Each of these have one or two types that represent a certain kind of data:
Date - An instant in continuous time.Period - An angle automatically corrected to be between [0°, 360°]. Which can also represent a time of day.Coord - A pair of angles, representing latitude/longitude on a sphere.Planet - A planets orbital properties, along with data required for orbital correction.Moon - The moons orbital properties.These types have methods to get the properties of this data. Primarily in pairs of methods that convert to/from a certain representation of that data. Although lone methods that get certain data for a type do exist.
use pracstro::*;
time::Period::from_radians(time::Period::from_decimal(16.0).radians()).clock();
| Test | Mean (n=40000) |
|---|---|
| Control (NOP) | 0ns |
| Current time | 34ns |
| Full ephemeris | 3.406µs |
| Moon Phase | 558ns |
This library aims to be accurate enough across a large enough range of time for most user-end applications. Its not perfect in its answers down to the arcsecond (nor could it be on a reasonable scale), but is does provide enough accuracy for widgets, telescope pointing, scheduling ("Will I be able to see Venus this weekend?"), etc.
Any substantial algorithm implemented from another source will be annotated with its source in this documentation. This library started as an attempt to implement the algorithms from Practical astronomy with Your Calculator, but branched out into different techniques. Most test cases in this library were either pulled from Practical Astronomy with Your Calculator or created from data from Stellariun.
The algorithms in this library are from several sources, mainly:
Additional tools similar to this in job: