Bodies¶
For swe.calc() and related functions, you’ll need to pass an integer to identify which celestial body to calculate. You can use the named constants or the numeric values directly. These numbers are defined in swephexp.h.
Major bodies and asteroids¶
Constant |
Value |
Body |
|---|---|---|
|
0 |
Sun |
|
1 |
Moon |
|
2 |
Mercury |
|
3 |
Venus |
|
4 |
Mars |
|
5 |
Jupiter |
|
6 |
Saturn |
|
7 |
Uranus |
|
8 |
Neptune |
|
9 |
Pluto |
|
10 |
Mean lunar node |
|
11 |
True lunar node |
|
12 |
Mean lunar apogee (Lilith) |
|
13 |
Osculating lunar apogee (Lilith) |
|
14 |
Earth |
|
15 |
Chiron |
|
16 |
Pholus |
|
17 |
Ceres |
|
18 |
Pallas Athena |
|
19 |
Juno |
|
20 |
Vesta |
Example using constants¶
coords, flags = swe.calc_ut(jd, swe.MARS)
print("Mars: {coords[0]}")
Example using numeric values¶
for planet_id in range(10):
coords, flags = swe.calc_ut(jd, planet_id)
print(f"Planet {planet_id}: {coords[0]}")
Custom asteroids and minor planets¶
To calculate the position of an asteroid or minor planet not listed in the standard bodies, you must combine the constant swe.AST_OFFSET with the asteroid’s catalogue number.
The catalogue number is added to the offset (swe.AST_OFFSET = 10000) to form the correct body ID (ipl) for use in functions like swe.calc_ut(). The names and catalogue numbers can be referenced in the Swiss Ephemeris file seasnam.txt.
Construction¶
The required integer ID (ipl) is constructed using
ipl = swe.AST_OFFSET + catalogue number
Example: Asteroid 433 Eros¶
1 2 3 4 5 6 7 8 9 | |
Configuration¶
To access these minor objects, you’ll have to download additional ephemeris files and set their path as described in :ref:’Configuration’.
See also¶
Swiss Ephemeris Programming Interface: Bodies (int ipl)
All major bodies:
swephexp.hAll additional asteroids:
seasnam.txt