Expand description
astroceleste-engine: astrological chart calculation on JPL ephemerides.
One implementation shared by the Astroceleste server (Python bindings), desktop and mobile apps (native) and the web app (WASM), so every platform computes identical charts.
Experimental (0.0.x): the API may change in any release.
use astroceleste_engine::ephemeris::{Kernel, KernelSet, Spk};
use astroceleste_engine::{calculate_chart, ChartRequest, UtcInstant};
// Kernels in preference order: the first one covering a date is used.
let mut kernels = KernelSet::new();
kernels.push(Kernel::new("de440s.bsp", Spk::open("kernels/de440s.bsp")?)?);
let mut request = ChartRequest::new(UtcInstant::parse("1987-05-17T14:30:00Z")?, 41.9, 12.5);
request.house_system = "P";
request.zodiac_type = "sidereal";
request.ayanamsa = "lahiri";
let chart = calculate_chart(&kernels, &request)?;
println!("{}", serde_json::to_string_pretty(&chart)?);§Entry points
| Function | Result |
|---|---|
calculate_chart | a natal or event Chart: planets (the seven with their Condition), houses, aspects, fixed stars, lots, temperament, lunar status, sect, Receptions, antiscia, planetary hours |
calculate_horary_chart | the chart plus HoraryData: planetary hours, the Moon’s aspects, strictures and the Judgment (significators, perfection, prohibition, translation, collection) |
calculate_transit_chart | the sky at a moment and place, with its CrossAspects to natal planets |
calculate_synastry | cross-aspects between two charts’ planets (no kernel needed) |
calculate_derived_chart | a stored chart turned to a new first house (no kernel needed) |
calculate_election_chart | the chart plus ElectionData: an electional score with the rules that apply |
search_elections | the best ElectionWindows over a span of time at a place |
degree_qualities | Lilly’s DegreeQualities of the degree a longitude falls in (no kernel needed) |
chart_dignities | a computed chart’s Conditions and Receptions judged again under the Lilly or Dorothean scheme (no kernel needed) |
time_lords | the annual Profections and Firdaria of a nativity over a span of time (no kernel needed) |
chinese_calendar | the ChineseCalendar around a moment: solar terms, lunar months, equation of time (also on a chart, with ChartRequest::chinese_calendar) |
bazi | the Four Pillars (Bazi) of a birth from its Chinese calendar: hidden stems, Ten Gods, NaYin, element balance, luck pillars (no kernel needed) |
zi_wei | the Zi Wei Dou Shu chart (ZiWei) of a birth from its Chinese calendar: palaces, bureau, the 14 major and 14 auxiliary stars with brightness, the Four Transformations, minor stars and cycles of gods, flying transformations, decade and small limits and a year’s horoscope (no kernel needed) |
jyotish | the Vedic reading (Jyotish) of a chart: sidereal placements with their Nakshatras, the divisional charts D1-D60 and the Vimshottari dasha (no kernel needed) |
vedic_calendar | the panchanga (VedicCalendar) of a moment and place: sunrise, vara, tithi, nakshatra, yoga, karana, lunar month, samvatsara (also on a chart, with ChartRequest::vedic_calendar) |
Every result implements serde::Serialize and serializes to the JSON of the
Astroceleste API, with the same key order and the same integer vs float types. The
Python and WebAssembly bindings return exactly that JSON.
§Loading kernels
Positions come from NASA JPL SPK kernels (de440s.bsp covers 1849–2150; DE441 covers
13200 BC–17191). A KernelSet holds them in preference order,
and each date is computed with the first kernel that covers it. Spk::open reads a
file. Where there is no file system (WebAssembly) or the kernel is bundled with an app,
load the bytes and use Spk::from_bytes. Spk::excerpt cuts a smaller kernel for a
date range, with positions unchanged inside it (1950–2050 of DE440s is about 11 MB).
use astroceleste_engine::ephemeris::{Kernel, KernelSet, Spk};
let bytes: Vec<u8> = download("https://example.com/de440s-1950-2050.bsp");
let mut kernels = KernelSet::new();
kernels.push(Kernel::new("de440s-1950-2050.bsp", Spk::from_bytes(bytes)?)?);
assert!(kernels.coverage().is_some());§Errors
Calculations return EngineError, whose code is the stable
error code of the Astroceleste API. A date that no loaded kernel covers is
EngineError::OutOfRange: the engine never extrapolates or approximates.
let request = ChartRequest::new(UtcInstant::parse("1700-01-01T00:00:00Z")?, 41.9, 12.5);
match calculate_chart(&kernels, &request) {
Ok(chart) => println!("{} planets", chart.planets.len()),
Err(EngineError::OutOfRange { jd, coverage }) => {
eprintln!("JD {jd} is outside the loaded kernels ({coverage:?})")
}
Err(err) => eprintln!("{}: {err}", err.code()),
}§Platforms
The crate is pure Rust with no C code, and depends only on serde and serde_json.
It builds for servers and desktops, wasm32-unknown-unknown, Android and iOS. Python
(pip install astroceleste-engine) and JavaScript (npm install astroceleste-engine)
bindings are published from the same repository.
§Further reading
- API guide: request options (house systems, ayanamsas, orb settings) and the chart JSON
- Ephemerides: kernels, coverage and excerpts
- Accuracy: how results are verified against the reference implementation
- Live demo: this crate compiled to WebAssembly, computing charts in your browser
Modules§
- ephemeris
- Ephemeris sources. Everything above this layer (houses, aspects, lots, stars, …) is independent of where planetary positions come from.
Structs§
- AgeRange
- A range of nominal ages (虛歲), inclusive.
- Anga
- One of the angas running at the moment.
- Antiscia
Contact - Two points joined by antiscion (mirrored across the solstitial axis, Cancer–Capricorn) or contra-antiscion (across the equinoctial axis, Aries–Libra).
- Applying
Aspect - A Ptolemaic aspect the Moon perfects before leaving its sign.
- Aspect
- An aspect between two chart points. Fixed-star conjunctions carry no
is_major. - Bazi
- The Four Pillars of a birth.
- Bazi
Flow - The pillars of a date read against a chart.
- Bazi
Options - How to cast the pillars.
- Bureau
- The five-element bureau.
- Chart
- A complete chart (
calculate_chart_data); serializes to the API’s JSON. - Chart
Dignities - A chart’s dignities judged again under a scheme: what
chart_dignitiesreturns. - Chart
Request - What to compute.
- Chinese
Calendar - The Chinese calendar around a moment: what the Four Pillars and the Purple Star chart need from the ephemeris.
- Collection
- A heavier planet that both significators apply to.
- Condition
- The condition of one of the seven planets.
- Criteria
Summary - The criteria a search ran with, defaults resolved (the natal chart only as a flag).
- Cross
Aspect - A cross-aspect between an overlay body (transit, partner) and a base body (natal).
- Dasha
Period - A dasha period and, to the depth asked, its subperiods.
- Degree
Qualities - The qualities of the degree an ecliptic longitude falls in.
- Degree
Run - A run of degrees sharing one quality, from the end of the previous run (or the start of
the sign) up to and including
end. - Dignity
Lords - The lords of each essential dignity at a longitude.
- Election
Chart - A chart for a candidate moment with its electional assessment (serialized flattened).
- Election
Criteria - What to look for. Every field has a default, so
{}is a valid criteria object. - Election
Data - The electional assessment of a moment.
- Election
Factor - One electional rule that applies to a moment.
- Election
Search - The result of a search.
- Election
Window - A run of consecutive assessed moments scoring at least the minimum.
- Element
Balance - Weight of each element among the eight characters (stems count 1, each branch 1 shared among its hidden stems).
- Essential
Dignity - A planet’s essential dignities and debilities where it stands.
- Exclusions
- How many moments each criteria filter left out.
- Factor
- One contribution to the temperament, with its weighted qualities.
- Firdaria
- A major period of the firdaria, with its seven sub-periods (none for the nodes).
- Fixed
Star Position - A fixed star conjunct a chart point.
- Graha
- A body or the Ascendant in the sidereal zodiac.
- Hidden
Stem - A stem hidden in a branch.
- Horary
Chart - A horary chart: a complete chart plus
horary_data(serialized flattened). - Horary
Data - The horary-specific part of a horary chart.
- Hour
Range - Local clock hours,
frominclusive totoexclusive;from > tospans midnight. - House
Cusp - The cusp of one house.
- Judgment
- The judgment of a horary question.
- Jyotish
- The Vedic reading of a chart:
jyotish. - Jyotish
Options - What
jyotishcomputes; every field is optional in JSON. - Lot
- An Arabic part (lot) placed in the chart.
- Luck
- The luck pillars (大運).
- Luck
Pillar - A ten-year luck pillar.
- Lunar
Date - A date of the lunisolar calendar.
- Lunar
Mansion - One of the 28 lunar mansions (manazil al-qamar).
- Lunar
Month - A month of the lunisolar calendar.
- Lunar
Status - Lunar phase, speed, dignity and mansion.
- Masa
- The lunar month.
- Moon
Status - The Moon’s condition in a horary chart.
- Nakshatra
- The nakshatra of a sidereal longitude.
- Natal
Point - A natal point, as in a stored chart’s
planetslist (other fields are ignored). - Parse
Error - The text given to
UtcInstant::parseis not a supported date-time. - Perfection
- An aspect that becomes exact between two planets, both still in their present signs.
- Period
- A span of time ruled by a planet.
- Pillar
- A stem and a branch: one of the four pillars, or a luck pillar.
- Placement
- A planet, lunar point or angle placed in the chart.
- Planet
Condition - The condition of one planet, by name.
- Planetary
Hours - Planetary day and hour of a horary chart.
- Profection
- One year of life and the sign the Ascendant has profected to.
- Prohibition
- A third planet that perfects an aspect with one of the significators first.
- Qualities
- The four primary qualities.
- Reception
- One planet received by another: it stands in a dignity of the receiver.
- Refranation
- A significator that turns retrograde (or direct) before the aspect perfects.
- Scores
- The four temperaments.
- Separating
Aspect - A Ptolemaic aspect the Moon has perfected since entering its sign.
- Sign
Degrees - Lilly’s qualities of the degrees of one sign. Degrees are ordinal: degree
nspansn-1°00’ ton-1°59’ of the sign. - Solar
Term - One of the 24 solar terms (節氣): the moment the Sun reaches a multiple of 15°.
- Stricture
- A consideration before judgement (stricture against judging the chart).
- Synastry
- Synastry between two charts.
- Temperament
- Temperament assessment from the chart’s qualities.
- Term
Moment - A solar term the pillars refer to.
- Time
Lords - The time-lords active over a span of a life.
- Transit
Chart - Transits to a natal chart (
calculate_transit_chart). - Translation
- A lighter planet carrying the light of one significator to the other.
- UtcInstant
- A UTC instant, as microseconds since 1970-01-01T00:00:00Z.
- UtcOffset
- The UTC offset of local time from an instant on (until the next one), so that
ElectionCriteria::local_hoursfollows daylight saving time. - Vara
- The weekday of the Vedic day, which begins at sunrise.
- Varga
- A divisional chart: the Ascendant first, then the grahas.
- Varga
Placement - A placement in a divisional chart.
- Vedic
Calendar - The panchanga of a moment and place:
vedic_calendar. - Vimshottari
- The Vimshottari dasha of a birth, in a
Jyotishreading. - ZiWei
- The Purple Star chart of a birth.
- ZiWei
Flow Star - A moving star of a horoscope period.
- ZiWei
God - A god of a yearly cycle of twelve.
- ZiWei
Gods - The gods of the four cycles of twelve in a palace.
- ZiWei
Horoscope - The horoscope of a year.
- ZiWei
Options - How to cast the chart.
- ZiWei
Palace - One of the twelve palaces.
- ZiWei
Period - One period of a horoscope: a decade, the childhood limit or a year.
- ZiWei
Star - A star in a palace.
- ZiWei
Transformation - A natal transformation.
Enums§
- Dignity
Scheme - The doctrine of triplicities and bounds a chart is judged by.
- Engine
Error - Why a calculation failed.
EngineError::codegives the API error code. - Purpose
- What the election is for. Each purpose has a house of the matter, a natural significator and the planetary hours that favour it.
Constants§
- MAX_
DASHA_ DEPTH - Most levels returned in one tree below
path. - MAX_
DASHA_ LEVELS - Levels below the mahadashas: antardasha, pratyantardasha, sookshma, prana.
- MAX_
SEARCH_ DAYS - Longest span a search covers, in days.
- MAX_
TIME_ LORDS_ YEARS - Longest span
time_lordscovers, in years. - MINOR_
BODIES - The bodies with a Horizons table, in chart order.
- NAKSHATRAS
- The 27 nakshatras from Ashwini, 13°20′ each from 0° sidereal Aries.
- VARGAS
- The vargas computed: the sixteen of Parashara’s shodashavarga plus D5, D6, D8 and D11.
Functions§
- bazi
- Cast the Four Pillars of a birth at
birth(UTC), atlongitude(degrees east) where civil time wasutc_offset_minutesahead of UTC, from itscalendar(chinese_calendarof the same moment). - calculate_
chart - Compute a chart (
calculate_chart_data), with its planetary day and hour. - calculate_
derived_ chart - A derived (turned) chart: radix house
root(1-12) becomes the first house; cusps, angles and house placements follow, with the meaning of each derived house (calculate_derived_chart_data). Works on a stored chart payload, keeping every field it does not turn. - calculate_
election_ chart - A chart for a candidate moment with its electional assessment.
- calculate_
horary_ chart - A chart for the moment of the question, with its horary analysis
(
calculate_horary_chart_data).quesited_house(1-12) is the house of the matter asked about; its lord is judged against the lord of the Ascendant. - calculate_
synastry - Cross-aspects from chart B (overlay) to chart A (base) (
calculate_synastry_chart). - calculate_
transit_ chart - The sky at
req(relocatable), with its cross-aspects tonatal_planets(calculate_transit_chart).req.chinese_calendarandreq.vedic_calendarare ignored: a transit chart has no calendar. - chart_
dignities - Judge the dignities of an already computed chart (its JSON, as
calculate_chartreturns it:planetswithname,ecliptic_longitudeandspeed, andaspects) underscheme(“lilly” or “dorothean”). No kernel is needed: a chart stored with one scheme can be shown with the other. - chinese_
calendar - The Chinese calendar around
instant, orNonewhen the loaded kernels do not cover the year or so of ephemeris it needs (about 14 months before the moment and 2 after). - degree_
qualities - The qualities of the degree
longitude(ecliptic, in degrees) falls in. The zodiac is whatever the longitude is measured in, as for every sign-based rule. - degree_
quality_ table - Lilly’s table of the degree qualities, one entry per sign from Aries.
- is_
minor_ body - Whether
nameis one ofMINOR_BODIES. - jyotish
- The sidereal placements, nakshatras, vargas and Vimshottari dasha of
chart(the chart JSON, tropical or sidereal under any ayanamsa) born atbirth, under the ayanamsa ofoptions. - nakshatra
- The nakshatra of sidereal longitude
longitude(degrees). - search_
elections - The best windows from
req.instanttoend(at mostMAX_SEARCH_DAYS) at the request’s place, with its house system and zodiac. - time_
lords - Annual profections and firdaria from
birth(with the natal Sun’s and Ascendant’s longitudes), for the years that overlapstart..end(at mostMAX_TIME_LORDS_YEARSafter the birth or the start, whichever is later). - vedic_
calendar - The panchanga at
instantfor a place, orNonewhen the loaded kernels do not cover the lunar month around it. - zi_wei
- Cast the Purple Star chart of a birth at
birth(UTC), atlongitude(degrees east) where civil time wasutc_offset_minutesahead of UTC, from itscalendar.