Source code for spiceypy.spiceypy

"""
The MIT License (MIT)

Copyright (c) [2015-2021] [Andrew Annex]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
import warnings
from contextlib import contextmanager
from datetime import datetime, timezone
import functools
import ctypes
from typing import Callable, Iterator, Iterable, Optional, Tuple, Union, Sequence


import numpy
from numpy import ndarray, str_

from .utils import support_types as stypes
from .utils.libspicehelper import libspice
from . import config

from .utils.callbacks import (
    UDFUNC,
    UDFUNS,
    UDFUNB,
    UDSTEP,
    UDREFN,
    UDREPI,
    UDREPU,
    UDREPF,
    UDBAIL,
    SpiceUDFUNS,
    SpiceUDFUNB,
)

from .utils.support_types import (
    Cell_Char,
    Cell_Bool,
    Cell_Time,
    Cell_Double,
    Cell_Int,
    Ellipse,
    Plane,
    SpiceCell,
    SpiceCellPointer,
    SpiceDLADescr,
    SpiceDSKDescr,
    SpiceEKAttDsc,
    SpiceEKSegSum,
)


__author__ = "AndrewAnnex"

################################################################################
OptionalInt = Optional[int]

_default_len_out = 256

_SPICE_EK_MAXQSEL = 100  # Twice the 50 in gcc-linux-64
_SPICE_EK_EKRCEX_ROOM_DEFAULT = 100  # Enough?


[docs]def warn_deprecated_args(**kwargs) -> None: keys = list(kwargs.keys()) values = list(kwargs.values()) if any(values): varnames = ", ".join(keys) warnings.warn( f"Specifying any of: {varnames} will be deprecated as of SpiceyPy 5.0.0", DeprecationWarning, stacklevel=2, ) pass
[docs]def check_for_spice_error(f: Optional[Callable]) -> None: """ Internal decorator function to check spice error system for failed calls :param f: function :raise stypes.SpiceyError: """ if failed(): short = getmsg("SHORT", 26) explain = getmsg("EXPLAIN", 100).strip() long = getmsg("LONG", 1841).strip() traceback = qcktrc(200) reset() raise stypes.dynamically_instantiate_spiceyerror( short=short, explain=explain, long=long, traceback=traceback )
[docs]def spice_error_check(f): """ Decorator for spiceypy hooking into spice error system. If an error is detected, an output similar to outmsg :return: """ @functools.wraps(f) def with_errcheck(*args, **kwargs): try: res = f(*args, **kwargs) check_for_spice_error(f) return res except BaseException: raise return with_errcheck
[docs]def spice_found_exception_thrower(f: Callable) -> Callable: """ Decorator for wrapping functions that use status codes """ @functools.wraps(f) def wrapper(*args, **kwargs): res = f(*args, **kwargs) if config.catch_false_founds: found = res[-1] if isinstance(found, bool) and not found: raise stypes.NotFoundError( "Spice returns not found for function: {}".format(f.__name__), found=found, ) elif stypes.is_iterable(found) and not all(found): raise stypes.NotFoundError( "Spice returns not found in a series of calls for function: {}".format( f.__name__ ), found=found, ) else: actualres = res[0:-1] if len(actualres) == 1: return actualres[0] else: return actualres else: return res return wrapper
[docs]@contextmanager def no_found_check() -> Iterator[None]: """ Temporarily disables spiceypy default behavior which raises exceptions for false found flags for certain spice functions. All spice functions executed within the context manager will no longer check the found flag return parameter and the found flag will be included in the return for the given function. For Example bodc2n in spiceypy is normally called like:: name = spice.bodc2n(399) With the possibility that an exception is thrown in the even of a invalid ID:: name = spice.bodc2n(-999991) # throws a SpiceyError With this function however, we can use it as a context manager to do this:: with spice.no_found_check(): name, found = spice.bodc2n(-999991) # found is false, no exception raised! Within the context any spice functions called that normally check the found flags will pass through the check without raising an exception if they are false. """ current_catch_state = config.catch_false_founds config.catch_false_founds = False yield config.catch_false_founds = current_catch_state
[docs]@contextmanager def found_check() -> Iterator[None]: """ Temporarily enables spiceypy default behavior which raises exceptions for false found flags for certain spice functions. All spice functions executed within the context manager will check the found flag return parameter and the found flag will be removed from the return for the given function. For Example bodc2n in spiceypy is normally called like:: name = spice.bodc2n(399) With the possibility that an exception is thrown in the even of a invalid ID:: name = spice.bodc2n(-999991) # throws a SpiceyError With this function however, we can use it as a context manager to do this:: with spice.found_check(): found = spice.bodc2n(-999991) # will raise an exception! Within the context any spice functions called that normally check the found flags will pass through the check without raising an exception if they are false. """ current_catch_state = config.catch_false_founds config.catch_false_founds = True yield config.catch_false_founds = current_catch_state
[docs]def found_check_off() -> None: """ Method that turns off found catching """ config.catch_false_founds = False
[docs]def found_check_on() -> None: """ Method that turns on found catching """ config.catch_false_founds = True
[docs]def get_found_catch_state() -> bool: """ Returns the current found catch state :return: """ return config.catch_false_founds
[docs]def cell_double(cell_size: int) -> SpiceCell: return stypes.SPICEDOUBLE_CELL(cell_size)
[docs]def cell_int(cell_size: int) -> SpiceCell: return stypes.SPICEINT_CELL(cell_size)
[docs]def cell_char(cell_size: int, length: int) -> SpiceCell: return stypes.SPICECHAR_CELL(cell_size, length)
[docs]def cell_bool(cell_size: int) -> SpiceCell: return stypes.SPICEBOOL_CELL(cell_size)
[docs]def cell_time(cell_size) -> SpiceCell: return stypes.SPICETIME_CELL(cell_size)
################################################################################ # A
[docs]@spice_error_check def appndc( item: Union[str, Iterable[str], ndarray, str_], cell: Union[Cell_Char, SpiceCell], ) -> None: """ Append an item to a character cell. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/appndc_c.html :param item: The item to append. :param cell: The cell to append to. """ assert isinstance(cell, stypes.SpiceCell) if stypes.is_iterable(item): for c in item: libspice.appndc_c(stypes.string_to_char_p(c), cell) else: item = stypes.string_to_char_p(item) libspice.appndc_c(item, cell)
[docs]@spice_error_check def appndd( item: Union[float, Iterable[float]], cell: Union[SpiceCell, Cell_Double] ) -> None: """ Append an item to a double precision cell. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/appndd_c.html :param item: The item to append. :param cell: The cell to append to. """ assert isinstance(cell, stypes.SpiceCell) if hasattr(item, "__iter__"): for d in item: libspice.appndd_c(ctypes.c_double(d), cell) else: item = ctypes.c_double(item) libspice.appndd_c(item, cell)
[docs]@spice_error_check def appndi(item: Union[Iterable[int], int], cell: Union[SpiceCell, Cell_Int]) -> None: """ Append an item to an integer cell. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/appndi_c.html :param item: The item to append. :param cell: The cell to append to. """ assert isinstance(cell, stypes.SpiceCell) if hasattr(item, "__iter__"): for i in item: libspice.appndi_c(ctypes.c_int(i), cell) else: item = ctypes.c_int(item) libspice.appndi_c(item, cell)
[docs]@spice_error_check def axisar(axis: Union[ndarray, Iterable[float]], angle: float) -> ndarray: """ Construct a rotation matrix that rotates vectors by a specified angle about a specified axis. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/axisar_c.html :param axis: Rotation axis. :param angle: Rotation angle, in radians. :return: Rotation matrix corresponding to axis and angle. """ axis = stypes.to_double_vector(axis) angle = ctypes.c_double(angle) r = stypes.empty_double_matrix() libspice.axisar_c(axis, angle, r) return stypes.c_matrix_to_numpy(r)
################################################################################ # B
[docs]@spice_error_check def b1900() -> float: """ Return the Julian Date corresponding to Besselian Date 1900.0. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/b1900_c.html :return: The Julian Date corresponding to Besselian Date 1900.0. """ return libspice.b1900_c()
[docs]@spice_error_check def b1950() -> float: """ Return the Julian Date corresponding to Besselian Date 1950.0. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/b1950_c.html :return: The Julian Date corresponding to Besselian Date 1950.0. """ return libspice.b1950_c()
[docs]@spice_error_check def badkpv( caller: str, name: str, comp: str, insize: int, divby: int, intype: str ) -> bool: """ Determine if a kernel pool variable is present and if so that it has the correct size and type. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/badkpv_c.html :param caller: Name of the routine calling this routine. :param name: Name of a kernel pool variable. :param comp: Comparison operator. :param insize: Expected size of the kernel pool variable. :param divby: A divisor of the size of the kernel pool variable. :param intype: Expected type of the kernel pool variable :return: returns false if the kernel pool variable is OK. """ caller = stypes.string_to_char_p(caller) name = stypes.string_to_char_p(name) comp = stypes.string_to_char_p(comp) insize = ctypes.c_int(insize) divby = ctypes.c_int(divby) intype = ctypes.c_char(intype.encode(encoding="UTF-8")) return bool(libspice.badkpv_c(caller, name, comp, insize, divby, intype))
[docs]@spice_error_check def bltfrm(frmcls: int, out_cell: Optional[SpiceCell] = None) -> SpiceCell: """ Return a SPICE set containing the frame IDs of all built-in frames of a specified class. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bltfrm_c.html :param frmcls: Frame class. :param out_cell: Optional SpiceInt Cell that is returned :return: Set of ID codes of frames of the specified class. """ frmcls = ctypes.c_int(frmcls) if not out_cell: out_cell = stypes.SPICEINT_CELL(1000) libspice.bltfrm_c(frmcls, out_cell) return out_cell
[docs]@spice_error_check def bodeul(body: int, et: float) -> Tuple[float, float, float, float]: """ Return the Euler angles needed to compute the transformation from inertial to body-fixed coordinates for any body in the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/bodeul.html :param body: NAIF ID code of body. :param et: Epoch of transformation in seconds past J2000 TDB. :return: Right ascension of the (IAU) north pole in radians. Declination of the (IAU) north pole of the body in radians. Prime meridian rotation angle in radians. Angle between the prime meridian and longitude of longest axis in radians. """ body = ctypes.c_int(body) et = ctypes.c_double(et) ra = ctypes.c_double() dec = ctypes.c_double() w = ctypes.c_double() lam = ctypes.c_double() libspice.bodeul_( ctypes.byref(body), ctypes.byref(et), ctypes.byref(ra), ctypes.byref(dec), ctypes.byref(w), ctypes.byref(lam), ) return ra.value, dec.value, w.value, lam.value
[docs]@spice_error_check @spice_found_exception_thrower def bodc2n(code: int, lenout: int = _default_len_out) -> Tuple[str, bool]: """ Translate the SPICE integer code of a body into a common name for that body. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodc2n_c.html :param code: Integer ID code to be translated into a name. :param lenout: Maximum length of output name. :return: A common name for the body identified by code. """ code = ctypes.c_int(code) name = stypes.string_to_char_p(" " * lenout) lenout = ctypes.c_int(lenout) found = ctypes.c_int() libspice.bodc2n_c(code, lenout, name, ctypes.byref(found)) return stypes.to_python_string(name), bool(found.value)
[docs]@spice_error_check def bodc2s(code: int, lenout: int = _default_len_out) -> str: """ Translate a body ID code to either the corresponding name or if no name to ID code mapping exists, the string representation of the body ID value. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodc2s_c.html :param code: Integer ID code to translate to a string. :param lenout: Maximum length of output name. :return: String corresponding to 'code'. """ code = ctypes.c_int(code) name = stypes.string_to_char_p(" " * lenout) lenout = ctypes.c_int(lenout) libspice.bodc2s_c(code, lenout, name) return stypes.to_python_string(name)
[docs]@spice_error_check def boddef(name: str, code: int) -> None: """ Define a body name/ID code pair for later translation via :func:`bodn2c` or :func:`bodc2n`. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/boddef_c.html :param name: Common name of some body. :param code: Integer code for that body. """ name = stypes.string_to_char_p(name) code = ctypes.c_int(code) libspice.boddef_c(name, code)
[docs]@spice_error_check def bodfnd(body: int, item: str) -> bool: """ Determine whether values exist for some item for any body in the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodfnd_c.html :param body: ID code of body. :param item: Item to find ("RADII", "NUT_AMP_RA", etc.). :return: True if the item is in the kernel pool, and is False if it is not. """ body = ctypes.c_int(body) item = stypes.string_to_char_p(item) return bool(libspice.bodfnd_c(body, item))
[docs]@spice_error_check @spice_found_exception_thrower def bodn2c(name: str) -> Tuple[int, bool]: """ Translate the name of a body or object to the corresponding SPICE integer ID code. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodn2c_c.html :param name: Body name to be translated into a SPICE ID code. :return: SPICE integer ID code for the named body. """ name = stypes.string_to_char_p(name) code = ctypes.c_int(0) found = ctypes.c_int(0) libspice.bodn2c_c(name, ctypes.byref(code), ctypes.byref(found)) return code.value, bool(found.value)
[docs]@spice_error_check @spice_found_exception_thrower def bods2c(name: str) -> Tuple[int, bool]: """ Translate a string containing a body name or ID code to an integer code. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bods2c_c.html :param name: String to be translated to an ID code. :return: Integer ID code corresponding to name. """ name = stypes.string_to_char_p(name) code = ctypes.c_int(0) found = ctypes.c_int(0) libspice.bods2c_c(name, ctypes.byref(code), ctypes.byref(found)) return code.value, bool(found.value)
[docs]@spice_error_check def bodvar(body: int, item: str, dim: int) -> ndarray: """ Deprecated: This routine has been superseded by :func:`bodvcd` and :func:`bodvrd`. This routine is supported for purposes of backward compatibility only. Return the values of some item for any body in the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvar_c.html :param body: ID code of body. :param item: Item for which values are desired, ("RADII", "NUT_PREC_ANGLES", etc.) :param dim: Number of values returned. :return: values """ body = ctypes.c_int(body) dim = ctypes.c_int(dim) item = stypes.string_to_char_p(item) values = stypes.empty_double_vector(dim.value) libspice.bodvar_c(body, item, ctypes.byref(dim), values) return stypes.c_vector_to_python(values)
[docs]@spice_error_check def bodvcd(bodyid: int, item: str, maxn: int) -> Tuple[int, ndarray]: """ Fetch from the kernel pool the double precision values of an item associated with a body, where the body is specified by an integer ID code. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvcd_c.html :param bodyid: Body ID code. :param item: Item for which values are desired, ("RADII", "NUT_PREC_ANGLES", etc.) :param maxn: Maximum number of values that may be returned. :return: dim, values """ bodyid = ctypes.c_int(bodyid) item = stypes.string_to_char_p(item) dim = ctypes.c_int() values = stypes.empty_double_vector(maxn) maxn = ctypes.c_int(maxn) libspice.bodvcd_c(bodyid, item, maxn, ctypes.byref(dim), values) return dim.value, stypes.c_vector_to_python(values)
[docs]@spice_error_check def bodvrd(bodynm: str, item: str, maxn: int) -> Tuple[int, ndarray]: """ Fetch from the kernel pool the double precision values of an item associated with a body. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvrd_c.html :param bodynm: Body name. :param item: Item for which values are desired, ("RADII", "NUT_PREC_ANGLES", etc.) :param maxn: Maximum number of values that may be returned. :return: tuple of (dim, values) """ bodynm = stypes.string_to_char_p(bodynm) item = stypes.string_to_char_p(item) dim = ctypes.c_int() values = stypes.empty_double_vector(maxn) maxn = ctypes.c_int(maxn) libspice.bodvrd_c(bodynm, item, maxn, ctypes.byref(dim), values) return dim.value, stypes.c_vector_to_python(values)
[docs]@spice_error_check def brcktd(number: float, end1: float, end2: float) -> float: """ Bracket a number. That is, given a number and an acceptable interval, make sure that the number is contained in the interval. (If the number is already in the interval, leave it alone. If not, set it to the nearest endpoint of the interval.) https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/brcktd_c.html :param number: Number to be bracketed. :param end1: One of the bracketing endpoints for number. :param end2: The other bracketing endpoint for number. :return: value within an interval """ number = ctypes.c_double(number) end1 = ctypes.c_double(end1) end2 = ctypes.c_double(end2) return libspice.brcktd_c(number, end1, end2)
[docs]@spice_error_check def brckti(number: int, end1: int, end2: int) -> int: """ Bracket a number. That is, given a number and an acceptable interval, make sure that the number is contained in the interval. (If the number is already in the interval, leave it alone. If not, set it to the nearest endpoint of the interval.) https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/brckti_c.html :param number: Number to be bracketed. :param end1: One of the bracketing endpoints for number. :param end2: The other bracketing endpoint for number. :return: value within an interval """ number = ctypes.c_int(number) end1 = ctypes.c_int(end1) end2 = ctypes.c_int(end2) return libspice.brckti_c(number, end1, end2)
[docs]@spice_error_check def bschoc( value: Union[str_, str], ndim: int, lenvals: int, array: Union[ndarray, Iterable[str]], order: Union[ndarray, Iterable[int]], ) -> int: """ Do a binary search for a given value within a character string array, accompanied by an order vector. Return the index of the matching array entry, or -1 if the key value is not found. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bschoc_c.html :param value: Key value to be found in array. :param ndim: Dimension of array. :param lenvals: String length. :param array: Character string array to search. :param order: Order vector. :return: index """ value = stypes.string_to_char_p(value) ndim = ctypes.c_int(ndim) lenvals = ctypes.c_int(lenvals) array = stypes.list_to_char_array_ptr(array, x_len=lenvals, y_len=ndim) order = stypes.to_int_vector(order) return libspice.bschoc_c(value, ndim, lenvals, array, order)
[docs]@spice_error_check def bschoi( value: int, ndim: int, array: Union[ndarray, Iterable[int]], order: Union[ndarray, Iterable[int]], ) -> int: """ Do a binary search for a given value within an integer array, accompanied by an order vector. Return the index of the matching array entry, or -1 if the key value is not found. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bschoi_c.html :param value: Key value to be found in array. :param ndim: Dimension of array. :param array: Integer array to search. :param order: Order vector. :return: index """ value = ctypes.c_int(value) ndim = ctypes.c_int(ndim) array = stypes.to_int_vector(array) order = stypes.to_int_vector(order) return libspice.bschoi_c(value, ndim, array, order)
[docs]@spice_error_check def bsrchc(value: str, ndim: int, lenvals: int, array: Iterable[str]) -> int: """ Do a binary earch for a given value within a character string array. Return the index of the first matching array entry, or -1 if the key value was not found. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bsrchc_c.html :param value: Key value to be found in array. :param ndim: Dimension of array. :param lenvals: String length. :param array: Character string array to search. :return: index """ value = stypes.string_to_char_p(value) ndim = ctypes.c_int(ndim) lenvals = ctypes.c_int(lenvals) array = stypes.list_to_char_array_ptr(array, x_len=lenvals, y_len=ndim) return libspice.bsrchc_c(value, ndim, lenvals, array)
[docs]@spice_error_check def bsrchd(value: float, ndim: int, array: ndarray) -> int: """ Do a binary search for a key value within a double precision array, assumed to be in increasing order. Return the index of the matching array entry, or -1 if the key value is not found. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bsrchd_c.html :param value: Value to find in array. :param ndim: Dimension of array. :param array: Array to be searched. :return: index """ value = ctypes.c_double(value) ndim = ctypes.c_int(ndim) array = stypes.to_double_vector(array) return libspice.bsrchd_c(value, ndim, array)
[docs]@spice_error_check def bsrchi(value: int, ndim: int, array: ndarray) -> int: """ Do a binary search for a key value within an integer array, assumed to be in increasing order. Return the index of the matching array entry, or -1 if the key value is not found. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bsrchi_c.html :param value: Value to find in array. :param ndim: Dimension of array. :param array: Array to be searched. :return: index """ value = ctypes.c_int(value) ndim = ctypes.c_int(ndim) array = stypes.to_int_vector(array) return libspice.bsrchi_c(value, ndim, array)
################################################################################ # C
[docs]@spice_error_check def card(cell: SpiceCell) -> int: """ Return the cardinality (current number of elements) in a cell of any data type. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/card_c.html :param cell: Input cell. :return: the number of elements in a cell of any data type. """ return libspice.card_c(ctypes.byref(cell))
[docs]@spice_error_check @spice_found_exception_thrower def ccifrm( frclss: int, clssid: int, lenout: int = _default_len_out ) -> Tuple[int, str, int, bool]: """ Return the frame name, frame ID, and center associated with a given frame class and class ID. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ccifrm_c.html :param frclss: Class of frame. :param clssid: Class ID of frame. :param lenout: Maximum length of output string. :return: the frame name, frame ID, center. """ frclss = ctypes.c_int(frclss) clssid = ctypes.c_int(clssid) lenout = ctypes.c_int(lenout) frcode = ctypes.c_int() frname = stypes.string_to_char_p(lenout) center = ctypes.c_int() found = ctypes.c_int() libspice.ccifrm_c( frclss, clssid, lenout, ctypes.byref(frcode), frname, ctypes.byref(center), ctypes.byref(found), ) return ( frcode.value, stypes.to_python_string(frname), center.value, bool(found.value), )
[docs]@spice_error_check def cgv2el( center: Union[ndarray, Iterable[float]], vec1: Union[ndarray, Iterable[float]], vec2: Union[ndarray, Iterable[float]], ) -> Ellipse: """ Form a SPICE ellipse from a center vector and two generating vectors. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cgv2el_c.html :param center: Center Vector :param vec1: Vector 1 :param vec2: Vector 2 :return: Ellipse """ center = stypes.to_double_vector(center) vec1 = stypes.to_double_vector(vec1) vec2 = stypes.to_double_vector(vec2) ellipse = stypes.Ellipse() libspice.cgv2el_c(center, vec1, vec2, ctypes.byref(ellipse)) return ellipse
[docs]@spice_error_check def chbder( cp: Union[ndarray, Iterable[float]], degp: int, x2s: Union[ndarray, Iterable[float]], x: float, nderiv: int, ) -> ndarray: """ Given the coefficients for the Chebyshev expansion of a polynomial, this returns the value of the polynomial and its first nderiv derivatives evaluated at the input X. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/chbder_c.html :param cp: degp+1 Chebyshev polynomial coefficients. :param degp: Degree of polynomial. :param x2s: Transformation parameters of polynomial. :param x: Value for which the polynomial is to be evaluated :param nderiv: The number of derivatives to compute :return: Array of the derivatives of the polynomial """ cp = stypes.to_double_vector(cp) degp = ctypes.c_int(degp) x2s = stypes.to_double_vector(x2s) x = ctypes.c_double(x) partdp = stypes.empty_double_vector(3 * (nderiv + 1)) dpdxs = stypes.empty_double_vector(nderiv + 1) nderiv = ctypes.c_int(nderiv) libspice.chbder_c(cp, degp, x2s, x, nderiv, partdp, dpdxs) return stypes.c_vector_to_python(dpdxs)
[docs]@spice_error_check def chkin(module: str) -> None: """ Inform the SPICE error handling mechanism of entry into a routine. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/chkin_c.html :param module: The name of the calling routine. """ module = stypes.string_to_char_p(module) libspice.chkin_c(module)
[docs]@spice_error_check def chkout(module: str) -> None: """ Inform the SPICE error handling mechanism of exit from a routine. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/chkout_c.html :param module: The name of the calling routine. """ module = stypes.string_to_char_p(module) libspice.chkout_c(module)
[docs]@spice_error_check @spice_found_exception_thrower def cidfrm(cent: int, lenout: int = _default_len_out) -> Tuple[int, str, bool]: """ Retrieve frame ID code and name to associate with a frame center. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cidfrm_c.html :param cent: An object to associate a frame with. :param lenout: Available space in output string frname. :return: frame ID code, name to associate with a frame center. """ cent = ctypes.c_int(cent) lenout = ctypes.c_int(lenout) frcode = ctypes.c_int() frname = stypes.string_to_char_p(lenout) found = ctypes.c_int() libspice.cidfrm_c(cent, lenout, ctypes.byref(frcode), frname, ctypes.byref(found)) return frcode.value, stypes.to_python_string(frname), bool(found.value)
[docs]@spice_error_check def ckcls(handle: int) -> None: """ Close an open CK file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckcls_c.html :param handle: Handle of the CK file to be closed. """ handle = ctypes.c_int(handle) libspice.ckcls_c(handle)
[docs]@spice_error_check def ckcov( ck: str, idcode: int, needav: bool, level: str, tol: float, timsys: str, cover: Optional[SpiceCell] = None, ) -> SpiceCell: """ Find the coverage window for a specified object in a specified CK file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckcov_c.html :param ck: Name of CK file. :param idcode: ID code of object. :param needav: Flag indicating whether angular velocity is needed. :param level: Coverage level: (SEGMENT OR INTERVAL) :param tol: Tolerance in ticks. :param timsys: Time system used to represent coverage. :param cover: Window giving coverage for idcode. :return: coverage window for a specified object in a specified CK file """ ck = stypes.string_to_char_p(ck) idcode = ctypes.c_int(idcode) needav = ctypes.c_int(needav) level = stypes.string_to_char_p(level) tol = ctypes.c_double(tol) timsys = stypes.string_to_char_p(timsys) if not cover: cover = stypes.SPICEDOUBLE_CELL(20000) assert isinstance(cover, stypes.SpiceCell) assert cover.dtype == 1 libspice.ckcov_c(ck, idcode, needav, level, tol, timsys, ctypes.byref(cover)) return cover
[docs]@spice_error_check @spice_found_exception_thrower def ckfrot(inst: int, et: float) -> Tuple[ndarray, int, bool]: """ Find the rotation from a C-kernel Id to the native frame at the time requested. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/ckfrot.html :param inst: NAIF instrument ID :param et: Epoch measured in seconds past J2000 :return: Rotation matrix from the input frame to the returned reference frame, id for the reference frame """ inst = ctypes.c_int(inst) et = ctypes.c_double(et) rotate_m = stypes.empty_double_matrix(x=3, y=3) ref = ctypes.c_int() found = ctypes.c_int() libspice.ckfrot_( ctypes.byref(inst), ctypes.byref(et), rotate_m, ctypes.byref(ref), ctypes.byref(found), ) return stypes.c_matrix_to_numpy(rotate_m), ref.value, bool(found.value)
[docs]@spice_error_check @spice_found_exception_thrower def ckgp( inst: int, sclkdp: Union[float, int], tol: int, ref: str ) -> Tuple[ndarray, float, bool]: """ Get pointing (attitude) for a specified spacecraft clock time. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckgp_c.html :param inst: NAIF ID of instrument, spacecraft, or structure. :param sclkdp: Encoded spacecraft clock time. :param tol: Time tolerance. :param ref: Reference frame. :return: C-matrix pointing data, Output encoded spacecraft clock time """ inst = ctypes.c_int(inst) sclkdp = ctypes.c_double(sclkdp) tol = ctypes.c_double(tol) ref = stypes.string_to_char_p(ref) cmat = stypes.empty_double_matrix() clkout = ctypes.c_double() found = ctypes.c_int() libspice.ckgp_c( inst, sclkdp, tol, ref, cmat, ctypes.byref(clkout), ctypes.byref(found) ) return stypes.c_matrix_to_numpy(cmat), clkout.value, bool(found.value)
[docs]@spice_error_check @spice_found_exception_thrower def ckgpav( inst: int, sclkdp: Union[float, float], tol: Union[float, int], ref: str ) -> Tuple[ndarray, ndarray, float, bool]: """ Get pointing (attitude) and angular velocity for a specified spacecraft clock time. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckgpav_c.html :param inst: NAIF ID of instrument, spacecraft, or structure. :param sclkdp: Encoded spacecraft clock time. :param tol: Time tolerance. :param ref: Reference frame. :return: C-matrix pointing data, Angular velocity vector, Output encoded spacecraft clock time. """ inst = ctypes.c_int(inst) sclkdp = ctypes.c_double(sclkdp) tol = ctypes.c_double(tol) ref = stypes.string_to_char_p(ref) cmat = stypes.empty_double_matrix() av = stypes.empty_double_vector(3) clkout = ctypes.c_double() found = ctypes.c_int() libspice.ckgpav_c( inst, sclkdp, tol, ref, cmat, av, ctypes.byref(clkout), ctypes.byref(found) ) return ( stypes.c_matrix_to_numpy(cmat), stypes.c_vector_to_python(av), clkout.value, bool(found.value), )
[docs]@spice_error_check def cklpf(filename: str) -> int: """ Load a CK pointing file for use by the CK readers. Return that file's handle, to be used by other CK routines to refer to the file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cklpf_c.html :param filename: Name of the CK file to be loaded. :return: Loaded file's handle. """ filename = stypes.string_to_char_p(filename) handle = ctypes.c_int() libspice.cklpf_c(filename, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def ckobj(ck: str, out_cell: Optional[SpiceCell] = None) -> SpiceCell: """ Find the set of ID codes of all objects in a specified CK file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckobj_c.html :param ck: Name of CK file. :param out_cell: Optional user provided Spice Int cell. :return: Set of ID codes of objects in CK file. """ assert isinstance(ck, str) ck = stypes.string_to_char_p(ck) if not out_cell: out_cell = stypes.SPICEINT_CELL(1000) assert isinstance(out_cell, stypes.SpiceCell) assert out_cell.dtype == 2 libspice.ckobj_c(ck, ctypes.byref(out_cell)) return out_cell
[docs]@spice_error_check def ckopn(filename: str, ifname: str, ncomch: int) -> int: """ Open a new CK file, returning the handle of the opened file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckopn_c.html :param filename: The name of the CK file to be opened. :param ifname: The internal filename for the CK. :param ncomch: The number of characters to reserve for comments. :return: The handle of the opened CK file. """ filename = stypes.string_to_char_p(filename) ifname = stypes.string_to_char_p(ifname) ncomch = ctypes.c_int(ncomch) handle = ctypes.c_int() libspice.ckopn_c(filename, ifname, ncomch, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def ckupf(handle: int) -> None: """ Unload a CK pointing file so that it will no longer be searched by the readers. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckupf_c.html :param handle: Handle of CK file to be unloaded """ handle = ctypes.c_int(handle) libspice.ckupf_c(handle)
[docs]@spice_error_check def ckw01( handle: int, begtim: Union[float, float], endtim: Union[float, float], inst: int, ref: str, avflag: bool, segid: str, nrec: int, sclkdp: Union[ndarray, Iterable[float]], quats: Union[ndarray, Iterable[Iterable[float]]], avvs: Union[ndarray, Iterable[Iterable[float]]], ) -> None: """ Add a type 1 segment to a C-kernel. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckw01_c.html :param handle: Handle of an open CK file. :param begtim: The beginning encoded SCLK of the segment. :param endtim: The ending encoded SCLK of the segment. :param inst: The NAIF instrument ID code. :param ref: The reference frame of the segment. :param avflag: True if the segment will contain angular velocity. :param segid: Segment identifier. :param nrec: Number of pointing records. :param sclkdp: Encoded SCLK times. :param quats: Quaternions representing instrument pointing. :param avvs: Angular velocity vectors. """ handle = ctypes.c_int(handle) begtim = ctypes.c_double(begtim) endtim = ctypes.c_double(endtim) inst = ctypes.c_int(inst) ref = stypes.string_to_char_p(ref) avflag = ctypes.c_int(avflag) segid = stypes.string_to_char_p(segid) sclkdp = stypes.to_double_vector(sclkdp) quats = stypes.to_double_matrix(quats) avvs = stypes.to_double_matrix(avvs) nrec = ctypes.c_int(nrec) libspice.ckw01_c( handle, begtim, endtim, inst, ref, avflag, segid, nrec, sclkdp, quats, avvs )
[docs]@spice_error_check def ckw02( handle: int, begtim: float, endtim: float, inst: int, ref: str, segid: str, nrec: int, start: ndarray, stop: ndarray, quats: ndarray, avvs: ndarray, rates: Union[ndarray, Iterable[float]], ) -> None: """ Write a type 2 segment to a C-kernel. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckw02_c.html :param handle: Handle of an open CK file. :param begtim: The beginning encoded SCLK of the segment. :param endtim: The ending encoded SCLK of the segment. :param inst: The NAIF instrument ID code. :param ref: The reference frame of the segment. :param segid: Segment identifier. :param nrec: Number of pointing records. :param start: Encoded SCLK interval start times. :param stop: Encoded SCLK interval stop times. :param quats: Quaternions representing instrument pointing. :param avvs: Angular velocity vectors. :param rates: Number of seconds per tick for each interval. """ handle = ctypes.c_int(handle) begtim = ctypes.c_double(begtim) endtim = ctypes.c_double(endtim) inst = ctypes.c_int(inst) ref = stypes.string_to_char_p(ref) segid = stypes.string_to_char_p(segid) start = stypes.to_double_vector(start) stop = stypes.to_double_vector(stop) rates = stypes.to_double_vector(rates) quats = stypes.to_double_matrix(quats) avvs = stypes.to_double_matrix(avvs) nrec = ctypes.c_int(nrec) libspice.ckw02_c( handle, begtim, endtim, inst, ref, segid, nrec, start, stop, quats, avvs, rates )
[docs]@spice_error_check def ckw03( handle: int, begtim: float, endtim: float, inst: int, ref: str, avflag: bool, segid: str, nrec: int, sclkdp: ndarray, quats: ndarray, avvs: ndarray, nints: int, starts: Union[ndarray, Iterable[float]], ) -> None: """ Add a type 3 segment to a C-kernel. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckw03_c.html :param handle: Handle of an open CK file. :param begtim: The beginning encoded SCLK of the segment. :param endtim: The ending encoded SCLK of the segment. :param inst: The NAIF instrument ID code. :param ref: The reference frame of the segment. :param avflag: True if the segment will contain angular velocity. :param segid: Segment identifier. :param nrec: Number of pointing records. :param sclkdp: Encoded SCLK times. :param quats: Quaternions representing instrument pointing. :param avvs: Angular velocity vectors. :param nints: Number of intervals. :param starts: Encoded SCLK interval start times. """ handle = ctypes.c_int(handle) begtim = ctypes.c_double(begtim) endtim = ctypes.c_double(endtim) inst = ctypes.c_int(inst) ref = stypes.string_to_char_p(ref) avflag = ctypes.c_int(avflag) segid = stypes.string_to_char_p(segid) sclkdp = stypes.to_double_vector(sclkdp) quats = stypes.to_double_matrix(quats) avvs = stypes.to_double_matrix(avvs) nrec = ctypes.c_int(nrec) starts = stypes.to_double_vector(starts) nints = ctypes.c_int(nints) libspice.ckw03_c( handle, begtim, endtim, inst, ref, avflag, segid, nrec, sclkdp, quats, avvs, nints, starts, )
[docs]@spice_error_check def ckw05( handle: int, subtype: int, degree: int, begtim: float, endtim: float, inst: int, ref: str, avflag: bool, segid: str, sclkdp: ndarray, packts: Sequence[Iterable[float]], rate: float, nints: int, starts: ndarray, ) -> None: """ Write a type 5 segment to a CK file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckw05_c.html :param handle: Handle of an open CK file. :param subtype: CK type 5 subtype code. Can be: 0, 1, 2, 3 see naif docs via link above. :param degree: Degree of interpolating polynomials. :param begtim: The beginning encoded SCLK of the segment. :param endtim: The ending encoded SCLK of the segment. :param inst: The NAIF instrument ID code. :param ref: The reference frame of the segment. :param avflag: True if the segment will contain angular velocity. :param segid: Segment identifier. :param sclkdp: Encoded SCLK times. :param packts: Array of packets. :param rate: Nominal SCLK rate in seconds per tick. :param nints: Number of intervals. :param starts: Encoded SCLK interval start times. """ handle = ctypes.c_int(handle) subtype = ctypes.c_int(subtype) degree = ctypes.c_int(degree) begtim = ctypes.c_double(begtim) endtim = ctypes.c_double(endtim) inst = ctypes.c_int(inst) ref = stypes.string_to_char_p(ref) avflag = ctypes.c_int(avflag) segid = stypes.string_to_char_p(segid) n = ctypes.c_int(len(packts)) sclkdp = stypes.to_double_vector(sclkdp) packts = stypes.to_double_matrix(packts) rate = ctypes.c_double(rate) nints = ctypes.c_int(nints) starts = stypes.to_double_vector(starts) libspice.ckw05_c( handle, subtype, degree, begtim, endtim, inst, ref, avflag, segid, n, sclkdp, packts, rate, nints, starts, )
[docs]def cleard() -> NotImplementedError: raise NotImplementedError
[docs]@spice_error_check def clight() -> float: """ Return the speed of light in a vacuum (IAU official value, in km/sec). https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/clight_c.html :return: The function returns the speed of light in vacuum (km/sec). """ return libspice.clight_c()
[docs]@spice_error_check def clpool() -> None: """ Remove all variables from the kernel pool. Watches on kernel variables are retained. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/clpool_c.html """ libspice.clpool_c()
[docs]@spice_error_check def cltext(fname: str) -> None: """ Internal undocumented command for closing a text file opened by RDTEXT. No URL available; relevant lines from SPICE source: FORTRAN SPICE, rdtext.f:: C$Procedure CLTEXT ( Close a text file opened by RDTEXT) ENTRY CLTEXT ( FILE ) CHARACTER*(*) FILE C VARIABLE I/O DESCRIPTION C -------- --- -------------------------------------------------- C FILE I Text file to be closed. CSPICE, rdtext.c:: /* $Procedure CLTEXT ( Close a text file opened by RDTEXT) */ /* Subroutine */ int cltext_(char *file, ftnlen file_len) :param fname: Text file to be closed. """ fname_p = stypes.string_to_char_p(fname) fname_len = ctypes.c_int(len(fname)) libspice.cltext_(fname_p, fname_len)
[docs]@spice_error_check def cmprss(delim: str, n: int, instr: str, lenout: int = _default_len_out) -> str: """ Compress a character string by removing occurrences of more than N consecutive occurrences of a specified character. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cmprss_c.html :param delim: Delimiter to be compressed. :param n: Maximum consecutive occurrences of delim. :param instr: Input string. :param lenout: Optional available space in output string. :return: Compressed string. """ delim = ctypes.c_char(delim.encode(encoding="UTF-8")) n = ctypes.c_int(n) instr = stypes.string_to_char_p(instr) output = stypes.string_to_char_p(lenout) libspice.cmprss_c(delim, n, instr, lenout, output) return stypes.to_python_string(output)
[docs]@spice_error_check @spice_found_exception_thrower def cnmfrm(cname: str, lenout: int = _default_len_out) -> Tuple[int, str, bool]: """ Retrieve frame ID code and name to associate with an object. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cnmfrm_c.html :param cname: Name of the object to find a frame for. :param lenout: Maximum length available for frame name. :return: The ID code of the frame associated with cname, The name of the frame with ID frcode. """ lenout = ctypes.c_int(lenout) frname = stypes.string_to_char_p(lenout) cname = stypes.string_to_char_p(cname) found = ctypes.c_int() frcode = ctypes.c_int() libspice.cnmfrm_c(cname, lenout, ctypes.byref(frcode), frname, ctypes.byref(found)) return frcode.value, stypes.to_python_string(frname), bool(found.value)
[docs]@spice_error_check def conics(elts: ndarray, et: float) -> ndarray: """ Determine the state (position, velocity) of an orbiting body from a set of elliptic, hyperbolic, or parabolic orbital elements. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/conics_c.html :param elts: Conic elements. :param et: Input time. :return: State of orbiting body at et. """ elts = stypes.to_double_vector(elts) et = ctypes.c_double(et) state = stypes.empty_double_vector(6) libspice.conics_c(elts, et, state) return stypes.c_vector_to_python(state)
[docs]@spice_error_check def convrt( x: Union[float, Iterable[float]], inunit: str, outunit: str ) -> Union[ndarray, float]: """ Take a measurement X, the units associated with X, and units to which X should be converted; return Y the value of the measurement in the output units. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/convrt_c.html :param x: Number representing a measurement in some units. :param inunit: The units in which x is measured. :param outunit: Desired units for the measurement. :return: The measurment in the desired units. """ inunit = stypes.string_to_char_p(inunit) outunit = stypes.string_to_char_p(outunit) y = ctypes.c_double() if hasattr(x, "__iter__"): out_array = [] for n in x: libspice.convrt_c(n, inunit, outunit, ctypes.byref(y)) check_for_spice_error(None) out_array.append(y.value) return numpy.array(out_array) else: x = ctypes.c_double(x) libspice.convrt_c(x, inunit, outunit, ctypes.byref(y)) return y.value
[docs]@spice_error_check def copy(cell: SpiceCell) -> SpiceCell: """ Copy the contents of a SpiceCell of any data type to another cell of the same type. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/copy_c.html :param cell: Cell to be copied. :return: New cell """ assert isinstance(cell, stypes.SpiceCell) # Next line was redundant with [raise NotImpImplementedError] below # assert cell.dtype == 0 or cell.dtype == 1 or cell.dtype == 2 if cell.dtype == 0: newcopy = stypes.SPICECHAR_CELL(cell.size, cell.length) elif cell.dtype == 1: newcopy = stypes.SPICEDOUBLE_CELL(cell.size) elif cell.dtype == 2: newcopy = stypes.SPICEINT_CELL(cell.size) else: raise NotImplementedError libspice.copy_c(ctypes.byref(cell), ctypes.byref(newcopy)) return newcopy
[docs]@spice_error_check def cpos(string: str, chars: str, start: int) -> int: """ Find the first occurrence in a string of a character belonging to a collection of characters, starting at a specified location, searching forward. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cpos_c.html :param string: Any character string. :param chars: A collection of characters. :param start: Position to begin looking for one of chars. :return: The index of the first character of str at or following index start that is in the collection chars. """ string = stypes.string_to_char_p(string) chars = stypes.string_to_char_p(chars) start = ctypes.c_int(start) return libspice.cpos_c(string, chars, start)
[docs]@spice_error_check def cposr(string: str, chars: str, start: int) -> int: """ Find the first occurrence in a string of a character belonging to a collection of characters, starting at a specified location, searching in reverse. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cposr_c.html :param string: Any character string. :param chars: A collection of characters. :param start: Position to begin looking for one of chars. :return: The index of the last character of str at or before index start that is in the collection chars. """ string = stypes.string_to_char_p(string) chars = stypes.string_to_char_p(chars) start = ctypes.c_int(start) return libspice.cposr_c(string, chars, start)
[docs]@spice_error_check def cvpool(agent: str) -> bool: """ Indicate whether or not any watched kernel variables that have a specified agent on their notification list have been updated. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cvpool_c.html :param agent: Name of the agent to check for notices. :return: True if variables for "agent" have been updated. """ agent = stypes.string_to_char_p(agent) update = ctypes.c_int() libspice.cvpool_c(agent, ctypes.byref(update)) return bool(update.value)
[docs]@spice_error_check def cyllat(r: float, lonc: float, z: float) -> Tuple[float, float, float]: """ Convert from cylindrical to latitudinal coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cyllat_c.html :param r: Distance of point from z axis. :param lonc: Cylindrical angle of point from XZ plane(radians). :param z: Height of point above XY plane. :return: Distance, Longitude (radians), and Latitude of point (radians). """ r = ctypes.c_double(r) lonc = ctypes.c_double(lonc) z = ctypes.c_double(z) radius = ctypes.c_double() lon = ctypes.c_double() lat = ctypes.c_double() libspice.cyllat_c( r, lonc, z, ctypes.byref(radius), ctypes.byref(lon), ctypes.byref(lat) ) return radius.value, lon.value, lat.value
[docs]@spice_error_check def cylrec(r: float, lon: float, z: float) -> ndarray: """ Convert from cylindrical to rectangular coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cylrec_c.html :param r: Distance of a point from z axis. :param lon: Angle (radians) of a point from xZ plane. :param z: Height of a point above xY plane. :return: Rectangular coordinates of the point. """ r = ctypes.c_double(r) lon = ctypes.c_double(lon) z = ctypes.c_double(z) rectan = stypes.empty_double_vector(3) libspice.cylrec_c(r, lon, z, rectan) return stypes.c_vector_to_python(rectan)
[docs]@spice_error_check def cylsph(r: float, lonc: float, z: float) -> Tuple[float, float, float]: """ Convert from cylindrical to spherical coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cylsph_c.html :param r: Rectangular coordinates of the point. :param lonc: Angle (radians) of point from XZ plane. :param z: Height of point above XY plane. :return: Distance of point from origin, Polar angle (co-latitude in radians) of point, Azimuthal angle (longitude) of point (radians). """ r = ctypes.c_double(r) lonc = ctypes.c_double(lonc) z = ctypes.c_double(z) radius = ctypes.c_double() colat = ctypes.c_double() lon = ctypes.c_double() libspice.cyllat_c( r, lonc, z, ctypes.byref(radius), ctypes.byref(colat), ctypes.byref(lon) ) return radius.value, colat.value, lon.value
################################################################################ # D
[docs]@spice_error_check def dafac(handle: int, buffer: Sequence[str]) -> None: """ Add comments from a buffer of character strings to the comment area of a binary DAF file, appending them to any comments which are already present in the file's comment area. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafac_c.html :param handle: handle of a DAF opened with write access. :param buffer: Buffer of comments to put into the comment area. """ handle = ctypes.c_int(handle) lenvals = ctypes.c_int(len(max(buffer, key=len)) + 1) n = ctypes.c_int(len(buffer)) buffer = stypes.list_to_char_array_ptr(buffer) libspice.dafac_c(handle, n, lenvals, buffer)
[docs]@spice_error_check def dafbbs(handle: int) -> None: """ Begin a backward search for arrays in a DAF. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafbbs_c.html :param handle: Handle of DAF to be searched. """ handle = ctypes.c_int(handle) libspice.dafbbs_c(handle)
[docs]@spice_error_check def dafbfs(handle: int) -> None: """ Begin a forward search for arrays in a DAF. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafbfs_c.html :param handle: Handle of file to be searched. """ handle = ctypes.c_int(handle) libspice.dafbfs_c(handle)
[docs]@spice_error_check def dafcls(handle: int) -> None: """ Close the DAF associated with a given handle. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafcls_c.html :param handle: Handle of DAF to be closed. """ handle = ctypes.c_int(handle) libspice.dafcls_c(handle)
[docs]@spice_error_check def dafcs(handle: int) -> None: """ Select a DAF that already has a search in progress as the one to continue searching. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafcs_c.html :param handle: Handle of DAF to continue searching. """ handle = ctypes.c_int(handle) libspice.dafcs_c(handle)
[docs]@spice_error_check def dafdc(handle: int) -> None: """ Delete the entire comment area of a specified DAF file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafdc_c.html :param handle: The handle of a binary DAF opened for writing. """ handle = ctypes.c_int(handle) libspice.dafdc_c(handle)
[docs]@spice_error_check def dafec( handle: int, bufsiz: int, lenout: int = _default_len_out ) -> Tuple[int, Iterable[str], bool]: """ Extract comments from the comment area of a binary DAF. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafec_c.html :param handle: Handle of binary DAF opened with read access. :param bufsiz: Maximum size, in lines, of buffer. :param lenout: Length of strings in output buffer. :return: Number of extracted comment lines, buffer where extracted comment lines are placed, Indicates whether all comments have been extracted. """ handle = ctypes.c_int(handle) buffer = stypes.empty_char_array(y_len=bufsiz, x_len=lenout) bufsiz = ctypes.c_int(bufsiz) lenout = ctypes.c_int(lenout) n = ctypes.c_int() done = ctypes.c_int() libspice.dafec_c( handle, bufsiz, lenout, ctypes.byref(n), ctypes.byref(buffer), ctypes.byref(done), ) return n.value, stypes.c_vector_to_python(buffer), bool(done.value)
[docs]@spice_error_check def daffna() -> bool: """ Find the next (forward) array in the current DAF. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/daffna_c.html :return: True if an array was found. """ found = ctypes.c_int() libspice.daffna_c(ctypes.byref(found)) return bool(found.value)
[docs]@spice_error_check def daffpa() -> bool: """ Find the previous (backward) array in the current DAF. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/daffpa_c.html :return: True if an array was found. """ found = ctypes.c_int() libspice.daffpa_c(ctypes.byref(found)) return bool(found.value)
[docs]@spice_error_check def dafgda(handle: int, begin: int, end: int) -> ndarray: """ Read the double precision data bounded by two addresses within a DAF. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafgda_c.html :param handle: Handle of a DAF. :param begin: Initial address within file. :param end: Final address within file. :return: Data contained between begin and end. """ handle = ctypes.c_int(handle) data = stypes.empty_double_vector(abs(end - begin) + 1) begin = ctypes.c_int(begin) end = ctypes.c_int(end) libspice.dafgda_c(handle, begin, end, data) return stypes.c_vector_to_python(data)
[docs]@spice_error_check def dafgh() -> int: """ Return (get) the handle of the DAF currently being searched. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafgh_c.html :return: Handle for current DAF. """ outvalue = ctypes.c_int() libspice.dafgh_c(ctypes.byref(outvalue)) return outvalue.value
[docs]@spice_error_check def dafgn(lenout: int = _default_len_out) -> str: """ Return (get) the name for the current array in the current DAF. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafgn_c.html :param lenout: Length of array name string. :return: Name of current array. """ lenout = ctypes.c_int(lenout) name = stypes.string_to_char_p(lenout) libspice.dafgn_c(lenout, name) return stypes.to_python_string(name)
[docs]@spice_error_check def dafgs(n: int = 125) -> ndarray: # The 125 may be a hard set, # I got strange errors that occasionally happened without it """ Return (get) the summary for the current array in the current DAF. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafgs_c.html :param n: Optional length N for result Array. :return: Summary for current array. """ retarray = stypes.empty_double_vector(125) # libspice.dafgs_c(ctypes.cast(retarray, ctypes.POINTER(ctypes.c_double))) libspice.dafgs_c(retarray) return stypes.c_vector_to_python(retarray)[0:n]
[docs]@spice_error_check @spice_found_exception_thrower def dafgsr(handle: int, recno: int, begin: int, end: int) -> Tuple[ndarray, bool]: """ Read a portion of the contents of (words in) a summary record in a DAF file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafgsr_c.html :param handle: Handle of DAF. :param recno: Record number; word indices are 1-based, 1 to 128 inclusive. :param begin: Index of first word to read from record, will be clamped > 0. :param end: Index of last word to read, wll be clamped < 129 :return: Contents of request sub-record """ handle = ctypes.c_int(handle) recno = ctypes.c_int(recno) begin = ctypes.c_int(begin) end = ctypes.c_int(end) # dafgsr_c will retrieve no more than 128 words data = stypes.empty_double_vector(1 + min([128, end.value]) - max([begin.value, 1])) found = ctypes.c_int() libspice.dafgsr_c(handle, recno, begin, end, data, ctypes.byref(found)) return stypes.c_vector_to_python(data), bool(found.value)
[docs]@spice_error_check def dafopr(fname: str) -> int: """ Open a DAF for subsequent read requests. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafopr_c.html :param fname: Name of DAF to be opened. :return: Handle assigned to DAF. """ fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.dafopr_c(fname, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def dafopw(fname: str) -> int: """ Open a DAF for subsequent write requests. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafopw_c.html :param fname: Name of DAF to be opened. :return: Handle assigned to DAF. """ fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.dafopw_c(fname, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def dafps(nd: int, ni: int, dc: ndarray, ic: ndarray) -> ndarray: """ Pack (assemble) an array summary from its double precision and integer components. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafps_c.html :param nd: Number of double precision components. :param ni: Number of integer components. :param dc: Double precision components. :param ic: Integer components. :return: Array summary. """ dc = stypes.to_double_vector(dc) ic = stypes.to_int_vector(ic) outsum = stypes.empty_double_vector(nd + ni) nd = ctypes.c_int(nd) ni = ctypes.c_int(ni) libspice.dafps_c(nd, ni, dc, ic, outsum) return stypes.c_vector_to_python(outsum)
[docs]@spice_error_check def dafrda(handle: int, begin: int, end: int) -> ndarray: """ Read the double precision data bounded by two addresses within a DAF. Deprecated: This routine has been superseded by :func:`dafgda` and :func:`dafgsr`. This routine is supported for purposes of backward compatibility only. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafrda_c.html :param handle: Handle of a DAF. :param begin: Initial address within file. :param end: Final address within file. :return: Data contained between begin and end. """ handle = ctypes.c_int(handle) begin = ctypes.c_int(begin) end = ctypes.c_int(end) data = stypes.empty_double_vector(1 + end.value - begin.value) libspice.dafrda_c(handle, begin, end, data) return stypes.c_vector_to_python(data)
[docs]@spice_error_check def dafrfr( handle: int, lenout: int = _default_len_out ) -> Tuple[int, int, str, int, int, int]: """ Read the contents of the file record of a DAF. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafrfr_c.html :param handle: Handle of an open DAF file. :param lenout: Available room in the output string :return: Number of double precision components in summaries, Number of integer components in summaries, Internal file name, Forward list pointer, Backward list pointer, Free address pointer. """ handle = ctypes.c_int(handle) lenout = ctypes.c_int(lenout) nd = ctypes.c_int() ni = ctypes.c_int() ifname = stypes.string_to_char_p(lenout) fward = ctypes.c_int() bward = ctypes.c_int() free = ctypes.c_int() libspice.dafrfr_c( handle, lenout, ctypes.byref(nd), ctypes.byref(ni), ifname, ctypes.byref(fward), ctypes.byref(bward), ctypes.byref(free), ) return ( nd.value, ni.value, stypes.to_python_string(ifname), fward.value, bward.value, free.value, )
[docs]@spice_error_check def dafrs(insum: ndarray) -> None: """ Change the summary for the current array in the current DAF. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafrs_c.html :param insum: New summary for current array. """ insum = stypes.to_double_vector(insum) libspice.dafrs_c(ctypes.byref(insum))
[docs]@spice_error_check def dafus(insum: ndarray, nd: int, ni: int) -> Tuple[ndarray, ndarray]: """ Unpack an array summary into its double precision and integer components. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafus_c.html :param insum: Array summary. :param nd: Number of double precision components. :param ni: Number of integer components. :return: Double precision components, Integer components. """ insum = stypes.to_double_vector(insum) dc = stypes.empty_double_vector(nd) ic = stypes.empty_int_vector(ni) nd = ctypes.c_int(nd) ni = ctypes.c_int(ni) libspice.dafus_c(insum, nd, ni, dc, ic) return stypes.c_vector_to_python(dc), stypes.c_vector_to_python(ic)
[docs]@spice_error_check def dasac(handle: int, buffer: Sequence[str]) -> None: """ Add comments from a buffer of character strings to the comment area of a binary DAS file, appending them to any comments which are already present in the file's comment area. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dasac_c.html :param handle: DAS handle of a file opened with write access. :param buffer: Buffer of lines to be put into the comment area. """ handle = ctypes.c_int(handle) n = ctypes.c_int(len(buffer)) buflen = ctypes.c_int(max(len(s) for s in buffer) + 1) buffer = stypes.list_to_char_array_ptr(buffer) libspice.dasac_c(handle, n, buflen, buffer)
[docs]@spice_error_check def dascls(handle: int) -> None: """ Close a DAS file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dascls_c.html :param handle: Handle of an open DAS file. """ handle = ctypes.c_int(handle) libspice.dascls_c(handle)
[docs]@spice_error_check def dasdc(handle: int) -> None: """ Delete the entire comment area of a previously opened binary DAS file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dasdc_c.html :param handle: The handle of a binary DAS file opened for writing. """ handle = ctypes.c_int(handle) libspice.dasdc_c(handle)
[docs]@spice_error_check def dasec( handle: int, bufsiz: int = _default_len_out, buflen: int = _default_len_out ) -> Tuple[int, Iterable[str], int]: """ Extract comments from the comment area of a binary DAS file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dasec_c.html :param handle: Handle of binary DAS file open with read access. :param bufsiz: Maximum size, in lines, of buffer. :param buflen: Line length associated with buffer. :return: Number of comments extracted from the DAS file, Buffer in which extracted comments are placed, Indicates whether all comments have been extracted. """ handle = ctypes.c_int(handle) buffer = stypes.empty_char_array(buflen, bufsiz) bufsiz = ctypes.c_int(bufsiz) buflen = ctypes.c_int(buflen) n = ctypes.c_int(0) done = ctypes.c_int() libspice.dasec_c( handle, bufsiz, buflen, ctypes.byref(n), ctypes.byref(buffer), ctypes.byref(done), ) return n.value, stypes.c_vector_to_python(buffer), done.value
[docs]@spice_error_check def dashfn(handle: int, lenout: int = _default_len_out) -> str: """ Return the name of the DAS file associated with a handle. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dashfn_c.html :param handle: Handle of a DAS file. :param lenout: Length of output file name string. :return: Corresponding file name. """ handle = ctypes.c_int(handle) namlen = ctypes.c_int(lenout) fname = stypes.string_to_char_p(lenout) libspice.dashfn_c(handle, namlen, fname) return stypes.to_python_string(fname)
[docs]@spice_error_check def dasonw(fname: str, ftype: str, ifname: str, ncomch: int) -> int: """ Internal undocumented command for creating a new DAS file :param fname: filename :param ftype: type :param ifname: internal file name :param ncomch: amount of comment area :return: Handle to new DAS file """ fnamelen = ctypes.c_int(len(fname)) ftypelen = ctypes.c_int(len(ftype)) ifnamelen = ctypes.c_int(len(ifname)) ncomch = ctypes.c_int(ncomch) handle = ctypes.c_int() fname = stypes.string_to_char_p(fname) ftype = stypes.string_to_char_p(ftype) ifname = stypes.string_to_char_p(ifname) libspice.dasonw_( fname, ftype, ifname, ctypes.byref(ncomch), ctypes.byref(handle), fnamelen, ftypelen, ifnamelen, ) return handle.value
[docs]@spice_error_check def dasopr(fname: str) -> int: """ Open a DAS file for reading. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dasopr_c.html :param fname: Name of a DAS file to be opened. :return: Handle assigned to the opened DAS file. """ fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.dasopr_c(fname, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def dasopw(fname: str) -> int: """ Open a DAS file for writing. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dasopw_c.html :param fname: Name of a DAS file to be opened. :return: Handle assigned to the opened DAS file. """ fname = stypes.string_to_char_p(fname) handle = ctypes.c_int(0) libspice.dasopw_c(fname, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def dasrfr( handle: int, lenout: int = _default_len_out ) -> Tuple[str, str, int, int, int, int]: """ Return the contents of the file record of a specified DAS file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dasrfr_c.html :param handle: DAS file handle. :param lenout: length of output strs :return: ID word, DAS internal file name, Number of reserved records in file, \ Number of characters in use in reserved rec. area, Number of comment records in file, \ Number of characters in use in comment area. """ handle = ctypes.c_int(handle) idwlen = ctypes.c_int(lenout) # intentional ifnlen = ctypes.c_int(lenout) # intentional idword = stypes.string_to_char_p(lenout) ifname = stypes.string_to_char_p(lenout) nresvr = ctypes.c_int(0) nresvc = ctypes.c_int(0) ncomr = ctypes.c_int(0) ncomc = ctypes.c_int(0) libspice.dasrfr_c( handle, idwlen, ifnlen, idword, ifname, ctypes.byref(nresvr), ctypes.byref(nresvc), ctypes.byref(ncomr), ctypes.byref(ncomc), ) return ( stypes.to_python_string(idword), stypes.to_python_string(ifname), nresvr.value, nresvc.value, ncomr.value, ncomc.value, )
[docs]@spice_error_check def dcyldr(x: float, y: float, z: float) -> ndarray: """ This routine computes the Jacobian of the transformation from rectangular to cylindrical coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dcyldr_c.html :param x: X-coordinate of point. :param y: Y-coordinate of point. :param z: Z-coordinate of point. :return: Matrix of partial derivatives. """ x = ctypes.c_double(x) y = ctypes.c_double(y) z = ctypes.c_double(z) jacobi = stypes.empty_double_matrix() libspice.dcyldr_c(x, y, z, jacobi) return stypes.c_matrix_to_numpy(jacobi)
[docs]@spice_error_check def deltet(epoch: float, eptype: str) -> float: """ Return the value of Delta ET (ET-UTC) for an input epoch. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/deltet_c.html :param epoch: Input epoch (seconds past J2000). :param eptype: Type of input epoch ("UTC" or "ET"). :return: Delta ET (ET-UTC) at input epoch. """ epoch = ctypes.c_double(epoch) eptype = stypes.string_to_char_p(eptype) delta = ctypes.c_double() libspice.deltet_c(epoch, eptype, ctypes.byref(delta)) return delta.value
[docs]@spice_error_check def det(m1: ndarray) -> float: """ Compute the determinant of a double precision 3x3 matrix. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/det_c.html :param m1: Matrix whose determinant is to be found. :return: The determinant of the matrix. """ m1 = stypes.to_double_matrix(m1) return libspice.det_c(m1)
[docs]@spice_error_check def dgeodr(x: float, y: float, z: float, re: float, f: float) -> ndarray: """ This routine computes the Jacobian of the transformation from rectangular to geodetic coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dgeodr_c.html :param x: X-coordinate of point. :param y: Y-coordinate of point. :param z: Z-coord :param re: Equatorial radius of the reference spheroid. :param f: Flattening coefficient. :return: Matrix of partial derivatives. """ x = ctypes.c_double(x) y = ctypes.c_double(y) z = ctypes.c_double(z) re = ctypes.c_double(re) f = ctypes.c_double(f) jacobi = stypes.empty_double_matrix() libspice.dgeodr_c(x, y, z, re, f, jacobi) return stypes.c_matrix_to_numpy(jacobi)
[docs]@spice_error_check def diags2( symmat: Union[ndarray, Iterable[Iterable[float]]] ) -> Tuple[ndarray, ndarray]: """ Diagonalize a symmetric 2x2 matrix. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/diags2_c.html :param symmat: A symmetric 2x2 matrix. :return: A diagonal matrix similar to symmat, A rotation used as the similarity transformation. """ symmat = stypes.to_double_matrix(symmat) diag = stypes.empty_double_matrix(x=2, y=2) rotateout = stypes.empty_double_matrix(x=2, y=2) libspice.diags2_c(symmat, diag, rotateout) return stypes.c_matrix_to_numpy(diag), stypes.c_matrix_to_numpy(rotateout)
[docs]@spice_error_check def diff(a: SpiceCell, b: SpiceCell) -> SpiceCell: """ Take the difference of two sets of any data type to form a third set. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/diff_c.html :param a: First input set. :param b: Second input set. :return: Difference of a and b. """ assert isinstance(a, stypes.SpiceCell) assert isinstance(b, stypes.SpiceCell) assert a.dtype == b.dtype # The next line was redundant with the [raise NotImplementedError] line below # assert a.dtype == 0 or a.dtype == 1 or a.dtype == 2 if a.dtype == 0: c = stypes.SPICECHAR_CELL(max(a.size, b.size), max(a.length, b.length)) elif a.dtype == 1: c = stypes.SPICEDOUBLE_CELL(max(a.size, b.size)) elif a.dtype == 2: c = stypes.SPICEINT_CELL(max(a.size, b.size)) else: raise NotImplementedError libspice.diff_c(ctypes.byref(a), ctypes.byref(b), ctypes.byref(c)) return c
[docs]@spice_error_check @spice_found_exception_thrower def dlabbs(handle: int) -> Tuple[SpiceDLADescr, bool]: """ Begin a backward segment search in a DLA file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dlabbs_c.html :param handle: Handle of open DLA file. :return: Descriptor of last segment in DLA file """ handle = ctypes.c_int(handle) descr = stypes.SpiceDLADescr() found = ctypes.c_int() libspice.dlabbs_c(handle, ctypes.byref(descr), ctypes.byref(found)) return descr, bool(found.value)
[docs]@spice_error_check @spice_found_exception_thrower def dlabfs(handle: int) -> Tuple[SpiceDLADescr, bool]: """ Begin a forward segment search in a DLA file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dlabfs_c.html :param handle: Handle of open DLA file. :return: Descriptor of next segment in DLA file """ handle = ctypes.c_int(handle) descr = stypes.SpiceDLADescr() found = ctypes.c_int() libspice.dlabfs_c(handle, ctypes.byref(descr), ctypes.byref(found)) return descr, bool(found.value)
[docs]@spice_error_check @spice_found_exception_thrower def dlafns(handle: int, descr: SpiceDLADescr) -> Tuple[SpiceDLADescr, bool]: """ Find the segment following a specified segment in a DLA file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dlafns_c.html :param handle: Handle of open DLA file. :param descr: Descriptor of a DLA segment. :return: Descriptor of next segment in DLA file """ assert isinstance(descr, stypes.SpiceDLADescr) handle = ctypes.c_int(handle) nxtdsc = stypes.SpiceDLADescr() found = ctypes.c_int() libspice.dlafns_c( handle, ctypes.byref(descr), ctypes.byref(nxtdsc), ctypes.byref(found) ) return nxtdsc, bool(found.value)
[docs]@spice_error_check @spice_found_exception_thrower def dlafps(handle: int, descr: SpiceDLADescr) -> Tuple[SpiceDLADescr, bool]: """ Find the segment preceding a specified segment in a DLA file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dlafps_c.html :param handle: Handle of open DLA file. :param descr: Descriptor of a segment in DLA file. :return: Descriptor of previous segment in DLA file """ assert isinstance(descr, stypes.SpiceDLADescr) handle = ctypes.c_int(handle) prvdsc = stypes.SpiceDLADescr() found = ctypes.c_int() libspice.dlafps_c( handle, ctypes.byref(descr), ctypes.byref(prvdsc), ctypes.byref(found) ) return prvdsc, bool(found.value)
[docs]@spice_error_check def dlatdr(x: float, y: float, z: float) -> ndarray: """ This routine computes the Jacobian of the transformation from rectangular to latitudinal coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dlatdr_c.html :param x: X-coordinate of point. :param y: Y-coordinate of point. :param z: Z-coord :return: Matrix of partial derivatives. """ x = ctypes.c_double(x) y = ctypes.c_double(y) z = ctypes.c_double(z) jacobi = stypes.empty_double_matrix() libspice.dlatdr_c(x, y, z, jacobi) return stypes.c_matrix_to_numpy(jacobi)
[docs]@spice_error_check def dp2hx(number: float, lenout: int = _default_len_out) -> str: """ Convert a double precision number to an equivalent character string using base 16 "scientific notation." https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dp2hx_c.html :param number: D.p. number to be converted. :param lenout: Available space for output string. :return: Equivalent character string, left justified. """ number = ctypes.c_double(number) lenout = ctypes.c_int(lenout) string = stypes.string_to_char_p(lenout) length = ctypes.c_int() libspice.dp2hx_c(number, lenout, string, ctypes.byref(length)) return stypes.to_python_string(string)
[docs]@spice_error_check def dpgrdr(body: str, x: float, y: float, z: int, re: float, f: float) -> ndarray: """ This routine computes the Jacobian matrix of the transformation from rectangular to planetographic coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dpgrdr_c.html :param body: Body with which coordinate system is associated. :param x: X-coordinate of point. :param y: Y-coordinate of point. :param z: Z-coordinate of point. :param re: Equatorial radius of the reference spheroid. :param f: Flattening coefficient. :return: Matrix of partial derivatives. """ body = stypes.string_to_char_p(body) x = ctypes.c_double(x) y = ctypes.c_double(y) z = ctypes.c_double(z) re = ctypes.c_double(re) f = ctypes.c_double(f) jacobi = stypes.empty_double_matrix() libspice.dpgrdr_c(body, x, y, z, re, f, jacobi) return stypes.c_matrix_to_numpy(jacobi)
[docs]@spice_error_check def dpmax() -> float: """ Return the value of the largest (positive) number representable in a double precision variable. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dpmax_c.html :return: The largest (positive) number representable in a double precision variable. """ return libspice.dpmax_c()
[docs]@spice_error_check def dpmin() -> float: """ Return the value of the smallest (negative) number representable in a double precision variable. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dpmin_c.html :return: The smallest (negative) number that can be represented in a double precision variable. """ return libspice.dpmin_c()
[docs]@spice_error_check def dpr() -> float: """ Return the number of degrees per radian. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dpr_c.html :return: The number of degrees per radian. """ return libspice.dpr_c()
[docs]@spice_error_check def drdcyl(r: float, lon: float, z: float) -> ndarray: """ This routine computes the Jacobian of the transformation from cylindrical to rectangular coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/drdcyl_c.html :param r: Distance of a point from the origin. :param lon: Angle of the point from the xz plane in radians. :param z: Height of the point above the xy plane. :return: Matrix of partial derivatives. """ r = ctypes.c_double(r) lon = ctypes.c_double(lon) z = ctypes.c_double(z) jacobi = stypes.empty_double_matrix() libspice.drdcyl_c(r, lon, z, jacobi) return stypes.c_matrix_to_numpy(jacobi)
[docs]@spice_error_check def drdgeo(lon: float, lat: float, alt: float, re: float, f: float) -> ndarray: """ This routine computes the Jacobian of the transformation from geodetic to rectangular coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/drdgeo_c.html :param lon: Geodetic longitude of point (radians). :param lat: Geodetic latitude of point (radians). :param alt: Altitude of point above the reference spheroid. :param re: Equatorial radius of the reference spheroid. :param f: Flattening coefficient. :return: Matrix of partial derivatives. """ lon = ctypes.c_double(lon) lat = ctypes.c_double(lat) alt = ctypes.c_double(alt) re = ctypes.c_double(re) f = ctypes.c_double(f) jacobi = stypes.empty_double_matrix() libspice.drdgeo_c(lon, lat, alt, re, f, jacobi) return stypes.c_matrix_to_numpy(jacobi)
[docs]@spice_error_check def drdlat(r: float, lon: float, lat: float) -> ndarray: """ Compute the Jacobian of the transformation from latitudinal to rectangular coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/drdlat_c.html :param r: Distance of a point from the origin. :param lon: Angle of the point from the XZ plane in radians. :param lat: Angle of the point from the XY plane in radians. :return: Matrix of partial derivatives. """ r = ctypes.c_double(r) lon = ctypes.c_double(lon) lat = ctypes.c_double(lat) jacobi = stypes.empty_double_matrix() libspice.drdlat_c(r, lon, lat, jacobi) return stypes.c_matrix_to_numpy(jacobi)
[docs]@spice_error_check def drdpgr(body: str, lon: float, lat: float, alt: int, re: float, f: float) -> ndarray: """ This routine computes the Jacobian matrix of the transformation from planetographic to rectangular coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/drdpgr_c.html :param body: Body with which coordinate system is associated. :param lon: Planetographic longitude of a point (radians). :param lat: Planetographic latitude of a point (radians). :param alt: Altitude of a point above reference spheroid. :param re: Equatorial radius of the reference spheroid. :param f: Flattening coefficient. :return: Matrix of partial derivatives. """ body = stypes.string_to_char_p(body) lon = ctypes.c_double(lon) lat = ctypes.c_double(lat) alt = ctypes.c_double(alt) re = ctypes.c_double(re) f = ctypes.c_double(f) jacobi = stypes.empty_double_matrix() libspice.drdpgr_c(body, lon, lat, alt, re, f, jacobi) return stypes.c_matrix_to_numpy(jacobi)
[docs]@spice_error_check def drdsph(r: float, colat: float, lon: float) -> ndarray: """ This routine computes the Jacobian of the transformation from spherical to rectangular coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/drdsph_c.html :param r: Distance of a point from the origin. :param colat: Angle of the point from the positive z-axis. :param lon: Angle of the point from the xy plane. :return: Matrix of partial derivatives. """ r = ctypes.c_double(r) colat = ctypes.c_double(colat) lon = ctypes.c_double(lon) jacobi = stypes.empty_double_matrix() libspice.drdsph_c(r, colat, lon, jacobi) return stypes.c_matrix_to_numpy(jacobi)
[docs]@spice_error_check def dskb02( handle: int, dladsc: SpiceDLADescr ) -> Tuple[int, int, int, ndarray, float, ndarray, ndarray, int, int, int, int]: """ Return bookkeeping data from a DSK type 2 segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskb02_c.html :param handle: DSK file handle :param dladsc: DLA descriptor :return: bookkeeping data from a DSK type 2 segment """ handle = ctypes.c_int(handle) nv = ctypes.c_int(0) np = ctypes.c_int(0) nvxtot = ctypes.c_int(0) vtxbds = stypes.empty_double_matrix(3, 2) voxsiz = ctypes.c_double(0.0) voxori = stypes.empty_double_vector(3) vgrext = stypes.empty_int_vector(3) cgscal = ctypes.c_int(0) vtxnpl = ctypes.c_int(0) voxnpt = ctypes.c_int(0) voxnpl = ctypes.c_int(0) libspice.dskb02_c( handle, dladsc, ctypes.byref(nv), ctypes.byref(np), ctypes.byref(nvxtot), vtxbds, ctypes.byref(voxsiz), voxori, vgrext, ctypes.byref(cgscal), ctypes.byref(vtxnpl), ctypes.byref(voxnpt), ctypes.byref(voxnpl), ) return ( nv.value, np.value, nvxtot.value, stypes.c_matrix_to_numpy(vtxbds), voxsiz.value, stypes.c_vector_to_python(voxori), stypes.c_vector_to_python(vgrext), cgscal.value, vtxnpl.value, voxnpt.value, voxnpl.value, )
[docs]@spice_error_check def dskcls(handle: int, optmiz: bool = False) -> None: """ Close a DSK file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskcls_c.html :param handle: Handle assigned to the opened DSK file. :param optmiz: Flag indicating whether to segregate the DSK. :return: """ handle = ctypes.c_int(handle) optmiz = ctypes.c_int(optmiz) libspice.dskcls_c(handle, optmiz)
[docs]@spice_error_check def dskd02( handle: int, dladsc: SpiceDLADescr, item: int, start: int, room: int ) -> ndarray: """ Fetch double precision data from a type 2 DSK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskd02_c.html :param handle: DSK file handle :param dladsc: DLA descriptor :param item: Keyword identifying item to fetch :param start: Start index :param room: Amount of room in output array :return: Array containing requested item """ handle = ctypes.c_int(handle) item = ctypes.c_int(item) start = ctypes.c_int(start) room = ctypes.c_int(room) n = ctypes.c_int(0) values = stypes.empty_double_vector(room) libspice.dskd02_c(handle, dladsc, item, start, room, ctypes.byref(n), values) return stypes.c_vector_to_python(values)
[docs]@spice_error_check def dskgd(handle: int, dladsc: SpiceDLADescr) -> SpiceDSKDescr: """ Return the DSK descriptor from a DSK segment identified by a DAS handle and DLA descriptor. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskgd_c.html :param handle: Handle assigned to the opened DSK file. :param dladsc: DLA segment descriptor. :return: DSK segment descriptor. """ handle = ctypes.c_int(handle) dskdsc = stypes.SpiceDSKDescr() libspice.dskgd_c(handle, ctypes.byref(dladsc), ctypes.byref(dskdsc)) return dskdsc
[docs]@spice_error_check def dskgtl(keywrd: int) -> float: """ Retrieve the value of a specified DSK tolerance or margin parameter. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskgtl_c.html :param keywrd: Code specifying parameter to retrieve. :return: Value of parameter. """ keywrd = ctypes.c_int(keywrd) dpval = ctypes.c_double(0) libspice.dskgtl_c(keywrd, ctypes.byref(dpval)) return dpval.value
[docs]@spice_error_check def dski02( handle: int, dladsc: SpiceDLADescr, item: int, start: int, room: int ) -> ndarray: """ Fetch integer data from a type 2 DSK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dski02_c.html :param handle: DSK file handle. :param dladsc: DLA descriptor. :param item: Keyword identifying item to fetch. :param start: Start index. :param room: Amount of room in output array. :return: Array containing requested item. """ handle = ctypes.c_int(handle) item = ctypes.c_int(item) start = ctypes.c_int(start) room = ctypes.c_int(room) n = ctypes.c_int() values = stypes.empty_int_vector(room) libspice.dski02_c(handle, dladsc, item, start, room, ctypes.byref(n), values) return stypes.c_matrix_to_numpy(values)
[docs]@spice_error_check def dskmi2( vrtces: ndarray, plates: ndarray, finscl: float, corscl: int, worksz: int, voxpsz: int, voxlsz: int, makvtl: bool, spxisz: int, ) -> Tuple[ndarray, ndarray]: """ Make spatial index for a DSK type 2 segment. The index is returned as a pair of arrays, one of type int and one of type float. These arrays are suitable for use with the DSK type 2 writer dskw02. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskmi2_c.html :param vrtces: Vertices :param plates: Plates :param finscl: Fine voxel scale :param corscl: Coarse voxel scale :param worksz: Workspace size :param voxpsz: Voxel plate pointer array size :param voxlsz: Voxel plate list array size :param makvtl: Vertex plate list flag :param spxisz: Spatial index integer component size :return: double precision and integer components of the spatial index of the segment. """ nv = ctypes.c_int(len(vrtces)) vrtces = stypes.to_double_matrix(vrtces) np = ctypes.c_int(len(plates)) plates = stypes.to_int_matrix(plates) finscl = ctypes.c_double(finscl) corscl = ctypes.c_int(corscl) worksz = ctypes.c_int(worksz) voxpsz = ctypes.c_int(voxpsz) voxlsz = ctypes.c_int(voxlsz) makvtl = ctypes.c_int(makvtl) spxisz = ctypes.c_int(spxisz) work = stypes.empty_int_matrix(2, worksz) spaixd = stypes.empty_double_vector(10) # SPICE_DSK02_SPADSZ spaixi = stypes.empty_int_vector(spxisz) libspice.dskmi2_c( nv, vrtces, np, plates, finscl, corscl, worksz, voxpsz, voxlsz, makvtl, spxisz, work, spaixd, spaixi, ) return stypes.c_vector_to_python(spaixd), stypes.c_vector_to_python(spaixi)
[docs]@spice_error_check def dskn02(handle: int, dladsc: SpiceDLADescr, plid: int) -> ndarray: """ Compute the unit normal vector for a specified plate from a type 2 DSK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskn02_c.html :param handle: DSK file handle. :param dladsc: DLA descriptor. :param plid: Plate ID. :return: late's unit normal vector. """ handle = ctypes.c_int(handle) plid = ctypes.c_int(plid) normal = stypes.empty_double_vector(3) libspice.dskn02_c(handle, dladsc, plid, normal) return stypes.c_vector_to_python(normal)
[docs]@spice_error_check def dskobj(dsk: str) -> SpiceCell: """ Find the set of body ID codes of all objects for which topographic data are provided in a specified DSK file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskobj_c.html :param dsk: Name of DSK file. :return: Set of ID codes of objects in DSK file. """ dsk = stypes.string_to_char_p(dsk) bodids = stypes.SPICEINT_CELL(10000) libspice.dskobj_c(dsk, ctypes.byref(bodids)) return bodids
[docs]@spice_error_check def dskopn(fname: str, ifname: str, ncomch: int) -> int: """ Open a new DSK file for subsequent write operations. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskopn_c.html :param fname: Name of a DSK file to be opened. :param ifname: Internal file name. :param ncomch: Number of comment characters to allocate. :return: Handle assigned to the opened DSK file. """ fname = stypes.string_to_char_p(fname) ifname = stypes.string_to_char_p(ifname) ncomch = ctypes.c_int(ncomch) handle = ctypes.c_int() libspice.dskopn_c(fname, ifname, ncomch, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def dskp02(handle: int, dladsc: SpiceDLADescr, start: int, room: int) -> ndarray: """ Fetch triangular plates from a type 2 DSK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskp02_c.html :param handle: DSK file handle. :param dladsc: DLA descriptor. :param start: Start index. :param room: Amount of room in output array. :return: Array containing plates. """ handle = ctypes.c_int(handle) start = ctypes.c_int(start) room = ctypes.c_int(room) n = ctypes.c_int(0) plates = stypes.empty_int_matrix(3, room) libspice.dskp02_c(handle, dladsc, start, room, ctypes.byref(n), plates) return stypes.c_matrix_to_numpy(plates)
[docs]@spice_error_check def dskrb2( vrtces: ndarray, plates: ndarray, corsys: int, corpar: ndarray ) -> Tuple[float, float]: """ Determine range bounds for a set of triangular plates to be stored in a type 2 DSK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskrb2_c.html :param vrtces: Vertices :param plates: Plates :param corsys: DSK coordinate system code :param corpar: DSK coordinate system parameters :return: Lower and Upper bound on range of third coordinate """ nv = ctypes.c_int(len(vrtces)) vrtces = stypes.to_double_matrix(vrtces) np = ctypes.c_int(len(plates)) plates = stypes.to_int_matrix(plates) corsys = ctypes.c_int(corsys) corpar = stypes.to_double_vector(corpar) mncor3 = ctypes.c_double(0.0) mxcor3 = ctypes.c_double(0.0) libspice.dskrb2_c( nv, vrtces, np, plates, corsys, corpar, ctypes.byref(mncor3), ctypes.byref(mxcor3), ) return mncor3.value, mxcor3.value
[docs]@spice_error_check def dsksrf(dsk: str, bodyid: int) -> SpiceCell: """ Find the set of surface ID codes for all surfaces associated with a given body in a specified DSK file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dsksrf_c.html :param dsk: Name of DSK file. :param bodyid: Integer body ID code. :return: Set of ID codes of surfaces in DSK file. """ dsk = stypes.string_to_char_p(dsk) bodyid = ctypes.c_int(bodyid) srfids = stypes.SPICEINT_CELL(10000) libspice.dsksrf_c(dsk, bodyid, ctypes.byref(srfids)) return srfids
[docs]@spice_error_check def dskstl(keywrd: int, dpval: float) -> None: """ Set the value of a specified DSK tolerance or margin parameter. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskstl_c.html :param keywrd: Code specifying parameter to set. :param dpval: Value of parameter. :return: """ keywrd = ctypes.c_int(keywrd) dpval = ctypes.c_double(dpval) libspice.dskstl_c(keywrd, dpval)
[docs]@spice_error_check def dskv02(handle: int, dladsc: SpiceDLADescr, start: int, room: int) -> ndarray: """ Fetch vertices from a type 2 DSK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskv02_c.html :param handle: DSK file handle. :param dladsc: DLA descriptor. :param start: Start index. :param room: Amount of room in output array. :return: Array containing vertices. """ handle = ctypes.c_int(handle) start = ctypes.c_int(start) room = ctypes.c_int(room) n = ctypes.c_int() vrtces = stypes.empty_double_matrix(3, room) libspice.dskv02_c(handle, dladsc, start, room, ctypes.byref(n), vrtces) return stypes.c_matrix_to_numpy(vrtces)
[docs]@spice_error_check def dskw02( handle: int, center: int, surfid: int, dclass: int, fname: str, corsys: int, corpar: ndarray, mncor1: float, mxcor1: float, mncor2: float, mxcor2: float, mncor3: float, mxcor3: float, first: float, last: float, vrtces: ndarray, plates: ndarray, spaixd: ndarray, spaixi: ndarray, ) -> None: """ Write a type 2 segment to a DSK file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskw02_c.html :param handle: Handle assigned to the opened DSK file :param center: Central body ID code :param surfid: Surface ID code :param dclass: Data class :param fname: Reference frame :param corsys: Coordinate system code :param corpar: Coordinate system parameters :param mncor1: Minimum value of first coordinate :param mxcor1: Maximum value of first coordinate :param mncor2: Minimum value of second coordinate :param mxcor2: Maximum value of second coordinate :param mncor3: Minimum value of third coordinate :param mxcor3: Maximum value of third coordinate :param first: Coverage start time :param last: Coverage stop time :param vrtces: Vertices :param plates: Plates :param spaixd: Double precision component of spatial index :param spaixi: Integer component of spatial index """ handle = ctypes.c_int(handle) center = ctypes.c_int(center) surfid = ctypes.c_int(surfid) dclass = ctypes.c_int(dclass) fname = stypes.string_to_char_p(fname) corsys = ctypes.c_int(corsys) corpar = stypes.to_double_vector(corpar) mncor1 = ctypes.c_double(mncor1) mxcor1 = ctypes.c_double(mxcor1) mncor2 = ctypes.c_double(mncor2) mxcor2 = ctypes.c_double(mxcor2) mncor3 = ctypes.c_double(mncor3) mxcor3 = ctypes.c_double(mxcor3) first = ctypes.c_double(first) last = ctypes.c_double(last) nv = ctypes.c_int(len(vrtces)) vrtces = stypes.to_double_matrix(vrtces) np = ctypes.c_int(len(plates)) plates = stypes.to_int_matrix(plates) spaixd = stypes.to_double_vector(spaixd) spaixi = stypes.to_int_vector(spaixi) libspice.dskw02_c( handle, center, surfid, dclass, fname, corsys, corpar, mncor1, mxcor1, mncor2, mxcor2, mncor3, mxcor3, first, last, nv, vrtces, np, plates, spaixd, spaixi, )
[docs]@spice_error_check def dskx02( handle: int, dladsc: SpiceDLADescr, vertex: ndarray, raydir: ndarray ) -> Tuple[int, ndarray, bool]: """ Determine the plate ID and body-fixed coordinates of the intersection of a specified ray with the surface defined by a type 2 DSK plate model. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskx02_c.html :param handle: Handle of DSK kernel containing plate model. :param dladsc: DLA descriptor of plate model segment. :param vertex: Ray's vertex in the body fixed frame. :param raydir: Ray direction in the body fixed frame. :return: ID code of the plate intersected by the ray, Intercept, and Flag indicating whether intercept exists. """ handle = ctypes.c_int(handle) vertex = stypes.to_double_vector(vertex) raydir = stypes.to_double_vector(raydir) plid = ctypes.c_int() xpt = stypes.empty_double_vector(3) found = ctypes.c_int() libspice.dskx02_c( handle, ctypes.byref(dladsc), vertex, raydir, ctypes.byref(plid), xpt, ctypes.byref(found), ) return plid.value, stypes.c_vector_to_python(xpt), bool(found.value)
[docs]@spice_error_check @spice_found_exception_thrower def dskxsi( pri: bool, target: str, srflst: Sequence[int], et: float, fixref: str, vertex: ndarray, raydir: ndarray, ) -> Tuple[ndarray, int, SpiceDLADescr, SpiceDSKDescr, ndarray, ndarray, bool]: """ Compute a ray-surface intercept using data provided by multiple loaded DSK segments. Return information about the source of the data defining the surface on which the intercept was found: DSK handle, DLA and DSK descriptors, and DSK data type-dependent parameters. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskxsi_c.html :param pri: Data prioritization flag. :param target: Target body name. :param srflst: Surface ID list. :param et: Epoch, expressed as seconds past J2000 TDB. :param fixref: Name of target body-fixed reference frame. :param vertex: Vertex of ray. :param raydir: Direction vector of ray. :return: Intercept point, Handle of segment contributing surface data, DLADSC, DSKDSC, Double precision component of source info, Integer component of source info """ pri = ctypes.c_int(pri) target = stypes.string_to_char_p(target) nsurf = ctypes.c_int(len(srflst)) srflst = stypes.to_int_vector(srflst) et = ctypes.c_double(et) fixref = stypes.string_to_char_p(fixref) vertex = stypes.to_double_vector(vertex) raydir = stypes.to_double_vector(raydir) maxd = ctypes.c_int(1) maxi = ctypes.c_int(1) xpt = stypes.empty_double_vector(3) handle = ctypes.c_int(0) dladsc = stypes.SpiceDLADescr() dskdsc = stypes.SpiceDSKDescr() dc = stypes.empty_double_vector(1) ic = stypes.empty_int_vector(1) found = ctypes.c_int() libspice.dskxsi_c( pri, target, nsurf, srflst, et, fixref, vertex, raydir, maxd, maxi, xpt, handle, dladsc, dskdsc, dc, ic, found, ) return ( stypes.c_vector_to_python(xpt), handle.value, dladsc, dskdsc, stypes.c_vector_to_python(dc), stypes.c_vector_to_python(ic), bool(found.value), )
[docs]@spice_error_check def dskxv( pri: bool, target: str, srflst: Sequence[int], et: float, fixref: str, vtxarr: Sequence[ndarray], dirarr: Sequence[ndarray], ) -> Tuple[ndarray, ndarray]: """ Compute ray-surface intercepts for a set of rays, using data provided by multiple loaded DSK segments. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskxv_c.html :param pri: Data prioritization flag. :param target: Target body name. :param srflst: Surface ID list. :param et: Epoch, expressed as seconds past J2000 TDB. :param fixref: Name of target body-fixed reference frame. :param vtxarr: Array of vertices of rays. :param dirarr: Array of direction vectors of rays. :return: Intercept point array and Found flag array. """ pri = ctypes.c_int(pri) target = stypes.string_to_char_p(target) nsurf = ctypes.c_int(len(srflst)) srflst = stypes.to_int_vector(srflst) et = ctypes.c_double(et) fixref = stypes.string_to_char_p(fixref) nray = ctypes.c_int(len(vtxarr)) vtxarr = stypes.to_double_matrix(vtxarr) dirarr = stypes.to_double_matrix(dirarr) xptarr = stypes.empty_double_matrix(y=nray) fndarr = stypes.empty_int_vector(nray) libspice.dskxv_c( pri, target, nsurf, srflst, et, fixref, nray, vtxarr, dirarr, xptarr, fndarr ) return stypes.c_matrix_to_numpy(xptarr), stypes.c_vector_to_python(fndarr)
[docs]@spice_error_check def dskz02(handle: int, dladsc: SpiceDLADescr) -> Tuple[int, int]: """ Return plate model size parameters---plate count and vertex count---for a type 2 DSK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskz02_c.html :param handle: DSK file handle. :param dladsc: DLA descriptor. :return: Number of vertices, Number of plates. """ handle = ctypes.c_int(handle) nv = ctypes.c_int() np = ctypes.c_int() libspice.dskz02_c(handle, dladsc, ctypes.byref(nv), ctypes.byref(np)) return nv.value, np.value
[docs]@spice_error_check def dsphdr(x: float, y: float, z: float) -> ndarray: """ This routine computes the Jacobian of the transformation from rectangular to spherical coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dsphdr_c.html :param x: X-coordinate of point. :param y: Y-coordinate of point. :param z: Z-coordinate of point. :return: Matrix of partial derivatives. """ x = ctypes.c_double(x) y = ctypes.c_double(y) z = ctypes.c_double(z) jacobi = stypes.empty_double_matrix() libspice.dsphdr_c(x, y, z, jacobi) return stypes.c_matrix_to_numpy(jacobi)
[docs]@spice_error_check @spice_found_exception_thrower def dtpool(name: str) -> Tuple[int, str, bool]: """ Return the data about a kernel pool variable. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dtpool_c.html :param name: Name of the variable whose value is to be returned. :return: Number of values returned for name, Type of the variable "C", "N", or "X". """ name = stypes.string_to_char_p(name) found = ctypes.c_int() n = ctypes.c_int() typeout = ctypes.c_char() libspice.dtpool_c(name, ctypes.byref(found), ctypes.byref(n), ctypes.byref(typeout)) return n.value, stypes.to_python_string(typeout.value), bool(found.value)
[docs]@spice_error_check def ducrss(s1: ndarray, s2: ndarray) -> ndarray: """ Compute the unit vector parallel to the cross product of two 3-dimensional vectors and the derivative of this unit vector. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ducrss_c.html :param s1: Left hand state for cross product and derivative. :param s2: Right hand state for cross product and derivative. :return: Unit vector and derivative of the cross product. """ assert len(s1) == 6 and len(s2) == 6 s1 = stypes.to_double_vector(s1) s2 = stypes.to_double_vector(s2) sout = stypes.empty_double_vector(6) libspice.ducrss_c(s1, s2, sout) return stypes.c_vector_to_python(sout)
[docs]@spice_error_check def dvcrss(s1: ndarray, s2: ndarray) -> ndarray: """ Compute the cross product of two 3-dimensional vectors and the derivative of this cross product. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dvcrss_c.html :param s1: Left hand state for cross product and derivative. :param s2: Right hand state for cross product and derivative. :return: State associated with cross product of positions. """ assert len(s1) == 6 and len(s2) == 6 s1 = stypes.to_double_vector(s1) s2 = stypes.to_double_vector(s2) sout = stypes.empty_double_vector(6) libspice.dvcrss_c(s1, s2, sout) return stypes.c_vector_to_python(sout)
[docs]@spice_error_check def dvdot(s1: Sequence[float], s2: Sequence[float]) -> float: """ Compute the derivative of the dot product of two double precision position vectors. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dvdot_c.html :param s1: First state vector in the dot product. :param s2: Second state vector in the dot product. :return: The derivative of the dot product. """ assert len(s1) == 6 and len(s2) == 6 s1 = stypes.to_double_vector(s1) s2 = stypes.to_double_vector(s2) return libspice.dvdot_c(s1, s2)
[docs]@spice_error_check def dvhat(s1: ndarray) -> ndarray: """ Find the unit vector corresponding to a state vector and the derivative of the unit vector. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dvhat_c.html :param s1: State to be normalized. :return: Unit vector s1 / abs(s1), and its time derivative. """ assert len(s1) == 6 s1 = stypes.to_double_vector(s1) sout = stypes.empty_double_vector(6) libspice.dvhat_c(s1, sout) return stypes.c_vector_to_python(sout)
[docs]@spice_error_check def dvnorm(state: ndarray) -> float: """ Function to calculate the derivative of the norm of a 3-vector. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dvnorm_c.html :param state: A 6-vector composed of three coordinates and their derivatives. :return: The derivative of the norm of a 3-vector. """ assert len(state) == 6 state = stypes.to_double_vector(state) return libspice.dvnorm_c(state)
[docs]@spice_error_check def dvpool(name: str) -> None: """ Delete a variable from the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dvpool_c.html :param name: Name of the kernel variable to be deleted. """ name = stypes.string_to_char_p(name) libspice.dvpool_c(name)
[docs]@spice_error_check def dvsep(s1: ndarray, s2: ndarray) -> float: """ Calculate the time derivative of the separation angle between two input states, S1 and S2. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dvsep_c.html :param s1: State vector of the first body. :param s2: State vector of the second body. :return: The time derivative of the angular separation between S1 and S2. """ assert len(s1) == 6 and len(s2) == 6 s1 = stypes.to_double_vector(s1) s2 = stypes.to_double_vector(s2) return libspice.dvsep_c(s1, s2)
################################################################################ # E
[docs]@spice_error_check def edlimb( a: float, b: float, c: float, viewpt: Union[Iterable[Union[float, float]], Iterable[float]], ) -> Ellipse: """ Find the limb of a triaxial ellipsoid, viewed from a specified point. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/edlimb_c.html :param a: Length of ellipsoid semi-axis lying on the x-axis. :param b: Length of ellipsoid semi-axis lying on the y-axis. :param c: Length of ellipsoid semi-axis lying on the z-axis. :param viewpt: Location of viewing point. :return: Limb of ellipsoid as seen from viewing point. """ limb = stypes.Ellipse() a = ctypes.c_double(a) b = ctypes.c_double(b) c = ctypes.c_double(c) viewpt = stypes.to_double_vector(viewpt) libspice.edlimb_c(a, b, c, viewpt, ctypes.byref(limb)) return limb
[docs]@spice_error_check def edterm( trmtyp: str, source: str, target: str, et: float, fixref: str, abcorr: str, obsrvr: str, npts: int, ) -> Tuple[float, ndarray, ndarray]: """ Compute a set of points on the umbral or penumbral terminator of a specified target body, where the target shape is modeled as an ellipsoid. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/edterm_c.html :param trmtyp: Terminator type. :param source: Light source. :param target: Target body. :param et: Observation epoch. :param fixref: Body-fixed frame associated with target. :param abcorr: Aberration correction. :param obsrvr: Observer. :param npts: Number of points in terminator set. :return: Epoch associated with target center, Position of observer in body-fixed frame, Terminator point set. """ trmtyp = stypes.string_to_char_p(trmtyp) source = stypes.string_to_char_p(source) target = stypes.string_to_char_p(target) et = ctypes.c_double(et) fixref = stypes.string_to_char_p(fixref) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) trgepc = ctypes.c_double() obspos = stypes.empty_double_vector(3) trmpts = stypes.empty_double_matrix(x=3, y=npts) npts = ctypes.c_int(npts) libspice.edterm_c( trmtyp, source, target, et, fixref, abcorr, obsrvr, npts, ctypes.byref(trgepc), obspos, trmpts, ) return ( trgepc.value, stypes.c_vector_to_python(obspos), stypes.c_matrix_to_numpy(trmpts), )
[docs]@spice_error_check def ekacec( handle: int, segno: int, recno: int, column: str, nvals: int, cvals: Iterable[str], isnull: bool, ) -> None: """ Add data to a character column in a specified EK record. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekacec_c.html :param handle: EK file handle. :param segno: Index of segment containing record. :param recno: Record to which data is to be added. :param column: Column name. :param nvals: Number of values to add to column. :param cvals: Character values to add to column. :param isnull: Flag indicating whether column entry is null. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) vallen = ctypes.c_int(len(max(cvals, key=len)) + 1) cvals = stypes.list_to_char_array_ptr(cvals) isnull = ctypes.c_int(isnull) libspice.ekacec_c(handle, segno, recno, column, nvals, vallen, cvals, isnull)
[docs]@spice_error_check def ekaced( handle: int, segno: int, recno: int, column: str, nvals: int, dvals: Union[ndarray, Iterable[float]], isnull: bool, ) -> None: """ Add data to an double precision column in a specified EK record. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekaced_c.html :param handle: EK file handle. :param segno: Index of segment containing record. :param recno: Record to which data is to be added. :param column: Column name. :param nvals: Number of values to add to column. :param dvals: Double precision values to add to column. :param isnull: Flag indicating whether column entry is null. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) dvals = stypes.to_double_vector(dvals) isnull = ctypes.c_int(isnull) libspice.ekaced_c(handle, segno, recno, column, nvals, dvals, isnull)
[docs]@spice_error_check def ekacei( handle: int, segno: int, recno: int, column: str, nvals: int, ivals: Union[ndarray, Iterable[int]], isnull: bool, ) -> None: """ Add data to an integer column in a specified EK record. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekacei_c.html :param handle: EK file handle. :param segno: Index of segment containing record. :param recno: Record to which data is to be added. :param column: Column name. :param nvals: Number of values to add to column. :param ivals: Integer values to add to column. :param isnull: Flag indicating whether column entry is null. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) ivals = stypes.to_int_vector(ivals) isnull = ctypes.c_int(isnull) libspice.ekacei_c(handle, segno, recno, column, nvals, ivals, isnull)
[docs]@spice_error_check def ekaclc( handle: int, segno: int, column: str, vallen: int, cvals: Iterable[str], entszs: Union[ndarray, Iterable[int]], nlflgs: Iterable[bool], rcptrs: ndarray, wkindx: Union[ndarray, Iterable[int]], ) -> ndarray: """ Add an entire character column to an EK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekaclc_c.html :param handle: EK file handle. :param segno: Number of segment to add column to. :param column: Column name. :param vallen: Length of character values. :param cvals: Character values to add to column. :param entszs: Array of sizes of column entries. :param nlflgs: Array of null flags for column entries. :param rcptrs: Record pointers for segment. :param wkindx: Work space for column index. :return: Work space for column index. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) column = stypes.string_to_char_p(column) vallen = ctypes.c_int(vallen) cvals = stypes.list_to_char_array_ptr(cvals) entszs = stypes.to_int_vector(entszs) nlflgs = stypes.to_int_vector(nlflgs) rcptrs = stypes.to_int_vector(rcptrs) wkindx = stypes.to_int_vector(wkindx) libspice.ekaclc_c( handle, segno, column, vallen, cvals, entszs, nlflgs, rcptrs, wkindx ) return stypes.c_vector_to_python(wkindx)
[docs]@spice_error_check def ekacld( handle: int, segno: int, column: str, dvals: Union[ndarray, Iterable[float]], entszs: Union[ndarray, Iterable[int]], nlflgs: Iterable[bool], rcptrs: ndarray, wkindx: Union[ndarray, Iterable[int]], ) -> ndarray: """ Add an entire double precision column to an EK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekacld_c.html :param handle: EK file handle. :param segno: Number of segment to add column to. :param column: Column name. :param dvals: Double precision values to add to column. :param entszs: Array of sizes of column entries. :param nlflgs: Array of null flags for column entries. :param rcptrs: Record pointers for segment. :param wkindx: Work space for column index. :return: Work space for column index. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) column = stypes.string_to_char_p(column) dvals = stypes.to_double_vector(dvals) entszs = stypes.to_int_vector(entszs) nlflgs = stypes.to_int_vector(nlflgs) rcptrs = stypes.to_int_vector(rcptrs) wkindx = stypes.to_int_vector(wkindx) libspice.ekacld_c(handle, segno, column, dvals, entszs, nlflgs, rcptrs, wkindx) return stypes.c_vector_to_python(wkindx)
[docs]@spice_error_check def ekacli( handle: int, segno: int, column: str, ivals: Union[ndarray, Iterable[int]], entszs: Union[ndarray, Iterable[int]], nlflgs: Iterable[bool], rcptrs: ndarray, wkindx: Union[ndarray, Iterable[int]], ) -> ndarray: """ Add an entire integer column to an EK segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekacli_c.html :param handle: EK file handle. :param segno: Number of segment to add column to. :param column: Column name. :param ivals: Integer values to add to column. :param entszs: Array of sizes of column entries. :param nlflgs: Array of null flags for column entries. :param rcptrs: Record pointers for segment. :param wkindx: Work space for column index. :return: Work space for column index. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) column = stypes.string_to_char_p(column) ivals = stypes.to_int_vector(ivals) entszs = stypes.to_int_vector(entszs) nlflgs = stypes.to_int_vector(nlflgs) rcptrs = stypes.to_int_vector(rcptrs) wkindx = stypes.to_int_vector(wkindx) libspice.ekacli_c(handle, segno, column, ivals, entszs, nlflgs, rcptrs, wkindx) return stypes.c_vector_to_python(wkindx)
[docs]@spice_error_check def ekappr(handle: int, segno: int) -> int: """ Append a new, empty record at the end of a specified E-kernel segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekappr_c.html :param handle: File handle. :param segno: Segment number. :return: Number of appended record. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int() libspice.ekappr_c(handle, segno, ctypes.byref(recno)) return recno.value
[docs]@spice_error_check def ekbseg( handle: int, tabnam: str, cnames: Sequence[str], decls: Sequence[str] ) -> int: """ Start a new segment in an E-kernel. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekbseg_c.html :param handle: File handle. :param tabnam: Table name. :param cnames: Names of columns. :param decls: Declarations of columns. :return: Segment number. """ handle = ctypes.c_int(handle) tabnam = stypes.string_to_char_p(tabnam) ncols = ctypes.c_int(len(cnames)) cnmlen = ctypes.c_int( len(max(cnames, key=len)) + 1 ) # needs to be len(name)+1 ie 'c1' to 3 for ekbseg do not fail cnames = stypes.list_to_char_array_ptr(cnames) declen = ctypes.c_int(len(max(decls, key=len)) + 1) decls = stypes.list_to_char_array_ptr(decls) segno = ctypes.c_int() libspice.ekbseg_c( handle, tabnam, ncols, cnmlen, cnames, declen, decls, ctypes.byref(segno) ) return segno.value
[docs]@spice_error_check def ekccnt(table: str) -> int: """ Return the number of distinct columns in a specified, currently loaded table. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekccnt_c.html :param table: Name of table. :return: Count of distinct, currently loaded columns. """ table = stypes.string_to_char_p(table) ccount = ctypes.c_int() libspice.ekccnt_c(table, ctypes.byref(ccount)) return ccount.value
[docs]@spice_error_check def ekcii( table: str, cindex: int, lenout: int = _default_len_out ) -> Tuple[str, SpiceEKAttDsc]: """ Return attribute information about a column belonging to a loaded EK table, specifying the column by table and index. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekcii_c.html :param table: Name of table containing column. :param cindex: Index of column whose attributes are to be found. :param lenout: Maximum allowed length of column name. :return: Name of column, Column attribute descriptor. """ table = stypes.string_to_char_p(table) cindex = ctypes.c_int(cindex) lenout = ctypes.c_int(lenout) column = stypes.string_to_char_p(lenout) attdsc = stypes.SpiceEKAttDsc() libspice.ekcii_c(table, cindex, lenout, column, ctypes.byref(attdsc)) return stypes.to_python_string(column), attdsc
[docs]@spice_error_check def ekcls(handle: int) -> None: """ Close an E-kernel. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekcls_c.html :param handle: EK file handle. """ handle = ctypes.c_int(handle) libspice.ekcls_c(handle)
[docs]@spice_error_check def ekdelr(handle: int, segno: int, recno: int) -> None: """ Delete a specified record from a specified E-kernel segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekdelr_c.html :param handle: File handle. :param segno: Segment number. :param recno: Record number. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) libspice.ekdelr_c(handle, segno, recno)
[docs]@spice_error_check def ekffld(handle: int, segno: int, rcptrs: ndarray) -> None: """ Complete a fast write operation on a new E-kernel segment. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekffld_c.html :param handle: File handle. :param segno: Segment number. :param rcptrs: Record pointers. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) rcptrs = stypes.to_int_vector(rcptrs) libspice.ekffld_c(handle, segno, ctypes.cast(rcptrs, ctypes.POINTER(ctypes.c_int)))
[docs]@spice_error_check def ekfind(query: str, lenout: int = _default_len_out) -> Tuple[int, int, str]: """ Find E-kernel data that satisfy a set of constraints. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekfind_c.html :param query: Query specifying data to be found. :param lenout: Declared length of output error message string. :return: Number of matching rows, Flag indicating whether query parsed correctly, Parse error description. """ query = stypes.string_to_char_p(query) lenout = ctypes.c_int(lenout) nmrows = ctypes.c_int() error = ctypes.c_int() errmsg = stypes.string_to_char_p(lenout) libspice.ekfind_c(query, lenout, ctypes.byref(nmrows), ctypes.byref(error), errmsg) return nmrows.value, error.value, stypes.to_python_string(errmsg)
[docs]@spice_error_check @spice_found_exception_thrower def ekgc( selidx: int, row: int, element: int, lenout: int = _default_len_out ) -> Tuple[str, int, bool]: """ Return an element of an entry in a column of character type in a specified row. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekgc_c.html :param selidx: Index of parent column in SELECT clause. :param row: Row to fetch from. :param element: Index of element, within column entry, to fetch. :param lenout: Maximum length of column element. :return: Character string element of column entry, Flag indicating whether column entry was null. """ selidx = ctypes.c_int(selidx) row = ctypes.c_int(row) element = ctypes.c_int(element) lenout = ctypes.c_int(lenout) null = ctypes.c_int() found = ctypes.c_int() cdata = stypes.string_to_char_p(lenout) libspice.ekgc_c( selidx, row, element, lenout, cdata, ctypes.byref(null), ctypes.byref(found) ) return stypes.to_python_string(cdata), null.value, bool(found.value)
[docs]@spice_error_check @spice_found_exception_thrower def ekgd(selidx: int, row: int, element: int) -> Tuple[float, int, bool]: """ Return an element of an entry in a column of double precision type in a specified row. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekgd_c.html :param selidx: Index of parent column in SELECT clause. :param row: Row to fetch from. :param element: Index of element, within column entry, to fetch. :return: Double precision element of column entry, Flag indicating whether column entry was null. """ selidx = ctypes.c_int(selidx) row = ctypes.c_int(row) element = ctypes.c_int(element) ddata = ctypes.c_double() null = ctypes.c_int() found = ctypes.c_int() libspice.ekgd_c( selidx, row, element, ctypes.byref(ddata), ctypes.byref(null), ctypes.byref(found), ) return ddata.value, null.value, bool(found.value)
[docs]@spice_error_check @spice_found_exception_thrower def ekgi(selidx: int, row: int, element: int) -> Tuple[int, int, bool]: """ Return an element of an entry in a column of integer type in a specified row. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekgi_c.html :param selidx: Index of parent column in SELECT clause. :param row: Row to fetch from. :param element: Index of element, within column entry, to fetch. :return: Integer element of column entry, Flag indicating whether column entry was null. """ selidx = ctypes.c_int(selidx) row = ctypes.c_int(row) element = ctypes.c_int(element) idata = ctypes.c_int() null = ctypes.c_int() found = ctypes.c_int() libspice.ekgi_c( selidx, row, element, ctypes.byref(idata), ctypes.byref(null), ctypes.byref(found), ) return idata.value, null.value, bool(found.value)
[docs]@spice_error_check def ekifld( handle: int, tabnam: str, ncols: int, nrows: int, cnmlen: int, cnames: Iterable[str], declen: int, decls: Iterable[str], ) -> Tuple[int, ndarray]: """ Initialize a new E-kernel segment to allow fast writing. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekifld_c.html :param handle: File handle. :param tabnam: Table name. :param ncols: Number of columns in the segment. :param nrows: Number of rows in the segment. :param cnmlen: Length of names in in column name array. :param cnames: Names of columns. :param declen: Length of declaration strings in declaration array. :param decls: Declarations of columns. :return: Segment number, Array of record pointers. """ handle = ctypes.c_int(handle) tabnam = stypes.string_to_char_p(tabnam) ncols = ctypes.c_int(ncols) nrows = ctypes.c_int(nrows) cnmlen = ctypes.c_int(cnmlen) cnames = stypes.list_to_char_array(cnames) declen = ctypes.c_int(declen) recptrs = stypes.empty_int_vector(nrows) decls = stypes.list_to_char_array(decls) segno = ctypes.c_int() libspice.ekifld_c( handle, tabnam, ncols, nrows, cnmlen, cnames, declen, decls, ctypes.byref(segno), recptrs, ) return segno.value, stypes.c_vector_to_python(recptrs)
[docs]@spice_error_check def ekinsr(handle: int, segno: int, recno: int) -> None: """ Add a new, empty record to a specified E-kernel segment at a specified index. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekinsr_c.html :param handle: File handle. :param segno: Segment number. :param recno: Record number. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) libspice.ekinsr_c(handle, segno, recno)
[docs]@spice_error_check def eklef(fname: str) -> int: """ Load an EK file, making it accessible to the EK readers. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/eklef_c.html :param fname: Name of EK file to load. :return: File handle of loaded EK file. """ fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.eklef_c(fname, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def eknelt(selidx: int, row: int) -> int: """ Return the number of elements in a specified column entry in the current row. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/eknelt_c.html :param selidx: Index of parent column in SELECT clause. :param row: Row containing element. :return: The number of elements in entry in current row. """ selidx = ctypes.c_int(selidx) row = ctypes.c_int(row) return libspice.eknelt_c(selidx, row)
[docs]@spice_error_check def eknseg(handle: int) -> int: """ Return the number of segments in a specified EK. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/eknseg_c.html :param handle: EK file handle. :return: The number of segments in the specified E-kernel. """ handle = ctypes.c_int(handle) return libspice.eknseg_c(handle)
[docs]@spice_error_check def ekntab() -> int: """ Return the number of loaded EK tables. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekntab_c.html :return: The number of loaded EK tables. """ n = ctypes.c_int(0) libspice.ekntab_c(ctypes.byref(n)) return n.value
[docs]@spice_error_check def ekopn(fname: str, ifname: str, ncomch: int) -> int: """ Open a new E-kernel file and prepare the file for writing. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekopn_c.html :param fname: Name of EK file. :param ifname: Internal file name. :param ncomch: The number of characters to reserve for comments. :return: Handle attached to new EK file. """ fname = stypes.string_to_char_p(fname) ifname = stypes.string_to_char_p(ifname) ncomch = ctypes.c_int(ncomch) handle = ctypes.c_int() libspice.ekopn_c(fname, ifname, ncomch, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def ekopr(fname: str) -> int: """ Open an existing E-kernel file for reading. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekopr_c.html :param fname: Name of EK file. :return: Handle attached to EK file. """ fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.ekopr_c(fname, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def ekops() -> int: """ Open a scratch (temporary) E-kernel file and prepare the file for writing. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekops_c.html :return: Handle attached to new EK file. """ handle = ctypes.c_int() libspice.ekops_c(ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def ekopw(fname: str) -> int: """ Open an existing E-kernel file for writing. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekopw_c.html :param fname: Name of EK file. :return: Handle attached to EK file. """ fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.ekopw_c(fname, ctypes.byref(handle)) return handle.value
[docs]@spice_error_check def ekpsel( query: str, msglen: int, tablen: int, collen: int ) -> Tuple[ int, ndarray, ndarray, ndarray, ndarray, Iterable[str], Iterable[str], int, str ]: """ Parse the SELECT clause of an EK query, returning full particulars concerning each selected item. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekpsel_c.html note: oddly docs at url are incomplete/incorrect. :param query: EK query. :param msglen: Available space in the output error message string. :param tablen: UNKNOWN? Length of Table? :param collen: UNKOWN? Length of Column? :return: Number of items in SELECT clause of query, Begin positions of expressions in SELECT clause, End positions of expressions in SELECT clause, Data types of expressions, Classes of expressions, Names of tables qualifying SELECT columns, Names of columns in SELECT clause of query, Error flag, Parse error message. """ query = stypes.string_to_char_p(query) msglen = ctypes.c_int(msglen) tablen = ctypes.c_int(tablen) collen = ctypes.c_int(collen) n = ctypes.c_int() xbegs = stypes.empty_int_vector(_SPICE_EK_MAXQSEL) xends = stypes.empty_int_vector(_SPICE_EK_MAXQSEL) xtypes = stypes.empty_int_vector(_SPICE_EK_MAXQSEL) xclass = stypes.empty_int_vector(_SPICE_EK_MAXQSEL) tabs = stypes.empty_char_array(y_len=_SPICE_EK_MAXQSEL, x_len=tablen) cols = stypes.empty_char_array(y_len=_SPICE_EK_MAXQSEL, x_len=collen) error = ctypes.c_int() errmsg = stypes.string_to_char_p(msglen) libspice.ekpsel_c( query, msglen, tablen, collen, ctypes.byref(n), xbegs, xends, xtypes, xclass, ctypes.byref(tabs), ctypes.byref(cols), ctypes.byref(error), errmsg, ) return ( n.value, stypes.c_vector_to_python(xbegs)[: n.value], stypes.c_vector_to_python(xends)[: n.value], stypes.c_vector_to_python(xtypes)[: n.value], stypes.c_vector_to_python(xclass)[: n.value], stypes.c_vector_to_python(tabs)[: n.value], stypes.c_vector_to_python(cols)[: n.value], error.value, stypes.to_python_string(errmsg), )
[docs]@spice_error_check def ekrcec( handle: int, segno: int, recno: int, column: str, lenout: int, nelts: int = _SPICE_EK_EKRCEX_ROOM_DEFAULT, ) -> Tuple[int, Iterable[str], bool]: """ Read data from a character column in a specified EK record. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekrcec_c.html :param handle: Handle attached to EK file. :param segno: Index of segment containing record. :param recno: Record from which data is to be read. :param column: Column name. :param lenout: Maximum length of output strings. :param nelts: Number of elements to allow for (default=100) :return: Number of values in column entry, Character values in column entry, Flag indicating whether column entry is null. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) column = stypes.string_to_char_p(column) lenout = ctypes.c_int(lenout) nvals = ctypes.c_int() cvals = stypes.empty_char_array(y_len=nelts, x_len=lenout) isnull = ctypes.c_int() libspice.ekrcec_c( handle, segno, recno, column, lenout, ctypes.byref(nvals), ctypes.byref(cvals), ctypes.byref(isnull), ) assert failed() or (nvals.value <= nelts) return ( nvals.value, stypes.c_vector_to_python(cvals)[: nvals.value], bool(isnull.value), )
[docs]@spice_error_check def ekrced( handle: int, segno: int, recno: int, column: str, nelts: int = _SPICE_EK_EKRCEX_ROOM_DEFAULT, ) -> Tuple[int, ndarray, bool]: """ Read data from a double precision column in a specified EK record. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekrced_c.html :param handle: Handle attached to EK file. :param segno: Index of segment containing record. :param recno: Record from which data is to be read. :param column: Column name. :param nelts: room for data default 100 :return: Number of values in column entry, Float values in column entry, Flag indicating whether column entry is null. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) column = stypes.string_to_char_p(column) nvals = ctypes.c_int(0) dvals = stypes.empty_double_vector(nelts) isnull = ctypes.c_int() libspice.ekrced_c( handle, segno, recno, column, ctypes.byref(nvals), dvals, ctypes.byref(isnull) ) assert failed() or (nvals.value <= nelts) return ( nvals.value, stypes.c_vector_to_python(dvals)[: nvals.value], bool(isnull.value), )
[docs]@spice_error_check def ekrcei( handle: int, segno: int, recno: int, column: str, nelts: int = _SPICE_EK_EKRCEX_ROOM_DEFAULT, ) -> Tuple[int, ndarray, bool]: """ Read data from an integer column in a specified EK record. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekrcei_c.html :param handle: Handle attached to EK file. :param segno: Index of segment containing record. :param recno: Record from which data is to be read. :param column: Column name. :param nelts: room for data default 100 :return: Number of values in column entry, Integer values in column entry, Flag indicating whether column entry is null. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) column = stypes.string_to_char_p(column) nvals = ctypes.c_int() ivals = stypes.empty_int_vector(nelts) isnull = ctypes.c_int() libspice.ekrcei_c( handle, segno, recno, column, ctypes.byref(nvals), ivals, ctypes.byref(isnull) ) assert failed() or (nvals.value <= nelts) return ( nvals.value, stypes.c_vector_to_python(ivals)[: nvals.value], bool(isnull.value), )
[docs]@spice_error_check def ekssum(handle: int, segno: int) -> SpiceEKSegSum: """ Return summary information for a specified segment in a specified EK. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekssum_c.html :param handle: Handle of EK. :param segno: Number of segment to be summarized. :return: EK segment summary. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) segsum = stypes.SpiceEKSegSum() libspice.ekssum_c(handle, segno, ctypes.byref(segsum)) return segsum
[docs]@spice_error_check def ektnam(n: int, lenout: int = _default_len_out) -> str: """ Return the name of a specified, loaded table. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ektnam_c.html :param n: Index of table. :param lenout: Maximum table name length. :return: Name of table. """ n = ctypes.c_int(n) lenout = ctypes.c_int(lenout) table = stypes.string_to_char_p(lenout) libspice.ektnam_c(n, lenout, table) return stypes.to_python_string(table)
[docs]@spice_error_check def ekucec( handle: int, segno: int, recno: int, column: str, nvals: int, cvals: Iterable[str], isnull: bool, ) -> None: """ Update a character column entry in a specified EK record. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekucec_c.html :param handle: EK file handle. :param segno: Index of segment containing record. :param recno: Record to which data is to be updated. :param column: Column name. :param nvals: Number of values in new column entry. :param cvals: Character values comprising new column entry. :param isnull: Flag indicating whether column entry is null. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) vallen = ctypes.c_int(len(max(cvals, key=len)) + 1) cvals = stypes.list_to_char_array_ptr(cvals, x_len=vallen) isnull = ctypes.c_int(isnull) libspice.ekucec_c(handle, segno, recno, column, nvals, vallen, cvals, isnull)
[docs]@spice_error_check def ekuced( handle: int, segno: int, recno: int, column: str, nvals: int, dvals: Union[ndarray, Iterable[float]], isnull: bool, ) -> None: """ Update a double precision column entry in a specified EK record. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekuced_c.html :param handle: EK file handle. :param segno: Index of segment containing record. :param recno: Record to which data is to be updated. :param column: Column name. :param nvals: Number of values in new column entry. :param dvals: Double precision values comprising new column entry. :param isnull: Flag indicating whether column entry is null. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) dvals = stypes.to_double_vector(dvals) isnull = ctypes.c_int(isnull) libspice.ekaced_c(handle, segno, recno, column, nvals, dvals, isnull)
[docs]@spice_error_check def ekucei( handle: int, segno: int, recno: int, column: str, nvals: int, ivals: Union[ndarray, Iterable[int]], isnull: bool, ) -> None: """ Update an integer column entry in a specified EK record. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekucei_c.html :param handle: EK file handle. :param segno: Index of segment containing record. :param recno: Record to which data is to be updated. :param column: Column name. :param nvals: Number of values in new column entry. :param ivals: Integer values comprising new column entry. :param isnull: Flag indicating whether column entry is null. """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) ivals = stypes.to_int_vector(ivals) isnull = ctypes.c_int(isnull) libspice.ekucei_c(handle, segno, recno, column, nvals, ivals, isnull)
[docs]@spice_error_check def ekuef(handle: int) -> None: """ Unload an EK file, making its contents inaccessible to the EK reader routines, and clearing space in order to allow other EK files to be loaded. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekuef_c.html :param handle: Handle of EK file. """ handle = ctypes.c_int(handle) libspice.ekuef_c(handle)
[docs]@spice_error_check def el2cgv(ellipse: Ellipse) -> Tuple[ndarray, ndarray, ndarray]: """ Convert an ellipse to a center vector and two generating vectors. The selected generating vectors are semi-axes of the ellipse. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/el2cgv_c.html :param ellipse: An Ellipse :return: Center and semi-axes of ellipse. """ assert isinstance(ellipse, stypes.Ellipse) center = stypes.empty_double_vector(3) smajor = stypes.empty_double_vector(3) sminor = stypes.empty_double_vector(3) libspice.el2cgv_c(ctypes.byref(ellipse), center, smajor, sminor) return ( stypes.c_vector_to_python(center), stypes.c_vector_to_python(smajor), stypes.c_vector_to_python(sminor), )
[docs]@spice_error_check def elemc(item: str, inset: SpiceCell) -> bool: """ Determine whether an item is an element of a character set. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/elemc_c.html :param item: Item to be tested. :param inset: Set to be tested. :return: True if item is an element of set. """ assert isinstance(inset, stypes.SpiceCell) item = stypes.string_to_char_p(item) return bool(libspice.elemc_c(item, ctypes.byref(inset)))
[docs]@spice_error_check def elemd(item: float, inset: SpiceCell) -> bool: """ Determine whether an item is an element of a double precision set. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/elemd_c.html :param item: Item to be tested. :param inset: Set to be tested. :return: True if item is an element of set. """ assert isinstance(inset, stypes.SpiceCell) assert inset.dtype == 1 item = ctypes.c_double(item) return bool(libspice.elemd_c(item, ctypes.byref(inset)))
[docs]@spice_error_check def elemi(item: int, inset: SpiceCell) -> bool: """ Determine whether an item is an element of an integer set. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/elemi_c.html :param item: Item to be tested. :param inset: Set to be tested. :return: True if item is an element of set. """ assert isinstance(inset, stypes.SpiceCell) assert inset.dtype == 2 item = ctypes.c_int(item) return bool(libspice.elemi_c(item, ctypes.byref(inset)))
[docs]@spice_error_check def eqncpv( et: float, epoch: float, eqel: Iterable[Union[float, float]], rapol: float, decpol: float, ) -> ndarray: """ Compute the state (position and velocity of an object whose trajectory is described via equinoctial elements relative to some fixed plane (usually the equatorial plane of some planet). https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/eqncpv_c.html :param et: Epoch in seconds past J2000 to find state. :param epoch: Epoch of elements in seconds past J2000. :param eqel: Array of equinoctial elements :param rapol: Right Ascension of the pole of the reference plane. :param decpol: Declination of the pole of the reference plane. :return: State of the object described by eqel. """ et = ctypes.c_double(et) epoch = ctypes.c_double(epoch) eqel = stypes.to_double_vector(eqel) rapol = ctypes.c_double(rapol) decpol = ctypes.c_double(decpol) state = stypes.empty_double_vector(6) libspice.eqncpv_c(et, epoch, eqel, rapol, decpol, state) return stypes.c_vector_to_python(state)
[docs]@spice_error_check def eqstr(a: str, b: str) -> bool: """ Determine whether two strings are equivalent. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/eqstr_c.html :param a: Arbitrary character string. :param b: Arbitrary character string. :return: True if A and B are equivalent. """ return bool( libspice.eqstr_c(stypes.string_to_char_p(a), stypes.string_to_char_p(b)) )
[docs]def erract(op: str, lenout: int, action: Optional[str] = None) -> str: """ Retrieve or set the default error action. spiceypy sets the default error action to "report" on init. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/erract_c.html :param op: peration, "GET" or "SET". :param lenout: Length of list for output. :param action: Error response action. :return: Error response action. """ if action is None: action = "" lenout = ctypes.c_int(lenout) op = stypes.string_to_char_p(op) action = ctypes.create_string_buffer(str.encode(action), lenout.value) actionptr = ctypes.c_char_p(ctypes.addressof(action)) libspice.erract_c(op, lenout, actionptr) return stypes.to_python_string(actionptr)
[docs]def errch(marker: str, string: str) -> None: """ Substitute a character string for the first occurrence of a marker in the current long error message. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/errch_c.html :param marker: A substring of the error message to be replaced. :param string: The character string to substitute for marker. """ marker = stypes.string_to_char_p(marker) string = stypes.string_to_char_p(string) libspice.errch_c(marker, string)
[docs]def errdev(op: str, lenout: int, device: str) -> str: """ Retrieve or set the name of the current output device for error messages. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/errdev_c.html :param op: The operation, "GET" or "SET". :param lenout: Length of device for output. :param device: The device name. :return: The device name. """ lenout = ctypes.c_int(lenout) op = stypes.string_to_char_p(op) device = ctypes.create_string_buffer(str.encode(device), lenout.value) deviceptr = ctypes.c_char_p(ctypes.addressof(device)) libspice.errdev_c(op, lenout, deviceptr) return stypes.to_python_string(deviceptr)
[docs]def errdp(marker: str, number: float) -> None: """ Substitute a double precision number for the first occurrence of a marker found in the current long error message. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/errdp_c.html :param marker: A substring of the error message to be replaced. :param number: The d.p. number to substitute for marker. """ marker = stypes.string_to_char_p(marker) number = ctypes.c_double(number) libspice.errdp_c(marker, number)
[docs]def errint(marker: str, number: int) -> None: """ Substitute an integer for the first occurrence of a marker found in the current long error message. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/errint_c.html :param marker: A substring of the error message to be replaced. :param number: The integer to substitute for marker. """ marker = stypes.string_to_char_p(marker) number = ctypes.c_int(number) libspice.errint_c(marker, number)
[docs]def errprt(op: str, lenout: int, inlist: str) -> str: """ Retrieve or set the list of error message items to be output when an error is detected. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/errprt_c.html :param op: The operation, "GET" or "SET". :param lenout: Length of list for output. :param inlist: Specification of error messages to be output. :return: A list of error message items. """ lenout = ctypes.c_int(lenout) op = stypes.string_to_char_p(op) inlist = ctypes.create_string_buffer(str.encode(inlist), lenout.value) inlistptr = ctypes.c_char_p(ctypes.addressof(inlist)) libspice.errdev_c(op, lenout, inlistptr) return stypes.to_python_string(inlistptr)
[docs]def esrchc(value: str, array: Sequence[str]) -> int: """ Search for a given value within a character string array. Return the index of the first equivalent array entry, or -1 if no equivalent element is found. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/esrchc_c.html :param value: Key value to be found in array. :param array: Character string array to search. :return: The index of the first array entry equivalent to value, or -1 if none is found. """ value = stypes.string_to_char_p(value) ndim = ctypes.c_int(len(array)) lenvals = ctypes.c_int(len(max(array, key=len)) + 1) array = stypes.list_to_char_array(array, x_len=lenvals, y_len=ndim) return libspice.esrchc_c(value, ndim, lenvals, array)
[docs]@spice_error_check def et2lst( et: float, body: int, lon: float, typein: str, timlen: int = _default_len_out, ampmlen: int = _default_len_out, ) -> Tuple[int, int, int, str, str]: """ Given an ephemeris epoch, compute the local solar time for an object on the surface of a body at a specified longitude. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/et2lst_c.html :param et: Epoch in seconds past J2000 epoch. :param body: ID-code of the body of interest. :param lon: Longitude of surface point (RADIANS). :param typein: Type of longitude "PLANETOCENTRIC", etc. :param timlen: Available room in output time string. :param ampmlen: Available room in output ampm string. :return: Local hour on a "24 hour" clock, Minutes past the hour, Seconds past the minute, String giving local time on 24 hour clock, String giving time on A.M. / P.M. scale. """ et = ctypes.c_double(et) body = ctypes.c_int(body) lon = ctypes.c_double(lon) typein = stypes.string_to_char_p(typein) timlen = ctypes.c_int(timlen) ampmlen = ctypes.c_int(ampmlen) hr = ctypes.c_int() mn = ctypes.c_int() sc = ctypes.c_int() time = stypes.string_to_char_p(timlen) ampm = stypes.string_to_char_p(ampmlen) libspice.et2lst_c( et, body, lon, typein, timlen, ampmlen, ctypes.byref(hr), ctypes.byref(mn), ctypes.byref(sc), time, ampm, ) return ( hr.value, mn.value, sc.value, stypes.to_python_string(time), stypes.to_python_string(ampm), )
[docs]@spice_error_check def et2utc( et: Union[float, Iterable[float]], format_str: str, prec: int, lenout: int = _default_len_out, ) -> Union[ndarray, str]: """ Convert an input time from ephemeris seconds past J2000 to Calendar, Day-of-Year, or Julian Date format, UTC. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/et2utc_c.html :param et: Input epoch, given in ephemeris seconds past J2000. :param format_str: Format of output epoch. :param prec: Digits of precision in fractional seconds or days. :param lenout: The length of the output string plus 1. :return: Output time string in UTC """ prec = ctypes.c_int(prec) lenout = ctypes.c_int(lenout) format_str = stypes.string_to_char_p(format_str) utcstr = stypes.string_to_char_p(lenout) if stypes.is_iterable(et): results = [] for t in et: libspice.et2utc_c(ctypes.c_double(t), format_str, prec, lenout, utcstr) check_for_spice_error(None) results.append(stypes.to_python_string(utcstr)) return numpy.array(results) else: libspice.et2utc_c(ctypes.c_double(et), format_str, prec, lenout, utcstr) return stypes.to_python_string(utcstr)
[docs]@spice_error_check def etcal( et: Union[float, ndarray], lenout: int = _default_len_out ) -> Union[str, Iterable[str]]: """ Convert from an ephemeris epoch measured in seconds past the epoch of J2000 to a calendar string format using a formal calendar free of leapseconds. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/etcal_c.html :param et: Ephemeris time measured in seconds past J2000. :param lenout: Length of output string. :return: A standard calendar representation of et. """ lenout = ctypes.c_int(lenout) string = stypes.string_to_char_p(lenout) if hasattr(et, "__iter__"): strings = [] for t in et: libspice.etcal_c(t, lenout, string) check_for_spice_error(None) strings.append(stypes.to_python_string(string)) return strings else: et = ctypes.c_double(et) libspice.etcal_c(et, lenout, string) return stypes.to_python_string(string)
[docs]@spice_error_check def eul2m( angle3: float, angle2: float, angle1: float, axis3: int, axis2: int, axis1: int ) -> ndarray: """ Construct a rotation matrix from a set of Euler angles. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/eul2m_c.html :param angle3: Rotation angle about third rotation axis (radians). :param angle2: Rotation angle about second rotation axis (radians). :param angle1: Rotation angle about first rotation axis (radians). :param axis3: Axis number of third rotation axis. :param axis2: Axis number of second rotation axis. :param axis1: Axis number of first rotation axis.] :return: Product of the 3 rotations. """ angle3 = ctypes.c_double(angle3) angle2 = ctypes.c_double(angle2) angle1 = ctypes.c_double(angle1) axis3 = ctypes.c_int(axis3) axis2 = ctypes.c_int(axis2) axis1 = ctypes.c_int(axis1) r = stypes.empty_double_matrix() libspice.eul2m_c(angle3, angle2, angle1, axis3, axis2, axis1, r) return stypes.c_matrix_to_numpy(r)
[docs]@spice_error_check def eul2xf(eulang: Sequence[float], axisa: int, axisb: int, axisc: int) -> ndarray: """ This routine computes a state transformation from an Euler angle factorization of a rotation and the derivatives of those Euler angles. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/eul2xf_c.html :param eulang: An array of Euler angles and their derivatives. :param axisa: Axis A of the Euler angle factorization. :param axisb: Axis B of the Euler angle factorization. :param axisc: Axis C of the Euler angle factorization. :return: A state transformation matrix. """ assert len(eulang) == 6 eulang = stypes.to_double_vector(eulang) axisa = ctypes.c_int(axisa) axisb = ctypes.c_int(axisb) axisc = ctypes.c_int(axisc) xform = stypes.empty_double_matrix(x=6, y=6) libspice.eul2xf_c(eulang, axisa, axisb, axisc, xform) return stypes.c_matrix_to_numpy(xform)
[docs]@spice_error_check def ev2lin(et: float, geophs: Sequence[float], elems: Sequence[float]) -> ndarray: """ This routine evaluates NORAD two-line element data for near-earth orbiting spacecraft (that is spacecraft with orbital periods less than 225 minutes). https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/ev2lin.html :param et: Epoch in seconds past ephemeris epoch J2000. :param geophs: Geophysical constants :param elems: Two-line element data :return: Evaluated state """ et = ctypes.c_double(et) assert len(geophs) == 8 geophs = stypes.to_double_vector(geophs) assert len(elems) == 10 elems = stypes.to_double_vector(elems) state = stypes.empty_double_vector(6) libspice.ev2lin_(ctypes.byref(et), geophs, elems, state) return stypes.c_vector_to_python(state)
[docs]@spice_error_check def exists(fname: str) -> bool: """ Determine whether a file exists. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/exists_c.html :param fname: Name of the file in question. :return: True if the file exists, False otherwise. """ fname = stypes.string_to_char_p(fname) return bool(libspice.exists_c(fname))
[docs]@spice_error_check def expool(name: str) -> bool: """ Confirm the existence of a kernel variable in the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/expool_c.html :param name: Name of the variable whose value is to be returned. :return: True when the variable is in the pool. """ name = stypes.string_to_char_p(name) found = ctypes.c_int() libspice.expool_c(name, ctypes.byref(found)) return bool(found.value)
################################################################################ # F
[docs]def failed() -> bool: """ True if an error condition has been signalled via sigerr_c. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/failed_c.html :return: a boolean """ return bool(libspice.failed_c())
[docs]@spice_error_check def fn2lun(fname: str) -> int: """ Internal undocumented command for mapping name of open file to its FORTRAN (F2C) logical unit. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/fn2lun.html :param fname: name of the file to be mapped to its logical unit. :return: the FORTRAN (F2C) logical unit associated with the filename. """ fname_p = stypes.string_to_char_p(fname) unit_out = ctypes.c_int() fname_len = ctypes.c_int(len(fname) + 1) libspice.fn2lun_(fname_p, ctypes.byref(unit_out), fname_len) return unit_out.value
[docs]@spice_error_check def fovray( inst: str, raydir: Union[ndarray, Iterable[float]], rframe: str, abcorr: str, observer: str, et: float, ) -> bool: """ Determine if a specified ray is within the field-of-view (FOV) of a specified instrument at a given time. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/fovray_c.html :param inst: Name or ID code string of the instrument. :param raydir: Ray's direction vector. :param rframe: Body-fixed, body-centered frame for target body. :param abcorr: Aberration correction flag. :param observer: Name or ID code string of the observer. :param et: Time of the observation (seconds past J2000). :return: Visibility flag """ inst = stypes.string_to_char_p(inst) raydir = stypes.to_double_vector(raydir) rframe = stypes.string_to_char_p(rframe) abcorr = stypes.string_to_char_p(abcorr) observer = stypes.string_to_char_p(observer) et = ctypes.c_double(et) visible = ctypes.c_int() libspice.fovray_c( inst, raydir, rframe, abcorr, observer, ctypes.byref(et), ctypes.byref(visible) ) return bool(visible.value)
[docs]@spice_error_check def fovtrg( inst: str, target: str, tshape: str, tframe: str, abcorr: str, observer: str, et: float, ) -> bool: """ Determine if a specified ephemeris object is within the field-of-view (FOV) of a specified instrument at a given time. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/fovtrg_c.html :param inst: Name or ID code string of the instrument. :param target: Name or ID code string of the target. :param tshape: Type of shape model used for the target. :param tframe: Body-fixed, body-centered frame for target body. :param abcorr: Aberration correction flag. :param observer: Name or ID code string of the observer. :param et: Time of the observation (seconds past J2000). :return: Visibility flag """ inst = stypes.string_to_char_p(inst) target = stypes.string_to_char_p(target) tshape = stypes.string_to_char_p(tshape) tframe = stypes.string_to_char_p(tframe) abcorr = stypes.string_to_char_p(abcorr) observer = stypes.string_to_char_p(observer) et = ctypes.c_double(et) visible = ctypes.c_int() libspice.fovtrg_c( inst, target, tshape, tframe, abcorr, observer, ctypes.byref(et), ctypes.byref(visible), ) return bool(visible.value)
[docs]@spice_error_check def frame(x: Union[ndarray, Iterable[float]]) -> Tuple[ndarray, ndarray, ndarray]: """ https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/frame_c.html :param x: Input vector. A parallel unit vector on output. :return: a tuple of 3 list[3] """ x = stypes.to_double_vector(x) y = stypes.empty_double_vector(3) z = stypes.empty_double_vector(3) libspice.frame_c(x, y, z) return ( stypes.c_vector_to_python(x), stypes.c_vector_to_python(y), stypes.c_vector_to_python(z), )
[docs]@spice_error_check @spice_found_exception_thrower def frinfo(frcode: int) -> Tuple[int, int, int, bool]: """ https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/frinfo_c.html :param frcode: the idcode for some frame. :return: a tuple of attributes associated with the frame. """ frcode = ctypes.c_int(frcode) cent = ctypes.c_int() frclss = ctypes.c_int() clssid = ctypes.c_int() found = ctypes.c_int() libspice.frinfo_c( frcode, ctypes.byref(cent), ctypes.byref(frclss), ctypes.byref(clssid), ctypes.byref(found), ) return cent.value, frclss.value, clssid.value, bool(found.value)
[docs]@spice_error_check def frmnam(frcode: int, lenout: int = _default_len_out) -> str: """ Retrieve the name of a reference frame associated with a SPICE ID code. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/frmnam_c.html :param frcode: an integer code for a reference frame :param lenout: Maximum length of output string. :return: the name associated with the reference frame. """ frcode = ctypes.c_int(frcode) lenout = ctypes.c_int(lenout) frname = stypes.string_to_char_p(lenout) libspice.frmnam_c(frcode, lenout, frname) return stypes.to_python_string(frname)
[docs]@spice_error_check def ftncls(unit: int) -> None: """ Close a file designated by a Fortran-style integer logical unit. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ftncls_c.html :param unit: Fortran-style logical unit. """ unit = ctypes.c_int(unit) libspice.ftncls_c(unit)
[docs]@spice_error_check def furnsh(path: Union[str, Iterable[str]]) -> None: """ Load one or more SPICE kernels into a program. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/furnsh_c.html :param path: one or more paths to kernels """ if stypes.is_iterable(path): for p in path: libspice.furnsh_c(stypes.string_to_char_p(p)) else: path = stypes.string_to_char_p(path) libspice.furnsh_c(path)
################################################################################ # G
[docs]@spice_error_check @spice_found_exception_thrower def gcpool( name: str, start: int, room: int, lenout: int = _default_len_out ) -> Tuple[Iterable[str], bool]: """ Return the character value of a kernel variable from the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gcpool_c.html :param name: Name of the variable whose value is to be returned. :param start: Which component to start retrieving for name. :param room: The largest number of values to return. :param lenout: The length of the output string. :return: Values associated with name. """ name = stypes.string_to_char_p(name) start = ctypes.c_int(start) room = ctypes.c_int(room) lenout = ctypes.c_int(lenout) n = ctypes.c_int() cvals = stypes.empty_char_array(lenout, room) found = ctypes.c_int() libspice.gcpool_c( name, start, room, lenout, ctypes.byref(n), ctypes.byref(cvals), ctypes.byref(found), ) return ( [stypes.to_python_string(x.value) for x in cvals[0 : n.value]], bool(found.value), )
[docs]@spice_error_check @spice_found_exception_thrower def gdpool(name: str, start: int, room: int) -> Tuple[ndarray, bool]: """ Return the d.p. value of a kernel variable from the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gdpool_c.html :param name: Name of the variable whose value is to be returned. :param start: Which component to start retrieving for name. :param room: The largest number of values to return. :return: Values associated with name. """ name = stypes.string_to_char_p(name) start = ctypes.c_int(start) values = stypes.empty_double_vector(room) room = ctypes.c_int(room) n = ctypes.c_int() found = ctypes.c_int() libspice.gdpool_c( name, start, room, ctypes.byref(n), ctypes.cast(values, ctypes.POINTER(ctypes.c_double)), ctypes.byref(found), ) return stypes.c_vector_to_python(values)[0 : n.value], bool(found.value)
[docs]@spice_error_check def georec(lon: float, lat: float, alt: float, re: float, f: float) -> ndarray: """ Convert geodetic coordinates to rectangular coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/georec_c.html :param lon: Geodetic longitude of point (radians). :param lat: Geodetic latitude of point (radians). :param alt: Altitude of point above the reference spheroid. :param re: Equatorial radius of the reference spheroid. :param f: Flattening coefficient. :return: Rectangular coordinates of point. """ lon = ctypes.c_double(lon) lat = ctypes.c_double(lat) alt = ctypes.c_double(alt) re = ctypes.c_double(re) f = ctypes.c_double(f) rectan = stypes.empty_double_vector(3) libspice.georec_c(lon, lat, alt, re, f, rectan) return stypes.c_vector_to_python(rectan)
# getcml not really needed
[docs]@spice_error_check def getelm(frstyr: int, lineln: int, lines: Iterable[str]) -> Tuple[float, ndarray]: """ Given a the "lines" of a two-line element set, parse the lines and return the elements in units suitable for use in SPICE software. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/getelm_c.html :param frstyr: Year of earliest representable two-line elements. :param lineln: Length of strings in lines array. :param lines: A pair of "lines" containing two-line elements. :return: The epoch of the elements in seconds past J2000, The elements converted to SPICE units. """ frstyr = ctypes.c_int(frstyr) lineln = ctypes.c_int(lineln) lines = stypes.list_to_char_array_ptr(lines, x_len=lineln, y_len=2) epoch = ctypes.c_double() elems = stypes.empty_double_vector(10) # guess for length libspice.getelm_c(frstyr, lineln, lines, ctypes.byref(epoch), elems) return epoch.value, stypes.c_vector_to_python(elems)
[docs]@spice_error_check def getfat(file: str) -> Tuple[str, str]: """ Determine the file architecture and file type of most SPICE kernel files. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/getfat_c.html :param file: The name of a file to be examined. :return: The architecture of the kernel file, The type of the kernel file. """ file = stypes.string_to_char_p(file) arclen = ctypes.c_int(4) typlen = ctypes.c_int(4) arch = stypes.string_to_char_p(arclen) rettype = stypes.string_to_char_p(typlen) libspice.getfat_c(file, arclen, typlen, arch, rettype) return stypes.to_python_string(arch), stypes.to_python_string(rettype)
[docs]@spice_error_check def getfov( instid: int, room: int, shapelen: int = _default_len_out, framelen: int = _default_len_out, ) -> Tuple[str, str, ndarray, int, ndarray]: """ This routine returns the field-of-view (FOV) parameters for a specified instrument. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/getfov_c.html :param instid: NAIF ID of an instrument. :param room: Maximum number of vectors that can be returned. :param shapelen: Space available in the string shape. :param framelen: Space available in the string frame. :return: Instrument FOV shape, Name of the frame in which FOV vectors are defined, Boresight vector, Number of boundary vectors returned, FOV boundary vectors. """ instid = ctypes.c_int(instid) shape = stypes.string_to_char_p(" " * shapelen) framen = stypes.string_to_char_p(" " * framelen) shapelen = ctypes.c_int(shapelen) framelen = ctypes.c_int(framelen) bsight = stypes.empty_double_vector(3) n = ctypes.c_int() bounds = stypes.empty_double_matrix(x=3, y=room) room = ctypes.c_int(room) libspice.getfov_c( instid, room, shapelen, framelen, shape, framen, bsight, ctypes.byref(n), bounds ) return ( stypes.to_python_string(shape), stypes.to_python_string(framen), stypes.c_vector_to_python(bsight), n.value, stypes.c_matrix_to_numpy(bounds)[0 : n.value], )
[docs]def getmsg(option: str, lenout: int = _default_len_out) -> str: """ Retrieve the current short error message, the explanation of the short error message, or the long error message. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/getmsg_c.html :param option: Indicates type of error message. :param lenout: Available space in the output string msg. :return: The error message to be retrieved. """ option = stypes.string_to_char_p(option) lenout = ctypes.c_int(lenout) msg = stypes.string_to_char_p(lenout) libspice.getmsg_c(option, lenout, msg) return stypes.to_python_string(msg)
[docs]@spice_error_check def gfbail() -> bool: """ Indicate whether an interrupt signal (SIGINT) has been received. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfbail_c.html :return: True if an interrupt signal has been received by the GF handler. """ return bool(libspice.gfbail_c())
[docs]@spice_error_check def gfclrh() -> None: """ Clear the interrupt signal handler status, so that future calls to :func:`gfbail` will indicate no interrupt was received. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfclrh_c.html """ libspice.gfclrh_c()
[docs]@spice_error_check def gfdist( target: str, abcorr: str, obsrvr: str, relate: str, refval: int, adjust: float, step: float, nintvls: int, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ) -> SpiceCell: """ Return the time window over which a specified constraint on observer-target distance is met. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfdist_c.html :param target: Name of the target body. :param abcorr: Aberration correction flag. :param obsrvr: Name of the observing body. :param relate: Relational operator. :param refval: Reference value. :param adjust: Adjustment value for absolute extrema searches. :param step: Step size used for locating extrema and roots. :param nintvls: Workspace window interval count. :param cnfine: SPICE window to which the search is confined. :param result: Optional SPICE window containing results. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() target = stypes.string_to_char_p(target) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) relate = stypes.string_to_char_p(relate) refval = ctypes.c_double(refval) adjust = ctypes.c_double(adjust) step = ctypes.c_double(step) nintvls = ctypes.c_int(nintvls) libspice.gfdist_c( target, abcorr, obsrvr, relate, refval, adjust, step, nintvls, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfevnt( udstep: UDSTEP, udrefn: UDREFN, gquant: str, qnpars: int, lenvals: int, qpnams: Iterable[str], qcpars: Iterable[str], qdpars: Union[ndarray, Iterable[float]], qipars: Union[ndarray, Iterable[int]], qlpars: Union[ndarray, Iterable[int]], op: str, refval: float, tol: float, adjust: float, rpt: int, udrepi: UDREPI, udrepu: UDREPU, udrepf: UDREPF, nintvls: int, bail: int, udbail: UDBAIL, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ): """ Determine time intervals when a specified geometric quantity satisfies a specified mathematical condition. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfevnt_c.html :param udstep: Name of the routine that computes and returns a :param udrefn: Name of the routine that computes a refined time :param gquant: Type of geometric quantity :param qnpars: Number of quantity definition parameters :param lenvals: Length of strings in qpnams and qcpars :param qpnams: Names of quantity definition parameters :param qcpars: Array of character quantity definition parameters :param qdpars: Array of double precision quantity definition :param qipars: Array of integer quantity definition parameters :param qlpars: Array of logical quantity definition parameters :param op: Operator that either looks for an extreme value :param refval: Reference value :param tol: Convergence tolerance in seconds :param adjust: Absolute extremum adjustment value :param rpt: Progress reporter on TRUE or off FALSE :param udrepi: Function that initializes progress reporting :param udrepu: Function that updates the progress report :param udrepf: Function that finalizes progress reporting :param nintvls: Workspace window interval count :param bail: Logical indicating program interrupt monitoring :param udbail: Name of a routine that signals a program interrupt :param cnfine: SPICE window to which the search is restricted :param result: Optional SPICE window containing results """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() gquant = stypes.string_to_char_p(gquant) qnpars = ctypes.c_int(qnpars) lenvals = ctypes.c_int(lenvals) qpnams = stypes.list_to_char_array_ptr(qpnams, x_len=lenvals, y_len=qnpars) qcpars = stypes.list_to_char_array_ptr(qcpars, x_len=lenvals, y_len=qnpars) qdpars = stypes.to_double_vector(qdpars) qipars = stypes.to_int_vector(qipars) qlpars = stypes.to_int_vector(qlpars) op = stypes.string_to_char_p(op) refval = ctypes.c_double(refval) tol = ctypes.c_double(tol) adjust = ctypes.c_double(adjust) rpt = ctypes.c_int(rpt) nintvls = ctypes.c_int(nintvls) bail = ctypes.c_int(bail) libspice.gfevnt_c( udstep, udrefn, gquant, qnpars, lenvals, qpnams, qcpars, qdpars, qipars, qlpars, op, refval, tol, adjust, rpt, udrepi, udrepu, udrepf, nintvls, bail, udbail, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gffove( inst: str, tshape: str, raydir: Union[ndarray, Iterable[float]], target: str, tframe: str, abcorr: str, obsrvr: str, tol: float, udstep: UDSTEP, udrefn: UDREFN, rpt: int, udrepi: UDREPI, udrepu: UDREPU, udrepf: UDREPF, bail: int, udbail: UDBAIL, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ): """ Determine time intervals when a specified target body or ray intersects the space bounded by the field-of-view (FOV) of a specified instrument. Report progress and handle interrupts if so commanded. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gffove_c.html :param inst: Name of the instrument :param tshape: Type of shape model used for target body :param raydir: Ray s direction vector :param target: Name of the target body :param tframe: Body fixed body centered frame for target body :param abcorr: Aberration correction flag :param obsrvr: Name of the observing body :param tol: Convergence tolerance in seconds :param udstep: Name of the routine that returns a time step :param udrefn: Name of the routine that computes a refined time :param rpt: Progress report flag :param udrepi: Function that initializes progress reporting. :param udrepu: Function that updates the progress report :param udrepf: Function that finalizes progress reporting :param bail: Logical indicating program interrupt monitoring :param udbail: Name of a routine that signals a program interrupt :param cnfine: SPICE window to which the search is restricted :param result: Optional SPICE window containing results """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() inst = stypes.string_to_char_p(inst) tshape = stypes.string_to_char_p(tshape) raydir = stypes.to_double_vector(raydir) target = stypes.string_to_char_p(target) tframe = stypes.string_to_char_p(tframe) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) tol = ctypes.c_double(tol) rpt = ctypes.c_int(rpt) bail = ctypes.c_int(bail) libspice.gffove_c( inst, tshape, raydir, target, tframe, abcorr, obsrvr, tol, udstep, udrefn, rpt, udrepi, udrepu, udrepf, bail, udbail, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfilum( method: str, angtyp: str, target: str, illumn: str, fixref: str, abcorr: str, obsrvr: str, spoint: Union[ndarray, Iterable[float]], relate: str, refval: float, adjust: float, step: float, nintvls: int, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ) -> SpiceCell: """ Return the time window over which a specified constraint on the observed phase, solar incidence, or emission angle at a specifed target body surface point is met. :param method: Shape model used to represent the surface of the target body. :param angtyp: The type of illumination angle for which a search is to be performed. :param target: Name of a target body. :param illumn: Name of the illumination source. :param fixref: Name of the body-fixed, body-centered reference frame associated with the target body. :param abcorr: The aberration corrections to be applied. :param obsrvr: Name of an observing body. :param spoint: Body-fixed coordinates of a target surface point. :param relate: Relational operator used to define a constraint on a specified illumination angle. :param refval: Reference value used with 'relate' to define an equality or inequality to be satisfied by the specified illumination angle. :param adjust: Parameter used to modify searches for absolute extrema. :param step: Step size to be used in the search. :param nintvls: Number of intervals that can be accommodated by each of the dynamically allocated workspace windows used internally by this routine. :param cnfine: Window that confines the time period over which the specified search is conducted. This can be updated by gfilum :param result: Optional SPICE Window of intervals in the confinement window that the illumination angle constraint is satisfied. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() method = stypes.string_to_char_p(method) angtyp = stypes.string_to_char_p(angtyp) target = stypes.string_to_char_p(target) illumn = stypes.string_to_char_p(illumn) fixref = stypes.string_to_char_p(fixref) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) spoint = stypes.to_double_vector(spoint) relate = stypes.string_to_char_p(relate) refval = ctypes.c_double(refval) adjust = ctypes.c_double(adjust) step = ctypes.c_double(step) nintvls = ctypes.c_int(nintvls) libspice.gfilum_c( method, angtyp, target, illumn, fixref, abcorr, obsrvr, spoint, relate, refval, adjust, step, nintvls, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfinth(sigcode: int) -> None: """ Respond to the interrupt signal SIGINT: save an indication that the signal has been received. This routine restores itself as the handler for SIGINT. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfinth_c.html :param sigcode: Interrupt signal ID code. """ sigcode = ctypes.c_int(sigcode) libspice.gfinth_c(sigcode)
[docs]@spice_error_check def gfocce( occtyp: str, front: str, fshape: str, fframe: str, back: str, bshape: str, bframe: str, abcorr: str, obsrvr: str, tol: float, udstep: UDSTEP, udrefn: UDREFN, rpt: int, udrepi: UDREPI, udrepu: UDREPU, udrepf: UDREPF, bail: int, udbail: UDBAIL, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ): """ Determine time intervals when an observer sees one target occulted by another. Report progress and handle interrupts if so commanded. The surfaces of the target bodies may be represented by triaxial ellipsoids or by topographic data provided by DSK files. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfocce_c.html :param occtyp: Type of occultation :param front: Name of body occulting the other :param fshape: Type of shape model used for front body :param fframe: Body fixed body centered frame for front body :param back: Name of body occulted by the other :param bshape: Type of shape model used for back body :param bframe: Body fixed body centered frame for back body :param abcorr: Aberration correction flag :param obsrvr: Name of the observing body :param tol: Convergence tolerance in seconds :param udstep: Name of the routine that returns a time step :param udrefn: Name of the routine that computes a refined time :param rpt: Progress report flag :param udrepi: Function that initializes progress reporting. :param udrepu: Function that updates the progress report :param udrepf: Function that finalizes progress reporting :param bail: Logical indicating program interrupt monitoring :param udbail: Name of a routine that signals a program interrupt :param cnfine: SPICE window to which the search is restricted :param result: Optional SPICE window containing results. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() occtyp = stypes.string_to_char_p(occtyp) front = stypes.string_to_char_p(front) fshape = stypes.string_to_char_p(fshape) fframe = stypes.string_to_char_p(fframe) back = stypes.string_to_char_p(back) bshape = stypes.string_to_char_p(bshape) bframe = stypes.string_to_char_p(bframe) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) tol = ctypes.c_double(tol) rpt = ctypes.c_int(rpt) bail = ctypes.c_int(bail) libspice.gfocce_c( occtyp, front, fshape, fframe, back, bshape, bframe, abcorr, obsrvr, tol, udstep, udrefn, rpt, udrepi, udrepu, udrepf, bail, udbail, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check 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: Optional[SpiceCell] = None, ) -> SpiceCell: """ Determine time intervals when an observer sees one target occulted by, or in transit across, another. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfoclt_c.html :param occtyp: Type of occultation. :param front: Name of body occulting the other. :param fshape: Type of shape model used for front body. :param fframe: Body-fixed, body-centered frame for front body. :param back: Name of body occulted by the other. :param bshape: Type of shape model used for back body. :param bframe: Body-fixed, body-centered frame for back body. :param abcorr: Aberration correction flag. :param obsrvr: Name of the observing body. :param step: Step size in seconds for finding occultation events. :param cnfine: SPICE window to which the search is restricted. :param result: Optional SPICE window containing results. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() occtyp = stypes.string_to_char_p(occtyp) front = stypes.string_to_char_p(front) fshape = stypes.string_to_char_p(fshape) fframe = stypes.string_to_char_p(fframe) back = stypes.string_to_char_p(back) bshape = stypes.string_to_char_p(bshape) bframe = stypes.string_to_char_p(bframe) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) step = ctypes.c_double(step) libspice.gfoclt_c( occtyp, front, fshape, fframe, back, bshape, bframe, abcorr, obsrvr, step, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfpa( target: str, illmin: str, abcorr: str, obsrvr: str, relate: str, refval: float, adjust: float, step: float, nintvls: int, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ) -> SpiceCell: """ Determine time intervals for which a specified constraint on the phase angle between an illumination source, a target, and observer body centers is met. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfpa_c.html :param target: Name of the target body. :param illmin: Name of the illuminating body. :param abcorr: Aberration correction flag. :param obsrvr: Name of the observing body. :param relate: Relational operator. :param refval: Reference value. :param adjust: Adjustment value for absolute extrema searches. :param step: Step size used for locating extrema and roots. :param nintvls: Workspace window interval count. :param cnfine: SPICE window to which the search is restricted. :param result: Optional SPICE window containing results. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() target = stypes.string_to_char_p(target) illmin = stypes.string_to_char_p(illmin) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) relate = stypes.string_to_char_p(relate) refval = ctypes.c_double(refval) adjust = ctypes.c_double(adjust) step = ctypes.c_double(step) nintvls = ctypes.c_int(nintvls) libspice.gfpa_c( target, illmin, abcorr, obsrvr, relate, refval, adjust, step, nintvls, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfposc( target: str, inframe: str, abcorr: str, obsrvr: str, crdsys: str, coord: str, relate: str, refval: float, adjust: float, step: float, nintvls: int, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ) -> SpiceCell: """ Determine time intervals for which a coordinate of an observer-target position vector satisfies a numerical constraint. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfposc_c.html :param target: Name of the target body. :param inframe: Name of the reference frame for coordinate calculations. :param abcorr: Aberration correction flag. :param obsrvr: Name of the observing body. :param crdsys: Name of the coordinate system containing COORD :param coord: Name of the coordinate of interest :param relate: Relational operator. :param refval: Reference value. :param adjust: Adjustment value for absolute extrema searches. :param step: Step size used for locating extrema and roots. :param nintvls: Workspace window interval count. :param cnfine: SPICE window to which the search is restricted. :param result: Optional SPICE window containing results. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() target = stypes.string_to_char_p(target) inframe = stypes.string_to_char_p(inframe) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) crdsys = stypes.string_to_char_p(crdsys) coord = stypes.string_to_char_p(coord) relate = stypes.string_to_char_p(relate) refval = ctypes.c_double(refval) adjust = ctypes.c_double(adjust) step = ctypes.c_double(step) nintvls = ctypes.c_int(nintvls) libspice.gfposc_c( target, inframe, abcorr, obsrvr, crdsys, coord, relate, refval, adjust, step, nintvls, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfrefn(t1: float, t2: float, s1: Union[bool, int], s2: Union[bool, int]) -> float: """ For those times when we can't do better, we use a bisection method to find the next time at which to test for state change. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfrefn_c.html :param t1: One of two values bracketing a state change. :param t2: The other value that brackets a state change. :param s1: State at t1. :param s2: State at t2. :return: New value at which to check for transition. """ t1 = ctypes.c_double(t1) t2 = ctypes.c_double(t2) s1 = ctypes.c_int(s1) s2 = ctypes.c_int(s2) t = ctypes.c_double() libspice.gfrefn_c(t1, t2, s1, s2, ctypes.byref(t)) return t.value
[docs]@spice_error_check def gfrepf() -> None: """ Finish a GF progress report. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfrepf_c.html """ libspice.gfrepf_c()
[docs]@spice_error_check def gfrepi( window: Union[SpiceCell, SpiceCellPointer], begmss: str, endmss: str ) -> None: """ This entry point initializes a search progress report. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfrepi_c.html :param window: A window over which a job is to be performed. :param begmss: Beginning of the text portion of the output message. :param endmss: End of the text portion of the output message. """ begmss = stypes.string_to_char_p(begmss) endmss = stypes.string_to_char_p(endmss) # don't do anything if we were given a pointer to a SpiceCell, like if we were in a callback if not isinstance(window, SpiceCellPointer): assert isinstance(window, stypes.SpiceCell) assert window.is_double() window = ctypes.byref(window) libspice.gfrepi_c(window, begmss, endmss)
[docs]@spice_error_check def gfrepu(ivbeg: float, ivend: float, time: float) -> None: """ This function tells the progress reporting system how far a search has progressed. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfrepu_c.html :param ivbeg: Start time of work interval. :param ivend: End time of work interval. :param time: Current time being examined in the search process. """ ivbeg = ctypes.c_double(ivbeg) ivend = ctypes.c_double(ivend) time = ctypes.c_double(time) libspice.gfrepu_c(ivbeg, ivend, time)
[docs]@spice_error_check def gfrfov( inst: str, raydir: ndarray, rframe: str, abcorr: str, obsrvr: str, step: float, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ) -> SpiceCell: """ Determine time intervals when a specified ray intersects the space bounded by the field-of-view (FOV) of a specified instrument. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfrfov_c.html :param inst: Name of the instrument. :param raydir: Ray's direction vector. :param rframe: Reference frame of ray's direction vector. :param abcorr: Aberration correction flag. :param obsrvr: Name of the observing body. :param step: Step size in seconds for finding FOV events. :param cnfine: SPICE window to which the search is restricted. :param result: Optional SPICE window containing results. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() inst = stypes.string_to_char_p(inst) raydir = stypes.to_double_vector(raydir) rframe = stypes.string_to_char_p(rframe) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) step = ctypes.c_double(step) libspice.gfrfov_c( inst, raydir, rframe, abcorr, obsrvr, step, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfrr( target: str, abcorr: str, obsrvr: str, relate: str, refval: float, adjust: float, step: float, nintvls: int, cnfine: SpiceCell, result: SpiceCell, ) -> SpiceCell: """ Determine time intervals for which a specified constraint on the observer-target range rate is met. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfrr_c.html :param target: Name of the target body. :param abcorr: Aberration correction flag. :param obsrvr: Name of the observing body. :param relate: Relational operator. :param refval: Reference value. :param adjust: Adjustment value for absolute extrema searches. :param step: Step size used for locating extrema and roots. :param nintvls: Workspace window interval count. :param cnfine: SPICE window to which the search is restricted. :param result: Optional SPICE window containing results. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() target = stypes.string_to_char_p(target) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) relate = stypes.string_to_char_p(relate) refval = ctypes.c_double(refval) adjust = ctypes.c_double(adjust) step = ctypes.c_double(step) nintvls = ctypes.c_int(nintvls) libspice.gfrr_c( target, abcorr, obsrvr, relate, refval, adjust, step, nintvls, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfsep( targ1: str, shape1: str, inframe1: str, targ2: str, shape2: str, inframe2: str, abcorr: str, obsrvr: str, relate: str, refval: float, adjust: float, step: float, nintvls: int, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ) -> SpiceCell: """ Determine time intervals when the angular separation between the position vectors of two target bodies relative to an observer satisfies a numerical relationship. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfsep_c.html :param targ1: Name of first body. :param shape1: Name of shape model describing the first body. :param inframe1: The body-fixed reference frame of the first body. :param targ2: Name of second body. :param shape2: Name of the shape model describing the second body. :param inframe2: The body-fixed reference frame of the second body :param abcorr: Aberration correction flag :param obsrvr: Name of the observing body. :param relate: Relational operator. :param refval: Reference value. :param adjust: Absolute extremum adjustment value. :param step: Step size in seconds for finding angular separation events. :param nintvls: Workspace window interval count. :param cnfine: SPICE window to which the search is restricted. :param result: Optional SPICE window containing results. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() targ1 = stypes.string_to_char_p(targ1) shape1 = stypes.string_to_char_p(shape1) inframe1 = stypes.string_to_char_p(inframe1) targ2 = stypes.string_to_char_p(targ2) shape2 = stypes.string_to_char_p(shape2) inframe2 = stypes.string_to_char_p(inframe2) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) relate = stypes.string_to_char_p(relate) refval = ctypes.c_double(refval) adjust = ctypes.c_double(adjust) step = ctypes.c_double(step) nintvls = ctypes.c_int(nintvls) libspice.gfsep_c( targ1, shape1, inframe1, targ2, shape2, inframe2, abcorr, obsrvr, relate, refval, adjust, step, nintvls, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfsntc( target: str, fixref: str, method: str, abcorr: str, obsrvr: str, dref: str, dvec: Union[ndarray, Iterable[float]], crdsys: str, coord: str, relate: str, refval: float, adjust: float, step: float, nintvls: int, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ) -> SpiceCell: """ Determine time intervals for which a coordinate of an surface intercept position vector satisfies a numerical constraint. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfsntc_c.html :param target: Name of the target body. :param fixref: Body fixed frame associated with the target. :param method: Name of method type for surface intercept calculation. :param abcorr: Aberration correction flag :param obsrvr: Name of the observing body. :param dref: Reference frame of direction vector of dvec. :param dvec: Pointing direction vector from the observer. :param crdsys: Name of the coordinate system containing COORD. :param coord: Name of the coordinate of interest :param relate: Relational operator. :param refval: Reference value. :param adjust: Absolute extremum adjustment value. :param step: Step size in seconds for finding angular separation events. :param nintvls: Workspace window interval count. :param cnfine: SPICE window to which the search is restricted. :param result: Optional SPICE window containing results. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() target = stypes.string_to_char_p(target) fixref = stypes.string_to_char_p(fixref) method = stypes.string_to_char_p(method) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) dref = stypes.string_to_char_p(dref) dvec = stypes.to_double_vector(dvec) crdsys = stypes.string_to_char_p(crdsys) coord = stypes.string_to_char_p(coord) relate = stypes.string_to_char_p(relate) refval = ctypes.c_double(refval) adjust = ctypes.c_double(adjust) step = ctypes.c_double(step) nintvls = ctypes.c_int(nintvls) libspice.gfsntc_c( target, fixref, method, abcorr, obsrvr, dref, dvec, crdsys, coord, relate, refval, adjust, step, nintvls, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfsstp(step: float) -> None: """ Set the step size to be returned by :func:`gfstep`. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfsstp_c.html :param step: Time step to take. """ step = ctypes.c_double(step) libspice.gfsstp_c(step)
[docs]@spice_error_check def gfstep(time: float) -> float: """ Return the time step set by the most recent call to :func:`gfsstp`. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfstep_c.html :param time: Ignored ET value. :return: Time step to take. """ time = ctypes.c_double(time) step = ctypes.c_double() libspice.gfstep_c(time, ctypes.byref(step)) return step.value
[docs]@spice_error_check def gfstol(value: float) -> None: """ Override the default GF convergence value used in the high level GF routines. Default value is 1.0e-6 https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfstol_c.html :param value: Double precision value returned or to store. """ value = ctypes.c_double(value) libspice.gfstol_c(value)
[docs]@spice_error_check def gfsubc( target: str, fixref: str, method: str, abcorr: str, obsrvr: str, crdsys: str, coord: str, relate: str, refval: float, adjust: float, step: float, nintvls: int, cnfine: SpiceCell, result: SpiceCell, ) -> SpiceCell: """ Determine time intervals for which a coordinate of an subpoint position vector satisfies a numerical constraint. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfsubc_c.html :param target: Name of the target body. :param fixref: Body fixed frame associated with the target. :param method: Name of method type for subpoint calculation. :param abcorr: Aberration correction flag :param obsrvr: Name of the observing body. :param crdsys: Name of the coordinate system containing COORD. :param coord: Name of the coordinate of interest :param relate: Relational operator. :param refval: Reference value. :param adjust: Adjustment value for absolute extrema searches. :param step: Step size used for locating extrema and roots. :param nintvls: Workspace window interval count. :param cnfine: SPICE window to which the search is restricted. :param result: Optional SPICE window containing results. """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(2000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() target = stypes.string_to_char_p(target) fixref = stypes.string_to_char_p(fixref) method = stypes.string_to_char_p(method) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) crdsys = stypes.string_to_char_p(crdsys) coord = stypes.string_to_char_p(coord) relate = stypes.string_to_char_p(relate) refval = ctypes.c_double(refval) adjust = ctypes.c_double(adjust) step = ctypes.c_double(step) nintvls = ctypes.c_int(nintvls) libspice.gfsubc_c( target, fixref, method, abcorr, obsrvr, crdsys, coord, relate, refval, adjust, step, nintvls, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gftfov( inst: str, target: str, tshape: str, tframe: str, abcorr: str, obsrvr: str, step: float, cnfine: SpiceCell, result: Optional[SpiceCell] = None, ) -> SpiceCell: """ Determine time intervals when a specified ephemeris object intersects the space bounded by the field-of-view (FOV) of a specified instrument. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gftfov_c.html :param inst: Name of the instrument. :param target: Name of the target body. :param tshape: Type of shape model used for target body. :param tframe: Body-fixed, body-centered frame for target body. :param abcorr: Aberration correction flag. :param obsrvr: Name of the observing body. :param step: Step size in seconds for finding FOV events. :param cnfine: SPICE window to which the search is restricted. :param result: Optional pass-in SpiceCell for results :return: SpiceCell containing set of time intervals, within the confinement period, when the target body is visible """ assert isinstance(cnfine, stypes.SpiceCell) assert cnfine.is_double() if result is None: result = stypes.SPICEDOUBLE_CELL(20000) else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() inst = stypes.string_to_char_p(inst) target = stypes.string_to_char_p(target) tshape = stypes.string_to_char_p(tshape) tframe = stypes.string_to_char_p(tframe) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) step = ctypes.c_double(step) libspice.gftfov_c( inst, target, tshape, tframe, abcorr, obsrvr, step, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check def gfudb( udfuns: UDFUNS, udfunb: UDFUNB, step: float, cnfine: SpiceCell, result: SpiceCell ): """ Perform a GF search on a user defined boolean quantity. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfudb_c.html :param udfuns: Name of the routine that computes a scalar quantity of interest corresponding to an 'et'. :param udfunb: Name of the routine returning the boolean value corresponding to an 'et'. :param step: Step size used for locating extrema and roots. :param cnfine: SPICE window to which the search is restricted. :param result: SPICE window containing results. :return: result """ step = ctypes.c_double(step) libspice.gfudb_c(udfuns, udfunb, step, ctypes.byref(cnfine), ctypes.byref(result))
[docs]@spice_error_check def gfuds( udfuns: UDFUNS, udqdec: UDFUNB, relate: str, refval: float, adjust: float, step: float, nintvls: int, cnfine: SpiceCell, result: SpiceCell, ) -> SpiceCell: """ Perform a GF search on a user defined scalar quantity. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfuds_c.html :param udfuns: Name of the routine that computes the scalar quantity of interest at some time. :param udqdec: Name of the routine that computes whether the scalar quantity is decreasing. :param relate: Operator that either looks for an extreme value (max, min, local, absolute) or compares the geometric quantity value and a number. :param refval: Value used as reference for scalar quantity condition. :param adjust: Allowed variation for absolute extremal geometric conditions. :param step: Step size used for locating extrema and roots. :param nintvls: Workspace window interval count. :param cnfine: SPICE window to which the search is restricted. :param result: SPICE window containing results. :return: result """ relate = stypes.string_to_char_p(relate) refval = ctypes.c_double(refval) adjust = ctypes.c_double(adjust) step = ctypes.c_double(step) nintvls = ctypes.c_int(nintvls) libspice.gfuds_c( udfuns, udqdec, relate, refval, adjust, step, nintvls, ctypes.byref(cnfine), ctypes.byref(result), ) return result
[docs]@spice_error_check @spice_found_exception_thrower def gipool(name: str, start: int, room: int) -> Tuple[ndarray, bool]: """ Return the integer value of a kernel variable from the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gipool_c.html :param name: Name of the variable whose value is to be returned. :param start: Which component to start retrieving for name. :param room: The largest number of values to return. :return: Values associated with name. """ name = stypes.string_to_char_p(name) start = ctypes.c_int(start) ivals = stypes.empty_int_vector(room) room = ctypes.c_int(room) n = ctypes.c_int() found = ctypes.c_int() libspice.gipool_c(name, start, room, ctypes.byref(n), ivals, ctypes.byref(found)) return stypes.c_vector_to_python(ivals)[0 : n.value], bool(found.value)
[docs]@spice_error_check @spice_found_exception_thrower def gnpool( name: str, start: int, room: int, lenout: int = _default_len_out ) -> Tuple[Iterable[str], bool]: """ Return names of kernel variables matching a specified template. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gnpool_c.html :param name: Template that names should match. :param start: Index of first matching name to retrieve. :param room: The largest number of values to return. :param lenout: Length of strings in output array kvars. :return: Kernel pool variables whose names match name. """ name = stypes.string_to_char_p(name) start = ctypes.c_int(start) kvars = stypes.empty_char_array(y_len=room, x_len=lenout) room = ctypes.c_int(room) lenout = ctypes.c_int(lenout) n = ctypes.c_int() found = ctypes.c_int() libspice.gnpool_c( name, start, room, lenout, ctypes.byref(n), kvars, ctypes.byref(found) ) return stypes.c_vector_to_python(kvars)[0 : n.value], bool(found.value)
################################################################################ # H
[docs]@spice_error_check def halfpi() -> float: """ Return half the value of pi (the ratio of the circumference of a circle to its diameter). https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/halfpi_c.html :return: Half the value of pi. """ return libspice.halfpi_c()
[docs]@spice_error_check def hrmint( xvals: Sequence[float], yvals: Sequence[float], x: int ) -> Tuple[float, float]: """ Evaluate a Hermite interpolating polynomial at a specified abscissa value. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/hrmint_c.html :param xvals: Abscissa values. :param yvals: Ordinate and derivative values. :param x: Point at which to interpolate the polynomial. :return: Interpolated function value at x and the Interpolated function's derivative at x """ work = stypes.empty_double_vector(int(2 * len(yvals) + 1)) n = ctypes.c_int(len(xvals)) xvals = stypes.to_double_vector(xvals) yvals = stypes.to_double_vector(yvals) x = ctypes.c_double(x) f = ctypes.c_double(0) df = ctypes.c_double(0) libspice.hrmint_c(n, xvals, yvals, x, work, f, df) return f.value, df.value
[docs]@spice_error_check def hx2dp(string: str) -> Union[float, str]: """ Convert a string representing a double precision number in a base 16 scientific notation into its equivalent double precision number. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/hx2dp_c.html :param string: Hex form string to convert to double precision. :return: Double precision value to be returned, Or Error Message. """ string = stypes.string_to_char_p(string) lenout = ctypes.c_int(80) errmsg = stypes.string_to_char_p(lenout) number = ctypes.c_double() error = ctypes.c_int() libspice.hx2dp_c(string, lenout, ctypes.byref(number), ctypes.byref(error), errmsg) if not error.value: return number.value else: return stypes.to_python_string(errmsg)
################################################################################ # I
[docs]@spice_error_check def ident() -> ndarray: """ This routine returns the 3x3 identity matrix. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ident_c.html :return: The 3x3 identity matrix. """ matrix = stypes.empty_double_matrix() libspice.ident_c(matrix) return stypes.c_matrix_to_numpy(matrix)
[docs]@spice_error_check def illum( target: str, et: float, abcorr: str, obsrvr: str, spoint: ndarray ) -> Tuple[float, float, float]: """ Deprecated: This routine has been superseded by the CSPICE routine ilumin. This routine is supported for purposes of backward compatibility only. Find the illumination angles at a specified surface point of a target body. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/illum_c.html :param target: Name of target body. :param et: Epoch in ephemeris seconds past J2000. :param abcorr: Desired aberration correction. :param obsrvr: Name of observing body. :param spoint: Body-fixed coordinates of a target surface point. :return: Phase angle, Solar incidence angle, and Emission angle at the surface point. """ target = stypes.string_to_char_p(target) et = ctypes.c_double(et) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) spoint = stypes.to_double_vector(spoint) phase = ctypes.c_double(0) solar = ctypes.c_double(0) emissn = ctypes.c_double(0) libspice.illum_c( target, et, abcorr, obsrvr, spoint, ctypes.byref(phase), ctypes.byref(solar), ctypes.byref(emissn), ) return phase.value, solar.value, emissn.value
[docs]@spice_error_check def illumf( method: str, target: str, ilusrc: str, et: float, fixref: str, abcorr: str, obsrvr: str, spoint: ndarray, ) -> Tuple[float, ndarray, float, float, float, bool, bool]: """ Compute the illumination angles---phase, incidence, and emission---at a specified point on a target body. Return logical flags indicating whether the surface point is visible from the observer's position and whether the surface point is illuminated. The target body's surface is represented using topographic data provided by DSK files, or by a reference ellipsoid. The illumination source is a specified ephemeris object. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/illumf_c.html :param method: Computation method. :param target: Name of target body. :param ilusrc: Name of illumination source. :param et: Epoch in ephemeris seconds past J2000. :param fixref: Body-fixed, body-centered target body frame. :param abcorr: Desired aberration correction. :param obsrvr: Name of observing body. :param spoint: Body-fixed coordinates of a target surface point. :return: Target surface point epoch, Vector from observer to target surface point, Phase angle at the surface point, Source incidence angle at the surface point, Emission angle at the surface point, Visibility flag, Illumination flag """ method = stypes.string_to_char_p(method) target = stypes.string_to_char_p(target) ilusrc = stypes.string_to_char_p(ilusrc) et = ctypes.c_double(et) fixref = stypes.string_to_char_p(fixref) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) spoint = stypes.to_double_vector(spoint) trgepc = ctypes.c_double(0) srfvec = stypes.empty_double_vector(3) phase = ctypes.c_double(0) incdnc = ctypes.c_double(0) emissn = ctypes.c_double(0) visibl = ctypes.c_int() lit = ctypes.c_int() libspice.illumf_c( method, target, ilusrc, et, fixref, abcorr, obsrvr, spoint, ctypes.byref(trgepc), srfvec, ctypes.byref(phase), ctypes.byref(incdnc), ctypes.byref(emissn), ctypes.byref(visibl), ctypes.byref(lit), ) return ( trgepc.value, stypes.c_vector_to_python(srfvec), phase.value, incdnc.value, emissn.value, bool(visibl.value), bool(lit.value), )
[docs]@spice_error_check def illumg( method: str, target: str, ilusrc: str, et: float, fixref: str, abcorr: str, obsrvr: str, spoint: ndarray, ) -> Tuple[float, ndarray, float, float, float]: """ Find the illumination angles (phase, incidence, and emission) at a specified surface point of a target body. The surface of the target body may be represented by a triaxial ellipsoid or by topographic data provided by DSK files. The illumination source is a specified ephemeris object. param method: Computation method. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/illumg_c.html :param method: Computation method. :param target: Name of target body. :param ilusrc: Name of illumination source. :param et: Epoch in ephemeris seconds past J2000. :param fixref: Body-fixed, body-centered target body frame. :param abcorr: Desired aberration correction. :param obsrvr: Name of observing body. :param spoint: Body-fixed coordinates of a target surface point. :return: Target surface point epoch, Vector from observer to target surface point, Phase angle at the surface point, Source incidence angle at the surface point, Emission angle at the surface point, """ method = stypes.string_to_char_p(method) target = stypes.string_to_char_p(target) ilusrc = stypes.string_to_char_p(ilusrc) et = ctypes.c_double(et) fixref = stypes.string_to_char_p(fixref) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) spoint = stypes.to_double_vector(spoint) trgepc = ctypes.c_double(0) srfvec = stypes.empty_double_vector(3) phase = ctypes.c_double(0) incdnc = ctypes.c_double(0) emissn = ctypes.c_double(0) libspice.illumg_c( method, target, ilusrc, et, fixref, abcorr, obsrvr, spoint, ctypes.byref(trgepc), srfvec, ctypes.byref(phase), ctypes.byref(incdnc), ctypes.byref(emissn), ) return ( trgepc.value, stypes.c_vector_to_python(srfvec), phase.value, incdnc.value, emissn.value, )
[docs]@spice_error_check def ilumin( method: str, target: str, et: float, fixref: str, abcorr: str, obsrvr: str, spoint: ndarray, ) -> Tuple[float, ndarray, float, float, float]: """ Find the illumination angles (phase, solar incidence, and emission) at a specified surface point of a target body. This routine supersedes illum. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ilumin_c.html :param method: Computation method. :param target: Name of target body. :param et: Epoch in ephemeris seconds past J2000. :param fixref: Body-fixed, body-centered target body frame. :param abcorr: Desired aberration correction. :param obsrvr: Name of observing body. :param spoint: Body-fixed coordinates of a target surface point. :return: Target surface point epoch, Vector from observer to target surface point, Phase angle, Solar incidence angle, and Emission angle at the surface point. """ method = stypes.string_to_char_p(method) target = stypes.string_to_char_p(target) et = ctypes.c_double(et) fixref = stypes.string_to_char_p(fixref) abcorr = stypes.string_to_char_p(abcorr) obsrvr = stypes.string_to_char_p(obsrvr) spoint = stypes.to_double_vector(spoint) trgepc = ctypes.c_double(0) srfvec = stypes.empty_double_vector(3) phase = ctypes.c_double(0) solar = ctypes.c_double(0) emissn = ctypes.c_double(0) libspice.ilumin_c( method, target, et, fixref, abcorr, obsrvr, spoint, ctypes.byref(trgepc), srfvec, ctypes.byref(phase), ctypes.byref(solar), ctypes.byref(emissn), ) return ( trgepc.value, stypes.c_vector_to_python(srfvec), phase.value, solar.value, emissn.value, )
[docs]@spice_error_check @spice_found_exception_thrower def inedpl(a: float, b: float, c: float, plane: Plane) -> Tuple[Ellipse, bool]: """ Find the intersection of a triaxial ellipsoid and a plane. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/inedpl_c.html :param a: Length of ellipsoid semi-axis lying on the x-axis. :param b: Length of ellipsoid semi-axis lying on the y-axis. :param c: Length of ellipsoid semi-axis lying on the z-axis. :param plane: Plane that intersects ellipsoid. :return: Intersection ellipse. """ assert isinstance(plane, stypes.Plane) ellipse = stypes.Ellipse() a = ctypes.c_double(a) b = ctypes.c_double(b) c = ctypes.c_double(c) found = ctypes.c_int() libspice.inedpl_c( a, b, c, ctypes.byref(plane), ctypes.byref(ellipse), ctypes.byref(found) ) return ellipse, bool(found.value)
[docs]@spice_error_check def inelpl(ellips: Ellipse, plane: Plane) -> Tuple[int, ndarray, ndarray]: """ Find the intersection of an ellipse and a plane. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/inelpl_c.html :param ellips: A SPICE ellipse. :param plane: A SPICE plane. :return: Number of intersection points of plane and ellipse, Point 1, Point 2. """ assert isinstance(plane, stypes.Plane) assert isinstance(ellips, stypes.Ellipse) nxpts = ctypes.c_int() xpt1 = stypes.empty_double_vector(3) xpt2 = stypes.empty_double_vector(3) libspice.inelpl_c( ctypes.byref(ellips), ctypes.byref(plane), ctypes.byref(nxpts), xpt1, xpt2 ) return nxpts.value, stypes.c_vector_to_python(xpt1), stypes.c_vector_to_python(xpt2)
[docs]@spice_error_check def inrypl( vertex: Iterable[Union[float, float]], direct: Iterable[Union[float, float]], plane: Plane, ) -> Tuple[int, ndarray]: """ Find the intersection of a ray and a plane. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/inrypl_c.html :param vertex: Vertex vector of ray. :param direct: Direction vector of ray. :param plane: A SPICE plane. :return: Number of intersection points of ray and plane, Intersection point, if nxpts == 1. """ assert isinstance(plane, stypes.Plane) vertex = stypes.to_double_vector(vertex) direct = stypes.to_double_vector(direct) nxpts = ctypes.c_int() xpt = stypes.empty_double_vector(3) libspice.inrypl_c(vertex, direct, ctypes.byref(plane), ctypes.byref(nxpts), xpt) return nxpts.value, stypes.c_vector_to_python(xpt)
[docs]@spice_error_check def insrtc(item: Union[str, Iterable[str]], inset: SpiceCell) -> None: """ Insert an item into a character set. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/insrtc_c.html :param item: Item to be inserted. :param inset: Insertion set. """ assert isinstance(inset, stypes.SpiceCell) if stypes.is_iterable(item): for c in item: libspice.insrtc_c(stypes.string_to_char_p(c), ctypes.byref(inset)) else: item = stypes.string_to_char_p(item) libspice.insrtc_c(item, ctypes.byref(inset))
[docs]@spice_error_check def insrtd(item: Union[float, Iterable[float]], inset: SpiceCell) -> None: """ Insert an item into a double precision set. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/insrtd_c.html :param item: Item to be inserted. :param inset: Insertion set. """ assert isinstance(inset, stypes.SpiceCell) if hasattr(item, "__iter__"): for d in item: libspice.insrtd_c(ctypes.c_double(d), ctypes.byref(inset)) else: item = ctypes.c_double(item) libspice.insrtd_c(item, ctypes.byref(inset))
[docs]@spice_error_check def insrti(item: Union[Iterable[int], int], inset: SpiceCell) -> None: """ Insert an item into an integer set. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/insrti_c.html :param item: Item to be inserted. :param inset: Insertion set. """ assert isinstance(inset, stypes.SpiceCell) if hasattr(item, "__iter__"): for i in item: libspice.insrti_c(ctypes.c_int(i), ctypes.byref(inset)) else: item = ctypes.c_int(item) libspice.insrti_c(item, ctypes.byref(inset))
[docs]@spice_error_check def inter(a: SpiceCell, b: SpiceCell) -> SpiceCell: """ Intersect two sets of any data type to form a third set. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/inter_c.html :param a: First input set. :param b: Second input set. :return: Intersection of a and b. """ assert isinstance(a, stypes.SpiceCell) assert isinstance(b, stypes.SpiceCell) assert a.dtype == b.dtype # Next line was redundant with [raise NotImpImplementedError] below # assert a.dtype == 0 or a.dtype == 1 or a.dtype == 2 if a.dtype == 0: c = stypes.SPICECHAR_CELL(max(a.size, b.size), max(a.length, b.length)) elif a.dtype == 1: c = stypes.SPICEDOUBLE_CELL(max(a.size, b.size)) elif a.dtype == 2: c = stypes.SPICEINT_CELL(max(a.size, b.size)) else: raise NotImplementedError libspice.inter_c(ctypes.byref(a), ctypes.byref(b), ctypes.byref(c)) return c
[docs]@spice_error_check def intmax() -> int: """ Return the value of the largest (positive) number representable in a int variable. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/intmax_c.html :return: The largest (positive) number representablein a Int variable. """ return libspice.intmax_c()
[docs]@spice_error_check def intmin() -> int: """ Return the value of the smallest (negative) number representable in a SpiceInt variable. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/intmin_c.html :return: The smallest (negative) number representablein a Int variable. """ return libspice.intmin_c()
[docs]@spice_error_check def invert(m: ndarray) -> ndarray: """ Generate the inverse of a 3x3 matrix. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/invert_c.html :param m: Matrix to be inverted. :return: Inverted matrix (m1)^-1 """ m = stypes.to_double_matrix(m) mout = stypes.empty_double_matrix() libspice.invert_c(m, mout) return stypes.c_matrix_to_numpy(mout)
[docs]@spice_error_check def invort(m: ndarray) -> ndarray: """ Given a matrix, construct the matrix whose rows are the columns of the first divided by the length squared of the the corresponding columns of the input matrix. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/invort_c.html :param m: A 3x3 Matrix. :return: m after transposition and scaling of rows. """ m = stypes.to_double_matrix(m) mout = stypes.empty_double_matrix() libspice.invort_c(m, mout) return stypes.c_matrix_to_numpy(mout)
[docs]@spice_error_check def irfnam(index: int) -> str: """ Return the name of one of the standard inertial reference frames supported by :func:`irfrot` https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/irfnam.html :param index: Index of a standard inertial reference frame. :return: is the name of the frame. """ index = ctypes.c_int(index) name = stypes.string_to_char_p(16) # just give enough space name_len = ctypes.c_int(16) libspice.irfnam_(ctypes.byref(index), name, name_len) return stypes.to_python_string(name)
[docs]@spice_error_check def irfnum(name: str) -> int: """ Return the index of one of the standard inertial reference frames supported by :func:`irfrot` https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/irfnum.html :param name: Name of standard inertial reference frame. :return: is the index of the frame. """ index = ctypes.c_int() name_len = ctypes.c_int(len(name)) name = stypes.string_to_char_p(name) libspice.irfnum_(name, ctypes.byref(index), name_len) return index.value
[docs]@spice_error_check def irfrot(refa: int, refb: int) -> ndarray: """ Compute the matrix needed to rotate vectors between two standard inertial reference frames. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/irfrot.html :param refa: index of first reference frame. :param refb: index of second reference frame. :return: rotation from frame A to frame B. """ refa = ctypes.c_int(refa) refb = ctypes.c_int(refb) rotab = stypes.empty_double_matrix() libspice.irfrot_(ctypes.byref(refa), ctypes.byref(refb), rotab) # make sure to transpose to get back into c order from fortran ordering return stypes.c_matrix_to_numpy(rotab).T
[docs]@spice_error_check def irftrn(refa: str, refb: str) -> ndarray: """ Return the matrix that transforms vectors from one specified inertial reference frame to another. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/irftrn.html :param refa: Name of reference frame to transform vectors FROM. :param refb: Name of reference frame to transform vectors TO. :return: REFA-to-REFB transformation matrix. """ len_a = ctypes.c_int(len(refa)) len_b = ctypes.c_int(len(refb)) refa = stypes.string_to_char_p(refa) refb = stypes.string_to_char_p(refb) rotab = stypes.empty_double_matrix() libspice.irftrn_(refa, refb, rotab, len_a, len_b) # make sure to transpose to get back into c order from fortran ordering return stypes.c_matrix_to_numpy(rotab).T
[docs]@spice_error_check def isordv(array: Union[ndarray, Iterable[int]], n: int) -> bool: """ Determine whether an array of n items contains the integers 0 through n-1. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/isordv_c.html :param array: Array of integers. :param n: Number of integers in array. :return: The function returns True if the array contains the integers 0 through n-1, otherwise it returns False. """ array = stypes.to_int_vector(array) n = ctypes.c_int(n) return bool(libspice.isordv_c(array, n))
[docs]@spice_error_check def isrchc(value: str, ndim: int, lenvals: int, array: Iterable[str]) -> int: """ Search for a given value within a character string array. Return the index of the first matching array entry, or -1 if the key value was not found. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/isrchc_c.html :param value: Key value to be found in array. :param ndim: Dimension of array. :param lenvals: String length. :param array: Character string array to search. :return: The index of the first matching array element or -1 if the value is not found. """ value = stypes.string_to_char_p(value) array = stypes.list_to_char_array_ptr(array, x_len=lenvals, y_len=ndim) ndim = ctypes.c_int(ndim) lenvals = ctypes.c_int(lenvals) return libspice.isrchc_c(value, ndim, lenvals, array)
[docs]@spice_error_check def isrchd(value: float, ndim: int, array: Union[ndarray, Iterable[float]]) -> int: """ Search for a given value within a double precision array. Return the index of the first matching array entry, or -1 if the key value was not found. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/isrchd_c.html :param value: Key value to be found in array. :param ndim: Dimension of array. :param array: Double Precision array to search. :return: The index of the first matching array element or -1 if the value is not found. """ value = ctypes.c_double(value) ndim = ctypes.c_int(ndim) array = stypes.to_double_vector(array) return libspice.isrchd_c(value, ndim, array)
[docs]@spice_error_check def isrchi(value: int, ndim: int, array: Union[ndarray, Iterable[int]]) -> int: """ Search for a given value within an integer array. Return the index of the first matching array entry, or -1 if the key value was not found. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/isrchi_c.html :param value: Key value to be found in array. :param ndim: Dimension of array. :param array: Integer array to search. :return: The index of the first matching array element or -1 if the value is not found. """ value = ctypes.c_int(value) ndim = ctypes.c_int(ndim) array = stypes.to_int_vector(array) return libspice.isrchi_c(value, ndim, array)
[docs]@spice_error_check def isrot(m: ndarray, ntol: float, dtol: float) -> bool: """ Indicate whether a 3x3 matrix is a rotation matrix. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/isrot_c.html :param m: A matrix to be tested. :param ntol: Tolerance for the norms of the columns of m. :param dtol: Tolerance for the determinant of a matrix whose columns are the unitized columns of m. :return: True if and only if m is a rotation matrix. """ m = stypes.to_double_matrix(m) ntol = ctypes.c_double(ntol) dtol = ctypes.c_double(dtol) return bool(libspice.isrot_c(m, ntol, dtol))
[docs]@spice_error_check def iswhsp(string: str) -> bool: """ Return a boolean value indicating whether a string contains only white space characters. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/iswhsp_c.html :param string: String to be tested. :return: the boolean value True if the string is empty or contains only white space characters; otherwise it returns the value False. """ string = stypes.string_to_char_p(string) return bool(libspice.iswhsp_c(string))
################################################################################ # J
[docs]@spice_error_check def j1900() -> float: """ https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/j1900_c.html :return: Julian Date of 1899 DEC 31 12:00:00 """ return libspice.j1900_c()
[docs]@spice_error_check def j1950() -> float: """ https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/j1950_c.html :return: Julian Date of 1950 JAN 01 00:00:00 """ return libspice.j1950_c()
[docs]@spice_error_check def j2000() -> float: """ https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/j2000_c.html :return: Julian Date of 2000 JAN 01 12:00:00 """ return libspice.j2000_c()
[docs]@spice_error_check def j2100() -> float: """ https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/j2100_c.html :return: Julian Date of 2100 JAN 01 12:00:00 """ return libspice.j2100_c()
[docs]@spice_error_check def jyear() -> float: """ https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/jyear_c.html :return: number of seconds in a julian year """ return libspice.jyear_c()
################################################################################ # K
[docs]@spice_error_check def kclear() -> None: """ Clear the KEEPER subsystem: unload all kernels, clear the kernel pool, and re-initialize the subsystem. Existing watches on kernel variables are retained. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/kclear_c.html """ libspice.kclear_c()
[docs]@spice_error_check @spice_found_exception_thrower def kdata( which: int, kind: str, fillen: int = _default_len_out, typlen: int = _default_len_out, srclen: int = _default_len_out, ) -> Tuple[str, str, str, int, bool]: """ Return data for the nth kernel that is among a list of specified kernel types. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/kdata_c.html :param which: Index of kernel to fetch from the list of kernels. :param kind: The kind of kernel to which fetches are limited. :param fillen: Available space in output file string. :param typlen: Available space in output kernel type string. :param srclen: Available space in output source string. :return: The name of the kernel file, The type of the kernel, Name of the source file used to load file, The handle attached to file. """ which = ctypes.c_int(which) kind = stypes.string_to_char_p(kind) fillen = ctypes.c_int(fillen) typlen = ctypes.c_int(typlen) srclen = ctypes.c_int(srclen) file = stypes.string_to_char_p(fillen) filtyp = stypes.string_to_char_p(typlen) source = stypes.string_to_char_p(srclen) handle = ctypes.c_int() found = ctypes.c_int() libspice.kdata_c( which, kind, fillen, typlen, srclen, file, filtyp, source, ctypes.byref(handle), ctypes.byref(found), ) return ( stypes.to_python_string(file), stypes.to_python_string(filtyp), stypes.to_python_string(source), handle.value, bool(found.value), )
[docs]@spice_error_check def kepleq(ml: float, h: float, k: float) -> float: """ This function solves the equinoctial version of Kepler's equation. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/kepleq.html :param ml: Mean longitude :param h: h component of equinoctial elements :param k: k component of equinoctial elements :return: the value of F such that ML = F + h*COS(F) - k*SIN(F) """ ml = ctypes.c_double(ml) h = ctypes.c_double(h) k = ctypes.c_double(k) f = libspice.kepleq_(ctypes.byref(ml), ctypes.byref(h), ctypes.byref(k)) return f
[docs]@spice_error_check @spice_found_exception_thrower def kinfo( file: str, typlen: int = _default_len_out, srclen: int = _default_len_out ) -> Tuple[str, str, int, bool]: """ Return information about a loaded kernel specified by name. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/kinfo_c.html :param file: Name of a kernel to fetch information for :param typlen: Available space in output kernel type string. :param srclen: Available space in output source string. :return: The type of the kernel, Name of the source file used to load file, The handle attached to file. """ typlen = ctypes.c_int(typlen) srclen = ctypes.c_int(srclen) file = stypes.string_to_char_p(file) filtyp = stypes.string_to_char_p(" " * typlen.value) source = stypes.string_to_char_p(" " * srclen.value) handle = ctypes.c_int() found = ctypes.c_int() libspice.kinfo_c( file, typlen, srclen, filtyp, source, ctypes.byref(handle), ctypes.byref(found) ) return ( stypes.to_python_string(filtyp), stypes.to_python_string(source), handle.value, bool(found.value), )
[docs]@spice_error_check def kplfrm(frmcls: int, out_cell: Optional[SpiceCell] = None) -> SpiceCell: """ Return a SPICE set containing the frame IDs of all reference frames of a given class having specifications in the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/kplfrm_c.html :param frmcls: Frame class. :param out_cell: Optional output Spice Int Cell :return: Set of ID codes of frames of the specified class. """ if not out_cell: out_cell = stypes.SPICEINT_CELL(1000) frmcls = ctypes.c_int(frmcls) libspice.kplfrm_c(frmcls, ctypes.byref(out_cell)) return out_cell
[docs]@spice_error_check def kpsolv(evec: Tuple[float, float]) -> float: """ This routine solves the equation X = < EVEC, U(X) > where U(X) is the unit vector [ Cos(X), SIN(X) ] and < , > denotes the two-dimensional dot product. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/kpsolv.html :param evec: A 2-vector whose magnitude is less than 1. :return: the value of X such that X = EVEC(1)COS(X) + EVEC(2)SIN(X). """ evec = stypes.to_double_vector(evec) x = libspice.kpsolv_(evec) return x
[docs]@spice_error_check def ktotal(kind: str) -> int: """ Return the current number of kernels that have been loaded via the KEEPER interface that are of a specified type. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ktotal_c.html :param kind: A list of kinds of kernels to count. :return: The number of kernels of type kind. """ kind = stypes.string_to_char_p(kind) count = ctypes.c_int() libspice.ktotal_c(kind, ctypes.byref(count)) return count.value
[docs]@spice_error_check @spice_found_exception_thrower def kxtrct( keywd: str, terms: Sequence[str], nterms: int, instring: str, termlen: int = _default_len_out, stringlen: int = _default_len_out, substrlen: int = _default_len_out, ) -> Tuple[str, str, bool]: """ Locate a keyword in a string and extract the substring from the beginning of the first word following the keyword to the beginning of the first subsequent recognized terminator of a list. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/kxtrct_c.html :param keywd: Word that marks the beginning of text of interest. :param terms: Set of words, any of which marks the end of text. :param nterms: Number of terms. :param instring: String containing a sequence of words. :param termlen: Length of strings in string array term. :param stringlen: Available space in argument string. :param substrlen: Available space in output substring. :return: String containing a sequence of words, String from end of keywd to beginning of first terms item found. """ assert nterms <= len(terms) # Python strings and string arrays => to C char pointers keywd = stypes.string_to_char_p(keywd) terms = stypes.list_to_char_array_ptr( [s[: termlen - 1] for s in terms[:nterms]], x_len=termlen, y_len=nterms ) instring = stypes.string_to_char_p(instring[: stringlen - 1], inlen=stringlen) substr = stypes.string_to_char_p(substrlen) # Python ints => to C ints termlen = ctypes.c_int(termlen) nterms = ctypes.c_int(nterms) stringlen = ctypes.c_int(stringlen) substrlen = ctypes.c_int(substrlen) found = ctypes.c_int() libspice.kxtrct_c( keywd, termlen, terms, nterms, stringlen, substrlen, instring, ctypes.byref(found), substr, ) return ( stypes.to_python_string(instring), stypes.to_python_string(substr), bool(found.value), )
################################################################################ # L
[docs]@spice_error_check def lastnb(string: str) -> int: """ Return the zero based index of the last non-blank character in a character string. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lastnb_c.html :param string: Input character string. :return: """ string = stypes.string_to_char_p(string) return libspice.lastnb_c(string)
[docs]@spice_error_check def latcyl(radius: float, lon: float, lat: float) -> Tuple[float, float, float]: """ Convert from latitudinal coordinates to cylindrical coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/latcyl_c.html :param radius: Distance of a point from the origin. :param lon: Angle of the point from the XZ plane in radians. :param lat: Angle of the point from the XY plane in radians. :return: (r, lonc, z) """ radius = ctypes.c_double(radius) lon = ctypes.c_double(lon) lat = ctypes.c_double(lat) r = ctypes.c_double() lonc = ctypes.c_double() z = ctypes.c_double() libspice.latcyl_c( radius, lon, lat, ctypes.byref(r), ctypes.byref(lonc), ctypes.byref(z) ) return r.value, lonc.value, z.value
[docs]@spice_error_check def latrec( radius: float, longitude: Union[float, float], latitude: Union[float, float] ) -> ndarray: """ Convert from latitudinal coordinates to rectangular coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/latrec_c.html :param radius: Distance of a point from the origin. :param longitude: Longitude of point in radians. :param latitude: Latitude of point in radians. :return: Rectangular coordinates of the point. """ radius = ctypes.c_double(radius) longitude = ctypes.c_double(longitude) latitude = ctypes.c_double(latitude) rectan = stypes.empty_double_vector(3) libspice.latrec_c(radius, longitude, latitude, rectan) return stypes.c_vector_to_python(rectan)
[docs]@spice_error_check def latsph(radius: float, lon: float, lat: float) -> Tuple[float, float, float]: """ Convert from latitudinal coordinates to spherical coordinates. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/latsph_c.html :param radius: Distance of a point from the origin. :param lon: Angle of the point from the XZ plane in radians. :param lat: Angle of the point from the XY plane in radians. :return: (rho colat, lons) """ radius = ctypes.c_double(radius) lon = ctypes.c_double(lon) lat = ctypes.c_double(lat) rho = ctypes.c_double() colat = ctypes.c_double() lons = ctypes.c_double() libspice.latsph_c( radius, lon, lat, ctypes.byref(rho), ctypes.byref(colat), ctypes.byref(lons) ) return rho.value, colat.value, lons.value
[docs]@spice_error_check def latsrf( method: str, target: str, et: float, fixref: str, lonlat: Sequence[Sequence[float]] ) -> ndarray: """ Map array of planetocentric longitude/latitude coordinate pairs to surface points on a specified target body. The surface of the target body may be represented by a triaxial ellipsoid or by topographic data provided by DSK files. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/latsrf_c.html :param method: Computation method. :param target: Name of target body. :param et: Epoch in TDB seconds past J2000 TDB. :param fixref: Body-fixed, body-centered target body frame. :param lonlat: Array of longitude/latitude coordinate pairs. :return: Array of surface points. """ method = stypes.string_to_char_p(method) target = stypes.string_to_char_p(target) et = ctypes.c_double(et) fixref = stypes.string_to_char_p(fixref) npts = ctypes.c_int(len(lonlat)) lonlat = stypes.to_double_matrix(lonlat) srfpts = stypes.empty_double_matrix(3, npts.value) libspice.latsrf_c(method, target, et, fixref, npts, lonlat, srfpts) return stypes.c_matrix_to_numpy(srfpts)
[docs]@spice_error_check def lcase(instr: str, lenout: int = _default_len_out) -> str: """ Convert the characters in a string to lowercase. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lcase_c.html :param instr: Input string. :param lenout: Maximum length of output string. :return: Output string, all lowercase. """ instr = stypes.string_to_char_p(instr) lenout = ctypes.c_int(lenout) outstr = stypes.string_to_char_p(lenout) libspice.lcase_c(instr, lenout, outstr) return stypes.to_python_string(outstr)
[docs]@spice_error_check def ldpool(filename: str) -> None: """ Load the variables contained in a NAIF ASCII kernel file into the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ldpool_c.html :param filename: Name of the kernel file. """ filename = stypes.string_to_char_p(filename) libspice.ldpool_c(filename)
[docs]@spice_error_check def limbpt( method: str, target: str, et: float, fixref: str, abcorr: str, corloc: str, obsrvr: str, refvec: Union[ndarray, Iterable[float]], rolstp: float, ncuts: int, schstp: float, soltol: float, maxn: int, ) -> Tuple[ndarray, ndarray, ndarray, ndarray]: """ Find limb points on a target body. The limb is the set of points of tangency on the target of rays emanating from the observer. The caller specifies half-planes bounded by the observer-target center vector in which to search for limb points. The surface of the target body may be represented either by a triaxial ellipsoid or by topographic data. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/limbpt_c.html :param method: Computation method. :param target: Name of target body. :param et: Epoch in ephemeris seconds past J2000 TDB. :param fixref: Body-fixed, body-centered target body frame. :param abcorr: Aberration correction. :param corloc: Aberration correction locus. :param obsrvr: Name of observing body. :param refvec: Reference vector for cutting half-planes. :param rolstp: Roll angular step for cutting half-planes. :param ncuts: Number of cutting half-planes. :param schstp: Angular step size for searching. :param soltol: Solution convergence tolerance. :param maxn: Maximum number of entries in output arrays. :return: Counts of limb points corresponding to cuts, Limb points, Times associated with limb points, Tangent vectors emanating from the observer """ method = stypes.string_to_char_p(method) target = stypes.string_to_char_p(target) et = ctypes.c_double(et) fixref = stypes.string_to_char_p(fixref) abcorr = stypes.string_to_char_p(abcorr) corloc = stypes.string_to_char_p(corloc) obsrvr = stypes.string_to_char_p(obsrvr) refvec = stypes.to_double_vector(refvec) rolstp = ctypes.c_double(rolstp) ncuts = ctypes.c_int(ncuts) schstp = ctypes.c_double(schstp) soltol = ctypes.c_double(soltol) maxn = ctypes.c_int(maxn) npts = stypes.empty_int_vector(maxn.value) points = stypes.empty_double_matrix(3, maxn.value) epochs = stypes.empty_double_vector(maxn) tangts = stypes.empty_double_matrix(3, maxn.value) libspice.limbpt_c( method, target, et, fixref, abcorr, corloc, obsrvr, refvec, rolstp, ncuts, schstp, soltol, maxn, npts, points, epochs, tangts, ) # Clip the empty elements out of returned results npts = stypes.c_vector_to_python(npts) valid_points = numpy.where(npts >= 1) return ( npts[valid_points], stypes.c_matrix_to_numpy(points)[valid_points], stypes.c_vector_to_python(epochs)[valid_points], stypes.c_matrix_to_numpy(tangts)[valid_points], )
[docs]@spice_error_check def lgrind( xvals: Sequence[float], yvals: Sequence[float], x: float ) -> Tuple[float, float]: """ Evaluate a Lagrange interpolating polynomial for a specified set of coordinate pairs, at a specified abscissa value. Return the value of both polynomial and derivative. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lgrind_c.html :param xvals: Abscissa values. :param yvals: Ordinate values. :param x: Point at which to interpolate the polynomial. :return: Polynomial value at x, Polynomial derivative at x. """ n = ctypes.c_int(len(xvals)) xvals = stypes.to_double_vector(xvals) yvals = stypes.to_double_vector(yvals) work = stypes.empty_double_vector(n.value * 2) x = ctypes.c_double(x) p = ctypes.c_double(0) dp = ctypes.c_double(0) libspice.lgrind_c(n, xvals, yvals, work, x, p, dp) return p.value, dp.value
[docs]@spice_error_check def lmpool(cvals: Union[ndarray, Iterable[str]]) -> None: """ Load the variables contained in an internal buffer into the kernel pool. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lmpool_c.html :param cvals: list of strings. """ lenvals = ctypes.c_int(len(max(cvals, key=len)) + 1) n = ctypes.c_int(len(cvals)) cvals = stypes.list_to_char_array_ptr(cvals, x_len=lenvals, y_len=n) libspice.lmpool_c(cvals, lenvals, n)
[docs]@spice_error_check def lparse(inlist: str, delim: str, nmax: int) -> Iterable[str]: """ Parse a list of items delimited by a single character. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lparse_c.html :param inlist: list of items delimited by delim. :param delim: Single character used to delimit items. :param nmax: Maximum number of items to return. :return: Items in the list, left justified. """ delim = stypes.string_to_char_p(delim) lenout = ctypes.c_int(len(inlist)) inlist = stypes.string_to_char_p(inlist) nmax = ctypes.c_int(nmax) items = stypes.empty_char_array(lenout, nmax) n = ctypes.c_int() libspice.lparse_c(inlist, delim, nmax, lenout, ctypes.byref(n), ctypes.byref(items)) return [stypes.to_python_string(x.value) for x in items[0 : n.value]]
[docs]@spice_error_check def lparsm( inlist: str, delims: str, nmax: int, lenout: Optional[int] = None ) -> Iterable[str]: """ Parse a list of items separated by multiple delimiters. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lparsm_c.html :param inlist: list of items delimited by delims. :param delims: Single characters which delimit items. :param nmax: Maximum number of items to return. :param lenout: Optional Length of strings in item array. :return: Items in the list, left justified. """ if lenout is None: lenout = ctypes.c_int(len(inlist) + 1) else: lenout = ctypes.c_int(lenout) inlist = stypes.string_to_char_p(inlist) delims = stypes.string_to_char_p(delims) items = stypes.empty_char_array(lenout.value, nmax) nmax = ctypes.c_int(nmax) n = ctypes.c_int() libspice.lparsm_c(inlist, delims, nmax, lenout, ctypes.byref(n), items) return [stypes.to_python_string(x.value) for x in items][0 : n.value]
[docs]@spice_error_check def lparss(inlist: str, delims: str, nmax: int = 20, length: int = 50) -> SpiceCell: """ Parse a list of items separated by multiple delimiters, placing the resulting items into a set. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lparss_c.html :param inlist: list of items delimited by delims. :param delims: Single characters which delimit items. :param nmax: Optional nmax of spice set. :param length: Optional length of strings in spice set :return: Set containing items in the list, left justified. """ inlist = stypes.string_to_char_p(inlist) delims = stypes.string_to_char_p(delims) return_set = stypes.SPICECHAR_CELL(nmax, length) libspice.lparss_c(inlist, delims, ctypes.byref(return_set)) return return_set
[docs]@spice_error_check def lspcn(body: str, et: float, abcorr: str) -> float: """ Compute L_s, the planetocentric longitude of the sun, as seen from a specified body. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lspcn_c.html :param body: Name of central body. :param et: Epoch in seconds past J2000 TDB. :param abcorr: Aberration correction. :return: planetocentric longitude of the sun """ body = stypes.string_to_char_p(body) et = ctypes.c_double(et) abcorr = stypes.string_to_char_p(abcorr) return libspice.lspcn_c(body, et, abcorr)
[docs]@spice_error_check def lstlec(string: str, n: int, lenvals: int, array: Iterable[str]) -> int: """ Given a character string and an ordered array of character strings, find the index of the largest array element less than or equal to the given string. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lstlec_c.html :param string: Upper bound value to search against. :param n: Number elements in array. :param lenvals: String length. :param array: Array of possible lower bounds. :return: index of the last element of array that is lexically less than or equal to string. """ string = stypes.string_to_char_p(string) array = stypes.list_to_char_array_ptr(array, x_len=lenvals, y_len=n) n = ctypes.c_int(n) lenvals = ctypes.c_int(lenvals) return libspice.lstlec_c(string, n, lenvals, array)
[docs]@spice_error_check def lstled(x: float, n: int, array: Union[ndarray, Iterable[float]]) -> int: """ Given a number x and an array of non-decreasing floats find the index of the largest array element less than or equal to x. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lstled_c.html :param x: Value to search against. :param n: Number elements in array. :param array: Array of possible lower bounds :return: index of the last element of array that is less than or equal to x. """ array = stypes.to_double_vector(array) x = ctypes.c_double(x) n = ctypes.c_int(n) return libspice.lstled_c(x, n, array)
[docs]@spice_error_check def lstlei(x: int, n: int, array: Union[ndarray, Iterable[int]]) -> int: """ Given a number x and an array of non-decreasing ints, find the index of the largest array element less than or equal to x. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lstlei_c.html :param x: Value to search against. :param n: Number elements in array. :param array: Array of possible lower bounds :return: index of the last element of array that is less than or equal to x. """ array = stypes.to_int_vector(array) x = ctypes.c_int(x) n = ctypes.c_int(n) return libspice.lstlei_c(x, n, array)
[docs]@spice_error_check def lstltc(string: str, n: int, lenvals: int, array: Iterable[str]) -> int: """ Given a character string and an ordered array of character strings, find the index of the largest array element less than the given string. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lstltc_c.html :param string: Upper bound value to search against. :param n: Number elements in array. :param lenvals: String length. :param array: Array of possible lower bounds :return: index of the last element of array that is lexically less than string. """ string = stypes.string_to_char_p(string) array = stypes.list_to_char_array_ptr(array, x_len=lenvals, y_len=n) n = ctypes.c_int(n) lenvals = ctypes.c_int(lenvals) return libspice.lstltc_c(string, n, lenvals, array)
[docs]@spice_error_check def lstltd(x: float, n: int, array: Union[ndarray, Iterable[float]]) -> int: """ Given a number x and an array of non-decreasing floats find the index of the largest array element less than x. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lstltd_c.html :param x: Value to search against :param n: Number elements in array :param array: Array of possible lower bounds :return: index of the last element of array that is less than x. """ array = stypes.to_double_vector(array) x = ctypes.c_double(x) n = ctypes.c_int(n) return libspice.lstltd_c(x, n, array)
[docs]@spice_error_check def lstlti(x: int, n: int, array: Union[ndarray, Iterable[int]]) -> int: """ Given a number x and an array of non-decreasing int, find the index of the largest array element less than x. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lstlti_c.html :param x: Value to search against :param n: Number elements in array :param array: Array of possible lower bounds :return: index of the last element of array that is less than x. """ array = stypes.to_int_vector(array) x = ctypes.c_int(x) n = ctypes.c_int(n) return libspice.lstlti_c(x, n, array)
[docs]@spice_error_check def ltime(etobs: float, obs: int, direct: str, targ: int) -> Tuple[float, float]: """ This routine computes the transmit (or receive) time of a signal at a specified target, given the receive (or transmit) time at a specified observer. The elapsed time between transmit and receive is also returned. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ltime_c.html :param etobs: Epoch of a signal at some observer :param obs: NAIF ID of some observer :param direct: Direction the signal travels ( "->" or "<-" ) :param targ: NAIF ID of the target object :return: epoch and time """ etobs = ctypes.c_double(etobs) obs = ctypes.c_int(obs) direct = stypes.string_to_char_p(direct) targ = ctypes.c_int(targ) ettarg = ctypes.c_double() elapsd = ctypes.c_double() libspice.ltime_c( etobs, obs, direct, targ, ctypes.byref(ettarg), ctypes.byref(elapsd) ) return ettarg.value, elapsd.value
[docs]@spice_error_check def lx4dec(string: str, first: int) -> Tuple[int, int]: """ Scan a string from a specified starting position for the end of a decimal number. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lx4dec_c.html :param string: Any character string. :param first: First character to scan from in string. :return: last and nchar """ string = stypes.string_to_char_p(string) first = ctypes.c_int(first) last = ctypes.c_int() nchar = ctypes.c_int() libspice.lx4dec_c(string, first, ctypes.byref(last), ctypes.byref(nchar)) return last.value, nchar.value
[docs]@spice_error_check def lx4num(string: str, first: int) -> Tuple[int, int]: """ Scan a string from a specified starting position for the end of a number. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lx4num_c.html :param string: Any character string. :param first: First character to scan from in string. :return: last and nchar """ string = stypes