curryer.spicierpy.ext ===================== .. py:module:: curryer.spicierpy.ext .. autoapi-nested-parse:: Extensions to SPICE and the wrapper SpiceyPy. @author: Brandon Stone Attributes ---------- .. autoapisummary:: curryer.spicierpy.ext.logger curryer.spicierpy.ext.POSITION_COLUMNS curryer.spicierpy.ext.VELOCITY_COLUMNS Classes ------- .. autoapisummary:: curryer.spicierpy.ext.load_kernel Functions --------- .. autoapisummary:: curryer.spicierpy.ext.object_frame curryer.spicierpy.ext.kernel_coverage curryer.spicierpy.ext.kernel_objects curryer.spicierpy.ext.infer_ids curryer.spicierpy.ext.instrument_boresight curryer.spicierpy.ext.brief curryer.spicierpy.ext.spice_error_to_val curryer.spicierpy.ext.query_ephemeris Module Contents --------------- .. py:data:: logger .. py:class:: load_kernel(kernels) SPICE Kernel Context Manager. .. py:attribute:: _loaded :value: [] .. py:method:: __enter__() .. py:method:: __exit__(exc_type, exc_val, exc_tb) .. py:method:: __del__() .. py:property:: loaded List of kernels that have been loaded. .. py:method:: _iter_load(kernels) Load multiple kernels. .. py:method:: load(kernel) Load a kernel file. .. py:method:: unload(kernel=None, clear=False) Unload a kernel file. .. py:function:: object_frame(obj_name, as_id=False) Retrieve frame name/id associated with an object name or id. :param obj_name: Object name or id to get the frame for. :type obj_name: str or int :param as_id: If True, change return to be the frame id instead of the name. :type as_id: bool, default=False :returns: **frame_name** -- Associated frame name, or id if `as_id=True`. :rtype: str or int .. py:function:: kernel_coverage(filename, body, as_segments=False, to_fmt='ugps') Determine the coverage window for an entire kernel file. :param filename: SPICE kernel file. :type filename: str or Path :param body: NAIF body code or name to check coverage of. A string is assumed to be a body name, while an int is assumed to be a body code. Note: Using a body name requires that the body definition is loaded into memory; integer codes will work regardless. :type body: int or str :param as_segments: Option to return the coverage of each segment. :type as_segments: bool :param to_fmt: Datetime format for the returned times. Default='ugps'. :type to_fmt: str, optional :returns: Start and stop coverage times in `to_fmt` or GPS microseconds. :rtype: tuple of two int or float or str .. rubric:: Notes Kernel dependencies of `filename` should be loaded prior to the function call (i.e., the spacecraft clock kernel (SCLK) for an attitude kernel (CK)). .. py:function:: kernel_objects(filename, as_id=False) Determine what objects (names or codes) are within a kernel file. :param filename: SPICE kernel file. :type filename: str :param as_id: If False (default) return the NAIF body names, otherwise return the body codes. Note: Using a body name requires that the body definition is loaded into memory; integer codes will work regardless. :type as_id: bool, optional :returns: Collection of NAIF body names (default) or codes found within the kernel file (`filename`). :rtype: tuple of str or tuple of ints .. py:function:: infer_ids(spacecraft_name, spacecraft_id, instruments=None, from_dsn=False, from_norad=False) Infer NAIF IDs based on the spacecraft ID. Useful when planning out the necessary IDs; not meant to reverse existing IDs since the following rules are not strictly enforced. :param spacecraft_name: Spacecraft or mission name. :type spacecraft_name: str :param spacecraft_id: Spacecraft ID; all other IDs are based on this. NOTE: It should be a negative number, unless `from_dsn` or `from_norad` is used. :type spacecraft_id: int :param instruments: One or more instrument names to create IDs for. :type instruments: str or list of str, optional :param from_dsn: Option to interpret `spacecraft_id` as a JPL Deep Space Network (DSN) ID. It will be converted to a SPICE-like spacecraft ID using the standard convention. :type from_dsn: bool, optional :param from_norad: Option to interpret `spacecraft_id` as a NORAD tracking ID. It will be converted to a SPICE-like spacecraft ID using the standard convention. :type from_norad: bool, optional :returns: Collection of the mission name and IDs (spacecraft, clock, ephemeris, attitude), and instrument names and IDs. :rtype: collections.dict .. py:function:: instrument_boresight(instrument, n_vectors=1, norm=False) Retrieve an instrument's boresight vector from the kernel pool. :param instrument: The instrument ID, name or object to retrieve the boresight of. :type instrument: str or int or sds_spice.spicierypy.obj.Instrument :param n_vectors: Number of vectors to retrieve. Default=1 :type n_vectors: int, optional :param norm: Option to return normalized vectors. Default=False :type norm: bool, optional :rtype: numpy.ndarray .. py:function:: brief(kernel_file, bin_=None) Brief summary of a kernel file. .. py:function:: spice_error_to_val(err_value=None, err_flag=None, pass_flag=None, disable=False) Wrapper to catch spice errors and convert them to non-error values. :param err_value: Value to return when a SPICE error is encountered (e.g. nans). :type err_value: any :param err_flag: Value to return with the `err_value` to indicate that an error had occurred. Can be a callable, excepting the error object. :type err_flag: any :param pass_flag: Value to return with the function's return to indicate that no error had occurred. Can be a callable, excepting the output value. :type pass_flag: any :param disable: Option to disable to the error handling. :type disable: bool :returns: * *any* -- Return from the wrapped function if no error was encountered, otherwise the err_value. * *any* -- Flag indicating if an error occurred (`err_flag`) or not (`pass_flag`). .. py:data:: POSITION_COLUMNS :value: ('x', 'y', 'z') .. py:data:: VELOCITY_COLUMNS :value: ('vx', 'vy', 'vz') .. py:function:: query_ephemeris(ugps_times, target, observer, ref_frame='J2000', correction=None, velocity=False, allow_nans=False) Query SPICE ephemeris data from pre-loaded kernels. :param ugps_times: One or more UGPS times to query data for. :type ugps_times: list of int :param target: Name or ID of the target object. :type target: str or int or Body :param observer: Name or ID of the observing object. :type observer: str or int or Body :param ref_frame: Reference frame of the ephemeris data. Default="J2000" :type ref_frame: str or Frame, optional :param correction: SPICE correction to apply to the data (e.g., "LT"). Default=None :type correction: str, optional :param velocity: Query position and velocity. Default is position only. Note that velocity requires angular velocity in all connected CK kernels. :type velocity: bool, optional :param allow_nans: Allow setting NaNs for times when insufficient SPICE kernel data would otherwise raise an exception. Note: Setting this flag significantly impacts read performance. Default=False. :type allow_nans: bool, optional :rtype: pd.DataFrame