Core API¶
ITRS(pos, lon)
¶
Bases: BatchableObject
Location in ITRS.
This class stores Cartesian site coordinates in ITRS in meters and a longitude in radians.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
Float[ArrayLike, '... 3']
|
Geocentric equatorial rectangular coordinates in meters. |
required |
lon
|
Float[ArrayLike, ...]
|
Site longitude in radians. |
required |
Initialize an ITRS location from position and longitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
Float[ArrayLike, '... 3']
|
Geocentric equatorial rectangular coordinates in meters. |
required |
lon
|
Float[ArrayLike, ...]
|
Site longitude in radians. |
required |
geodetic_lat
property
¶
Geodetic latitude in radians.
geocentric_lat
property
¶
Geocentric latitude in radians.
geodetic_alt
property
¶
Ellipsoidal height in meters.
geocentric_dist
property
¶
Geocentric distance in meters.
shape
property
¶
Return the batch shape.
from_geodetic(lon, lat, alt)
classmethod
¶
Build an ITRS location from geodetic coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon
|
Float[ArrayLike, ...]
|
Geodetic longitude in degrees. |
required |
lat
|
Float[ArrayLike, ...]
|
Geodetic latitude in degrees. |
required |
alt
|
Float[ArrayLike, ...]
|
Ellipsoid height in meters. |
required |
Returns:
| Type | Description |
|---|---|
``ITRS``
|
Site position in |
References
- Urban, S. E., & Seidelmann, P. K. (2012). Explanatory Supplement to the Astronomical Almanac. Eq.7.131.
from_geocentric(lon, parallax_const1, parallax_const2)
classmethod
¶
Build an ITRS location from geocentric constants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon
|
Float[ArrayLike, ...]
|
Geocentric longitude in degrees. |
required |
parallax_const1
|
Float[ArrayLike, ...]
|
|
required |
parallax_const2
|
Float[ArrayLike, ...]
|
|
required |
Returns:
| Type | Description |
|---|---|
``ITRS``
|
Site position in |
Notes
The parallax constants follow the Minor Planet Center observatory code definition (https://www.minorplanetcenter.net/iau/lists/ObsCodesF.html).
References
- Urban, S. E., & Seidelmann, P. K. (2012). Explanatory Supplement to the Astronomical Almanac. Eq.7.131.
state(t, frame=GCRS, *, sun=None, earth=None, grid=False)
¶
Convert the location in ITRS to one requested frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
Time
|
Time. |
required |
frame
|
Frame
|
Target output frame. |
``GCRS``
|
sun
|
EphemerisBody
|
Sun ephemeris body used when |
None
|
earth
|
EphemerisBody
|
Earth ephemeris body used when converting from the canonical |
None
|
grid
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
State
|
Location in |
Raises:
| Type | Description |
|---|---|
ValueError
|
If converting the canonical |
References
- Sean Urban and P. Kenneth Seidelmann, Explanatory Supplement to the Astronomical Almanac, 2012, Sec. 7.4.3.
- Kaplan, G. H. (2005). The IAU Resolutions on Astronomical Reference Systems, Time Scales, and Earth Rotation Models. Sec. 6.4.
KepElement(tdb, p, e, inc, node, peri, m)
¶
Bases: BatchableObject
Osculating Keplerian elements.
The stored elements are (p, e, inc, node, peri, m) at a TDB epoch. Here p is the semi-latus rectum. All angles are
stored in radians.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tdb
|
TDBView
|
Epoch of the osculating elements in |
required |
p
|
Float[ArrayLike, ...]
|
Semi-latus rectum in |
required |
e
|
Float[ArrayLike, ...]
|
Eccentricity. |
required |
inc
|
Float[ArrayLike, ...]
|
Inclination in radians. |
required |
node
|
Float[ArrayLike, ...]
|
Longitude of ascending node in radians. |
required |
peri
|
Float[ArrayLike, ...]
|
Argument of perihelion in radians. |
required |
m
|
Float[ArrayLike, ...]
|
Mean anomaly in radians. |
required |
See Also
from_classical
Build from the classical (a, e, i, node, peri, M) elements set.
from_true_anomaly
Build from (p, e, i, node, peri, v) elements set.
from_equinoctial_elements
Build from equinoctial elements.
from_helio_eclip_j2000
Build from a heliocentric JPL Horizons ecliptic-of-J2000 state vector.
Examples:
>>> from difforb.core.element import KepElement
>>> from difforb.core.time.timescale import Time
>>> tdb = Time.from_tdb_date(2025, 1, 1).tdb()
>>> elem = KepElement.from_classical(tdb, 2.0, 0.1, 5.0, 30.0, 40.0, 10.0)
>>> elem.array.shape
(6,)
Initialize heliocentric ecliptic J2000 Keplerian elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tdb
|
TDBView
|
Epoch in |
required |
p
|
Float[ArrayLike, ...]
|
Semi-latus rectum in |
required |
e
|
Float[ArrayLike, ...]
|
Eccentricity. |
required |
inc
|
Float[ArrayLike, ...]
|
Inclination in radians. |
required |
node
|
Float[ArrayLike, ...]
|
Longitude of ascending node in radians. |
required |
peri
|
Float[ArrayLike, ...]
|
Argument of perihelion in radians. |
required |
m
|
Float[ArrayLike, ...]
|
Mean anomaly in radians. |
required |
a
property
¶
Semi-major axis in au. Returns inf for parabolic cases.
v
property
¶
True anomaly in radians.
References
- For elliptical Kepler equation solving: Vallado, D. A. (2022). Fundamentals of Astrodynamics and Applications. Algorithm 2.
- For hyperbolic Kepler equation solving: Vallado, D. A. (2022). Fundamentals of Astrodynamics and Applications. Algorithm 4.
- For parabolic Kepler equation solving: https://github.com/CelesTrak/fundamentals-of-astrodynamics/blob/main/software/python/src/valladopy/astro/twobody/newton.py#L161.
- For elliptical conversion from eccentric anomaly to true anomaly: 吴连大, 《人造卫星与空间碎片的轨道和探测》, p.44-45.
- For hyperbolic conversion from hyperbolic anomaly to true anomaly: https://github.com/CelesTrak/fundamentals-of-astrodynamics/blob/main/software/python/src/valladopy/astro/twobody/newton.py#L156
- For parabolic conversion from Barker variable to true anomaly: https://github.com/CelesTrak/fundamentals-of-astrodynamics/blob/main/software/python/src/valladopy/astro/twobody/newton.py#L165
period
property
¶
Orbital period in days. Returns inf for non-periodic cases.
perit_jd
property
¶
Perihelion time in Julian Date. Returns nan for non-periodic cases.
array
property
¶
Return the stacked element array.
Returns:
| Type | Description |
|---|---|
Float[Array, 'N 6']
|
Array ordered as |
shape
property
¶
Return the batch shape.
from_classical(tdb, a, e, inc, node, peri, m, degrees=True)
classmethod
¶
Build from the classical (a, e, i, node, peri, M) elements set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tdb
|
TDBView
|
Epoch in |
required |
a
|
Float[ArrayLike, ...]
|
Semi-major axis in |
required |
e
|
Float[ArrayLike, ...]
|
Eccentricity. |
required |
inc
|
Float[ArrayLike, ...]
|
Inclination. |
required |
node
|
Float[ArrayLike, ...]
|
Longitude of ascending node. |
required |
peri
|
Float[ArrayLike, ...]
|
Argument of perihelion. |
required |
m
|
Float[ArrayLike, ...]
|
Mean anomaly. |
required |
degrees
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
KepElement
|
Element object stored as |
from_true_anomaly(tdb, p, e, inc, node, peri, v, degrees=True)
classmethod
¶
Build from (p, e, i, node, peri, v) elements set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tdb
|
TDBView
|
Epoch in |
required |
p
|
Float[ArrayLike, ...]
|
Semi-latus rectum in |
required |
e
|
Float[ArrayLike, ...]
|
Eccentricity. |
required |
inc
|
Float[ArrayLike, ...]
|
Inclination. |
required |
node
|
Float[ArrayLike, ...]
|
Longitude of ascending node. |
required |
peri
|
Float[ArrayLike, ...]
|
Argument of perihelion. |
required |
v
|
Float[ArrayLike, ...]
|
True anomaly. |
required |
degrees
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
KepElement
|
Element object with mean anomaly derived from |
References
- For elliptical case: 吴连大, 《人造卫星与空间碎片的轨道和探测》, p.44-45.
- For other cases: Vallado, D. A. (2022). Fundamentals of Astrodynamics and Applications. Algorithm 5.
from_equinoctial_elements(tt, a, g, f, k, h, M)
classmethod
¶
Build from equinoctial elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tt
|
TTView
|
Epoch in |
required |
a
|
Float[ArrayLike, ...]
|
Semi-major axis in |
required |
g
|
Float[ArrayLike, ...]
|
|
required |
f
|
Float[ArrayLike, ...]
|
|
required |
k
|
Float[ArrayLike, ...]
|
|
required |
h
|
Float[ArrayLike, ...]
|
|
required |
M
|
Float[ArrayLike, ...]
|
Sum |
required |
Returns:
| Type | Description |
|---|---|
KepElement
|
Equivalent element set at the corresponding |
References
- https://spsweb.fltops.jpl.nasa.gov/portaldataops/mpg/MPG_Docs/Source%20Docs/EquinoctalElements-modified.pdf.
from_state(state, *, sun=None, earth=None)
classmethod
¶
Build from one frame-aware Cartesian state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
State
|
Input state at a |
required |
sun
|
EphemerisBody
|
Sun ephemeris body used if |
None
|
earth
|
EphemerisBody
|
Earth ephemeris body used if |
None
|
Returns:
| Type | Description |
|---|---|
KepElement
|
Osculating element set for |
Raises:
| Type | Description |
|---|---|
ValueError
|
If converting |
Notes
The canonical Cartesian boundary of :class:KepElement is heliocentric JPL Horizons ecliptic-of-J2000. This method converts the input state to that frame first and then applies the Cartesian-to-element mapping.
References
- Vallado, D. A. (2022). Fundamentals of Astrodynamics and Applications. Algorithm 9, pp. 115-116.
from_array(tdb, array)
classmethod
¶
Build from a stacked element array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tdb
|
TDBView
|
Epoch in |
required |
array
|
Float[ArrayLike, '... 6']
|
Array with shape |
required |
Returns:
| Type | Description |
|---|---|
KepElement
|
Element object of the receiving class. |
state()
¶
Convert elements to the canonical Cartesian state.
Returns:
| Type | Description |
|---|---|
State
|
Heliocentric JPL Horizons ecliptic-of-J2000 state at the same epoch. |
Notes
This is the canonical Cartesian boundary of :class:KepElement. The returned state uses the HELIO_ECLIP_J2000 frame of :mod:difforb.core.state.
References
- Vallado, D. A. (2022). Fundamentals of Astrodynamics and Applications. Algorithm 10.