docs
0
# Physical Constants and Bodies
1
2
Functions for retrieving physical constants, body properties, and solar system object information. These functions provide access to fundamental astronomical and physical data needed for space calculations.
3
4
## Capabilities
5
6
### Body Properties
7
8
Retrieve physical characteristics of solar system bodies.
9
10
```python { .api }
11
def bodvrd(bodynm: str, item: str, maxn: int) -> Tuple[int, ndarray]:
12
"""
13
Fetch values from kernel pool for a body.
14
15
Parameters:
16
- bodynm: str, body name
17
- item: str, property name ("RADII", "GM", "J2", etc.)
18
- maxn: int, maximum number of values to return
19
20
Returns:
21
Tuple[int, ndarray]: (n, values) - number of values and array of values
22
"""
23
24
def bodn2c(name: str) -> int:
25
"""
26
Translate body name to NAIF integer ID code.
27
28
Parameters:
29
- name: str, body name
30
31
Returns:
32
int: NAIF ID code
33
"""
34
35
def bodc2n(code: int) -> str:
36
"""
37
Translate NAIF integer ID code to body name.
38
39
Parameters:
40
- code: int, NAIF ID code
41
42
Returns:
43
str: body name
44
"""
45
```
46
47
### Mathematical Constants
48
49
Fundamental mathematical and physical constants.
50
51
```python { .api }
52
def spd() -> float:
53
"""
54
Return seconds per day.
55
56
Returns:
57
float: 86400.0 (seconds per day)
58
"""
59
60
def rpd() -> float:
61
"""
62
Return radians per degree.
63
64
Returns:
65
float: π/180 (radians per degree)
66
"""
67
68
def dpr() -> float:
69
"""
70
Return degrees per radian.
71
72
Returns:
73
float: 180/π (degrees per radian)
74
"""
75
76
def pi() -> float:
77
"""
78
Return the value of pi.
79
80
Returns:
81
float: π
82
"""
83
84
def halfpi() -> float:
85
"""
86
Return the value of pi/2.
87
88
Returns:
89
float: π/2
90
"""
91
92
def twopi() -> float:
93
"""
94
Return the value of 2*pi.
95
96
Returns:
97
float: 2π
98
"""
99
```
100
101
## Common Usage Patterns
102
103
### Get Planet Properties
104
```python
105
import spiceypy as spice
106
107
spice.furnsh("pck00010.tpc") # Load planetary constants kernel
108
109
# Get Earth's radii
110
n, radii = spice.bodvrd("EARTH", "RADII", 3)
111
print(f"Earth radii: {radii} km")
112
113
# Get Mars GM (gravitational parameter)
114
n, gm = spice.bodvrd("MARS", "GM", 1)
115
print(f"Mars GM: {gm[0]} km^3/s^2")
116
117
spice.kclear()
118
```
119
120
### Body Name/ID Conversion
121
```python
122
# Convert names to NAIF IDs
123
earth_id = spice.bodn2c("EARTH")
124
mars_id = spice.bodn2c("MARS")
125
print(f"Earth ID: {earth_id}, Mars ID: {mars_id}")
126
127
# Convert IDs back to names
128
earth_name = spice.bodc2n(399)
129
print(f"Body 399: {earth_name}")
130
```