A Python wrapper for the NAIF CSPICE Toolkit providing essential tools for spacecraft navigation and planetary science calculations
Advanced search capabilities for finding geometric events such as occultations, oppositions, and user-defined conditions. These functions enable sophisticated mission planning and analysis.
Find times when distances meet specified conditions.
def gfdist(target: str, abcorr: str, obsrvr: str, relate: str, refval: float, adjust: float, step: float, cnfine: SpiceCell, result: SpiceCell) -> None:
"""
Find times when distance between observer and target satisfies condition.
Parameters:
- target: str, target body name
- abcorr: str, aberration correction
- obsrvr: str, observer body name
- relate: str, relational operator ("=", "<", ">", "LOCMIN", "LOCMAX", "ABSMIN", "ABSMAX")
- refval: float, reference value for comparison
- adjust: float, adjustment value for absolute extrema searches
- step: float, search step size in seconds
- cnfine: SpiceCell, confinement window
- result: SpiceCell, result window (modified in place)
Returns:
None (result window is modified)
"""Find occultation events between celestial bodies.
def gfoclt(occtyp: str, front: str, fshape: str, fframe: str, back: str, bshape: str, bframe: str, abcorr: str, obsrvr: str, step: float, cnfine: SpiceCell, result: SpiceCell) -> None:
"""
Find occultation events.
Parameters:
- occtyp: str, occultation type ("FULL", "ANNULAR", "PARTIAL", "ANY")
- front: str, front body name
- fshape: str, front body shape ("POINT", "SPHERE", "ELLIPSOID")
- fframe: str, front body reference frame
- back: str, back body name
- bshape: str, back body shape
- bframe: str, back body reference frame
- abcorr: str, aberration correction
- obsrvr: str, observer body name
- step: float, search step size in seconds
- cnfine: SpiceCell, confinement window
- result: SpiceCell, result window (modified in place)
Returns:
None (result window is modified)
"""Find times when angular separations meet conditions.
def gfsep(targ1: str, shape1: str, frame1: str, targ2: str, shape2: str, frame2: str, abcorr: str, obsrvr: str, relate: str, refval: float, adjust: float, step: float, cnfine: SpiceCell, result: SpiceCell) -> None:
"""
Find times when angular separation between two targets satisfies condition.
Parameters:
- targ1: str, first target body name
- shape1: str, first target shape
- frame1: str, first target reference frame
- targ2: str, second target body name
- shape2: str, second target shape
- frame2: str, second target reference frame
- abcorr: str, aberration correction
- obsrvr: str, observer body name
- relate: str, relational operator
- refval: float, reference value in radians
- adjust: float, adjustment value
- step: float, search step size
- cnfine: SpiceCell, confinement window
- result: SpiceCell, result window (modified in place)
Returns:
None (result window is modified)
"""import spiceypy as spice
spice.furnsh("metakernel.mk")
# Create time window for search (1 year)
start_et = spice.str2et("2023-01-01")
end_et = spice.str2et("2024-01-01")
# Create confinement window
cnfine = spice.cell_double(2)
spice.wninsd(start_et, end_et, cnfine)
# Search for minimum distance (opposition)
result = spice.cell_double(100)
spice.gfdist(
"MARS", # Target
"LT+S", # Aberration correction
"EARTH", # Observer
"LOCMIN", # Local minimum
0.0, # Reference value (not used for LOCMIN)
86400.0, # Adjustment (1 day)
3600.0, # Step size (1 hour)
cnfine, # Confinement window
result # Result window
)
# Extract results
for i in range(spice.wncard(result)):
start, end = spice.wnfetd(result, i)
print(f"Mars opposition: {spice.et2utc(start, 'C', 0)}")
spice.kclear()Install with Tessl CLI
npx tessl i tessl/pypi-spiceypydocs