diff --git a/.pep8speaks.yml b/.pep8speaks.yml new file mode 100644 index 00000000..761af4ee --- /dev/null +++ b/.pep8speaks.yml @@ -0,0 +1,12 @@ +scanner: + diff_only: False + +pycodestyle: + max-line-length: 88 + ignore: + - E203 + - W503 + +no_blank_comment: False +descending_issues_order: True +only_mention_files_with_errors: False diff --git a/docs/conf.py b/docs/conf.py index 43ca28f7..48134ac8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,186 +16,187 @@ import sys import os +# EXTRA BITS FOR SPICEYPY +from unittest.mock import MagicMock + sys.setrecursionlimit(15000) # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) - +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.viewcode', + "sphinx.ext.autodoc", + "sphinx.ext.viewcode", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'SpiceyPy' -copyright = '2014-2019, Andrew Annex' +project = "SpiceyPy" +copyright = "2014-2019, Andrew Annex" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '2.3.1' +version = "2.3.1" # The full version, including alpha/beta/rc tags. -release = '2.3.1' +release = "2.3.1" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +html_theme = "default" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. html_short_title = "SpiceyPy Docs" # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". + html_static_path = [] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. -#html_extra_path = [] +# html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'SpiceyPydoc' +htmlhelp_basename = "SpiceyPydoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. # 'preamble': '\setcounter{tocdepth}{2000}' } @@ -203,42 +204,38 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'SpiceyPy.tex', 'SpiceyPy Documentation', - 'Andrew Annex', 'manual'), + ("index", "SpiceyPy.tex", "SpiceyPy Documentation", "Andrew Annex", "manual"), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'spiceypy', 'SpiceyPy Documentation', - ['Andrew Annex'], 1) -] +man_pages = [("index", "spiceypy", "SpiceyPy Documentation", ["Andrew Annex"], 1)] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------- @@ -247,90 +244,95 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'spiceypy', 'SpiceyPy Documentation', - 'Andrew Annex', 'SpiceyPy', - 'The NASA JPL NAIF SPICE toolkit wrapper written in Python.', - 'Miscellaneous'), + ( + "index", + "spiceypy", + "SpiceyPy Documentation", + "Andrew Annex", + "SpiceyPy", + "The NASA JPL NAIF SPICE toolkit wrapper written in Python.", + "Miscellaneous", + ), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False # -- Options for Epub output ---------------------------------------------- # Bibliographic Dublin Core info. -epub_title = 'SpiceyPy' -epub_author = 'Andrew Annex' -epub_publisher = 'Andrew Annex' -epub_copyright = '2014-2019, Andrew Annex' +epub_title = "SpiceyPy" +epub_author = "Andrew Annex" +epub_publisher = "Andrew Annex" +epub_copyright = "2014-2019, Andrew Annex" # The basename for the epub file. It defaults to the project name. -#epub_basename = 'SpiceyPy' +# epub_basename = 'SpiceyPy' # The HTML theme for the epub output. Since the default themes are not optimized # for small screen space, using the same theme for HTML and epub output is # usually not wise. This defaults to 'epub', a theme designed to save visual # space. -#epub_theme = 'epub' +# epub_theme = 'epub' # The language of the text. It defaults to the language option # or en if the language is not set. -#epub_language = '' +# epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. -#epub_scheme = '' +# epub_scheme = '' # The unique identifier of the text. This can be a ISBN number # or the project homepage. -#epub_identifier = '' +# epub_identifier = '' # A unique identification for the text. -#epub_uid = '' +# epub_uid = '' # A tuple containing the cover image and cover page html template filenames. -#epub_cover = () +# epub_cover = () # A sequence of (type, uri, title) tuples for the guide element of content.opf. -#epub_guide = () +# epub_guide = () # HTML files that should be inserted before the pages created by sphinx. # The format is a list of tuples containing the path and title. -#epub_pre_files = [] +# epub_pre_files = [] # HTML files shat should be inserted after the pages created by sphinx. # The format is a list of tuples containing the path and title. -#epub_post_files = [] +# epub_post_files = [] # A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] +epub_exclude_files = ["search.html"] # The depth of the table of contents in toc.ncx. -#epub_tocdepth = 3 +# epub_tocdepth = 3 # Allow duplicate toc entries. -#epub_tocdup = True +# epub_tocdup = True # Choose between 'default' and 'includehidden'. -#epub_tocscope = 'default' +# epub_tocscope = 'default' # Fix unsupported image types using the PIL. -#epub_fix_images = False +# epub_fix_images = False # Scale large images. -#epub_max_image_width = 0 +# epub_max_image_width = 0 # How to display URL addresses: 'footnote', 'no', or 'inline'. -#epub_show_urls = 'inline' +# epub_show_urls = 'inline' # If false, no index is generated. -#epub_use_index = True +# epub_use_index = True diff --git a/docs/remote_sensing.rst b/docs/remote_sensing.rst index 5bb50dec..141bdbf7 100644 --- a/docs/remote_sensing.rst +++ b/docs/remote_sensing.rst @@ -446,9 +446,9 @@ Solutions and answers et = spiceypy.str2et( utctim ) File "/home/bsemenov/local/lib/python3.5/site-packages/spiceypy/spi ceypy.py", line 76, in with_errcheck - checkForSpiceError(f) + check_for_spice_error(f) File "/home/bsemenov/local/lib/python3.5/site-packages/spiceypy/spi - ceypy.py", line 59, in checkForSpiceError + ceypy.py", line 59, in check_for_spice_error raise stypes.SpiceyError(msg) spiceypy.utils.support_types.SpiceyError: ===================================================================== @@ -491,9 +491,9 @@ Solutions and answers sclkst = spiceypy.sce2s( SCLKID, et ) File "/home/bsemenov/local/lib/python3.5/site-packages/spiceypy/spi ceypy.py", line 76, in with_errcheck - checkForSpiceError(f) + check_for_spice_error(f) File "/home/bsemenov/local/lib/python3.5/site-packages/spiceypy/spi - ceypy.py", line 59, in checkForSpiceError + ceypy.py", line 59, in check_for_spice_error raise stypes.SpiceyError(msg) spiceypy.utils.support_types.SpiceyError: ===================================================================== @@ -897,9 +897,9 @@ Solutions and answers 'LT+S', 'CASSINI' ) File "/home/bsemenov/local/lib/python3.5/site-packages/spiceypy/spi ceypy.py", line 76, in with_errcheck - checkForSpiceError(f) + check_for_spice_error(f) File "/home/bsemenov/local/lib/python3.5/site-packages/spiceypy/spi - ceypy.py", line 59, in checkForSpiceError + ceypy.py", line 59, in check_for_spice_error raise stypes.SpiceyError(msg) spiceypy.utils.support_types.SpiceyError: ===================================================================== @@ -1462,9 +1462,9 @@ Solutions and answers pform = spiceypy.pxform( 'CASSINI_HGA', 'J2000', et ) File "/home/bsemenov/local/lib/python3.5/site-packages/spiceypy/spi ceypy.py", line 76, in with_errcheck - checkForSpiceError(f) + check_for_spice_error(f) File "/home/bsemenov/local/lib/python3.5/site-packages/spiceypy/spi - ceypy.py", line 59, in checkForSpiceError + ceypy.py", line 59, in check_for_spice_error raise stypes.SpiceyError(msg) spiceypy.utils.support_types.SpiceyError: ===================================================================== diff --git a/getspice.py b/getspice.py index 56b785f4..d84388ad 100644 --- a/getspice.py +++ b/getspice.py @@ -95,6 +95,7 @@ class GetCSPICE(object): :type: str """ + # This class variable will be used to store the CSPICE package in memory. _local = None @@ -102,18 +103,19 @@ class GetCSPICE(object): _dists = { # system arch distribution name extension # -------- ---------- ------------------------- --------- - ('Darwin', '32bit'): ('MacIntel_OSX_AppleC_32bit', 'tar.Z'), - ('Darwin', '64bit'): ('MacIntel_OSX_AppleC_64bit', 'tar.Z'), - ('cygwin', '32bit'): ('PC_Cygwin_GCC_32bit', 'tar.Z'), - ('cygwin', '64bit'): ('PC_Cygwin_GCC_64bit', 'tar.Z'), - ('FreeBSD', '32bit'): ('PC_Linux_GCC_32bit', 'tar.Z'), - ('FreeBSD', '64bit'): ('PC_Linux_GCC_64bit', 'tar.Z'), - ('Linux', '32bit'): ('PC_Linux_GCC_32bit', 'tar.Z'), - ('Linux', '64bit'): ('PC_Linux_GCC_64bit', 'tar.Z'), - ('Windows', '32bit'): ('PC_Windows_VisualC_32bit', 'zip'), - ('Windows', '64bit'): ('PC_Windows_VisualC_64bit', 'zip')} - - def __init__(self, version='N0066'): + ("Darwin", "32bit"): ("MacIntel_OSX_AppleC_32bit", "tar.Z"), + ("Darwin", "64bit"): ("MacIntel_OSX_AppleC_64bit", "tar.Z"), + ("cygwin", "32bit"): ("PC_Cygwin_GCC_32bit", "tar.Z"), + ("cygwin", "64bit"): ("PC_Cygwin_GCC_64bit", "tar.Z"), + ("FreeBSD", "32bit"): ("PC_Linux_GCC_32bit", "tar.Z"), + ("FreeBSD", "64bit"): ("PC_Linux_GCC_64bit", "tar.Z"), + ("Linux", "32bit"): ("PC_Linux_GCC_32bit", "tar.Z"), + ("Linux", "64bit"): ("PC_Linux_GCC_64bit", "tar.Z"), + ("Windows", "32bit"): ("PC_Windows_VisualC_32bit", "zip"), + ("Windows", "64bit"): ("PC_Windows_VisualC_64bit", "zip"), + } + + def __init__(self, version="N0066"): """Init method that uses either the default N0066 toolkit version token or a user provided one. """ @@ -122,30 +124,34 @@ def __init__(self, version='N0066'): # executes the script. distribution, self._ext = self._distribution_info() except KeyError: - print('SpiceyPy currently does not support your system.') + print("SpiceyPy currently does not support your system.") else: - cspice = 'cspice.{}'.format(self._ext) - self._rcspice = ('https://naif.jpl.nasa.gov/pub/naif/misc' - '/toolkit_{0}/C/{1}/packages' - '/{2}').format(version, distribution, cspice) + cspice = "cspice.{}".format(self._ext) + self._rcspice = ( + "https://naif.jpl.nasa.gov/pub/naif/misc" + "/toolkit_{0}/C/{1}/packages" + "/{2}" + ).format(version, distribution, cspice) # Setup the local directory (where the package will be downloaded) self._root = os.path.realpath(os.path.dirname(__file__)) # Download the file - print('Downloading CSPICE for {0}...'.format(distribution)) - attempts = 10 # Let's try a maximum of attempts for getting SPICE + print("Downloading CSPICE for {0}...".format(distribution)) + attempts = 10 # Let's try a maximum of attempts for getting SPICE while attempts: attempts -= 1 try: self._download() except RuntimeError as error: - print("Download failed with URLError: {0}, trying again after " - "15 seconds!".format(error)) + print( + "Download failed with URLError: {0}, trying again after " + "15 seconds!".format(error) + ) time.sleep(15) else: # Unpack the file - print('Unpacking... (this may take some time!)') + print("Unpacking... (this may take some time!)") self._unpack() # We are done. Let's return to the calling code. break @@ -164,18 +170,18 @@ def _distribution_info(self): to any of the supported SpiceyPy environments. """ - print('Gathering information...') + print("Gathering information...") system = platform.system() # Cygwin system is CYGWIN-NT-xxx. - system = 'cygwin' if 'CYGWIN' in system else system + system = "cygwin" if "CYGWIN" in system else system processor = platform.processor() - machine = '64bit' if sys.maxsize > 2 ** 32 else '32bit' + machine = "64bit" if sys.maxsize > 2 ** 32 else "32bit" - print('SYSTEM: ', system) - print('PROCESSOR:', processor) - print('MACHINE: ', machine) + print("SYSTEM: ", system) + print("PROCESSOR:", processor) + print("MACHINE: ", machine) return self._dists[(system, machine)] @@ -199,9 +205,10 @@ def _download(self): distribution package. """ # Use urllib3 (based on PyOpenSSL). - if ssl.OPENSSL_VERSION < 'OpenSSL 1.0.1g': + if ssl.OPENSSL_VERSION < "OpenSSL 1.0.1g": # Force urllib3 to use pyOpenSSL import urllib3.contrib.pyopenssl + urllib3.contrib.pyopenssl.inject_into_urllib3() import certifi @@ -211,24 +218,30 @@ def _download(self): # Search proxy in ENV variables proxies = {} for key, value in os.environ.items(): - if '_proxy' in key.lower(): - proxies[key.lower().replace('_proxy','')] = value + if "_proxy" in key.lower(): + proxies[key.lower().replace("_proxy", "")] = value # Create a ProolManager - if 'https' in proxies: - https = urllib3.ProxyManager(proxies['https'], - cert_reqs='CERT_REQUIRED', - ca_certs=certifi.where()) - elif 'http' in proxies: - https = urllib3.ProxyManager(proxies['http'], - cert_reqs='CERT_REQUIRED', - ca_certs=certifi.where()) + if "https" in proxies: + https = urllib3.ProxyManager( + proxies["https"], + cert_reqs="CERT_REQUIRED", + ca_certs=certifi.where(), + ) + elif "http" in proxies: + https = urllib3.ProxyManager( + proxies["http"], + cert_reqs="CERT_REQUIRED", + ca_certs=certifi.where(), + ) else: - https = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', - ca_certs=certifi.where()) + https = urllib3.PoolManager( + cert_reqs="CERT_REQUIRED", ca_certs=certifi.where() + ) # Send the request to get the CSPICE package. - response = https.request('GET', self._rcspice, - timeout=urllib3.Timeout(10)) + response = https.request( + "GET", self._rcspice, timeout=urllib3.Timeout(10) + ) except urllib3.exceptions.HTTPError as err: raise RuntimeError(err.message) @@ -251,11 +264,11 @@ def _unpack(self): Package could either be the zipfile.ZipFile class for Windows platforms or tarfile.TarFile for other platforms. """ - if self._ext == 'zip': - with ZipFile(self._local, 'r') as archive: + if self._ext == "zip": + with ZipFile(self._local, "r") as archive: archive.extractall(self._root) else: - cmd = 'gunzip | tar xC ' + self._root + cmd = "gunzip | tar xC " + self._root proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE) proc.stdin.write(self._local.read()) self._local.close() diff --git a/requirements.txt b/requirements.txt index c647a4c8..257f1a58 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ numpy>=1.17.0; python_version >= "3.5" numpy<=1.16.4; python_version < "3.5" +coverage<5.0 # fix for coveralls 1.9.2 and coverage <5 issue https://github.com/coveralls-clients/coveralls-python/issues/203 six>=1.9.0 pytest>=2.9.0 -coverage>=4.0 coveralls>=1.1 setuptools>=38.0.0 pandas>=0.24.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 56930676..96356ffe 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ import platform import shutil -__author__ = 'AndrewAnnex' +__author__ = "AndrewAnnex" # Get OS platform host_OS = platform.system() @@ -42,22 +42,34 @@ # Get current working directory root_dir = os.path.dirname(os.path.realpath(__file__)) # Make the directory path for cspice -cspice_dir = os.path.join(root_dir, 'cspice') +cspice_dir = os.path.join(root_dir, "cspice") # Make the directory path for cspice/lib -lib_dir = os.path.join(cspice_dir, 'lib') - -TEST_DEPENDENCIES = ['setuptools>=38.0.0','numpy<=1.16.4;python_version<"3.5"', 'numpy>=1.17.0;python_version>="3.5"', 'six>=1.9.0', 'pytest>=2.9.0', 'pandas>=0.24.0'] -DEPENDENCIES = ['setuptools>=38.0.0','numpy<=1.16.4;python_version<"3.5"', 'numpy>=1.17.0;python_version>="3.5"', 'six>=1.9.0', 'certifi>=2017.1.23'] -REQUIRES = ['numpy', 'six'] +lib_dir = os.path.join(cspice_dir, "lib") + +TEST_DEPENDENCIES = [ + "setuptools>=38.0.0", + 'numpy<=1.16.4;python_version<"3.5"', + 'numpy>=1.17.0;python_version>="3.5"', + "six>=1.9.0", + "pytest>=2.9.0", + "pandas>=0.24.0", +] +DEPENDENCIES = [ + "setuptools>=38.0.0", + 'numpy<=1.16.4;python_version<"3.5"', + 'numpy>=1.17.0;python_version>="3.5"', + "six>=1.9.0", + "certifi>=2017.1.23", +] +REQUIRES = ["numpy", "six"] # If we have an old version of OpenSSL, CSPICE will be downloaded # (if required) using urllib3. Extend the list of required packages. -if ssl.OPENSSL_VERSION < 'OpenSSL 1.0.1g': - DEPENDENCIES.extend(['urllib3[secure]>=1.22', 'pyOpenSSL>=17.3.0']) +if ssl.OPENSSL_VERSION < "OpenSSL 1.0.1g": + DEPENDENCIES.extend(["urllib3[secure]>=1.22", "pyOpenSSL>=17.3.0"]) class InstallCSpice(object): - @staticmethod def get_cspice(): if InstallCSpice.check_for_spice(): @@ -71,15 +83,18 @@ def get_cspice(): @staticmethod def check_for_spice(): - print('Checking the path', cspice_dir) + print("Checking the path", cspice_dir) if not os.path.exists(cspice_dir): import getspice - message = 'Unable to find CSPICE at {0}. Attempting to Download CSPICE For you:'.format(cspice_dir) + + message = "Unable to find CSPICE at {0}. Attempting to Download CSPICE For you:".format( + cspice_dir + ) print(message) # Download cspice using getspice.py - getspice.GetCSPICE(version='N0066') + getspice.GetCSPICE(version="N0066") if not os.path.exists(cspice_dir): - message = 'Unable to find CSPICE at {0}. Exiting'.format(cspice_dir) + message = "Unable to find CSPICE at {0}. Exiting".format(cspice_dir) sys.exit(message) return True return False @@ -87,31 +102,43 @@ def check_for_spice(): @staticmethod def unpack_cspice(): if is_unix: - cspice_lib = os.path.join(lib_dir, ("cspice.lib" if host_OS is "Windows" else "cspice.a")) - csupport_lib = os.path.join(lib_dir, ("csupport.lib" if host_OS is "Windows" else "csupport.a")) + cspice_lib = os.path.join( + lib_dir, ("cspice.lib" if host_OS is "Windows" else "cspice.a") + ) + csupport_lib = os.path.join( + lib_dir, ("csupport.lib" if host_OS is "Windows" else "csupport.a") + ) if os.path.exists(cspice_lib) and os.path.exists(csupport_lib): cwd = os.getcwd() try: os.chdir(lib_dir) if host_OS is "Windows": - raise BaseException("Windows is not supported in this build method") + raise BaseException( + "Windows is not supported in this build method" + ) elif is_unix: for lib in ["ar -x cspice.a", "ar -x csupport.a"]: unpack_lib_process = subprocess.Popen(lib, shell=True) process_status = os.waitpid(unpack_lib_process.pid, 0)[1] if process_status != 0: - raise BaseException('{0}'.format(process_status)) + raise BaseException("{0}".format(process_status)) else: raise BaseException("Unsupported OS: {0}".format(host_OS)) except BaseException as error: status = error.args - sys.exit('Error: cspice object file extraction failed with exit status: {0}'.format(status)) + sys.exit( + "Error: cspice object file extraction failed with exit status: {0}".format( + status + ) + ) finally: os.chdir(cwd) else: - error_Message = "Error, cannot find CSPICE " \ - "static libraries at {0}".format(lib_dir) + error_Message = ( + "Error, cannot find CSPICE " + "static libraries at {0}".format(lib_dir) + ) sys.exit(error_Message) @staticmethod @@ -123,16 +150,22 @@ def build_library(): try: os.chdir(lib_dir) # find a way to make this work via Extension and setuptools, not using popen. - build_lib = subprocess.Popen('gcc -shared -fPIC -lm *.o -o spice.so', shell=True) + build_lib = subprocess.Popen( + "gcc -shared -fPIC -lm *.o -o spice.so", shell=True + ) status = os.waitpid(build_lib.pid, 0)[1] if status != 0: - raise BaseException('{0}'.format(status)) - success = os.path.exists(os.path.join(os.getcwd(), 'spice.so')) + raise BaseException("{0}".format(status)) + success = os.path.exists(os.path.join(os.getcwd(), "spice.so")) if not success: raise BaseException("Did not find spice.so, build went badly.") except BaseException as errorInst: status = errorInst.args - sys.exit('Error: compilation of shared spice.so build exit status: {0}'.format(status)) + sys.exit( + "Error: compilation of shared spice.so build exit status: {0}".format( + status + ) + ) elif host_OS == "Windows": try: @@ -146,7 +179,7 @@ def build_library(): windows_build = subprocess.Popen("makeDynamicSpice.bat", shell=True) status = windows_build.wait() if status != 0: - raise BaseException('{0}'.format(status)) + raise BaseException("{0}".format(status)) except BaseException as error: sys.exit("Build failed with: {0}".format(error.args)) # Change back to the stored 'current working directory @@ -154,18 +187,18 @@ def build_library(): @staticmethod def move_to_root_directory(): - sharedlib = 'spice.so' if is_unix else 'cspice.dll' - destination = os.path.join(root_dir, 'spiceypy', 'utils', sharedlib) + sharedlib = "spice.so" if is_unix else "cspice.dll" + destination = os.path.join(root_dir, "spiceypy", "utils", sharedlib) if not os.path.isfile(destination): if is_unix: - target = os.path.join(cspice_dir, 'lib', sharedlib) + target = os.path.join(cspice_dir, "lib", sharedlib) else: - target = os.path.join(cspice_dir, 'src', 'cspice', sharedlib) + target = os.path.join(cspice_dir, "src", "cspice", sharedlib) print("Attempting to move: {0} to: {1}".format(target, destination)) try: os.rename(target, destination) except BaseException as e: - sys.exit('{0} file not found, what happend?: {1}'.format(sharedlib, e)) + sys.exit("{0} file not found, what happend?: {1}".format(sharedlib, e)) @staticmethod def cleanup(): @@ -189,7 +222,7 @@ def unix_method(): def windows_method(): if os.path.exists(os.path.join(cspice_dir, "lib", "cspice.dll")): print("Found pre-made cspice.dll, not building") - elif os.path.exists(os.path.join(root_dir, 'spiceypy', 'utils', 'cspice.dll')): + elif os.path.exists(os.path.join(root_dir, "spiceypy", "utils", "cspice.dll")): print("Found pre-made cspice.dll in spiceypy, not building") else: # Build the DLL @@ -201,6 +234,7 @@ def windows_method(): class SpiceyPyBinaryDistribution(Distribution): def is_pure(self): return False + def root_is_pure(self): return False @@ -214,6 +248,7 @@ def finalize_options(self): def run_tests(self): import pytest + errcode = pytest.main(self.test_args) sys.exit(errcode) @@ -232,9 +267,11 @@ def run(self): InstallCSpice.get_cspice() install.run(self) + class GetCSPICECommand(Command): """ Custom command to get the correct cspice and build the shared library for spiceypy """ - description = 'downloads cspice and builds the shared library' + + description = "downloads cspice and builds the shared library" user_options = [] def initialize_options(self): @@ -246,6 +283,7 @@ def finalize_options(self): def run(self): InstallCSpice.get_cspice() + class BuildPyCommand(build_py): """ Custom build command to ensure cspice is built and packaged """ @@ -254,19 +292,21 @@ def run(self): build_py.run(self) - -cmdclass = { 'install': InstallSpiceyPy, - 'test': PyTest, - 'build_py': BuildPyCommand, - 'get_cspice': GetCSPICECommand } +cmdclass = { + "install": InstallSpiceyPy, + "test": PyTest, + "build_py": BuildPyCommand, + "get_cspice": GetCSPICECommand, +} # https://stackoverflow.com/questions/45150304/how-to-force-a-python-wheel-to-be-platform-specific-when-building-it # http://lepture.com/en/2014/python-on-a-hard-wheel try: from wheel.bdist_wheel import bdist_wheel + print("Wheel is Present") - class _bdist_wheel(bdist_wheel): + class _bdist_wheel(bdist_wheel): def finalize_options(self): bdist_wheel.finalize_options(self) self.root_is_pure = False @@ -274,35 +314,34 @@ def finalize_options(self): def get_tag(self): # TODO: since I use six, in future consider replacing first two tags with py2.py3 and none tag = bdist_wheel.get_tag(self) - repl = 'macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64' - if 'macosx_10' in tag[2]: - tag = (tag[0], tag[1], repl) + repl = "macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64" + if "macosx_10" in tag[2]: + tag = (tag[0], tag[1], repl) return tag # add our override to the cmdclass dict so we can inject this behavior - cmdclass['bdist_wheel'] = _bdist_wheel + cmdclass["bdist_wheel"] = _bdist_wheel except ImportError: # we don't have wheel installed so there is nothing to change print("Wheel is not installed...") pass - -readme = open('README.rst', 'r') +readme = open("README.rst", "r") readmetext = readme.read() readme.close() setup( - name='spiceypy', - version='2.3.1', - license='MIT', - author='Andrew Annex', - author_email='ama6fy@virginia.edu', - description='A Python Wrapper for the NAIF CSPICE Toolkit', + name="spiceypy", + version="2.3.1", + license="MIT", + author="Andrew Annex", + author_email="ama6fy@virginia.edu", + description="A Python Wrapper for the NAIF CSPICE Toolkit", long_description=readmetext, - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4', - keywords=['spiceypy', 'spice', 'naif', 'jpl', 'space', 'geometry'], - url='https://github.com/AndrewAnnex/SpiceyPy', + python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", + keywords=["spiceypy", "spice", "naif", "jpl", "space", "geometry"], + url="https://github.com/AndrewAnnex/SpiceyPy", classifiers=[ "Development Status :: 5 - Production/Stable", "Natural Language :: English", @@ -316,18 +355,18 @@ def get_tag(self): "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX :: Linux", "Operating System :: POSIX :: BSD :: FreeBSD", - "Operating System :: Microsoft :: Windows" + "Operating System :: Microsoft :: Windows", ], - packages=['spiceypy', 'spiceypy.utils'], + packages=["spiceypy", "spiceypy.utils"], include_package_data=True, zip_safe=False, distclass=SpiceyPyBinaryDistribution, - package_data={'spiceypy': ['utils/*.so', "utils/*.dll"]}, + package_data={"spiceypy": ["utils/*.so", "utils/*.dll"]}, setup_requires=DEPENDENCIES, install_requires=DEPENDENCIES, requires=REQUIRES, tests_require=TEST_DEPENDENCIES, cmdclass=cmdclass, - test_suite='spiceypy.tests.test_wrapper.py', - extras_require={'testing': ['pytest']} + test_suite="spiceypy.tests.test_wrapper.py", + extras_require={"testing": ["pytest"]}, ) diff --git a/spiceypy/__init__.py b/spiceypy/__init__.py index 33c84ad7..66602fec 100644 --- a/spiceypy/__init__.py +++ b/spiceypy/__init__.py @@ -25,7 +25,7 @@ from .spiceypy import * from .utils import support_types -__author__ = 'AndrewAnnex' +__author__ = "AndrewAnnex" # Default setting for error reporting so that programs don't just exit out! erract("set", 10, "return") diff --git a/spiceypy/spiceypy.py b/spiceypy/spiceypy.py index 593998fb..6d512b6a 100644 --- a/spiceypy/spiceypy.py +++ b/spiceypy/spiceypy.py @@ -33,17 +33,17 @@ from contextlib import contextmanager from datetime import datetime - -__author__ = 'AndrewAnnex' +__author__ = "AndrewAnnex" ################################################################################ _default_len_out = 256 -_SPICE_EK_MAXQSEL = 100 # Twice the 50 in gcc-linux-64 -_SPICE_EK_EKRCEX_ROOM_DEFAULT = 100 # Enough? +_SPICE_EK_MAXQSEL = 100 # Twice the 50 in gcc-linux-64 +_SPICE_EK_EKRCEX_ROOM_DEFAULT = 100 # Enough? + -def checkForSpiceError(f): +def check_for_spice_error(f): """ Internal function to check :param f: @@ -55,13 +55,14 @@ def checkForSpiceError(f): "short": getmsg("SHORT", 26), "explain": getmsg("EXPLAIN", 100).strip(), "long": getmsg("LONG", 321).strip(), - "traceback": qcktrc(200)} + "traceback": qcktrc(200), + } msg = stypes.errorformat.format(**errorparts) reset() raise stypes.SpiceyError(msg) -def spiceErrorCheck(f): +def spice_error_check(f): """ Decorator for spiceypy hooking into spice error system. If an error is detected, an output similar to outmsg @@ -75,27 +76,36 @@ def spiceErrorCheck(f): def with_errcheck(*args, **kwargs): try: res = f(*args, **kwargs) - checkForSpiceError(f) + check_for_spice_error(f) return res - except: + except BaseException: raise return with_errcheck -def spiceFoundExceptionThrower(f): +def spice_found_exception_thrower(f): """ 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.SpiceyError("Spice returns not found for function: {}".format(f.__name__), found=found) - elif hasattr(found, '__iter__') and not all(found): - raise stypes.SpiceyError("Spice returns not found in a series of calls for function: {}".format(f.__name__), found=found) + raise stypes.SpiceyError( + "Spice returns not found for function: {}".format(f.__name__), + found=found, + ) + elif hasattr(found, "__iter__") and not all(found): + raise stypes.SpiceyError( + "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: @@ -194,18 +204,23 @@ def get_found_catch_state(): """ return config.catch_false_founds + def cell_double(cell_size): return stypes.SPICEDOUBLE_CELL(cell_size) + def cell_int(cell_size): return stypes.SPICEINT_CELL(cell_size) + def cell_char(cell_size, length): return stypes.SPICECHAR_CELL(cell_size, length) + def cell_bool(cell_size): return stypes.SPICEBOOL_CELL(cell_size) + def cell_time(cell_size): return stypes.SPICETIME_CELL(cell_size) @@ -213,7 +228,8 @@ def cell_time(cell_size): ################################################################################ # A -@spiceErrorCheck + +@spice_error_check def appndc(item, cell): """ Append an item to a character cell. @@ -226,15 +242,15 @@ def appndc(item, cell): :type cell: spiceypy.utils.support_types.SpiceCell """ assert isinstance(cell, stypes.SpiceCell) - if stypes.isiterable(item): + if stypes.is_iterable(item): for c in item: - libspice.appndc_c(stypes.stringToCharP(c), cell) + libspice.appndc_c(stypes.string_to_char_p(c), cell) else: - item = stypes.stringToCharP(item) + item = stypes.string_to_char_p(item) libspice.appndc_c(item, cell) -@spiceErrorCheck +@spice_error_check def appndd(item, cell): """ Append an item to a double precision cell. @@ -255,7 +271,7 @@ def appndd(item, cell): libspice.appndd_c(item, cell) -@spiceErrorCheck +@spice_error_check def appndi(item, cell): """ Append an item to an integer cell. @@ -276,7 +292,7 @@ def appndi(item, cell): libspice.appndi_c(item, cell) -@spiceErrorCheck +@spice_error_check def axisar(axis, angle): """ Construct a rotation matrix that rotates vectors by a specified @@ -284,24 +300,25 @@ def axisar(axis, angle): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/axisar_c.html - :param axis: Rotation axis. + :param axis: Rotation axis. :type axis: 3 Element vector (list, tuple, numpy array) - :param angle: Rotation angle, in radians. + :param angle: Rotation angle, in radians. :type angle: float :return: Rotation matrix corresponding to axis and angle. :rtype: numpy array ((3, 3)) """ - axis = stypes.toDoubleVector(axis) + axis = stypes.to_double_vector(axis) angle = ctypes.c_double(angle) - r = stypes.emptyDoubleMatrix() + r = stypes.empty_double_matrix() libspice.axisar_c(axis, angle, r) - return stypes.cMatrixToNumpy(r) + return stypes.c_matrix_to_numpy(r) ################################################################################ # B -@spiceErrorCheck + +@spice_error_check def b1900(): """ Return the Julian Date corresponding to Besselian Date 1900.0. @@ -314,7 +331,7 @@ def b1900(): return libspice.b1900_c() -@spiceErrorCheck +@spice_error_check def b1950(): """ Return the Julian Date corresponding to Besselian Date 1950.0. @@ -327,7 +344,7 @@ def b1950(): return libspice.b1950_c() -@spiceErrorCheck +@spice_error_check def badkpv(caller, name, comp, insize, divby, intype): """ Determine if a kernel pool variable is present and if so @@ -350,17 +367,17 @@ def badkpv(caller, name, comp, insize, divby, intype): :return: returns false if the kernel pool variable is OK. :rtype: bool """ - caller = stypes.stringToCharP(caller) - name = stypes.stringToCharP(name) - comp = stypes.stringToCharP(comp) + 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')) + intype = ctypes.c_char(intype.encode(encoding="UTF-8")) return bool(libspice.badkpv_c(caller, name, comp, insize, divby, intype)) -@spiceErrorCheck -def bltfrm(frmcls, outCell=None): +@spice_error_check +def bltfrm(frmcls, out_cell=None): """ Return a SPICE set containing the frame IDs of all built-in frames of a specified class. @@ -369,20 +386,20 @@ def bltfrm(frmcls, outCell=None): :param frmcls: Frame class. :type frmcls: int - :param outCell: Optional SpiceInt Cell that is returned - :type outCell: spiceypy.utils.support_types.SpiceCell + :param out_cell: Optional SpiceInt Cell that is returned + :type out_cell: spiceypy.utils.support_types.SpiceCell :return: Set of ID codes of frames of the specified class. :rtype: spiceypy.utils.support_types.SpiceCell """ frmcls = ctypes.c_int(frmcls) - if not outCell: - outCell = stypes.SPICEINT_CELL(1000) - libspice.bltfrm_c(frmcls, outCell) - return outCell + if not out_cell: + out_cell = stypes.SPICEINT_CELL(1000) + libspice.bltfrm_c(frmcls, out_cell) + return out_cell -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def bodc2n(code, lenout=_default_len_out): """ Translate the SPICE integer code of a body into a common name @@ -398,14 +415,14 @@ def bodc2n(code, lenout=_default_len_out): :rtype: str """ code = ctypes.c_int(code) - name = stypes.stringToCharP(" " * lenout) + 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.toPythonString(name), bool(found.value) + return stypes.to_python_string(name), bool(found.value) -@spiceErrorCheck +@spice_error_check def bodc2s(code, lenout=_default_len_out): """ Translate a body ID code to either the corresponding name or if no @@ -422,13 +439,13 @@ def bodc2s(code, lenout=_default_len_out): :rtype: str """ code = ctypes.c_int(code) - name = stypes.stringToCharP(" " * lenout) + name = stypes.string_to_char_p(" " * lenout) lenout = ctypes.c_int(lenout) libspice.bodc2s_c(code, lenout, name) - return stypes.toPythonString(name) + return stypes.to_python_string(name) -@spiceErrorCheck +@spice_error_check def boddef(name, code): """ Define a body name/ID code pair for later translation via @@ -441,12 +458,12 @@ def boddef(name, code): :param code: Integer code for that body. :type code: int """ - name = stypes.stringToCharP(name) + name = stypes.string_to_char_p(name) code = ctypes.c_int(code) libspice.boddef_c(name, code) -@spiceErrorCheck +@spice_error_check def bodfnd(body, item): """ Determine whether values exist for some item for any body @@ -462,12 +479,12 @@ def bodfnd(body, item): :rtype: bool """ body = ctypes.c_int(body) - item = stypes.stringToCharP(item) + item = stypes.string_to_char_p(item) return bool(libspice.bodfnd_c(body, item)) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def bodn2c(name): """ Translate the name of a body or object to the corresponding SPICE @@ -480,15 +497,15 @@ def bodn2c(name): :return: SPICE integer ID code for the named body. :rtype: int """ - name = stypes.stringToCharP(name) + 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) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def bods2c(name): """ Translate a string containing a body name or ID code to an integer code. @@ -500,14 +517,14 @@ def bods2c(name): :return: Integer ID code corresponding to name. :rtype: int """ - name = stypes.stringToCharP(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) -@spiceErrorCheck +@spice_error_check def bodvar(body, item, dim): """ Deprecated: This routine has been superseded by :func:`bodvcd` and @@ -531,13 +548,13 @@ def bodvar(body, item, dim): """ body = ctypes.c_int(body) dim = ctypes.c_int(dim) - item = stypes.stringToCharP(item) - values = stypes.emptyDoubleVector(dim.value) + 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.cVectorToPython(values) + return stypes.c_vector_to_python(values) -@spiceErrorCheck +@spice_error_check def bodvcd(bodyid, item, maxn): """ Fetch from the kernel pool the double precision values of an item @@ -558,15 +575,15 @@ def bodvcd(bodyid, item, maxn): :rtype: tuple """ bodyid = ctypes.c_int(bodyid) - item = stypes.stringToCharP(item) + item = stypes.string_to_char_p(item) dim = ctypes.c_int() - values = stypes.emptyDoubleVector(maxn) + 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.cVectorToPython(values) + return dim.value, stypes.c_vector_to_python(values) -@spiceErrorCheck +@spice_error_check def bodvrd(bodynm, item, maxn): """ Fetch from the kernel pool the double precision values @@ -585,16 +602,16 @@ def bodvrd(bodynm, item, maxn): :return: tuple of (dim, values) :rtype: tuple """ - bodynm = stypes.stringToCharP(bodynm) - item = stypes.stringToCharP(item) + bodynm = stypes.string_to_char_p(bodynm) + item = stypes.string_to_char_p(item) dim = ctypes.c_int() - values = stypes.emptyDoubleVector(maxn) + 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.cVectorToPython(values) + return dim.value, stypes.c_vector_to_python(values) -@spiceErrorCheck +@spice_error_check def brcktd(number, end1, end2): """ Bracket a number. That is, given a number and an acceptable @@ -619,7 +636,7 @@ def brcktd(number, end1, end2): return libspice.brcktd_c(number, end1, end2) -@spiceErrorCheck +@spice_error_check def brckti(number, end1, end2): """ Bracket a number. That is, given a number and an acceptable @@ -644,7 +661,7 @@ def brckti(number, end1, end2): return libspice.brckti_c(number, end1, end2) -@spiceErrorCheck +@spice_error_check def bschoc(value, ndim, lenvals, array, order): """ Do a binary search for a given value within a character string array, @@ -666,15 +683,15 @@ def bschoc(value, ndim, lenvals, array, order): :return: index :rtype: int """ - value = stypes.stringToCharP(value) + value = stypes.string_to_char_p(value) ndim = ctypes.c_int(ndim) lenvals = ctypes.c_int(lenvals) - array = stypes.listToCharArrayPtr(array, xLen=lenvals, yLen=ndim) - order = stypes.toIntVector(order) + 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) -@spiceErrorCheck +@spice_error_check def bschoi(value, ndim, array, order): """ Do a binary search for a given value within an integer array, @@ -696,12 +713,12 @@ def bschoi(value, ndim, array, order): """ value = ctypes.c_int(value) ndim = ctypes.c_int(ndim) - array = stypes.toIntVector(array) - order = stypes.toIntVector(order) + array = stypes.to_int_vector(array) + order = stypes.to_int_vector(order) return libspice.bschoi_c(value, ndim, array, order) -@spiceErrorCheck +@spice_error_check def bsrchc(value, ndim, lenvals, array): """ Do a binary earch for a given value within a character string array. @@ -721,14 +738,14 @@ def bsrchc(value, ndim, lenvals, array): :return: index :rtype: int """ - value = stypes.stringToCharP(value) + value = stypes.string_to_char_p(value) ndim = ctypes.c_int(ndim) lenvals = ctypes.c_int(lenvals) - array = stypes.listToCharArrayPtr(array, xLen=lenvals, yLen=ndim) + array = stypes.list_to_char_array_ptr(array, x_len=lenvals, y_len=ndim) return libspice.bsrchc_c(value, ndim, lenvals, array) -@spiceErrorCheck +@spice_error_check def bsrchd(value, ndim, array): """ Do a binary search for a key value within a double precision array, @@ -748,11 +765,11 @@ def bsrchd(value, ndim, array): """ value = ctypes.c_double(value) ndim = ctypes.c_int(ndim) - array = stypes.toDoubleVector(array) + array = stypes.to_double_vector(array) return libspice.bsrchd_c(value, ndim, array) -@spiceErrorCheck +@spice_error_check def bsrchi(value, ndim, array): """ Do a binary search for a key value within an integer array, @@ -772,14 +789,15 @@ def bsrchi(value, ndim, array): """ value = ctypes.c_int(value) ndim = ctypes.c_int(ndim) - array = stypes.toIntVector(array) + array = stypes.to_int_vector(array) return libspice.bsrchi_c(value, ndim, array) ################################################################################ # C -@spiceErrorCheck + +@spice_error_check def card(cell): """ Return the cardinality (current number of elements) in a @@ -795,8 +813,8 @@ def card(cell): return libspice.card_c(ctypes.byref(cell)) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def ccifrm(frclss, clssid, lenout=_default_len_out): """ Return the frame name, frame ID, and center associated with @@ -820,16 +838,27 @@ def ccifrm(frclss, clssid, lenout=_default_len_out): clssid = ctypes.c_int(clssid) lenout = ctypes.c_int(lenout) frcode = ctypes.c_int() - frname = stypes.stringToCharP(lenout) + 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.toPythonString( - frname), center.value, bool(found.value) - - -@spiceErrorCheck + 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), + ) + + +@spice_error_check def cgv2el(center, vec1, vec2): """ Form a SPICE ellipse from a center vector and two generating vectors. @@ -845,22 +874,23 @@ def cgv2el(center, vec1, vec2): :return: Ellipse :rtype: spiceypy.utils.support_types.Ellipse """ - center = stypes.toDoubleVector(center) - vec1 = stypes.toDoubleVector(vec1) - vec2 = stypes.toDoubleVector(vec2) + 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 -@spiceErrorCheck + +@spice_error_check def chbder(cp, degp, x2s, x, nderiv): """ 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. :type cp: Array of floats :param degp: Degree of polynomial. @@ -874,18 +904,18 @@ def chbder(cp, degp, x2s, x, nderiv): :return: Array of the derivatives of the polynomial :rtype: Array of floats """ - cp = stypes.toDoubleVector(cp) + cp = stypes.to_double_vector(cp) degp = ctypes.c_int(degp) - x2s = stypes.toDoubleVector(x2s) + x2s = stypes.to_double_vector(x2s) x = ctypes.c_double(x) - partdp = stypes.emptyDoubleVector(3*(nderiv+1)) - dpdxs = stypes.emptyDoubleVector(nderiv+1) + 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.cVectorToPython(dpdxs) + return stypes.c_vector_to_python(dpdxs) -@spiceErrorCheck +@spice_error_check def chkin(module): """ Inform the SPICE error handling mechanism of entry into a routine. @@ -895,11 +925,11 @@ def chkin(module): :param module: The name of the calling routine. :type module: str """ - module = stypes.stringToCharP(module) + module = stypes.string_to_char_p(module) libspice.chkin_c(module) -@spiceErrorCheck +@spice_error_check def chkout(module): """ Inform the SPICE error handling mechanism of exit from a routine. @@ -909,12 +939,12 @@ def chkout(module): :param module: The name of the calling routine. :type module: str """ - module = stypes.stringToCharP(module) + module = stypes.string_to_char_p(module) libspice.chkout_c(module) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def cidfrm(cent, lenout=_default_len_out): """ Retrieve frame ID code and name to associate with a frame center. @@ -933,14 +963,13 @@ def cidfrm(cent, lenout=_default_len_out): cent = ctypes.c_int(cent) lenout = ctypes.c_int(lenout) frcode = ctypes.c_int() - frname = stypes.stringToCharP(lenout) + 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.toPythonString(frname), bool(found.value) + libspice.cidfrm_c(cent, lenout, ctypes.byref(frcode), frname, ctypes.byref(found)) + return frcode.value, stypes.to_python_string(frname), bool(found.value) -@spiceErrorCheck +@spice_error_check def ckcls(handle): """ Close an open CK file. @@ -954,7 +983,7 @@ def ckcls(handle): libspice.ckcls_c(handle) -@spiceErrorCheck +@spice_error_check def ckcov(ck, idcode, needav, level, tol, timsys, cover=None): """ Find the coverage window for a specified object in a specified CK file. @@ -978,23 +1007,22 @@ def ckcov(ck, idcode, needav, level, tol, timsys, cover=None): :return: coverage window for a specified object in a specified CK file :rtype: spiceypy.utils.support_types.SpiceCell """ - ck = stypes.stringToCharP(ck) + ck = stypes.string_to_char_p(ck) idcode = ctypes.c_int(idcode) needav = ctypes.c_int(needav) - level = stypes.stringToCharP(level) + level = stypes.string_to_char_p(level) tol = ctypes.c_double(tol) - timsys = stypes.stringToCharP(timsys) + 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)) + libspice.ckcov_c(ck, idcode, needav, level, tol, timsys, ctypes.byref(cover)) return cover -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def ckfrot(inst, et): """ Find the rotation from a C-kernel Id to the native @@ -1011,15 +1039,21 @@ def ckfrot(inst, et): """ inst = ctypes.c_int(inst) et = ctypes.c_double(et) - rotate = stypes.emptyDoubleMatrix(x=3, y=3) + 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, ctypes.byref(ref), ctypes.byref(found)) - return stypes.cMatrixToNumpy(rotate), ref.value, bool(found.value) - - -@spiceErrorCheck -@spiceFoundExceptionThrower + 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) + + +@spice_error_check +@spice_found_exception_thrower def ckgp(inst, sclkdp, tol, ref): """ Get pointing (attitude) for a specified spacecraft clock time. @@ -1042,17 +1076,18 @@ def ckgp(inst, sclkdp, tol, ref): inst = ctypes.c_int(inst) sclkdp = ctypes.c_double(sclkdp) tol = ctypes.c_double(tol) - ref = stypes.stringToCharP(ref) - cmat = stypes.emptyDoubleMatrix() + 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.cMatrixToNumpy(cmat), clkout.value, bool(found.value) + 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) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def ckgpav(inst, sclkdp, tol, ref): """ Get pointing (attitude) and angular velocity @@ -1077,18 +1112,23 @@ def ckgpav(inst, sclkdp, tol, ref): inst = ctypes.c_int(inst) sclkdp = ctypes.c_double(sclkdp) tol = ctypes.c_double(tol) - ref = stypes.stringToCharP(ref) - cmat = stypes.emptyDoubleMatrix() - av = stypes.emptyDoubleVector(3) + 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.cMatrixToNumpy(cmat), stypes.cVectorToPython( - av), clkout.value, bool(found.value) - - -@spiceErrorCheck + 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), + ) + + +@spice_error_check def cklpf(filename): """ Load a CK pointing file for use by the CK readers. Return that @@ -1102,14 +1142,14 @@ def cklpf(filename): :return: Loaded file's handle. :rtype: int """ - filename = stypes.stringToCharP(filename) + filename = stypes.string_to_char_p(filename) handle = ctypes.c_int() libspice.cklpf_c(filename, ctypes.byref(handle)) return handle.value -@spiceErrorCheck -def ckobj(ck, outCell=None): +@spice_error_check +def ckobj(ck, out_cell=None): """ Find the set of ID codes of all objects in a specified CK file. @@ -1117,22 +1157,22 @@ def ckobj(ck, outCell=None): :param ck: Name of CK file. :type ck: str - :param outCell: Optional user provided Spice Int cell. - :type outCell: Optional spiceypy.utils.support_types.SpiceCell + :param out_cell: Optional user provided Spice Int cell. + :type out_cell: Optional spiceypy.utils.support_types.SpiceCell :return: Set of ID codes of objects in CK file. :rtype: spiceypy.utils.support_types.SpiceCell """ assert isinstance(ck, str) - ck = stypes.stringToCharP(ck) - if not outCell: - outCell = stypes.SPICEINT_CELL(1000) - assert isinstance(outCell, stypes.SpiceCell) - assert outCell.dtype == 2 - libspice.ckobj_c(ck, ctypes.byref(outCell)) - return outCell + 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 -@spiceErrorCheck +@spice_error_check def ckopn(filename, ifname, ncomch): """ Open a new CK file, returning the handle of the opened file. @@ -1148,15 +1188,15 @@ def ckopn(filename, ifname, ncomch): :return: The handle of the opened CK file. :rtype: int """ - filename = stypes.stringToCharP(filename) - ifname = stypes.stringToCharP(ifname) + 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 -@spiceErrorCheck +@spice_error_check def ckupf(handle): """ Unload a CK pointing file so that it will no longer be searched @@ -1171,9 +1211,8 @@ def ckupf(handle): libspice.ckupf_c(handle) -@spiceErrorCheck -def ckw01(handle, begtim, endtim, inst, ref, avflag, segid, nrec, sclkdp, quats, - avvs): +@spice_error_check +def ckw01(handle, begtim, endtim, inst, ref, avflag, segid, nrec, sclkdp, quats, avvs): """ Add a type 1 segment to a C-kernel. @@ -1206,20 +1245,22 @@ def ckw01(handle, begtim, endtim, inst, ref, avflag, segid, nrec, sclkdp, quats, begtim = ctypes.c_double(begtim) endtim = ctypes.c_double(endtim) inst = ctypes.c_int(inst) - ref = stypes.stringToCharP(ref) + ref = stypes.string_to_char_p(ref) avflag = ctypes.c_int(avflag) - segid = stypes.stringToCharP(segid) - sclkdp = stypes.toDoubleVector(sclkdp) - quats = stypes.toDoubleMatrix(quats) - avvs = stypes.toDoubleMatrix(avvs) + 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) + libspice.ckw01_c( + handle, begtim, endtim, inst, ref, avflag, segid, nrec, sclkdp, quats, avvs + ) -@spiceErrorCheck -def ckw02(handle, begtim, endtim, inst, ref, segid, nrec, start, stop, quats, - avvs, rates): +@spice_error_check +def ckw02( + handle, begtim, endtim, inst, ref, segid, nrec, start, stop, quats, avvs, rates +): """ Write a type 2 segment to a C-kernel. @@ -1254,21 +1295,35 @@ def ckw02(handle, begtim, endtim, inst, ref, segid, nrec, start, stop, quats, begtim = ctypes.c_double(begtim) endtim = ctypes.c_double(endtim) inst = ctypes.c_int(inst) - ref = stypes.stringToCharP(ref) - segid = stypes.stringToCharP(segid) - start = stypes.toDoubleVector(start) - stop = stypes.toDoubleVector(stop) - rates = stypes.toDoubleVector(rates) - quats = stypes.toDoubleMatrix(quats) - avvs = stypes.toDoubleMatrix(avvs) + 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) - - -@spiceErrorCheck -def ckw03(handle, begtim, endtim, inst, ref, avflag, segid, nrec, sclkdp, quats, - avvs, nints, starts): + libspice.ckw02_c( + handle, begtim, endtim, inst, ref, segid, nrec, start, stop, quats, avvs, rates + ) + + +@spice_error_check +def ckw03( + handle, + begtim, + endtim, + inst, + ref, + avflag, + segid, + nrec, + sclkdp, + quats, + avvs, + nints, + starts, +): """ Add a type 3 segment to a C-kernel. @@ -1305,22 +1360,49 @@ def ckw03(handle, begtim, endtim, inst, ref, avflag, segid, nrec, sclkdp, quats, begtim = ctypes.c_double(begtim) endtim = ctypes.c_double(endtim) inst = ctypes.c_int(inst) - ref = stypes.stringToCharP(ref) + ref = stypes.string_to_char_p(ref) avflag = ctypes.c_int(avflag) - segid = stypes.stringToCharP(segid) - sclkdp = stypes.toDoubleVector(sclkdp) - quats = stypes.toDoubleMatrix(quats) - avvs = stypes.toDoubleMatrix(avvs) + 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.toDoubleVector(starts) + 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) - - -@spiceErrorCheck -def ckw05(handle, subtype, degree, begtim, endtim, inst, ref, avflag, segid, - sclkdp, packts, rate, nints, starts): + libspice.ckw03_c( + handle, + begtim, + endtim, + inst, + ref, + avflag, + segid, + nrec, + sclkdp, + quats, + avvs, + nints, + starts, + ) + + +@spice_error_check +def ckw05( + handle, + subtype, + degree, + begtim, + endtim, + inst, + ref, + avflag, + segid, + sclkdp, + packts, + rate, + nints, + starts, +): """ Write a type 5 segment to a CK file. @@ -1355,30 +1437,45 @@ def ckw05(handle, subtype, degree, begtim, endtim, inst, ref, avflag, segid, :param starts: Encoded SCLK interval start times. :type starts: Array of floats """ - handle = ctypes.c_int(handle) + 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.stringToCharP(ref) - avflag = ctypes.c_int(avflag) - segid = stypes.stringToCharP(segid) - n = ctypes.c_int(len(packts)) - sclkdp = stypes.toDoubleVector(sclkdp) - packts = stypes.toDoubleMatrix(packts) - rate = ctypes.c_double(rate) - nints = ctypes.c_int(nints) - starts = stypes.toDoubleVector(starts) - libspice.ckw05_c(handle, subtype, degree, begtim, endtim, inst, ref, avflag, - segid, n, sclkdp, packts, rate, nints, starts) + 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, + ) def cleard(): raise NotImplementedError -@spiceErrorCheck +@spice_error_check def clight(): """ Return the speed of light in a vacuum (IAU official value, in km/sec). @@ -1391,7 +1488,7 @@ def clight(): return libspice.clight_c() -@spiceErrorCheck +@spice_error_check def clpool(): """ Remove all variables from the kernel pool. Watches @@ -1402,7 +1499,7 @@ def clpool(): libspice.clpool_c() -@spiceErrorCheck +@spice_error_check def cltext(fname): """ Internal undocumented command for closing a text file opened by RDTEXT. @@ -1427,12 +1524,12 @@ def cltext(fname): :param fname: Text file to be closed. :type fname: str """ - fnameP = stypes.stringToCharP(fname) + fname_p = stypes.string_to_char_p(fname) fname_len = ctypes.c_int(len(fname)) - libspice.cltext_(fnameP, fname_len) + libspice.cltext_(fname_p, fname_len) -@spiceErrorCheck +@spice_error_check def cmprss(delim, n, instr, lenout=_default_len_out): """ Compress a character string by removing occurrences of @@ -1452,16 +1549,16 @@ def cmprss(delim, n, instr, lenout=_default_len_out): :return: Compressed string. :rtype: str """ - delim = ctypes.c_char(delim.encode(encoding='UTF-8')) + delim = ctypes.c_char(delim.encode(encoding="UTF-8")) n = ctypes.c_int(n) - instr = stypes.stringToCharP(instr) - output = stypes.stringToCharP(lenout) + instr = stypes.string_to_char_p(instr) + output = stypes.string_to_char_p(lenout) libspice.cmprss_c(delim, n, instr, lenout, output) - return stypes.toPythonString(output) + return stypes.to_python_string(output) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def cnmfrm(cname, lenout=_default_len_out): """ Retrieve frame ID code and name to associate with an object. @@ -1478,16 +1575,15 @@ def cnmfrm(cname, lenout=_default_len_out): :rtype: tuple """ lenout = ctypes.c_int(lenout) - frname = stypes.stringToCharP(lenout) - cname = stypes.stringToCharP(cname) + 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.toPythonString(frname), bool(found.value) + libspice.cnmfrm_c(cname, lenout, ctypes.byref(frcode), frname, ctypes.byref(found)) + return frcode.value, stypes.to_python_string(frname), bool(found.value) -@spiceErrorCheck +@spice_error_check def conics(elts, et): """ Determine the state (position, velocity) of an orbiting body @@ -1503,14 +1599,14 @@ def conics(elts, et): :return: State of orbiting body at et. :rtype: 6-Element Array of floats """ - elts = stypes.toDoubleVector(elts) + elts = stypes.to_double_vector(elts) et = ctypes.c_double(et) - state = stypes.emptyDoubleVector(6) + state = stypes.empty_double_vector(6) libspice.conics_c(elts, et, state) - return stypes.cVectorToPython(state) + return stypes.c_vector_to_python(state) -@spiceErrorCheck +@spice_error_check def convrt(x, inunit, outunit): """ Take a measurement X, the units associated with @@ -1528,23 +1624,23 @@ def convrt(x, inunit, outunit): :return: The measurment in the desired units. :rtype: float """ - - inunit = stypes.stringToCharP(inunit) - outunit = stypes.stringToCharP(outunit) + + inunit = stypes.string_to_char_p(inunit) + outunit = stypes.string_to_char_p(outunit) y = ctypes.c_double() if hasattr(x, "__iter__"): - outArray=[] + out_array = [] for n in x: libspice.convrt_c(n, inunit, outunit, ctypes.byref(y)) - checkForSpiceError(None) - outArray.append(y.value) - return outArray + check_for_spice_error(None) + out_array.append(y.value) + return out_array x = ctypes.c_double(x) libspice.convrt_c(x, inunit, outunit, ctypes.byref(y)) return y.value -@spiceErrorCheck +@spice_error_check def copy(cell): """ Copy the contents of a SpiceCell of any data type to another @@ -1572,7 +1668,7 @@ def copy(cell): return newcopy -@spiceErrorCheck +@spice_error_check def cpos(string, chars, start): """ Find the first occurrence in a string of a character belonging @@ -1592,13 +1688,13 @@ def cpos(string, chars, start): following index start that is in the collection chars. :rtype: int """ - string = stypes.stringToCharP(string) - chars = stypes.stringToCharP(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) -@spiceErrorCheck +@spice_error_check def cposr(string, chars, start): """ Find the first occurrence in a string of a character belonging @@ -1618,13 +1714,13 @@ def cposr(string, chars, start): before index start that is in the collection chars. :rtype: int """ - string = stypes.stringToCharP(string) - chars = stypes.stringToCharP(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) -@spiceErrorCheck +@spice_error_check def cvpool(agent): """ Indicate whether or not any watched kernel variables that have a @@ -1637,13 +1733,13 @@ def cvpool(agent): :return: True if variables for "agent" have been updated. :rtype: bool """ - agent = stypes.stringToCharP(agent) + agent = stypes.string_to_char_p(agent) update = ctypes.c_int() libspice.cvpool_c(agent, ctypes.byref(update)) return bool(update.value) -@spiceErrorCheck +@spice_error_check def cyllat(r, lonc, z): """ Convert from cylindrical to latitudinal coordinates. @@ -1665,12 +1761,13 @@ def cyllat(r, lonc, 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)) + libspice.cyllat_c( + r, lonc, z, ctypes.byref(radius), ctypes.byref(lon), ctypes.byref(lat) + ) return radius.value, lon.value, lat.value -@spiceErrorCheck +@spice_error_check def cylrec(r, lon, z): """ Convert from cylindrical to rectangular coordinates. @@ -1689,12 +1786,12 @@ def cylrec(r, lon, z): r = ctypes.c_double(r) lon = ctypes.c_double(lon) z = ctypes.c_double(z) - rectan = stypes.emptyDoubleVector(3) + rectan = stypes.empty_double_vector(3) libspice.cylrec_c(r, lon, z, rectan) - return stypes.cVectorToPython(rectan) + return stypes.c_vector_to_python(rectan) -@spiceErrorCheck +@spice_error_check def cylsph(r, lonc, z): """ Convert from cylindrical to spherical coordinates. @@ -1719,15 +1816,17 @@ def cylsph(r, lonc, 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)) + libspice.cyllat_c( + r, lonc, z, ctypes.byref(radius), ctypes.byref(colat), ctypes.byref(lon) + ) return radius.value, colat.value, lon.value ################################################################################ # D -@spiceErrorCheck + +@spice_error_check def dafac(handle, buffer): """ Add comments from a buffer of character strings to the comment @@ -1741,14 +1840,14 @@ def dafac(handle, buffer): :param buffer: Buffer of comments to put into the comment area. :type buffer: list[str] """ - handle = ctypes.c_int(handle) + handle = ctypes.c_int(handle) lenvals = ctypes.c_int(len(max(buffer, key=len)) + 1) - n = ctypes.c_int(len(buffer)) - buffer = stypes.listToCharArrayPtr(buffer) + n = ctypes.c_int(len(buffer)) + buffer = stypes.list_to_char_array_ptr(buffer) libspice.dafac_c(handle, n, lenvals, buffer) -@spiceErrorCheck +@spice_error_check def dafbbs(handle): """ Begin a backward search for arrays in a DAF. @@ -1762,7 +1861,7 @@ def dafbbs(handle): libspice.dafbbs_c(handle) -@spiceErrorCheck +@spice_error_check def dafbfs(handle): """ Begin a forward search for arrays in a DAF. @@ -1776,7 +1875,7 @@ def dafbfs(handle): libspice.dafbfs_c(handle) -@spiceErrorCheck +@spice_error_check def dafcls(handle): """ Close the DAF associated with a given handle. @@ -1790,7 +1889,7 @@ def dafcls(handle): libspice.dafcls_c(handle) -@spiceErrorCheck +@spice_error_check def dafcs(handle): """ Select a DAF that already has a search in progress as the @@ -1805,7 +1904,7 @@ def dafcs(handle): libspice.dafcs_c(handle) -@spiceErrorCheck +@spice_error_check def dafdc(handle): """ Delete the entire comment area of a specified DAF file. @@ -1819,7 +1918,7 @@ def dafdc(handle): libspice.dafdc_c(handle) -@spiceErrorCheck +@spice_error_check def dafec(handle, bufsiz, lenout=_default_len_out): """ Extract comments from the comment area of a binary DAF. @@ -1839,17 +1938,23 @@ def dafec(handle, bufsiz, lenout=_default_len_out): :rtype: tuple """ handle = ctypes.c_int(handle) - buffer = stypes.emptyCharArray(yLen=bufsiz, xLen=lenout) + 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.cVectorToPython(buffer), bool(done.value) - - -@spiceErrorCheck + 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) + + +@spice_error_check def daffna(): """ Find the next (forward) array in the current DAF. @@ -1864,7 +1969,7 @@ def daffna(): return bool(found.value) -@spiceErrorCheck +@spice_error_check def daffpa(): """ Find the previous (backward) array in the current DAF. @@ -1879,7 +1984,7 @@ def daffpa(): return bool(found.value) -@spiceErrorCheck +@spice_error_check def dafgda(handle, begin, end): """ Read the double precision data bounded by two addresses within a DAF. @@ -1896,14 +2001,14 @@ def dafgda(handle, begin, end): :rtype: Array of floats """ handle = ctypes.c_int(handle) - data = stypes.emptyDoubleVector(abs(end - begin) + 1) + 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.cVectorToPython(data) + return stypes.c_vector_to_python(data) -@spiceErrorCheck +@spice_error_check def dafgh(): """ Return (get) the handle of the DAF currently being searched. @@ -1918,7 +2023,7 @@ def dafgh(): return outvalue.value -@spiceErrorCheck +@spice_error_check def dafgn(lenout=_default_len_out): """ Return (get) the name for the current array in the current DAF. @@ -1931,12 +2036,12 @@ def dafgn(lenout=_default_len_out): :rtype: str """ lenout = ctypes.c_int(lenout) - name = stypes.stringToCharP(lenout) + name = stypes.string_to_char_p(lenout) libspice.dafgn_c(lenout, name) - return stypes.toPythonString(name) + return stypes.to_python_string(name) -@spiceErrorCheck +@spice_error_check def dafgs(n=125): # The 125 may be a hard set, # I got strange errors that occasionally happened without it @@ -1949,14 +2054,14 @@ def dafgs(n=125): :return: Summary for current array. :rtype: Array of floats """ - retarray = stypes.emptyDoubleVector(125) + retarray = stypes.empty_double_vector(125) # libspice.dafgs_c(ctypes.cast(retarray, ctypes.POINTER(ctypes.c_double))) libspice.dafgs_c(retarray) - return stypes.cVectorToPython(retarray)[0:n] + return stypes.c_vector_to_python(retarray)[0:n] -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def dafgsr(handle, recno, begin, end): """ Read a portion of the contents of (words in) a summary record in a DAF file. @@ -1979,13 +2084,13 @@ def dafgsr(handle, recno, begin, end): begin = ctypes.c_int(begin) end = ctypes.c_int(end) # dafgsr_c will retrieve no more than 128 words - data = stypes.emptyDoubleVector(1 + min([128,end.value]) - max([begin.value,1])) + 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.cVectorToPython(data), bool(found.value) + return stypes.c_vector_to_python(data), bool(found.value) -@spiceErrorCheck +@spice_error_check def dafopr(fname): """ Open a DAF for subsequent read requests. @@ -1997,13 +2102,13 @@ def dafopr(fname): :return: Handle assigned to DAF. :rtype: int """ - fname = stypes.stringToCharP(fname) + fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.dafopr_c(fname, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def dafopw(fname): """ Open a DAF for subsequent write requests. @@ -2015,13 +2120,13 @@ def dafopw(fname): :return: Handle assigned to DAF. :rtype: int """ - fname = stypes.stringToCharP(fname) + fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.dafopw_c(fname, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def dafps(nd, ni, dc, ic): """ Pack (assemble) an array summary from its double precision and @@ -2040,16 +2145,16 @@ def dafps(nd, ni, dc, ic): :return: Array summary. :rtype: Array of floats """ - dc = stypes.toDoubleVector(dc) - ic = stypes.toIntVector(ic) - outsum = stypes.emptyDoubleVector(nd + ni) + 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.cVectorToPython(outsum) + return stypes.c_vector_to_python(outsum) -@spiceErrorCheck +@spice_error_check def dafrda(handle, begin, end): """ Read the double precision data bounded by two addresses within a DAF. @@ -2072,12 +2177,12 @@ def dafrda(handle, begin, end): handle = ctypes.c_int(handle) begin = ctypes.c_int(begin) end = ctypes.c_int(end) - data = stypes.emptyDoubleVector(1 + end.value - begin.value) + data = stypes.empty_double_vector(1 + end.value - begin.value) libspice.dafrda_c(handle, begin, end, data) - return stypes.cVectorToPython(data) + return stypes.c_vector_to_python(data) -@spiceErrorCheck +@spice_error_check def dafrfr(handle, lenout=_default_len_out): """ Read the contents of the file record of a DAF. @@ -2100,18 +2205,31 @@ def dafrfr(handle, lenout=_default_len_out): lenout = ctypes.c_int(lenout) nd = ctypes.c_int() ni = ctypes.c_int() - ifname = stypes.stringToCharP(lenout) + 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.toPythonString( - ifname), fward.value, bward.value, free.value - - -@spiceErrorCheck + 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, + ) + + +@spice_error_check def dafrs(insum): """ Change the summary for the current array in the current DAF. @@ -2121,11 +2239,11 @@ def dafrs(insum): :param insum: New summary for current array. :type insum: Array of floats """ - insum = stypes.toDoubleVector(insum) + insum = stypes.to_double_vector(insum) libspice.dafrs_c(ctypes.byref(insum)) -@spiceErrorCheck +@spice_error_check def dafus(insum, nd, ni): """ Unpack an array summary into its double precision and integer components. @@ -2141,16 +2259,16 @@ def dafus(insum, nd, ni): :return: Double precision components, Integer components. :rtype: tuple """ - insum = stypes.toDoubleVector(insum) - dc = stypes.emptyDoubleVector(nd) - ic = stypes.emptyIntVector(ni) + 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.cVectorToPython(dc), stypes.cVectorToPython(ic) + return stypes.c_vector_to_python(dc), stypes.c_vector_to_python(ic) -@spiceErrorCheck +@spice_error_check def dasac(handle, buffer): """ Add comments from a buffer of character strings to the comment @@ -2167,11 +2285,11 @@ def dasac(handle, buffer): 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.listToCharArrayPtr(buffer) + buffer = stypes.list_to_char_array_ptr(buffer) libspice.dasac_c(handle, n, buflen, buffer) -@spiceErrorCheck +@spice_error_check def dascls(handle): """ Close a DAS file. @@ -2185,22 +2303,22 @@ def dascls(handle): libspice.dascls_c(handle) -@spiceErrorCheck +@spice_error_check def dasdc(handle): """ - Delete the entire comment area of a previously opened binary + 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. - :type handle: int + :type handle: int """ handle = ctypes.c_int(handle) libspice.dasdc_c(handle) -@spiceErrorCheck +@spice_error_check def dasec(handle, bufsiz=_default_len_out, buflen=_default_len_out): """ Extract comments from the comment area of a binary DAS file. @@ -2220,21 +2338,27 @@ def dasec(handle, bufsiz=_default_len_out, buflen=_default_len_out): :rtype: tuple """ handle = ctypes.c_int(handle) - buffer = stypes.emptyCharArray(buflen, bufsiz) + 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.cVectorToPython(buffer), done.value - - -@spiceErrorCheck + 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 + + +@spice_error_check def dashfn(handle, lenout=_default_len_out): """ 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. @@ -2246,16 +2370,16 @@ def dashfn(handle, lenout=_default_len_out): """ handle = ctypes.c_int(handle) namlen = ctypes.c_int(lenout) - fname = stypes.stringToCharP(lenout) + fname = stypes.string_to_char_p(lenout) libspice.dashfn_c(handle, namlen, fname) - return stypes.toPythonString(fname) + return stypes.to_python_string(fname) -@spiceErrorCheck +@spice_error_check def dasonw(fname, ftype, ifname, ncomch): """ Internal undocumented command for creating a new DAS file - + :param fname: filename :type fname: str :param ftype: type @@ -2270,16 +2394,25 @@ def dasonw(fname, ftype, ifname, ncomch): 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.stringToCharP(fname) - ftype = stypes.stringToCharP(ftype) - ifname = stypes.stringToCharP(ifname) - libspice.dasonw_(fname, ftype, ifname, ctypes.byref(ncomch), ctypes.byref(handle), fnamelen, ftypelen, ifnamelen) + 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 -@spiceErrorCheck +@spice_error_check def dasopr(fname): """ Open a DAS file for reading. @@ -2291,33 +2424,33 @@ def dasopr(fname): :return: Handle assigned to the opened DAS file. :rtype: int """ - fname = stypes.stringToCharP(fname) + fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.dasopr_c(fname, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def dasopw(fname): """ 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. + :param fname: Name of a DAS file to be opened. :type fname: str :return: Handle assigned to the opened DAS file. """ - fname = stypes.stringToCharP(fname) + fname = stypes.string_to_char_p(fname) handle = ctypes.c_int(0) libspice.dasopw_c(fname, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def dasrfr(handle, lenout=_default_len_out): """ - Return the contents of the file record of a specified DAS file. - + 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. @@ -2330,21 +2463,36 @@ def dasrfr(handle, lenout=_default_len_out): :rtype: tuple """ handle = ctypes.c_int(handle) - idwlen = ctypes.c_int(lenout) # intentional - ifnlen = ctypes.c_int(lenout) # intentional - idword = stypes.stringToCharP(lenout) - ifname = stypes.stringToCharP(lenout) + 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.toPythonString(idword), stypes.toPythonString(ifname), nresvr.value, nresvc.value, ncomr.value, ncomc.value - - -@spiceErrorCheck + 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, + ) + + +@spice_error_check def dcyldr(x, y, z): """ This routine computes the Jacobian of the transformation from @@ -2364,12 +2512,12 @@ def dcyldr(x, y, z): x = ctypes.c_double(x) y = ctypes.c_double(y) z = ctypes.c_double(z) - jacobi = stypes.emptyDoubleMatrix() + jacobi = stypes.empty_double_matrix() libspice.dcyldr_c(x, y, z, jacobi) - return stypes.cMatrixToNumpy(jacobi) + return stypes.c_matrix_to_numpy(jacobi) -@spiceErrorCheck +@spice_error_check def deltet(epoch, eptype): """ Return the value of Delta ET (ET-UTC) for an input epoch. @@ -2384,13 +2532,13 @@ def deltet(epoch, eptype): :rtype: float """ epoch = ctypes.c_double(epoch) - eptype = stypes.stringToCharP(eptype) + eptype = stypes.string_to_char_p(eptype) delta = ctypes.c_double() libspice.deltet_c(epoch, eptype, ctypes.byref(delta)) return delta.value -@spiceErrorCheck +@spice_error_check def det(m1): """ Compute the determinant of a double precision 3x3 matrix. @@ -2402,11 +2550,11 @@ def det(m1): :return: The determinant of the matrix. :rtype: float """ - m1 = stypes.toDoubleMatrix(m1) + m1 = stypes.to_double_matrix(m1) return libspice.det_c(m1) -@spiceErrorCheck +@spice_error_check def dgeodr(x, y, z, re, f): """ This routine computes the Jacobian of the transformation from @@ -2432,12 +2580,12 @@ def dgeodr(x, y, z, re, f): z = ctypes.c_double(z) re = ctypes.c_double(re) f = ctypes.c_double(f) - jacobi = stypes.emptyDoubleMatrix() + jacobi = stypes.empty_double_matrix() libspice.dgeodr_c(x, y, z, re, f, jacobi) - return stypes.cMatrixToNumpy(jacobi) + return stypes.c_matrix_to_numpy(jacobi) -@spiceErrorCheck +@spice_error_check def diags2(symmat): """ Diagonalize a symmetric 2x2 matrix. @@ -2451,14 +2599,14 @@ def diags2(symmat): A rotation used as the similarity transformation. :rtype: tuple """ - symmat = stypes.toDoubleMatrix(symmat) - diag = stypes.emptyDoubleMatrix(x=2, y=2) - rotateout = stypes.emptyDoubleMatrix(x=2, y=2) + 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.cMatrixToNumpy(diag), stypes.cMatrixToNumpy(rotateout) + return stypes.c_matrix_to_numpy(diag), stypes.c_matrix_to_numpy(rotateout) -@spiceErrorCheck +@spice_error_check def diff(a, b): """ Take the difference of two sets of any data type to form a third set. @@ -2488,54 +2636,54 @@ def diff(a, b): return c -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def dlabbs(handle): """ 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. :type handle: int :return: Descriptor of last segment in DLA file :rtype: spiceypy.utils.support_types.SpiceDLADescr """ handle = ctypes.c_int(handle) - descr = stypes.SpiceDLADescr() - found = ctypes.c_int() + descr = stypes.SpiceDLADescr() + found = ctypes.c_int() libspice.dlabbs_c(handle, ctypes.byref(descr), ctypes.byref(found)) return descr, bool(found.value) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def dlabfs(handle): """ 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. :type handle: int :return: Descriptor of next segment in DLA file :rtype: spiceypy.utils.support_types.SpiceDLADescr """ handle = ctypes.c_int(handle) - descr = stypes.SpiceDLADescr() - found = ctypes.c_int() + descr = stypes.SpiceDLADescr() + found = ctypes.c_int() libspice.dlabfs_c(handle, ctypes.byref(descr), ctypes.byref(found)) return descr, bool(found.value) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def dlafns(handle, descr): """ - Find the segment following a specified segment in a DLA file. - + 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. :type handle: c_int :param descr: Descriptor of a DLA segment. @@ -2546,22 +2694,24 @@ def dlafns(handle, descr): 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)) + found = ctypes.c_int() + libspice.dlafns_c( + handle, ctypes.byref(descr), ctypes.byref(nxtdsc), ctypes.byref(found) + ) return nxtdsc, bool(found.value) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def dlafps(handle, descr): """ 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. :type handle: c_int - :param descr: Descriptor of a segment in DLA file. + :param descr: Descriptor of a segment in DLA file. :type descr: spiceypy.utils.support_types.SpiceDLADescr :return: Descriptor of previous segment in DLA file :rtype: spiceypy.utils.support_types.SpiceDLADescr @@ -2570,12 +2720,13 @@ def dlafps(handle, descr): 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)) + libspice.dlafps_c( + handle, ctypes.byref(descr), ctypes.byref(prvdsc), ctypes.byref(found) + ) return prvdsc, bool(found.value) -@spiceErrorCheck +@spice_error_check def dlatdr(x, y, z): """ This routine computes the Jacobian of the transformation from @@ -2595,12 +2746,12 @@ def dlatdr(x, y, z): x = ctypes.c_double(x) y = ctypes.c_double(y) z = ctypes.c_double(z) - jacobi = stypes.emptyDoubleMatrix() + jacobi = stypes.empty_double_matrix() libspice.dlatdr_c(x, y, z, jacobi) - return stypes.cMatrixToNumpy(jacobi) + return stypes.c_matrix_to_numpy(jacobi) -@spiceErrorCheck +@spice_error_check def dp2hx(number, lenout=_default_len_out): """ Convert a double precision number to an equivalent character @@ -2617,13 +2768,13 @@ def dp2hx(number, lenout=_default_len_out): """ number = ctypes.c_double(number) lenout = ctypes.c_int(lenout) - string = stypes.stringToCharP(lenout) + string = stypes.string_to_char_p(lenout) length = ctypes.c_int() libspice.dp2hx_c(number, lenout, string, ctypes.byref(length)) - return stypes.toPythonString(string) + return stypes.to_python_string(string) -@spiceErrorCheck +@spice_error_check def dpgrdr(body, x, y, z, re, f): """ This routine computes the Jacobian matrix of the transformation @@ -2646,18 +2797,18 @@ def dpgrdr(body, x, y, z, re, f): :return: Matrix of partial derivatives. :rtype: 3x3-Element Array of floats """ - body = stypes.stringToCharP(body) + 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.emptyDoubleMatrix() + jacobi = stypes.empty_double_matrix() libspice.dpgrdr_c(body, x, y, z, re, f, jacobi) - return stypes.cMatrixToNumpy(jacobi) + return stypes.c_matrix_to_numpy(jacobi) -@spiceErrorCheck +@spice_error_check def dpmax(): """ Return the value of the largest (positive) number representable @@ -2673,7 +2824,7 @@ def dpmax(): return libspice.dpmax_c() -@spiceErrorCheck +@spice_error_check def dpmin(): """ Return the value of the smallest (negative) number representable @@ -2689,7 +2840,7 @@ def dpmin(): return libspice.dpmin_c() -@spiceErrorCheck +@spice_error_check def dpr(): """ Return the number of degrees per radian. @@ -2702,7 +2853,7 @@ def dpr(): return libspice.dpr_c() -@spiceErrorCheck +@spice_error_check def drdcyl(r, lon, z): """ This routine computes the Jacobian of the transformation from @@ -2722,12 +2873,12 @@ def drdcyl(r, lon, z): r = ctypes.c_double(r) lon = ctypes.c_double(lon) z = ctypes.c_double(z) - jacobi = stypes.emptyDoubleMatrix() + jacobi = stypes.empty_double_matrix() libspice.drdcyl_c(r, lon, z, jacobi) - return stypes.cMatrixToNumpy(jacobi) + return stypes.c_matrix_to_numpy(jacobi) -@spiceErrorCheck +@spice_error_check def drdgeo(lon, lat, alt, re, f): """ This routine computes the Jacobian of the transformation from @@ -2753,12 +2904,12 @@ def drdgeo(lon, lat, alt, re, f): alt = ctypes.c_double(alt) re = ctypes.c_double(re) f = ctypes.c_double(f) - jacobi = stypes.emptyDoubleMatrix() + jacobi = stypes.empty_double_matrix() libspice.drdgeo_c(lon, lat, alt, re, f, jacobi) - return stypes.cMatrixToNumpy(jacobi) + return stypes.c_matrix_to_numpy(jacobi) -@spiceErrorCheck +@spice_error_check def drdlat(r, lon, lat): """ Compute the Jacobian of the transformation from latitudinal to @@ -2778,12 +2929,12 @@ def drdlat(r, lon, lat): r = ctypes.c_double(r) lon = ctypes.c_double(lon) lat = ctypes.c_double(lat) - jacobi = stypes.emptyDoubleMatrix() + jacobi = stypes.empty_double_matrix() libspice.drdlat_c(r, lon, lat, jacobi) - return stypes.cMatrixToNumpy(jacobi) + return stypes.c_matrix_to_numpy(jacobi) -@spiceErrorCheck +@spice_error_check def drdpgr(body, lon, lat, alt, re, f): """ This routine computes the Jacobian matrix of the transformation @@ -2806,18 +2957,18 @@ def drdpgr(body, lon, lat, alt, re, f): :return: Matrix of partial derivatives. :rtype: 3x3-Element Array of floats """ - body = stypes.stringToCharP(body) + 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.emptyDoubleMatrix() + jacobi = stypes.empty_double_matrix() libspice.drdpgr_c(body, lon, lat, alt, re, f, jacobi) - return stypes.cMatrixToNumpy(jacobi) + return stypes.c_matrix_to_numpy(jacobi) -@spiceErrorCheck +@spice_error_check def drdsph(r, colat, lon): """ This routine computes the Jacobian of the transformation from @@ -2837,12 +2988,12 @@ def drdsph(r, colat, lon): r = ctypes.c_double(r) colat = ctypes.c_double(colat) lon = ctypes.c_double(lon) - jacobi = stypes.emptyDoubleMatrix() + jacobi = stypes.empty_double_matrix() libspice.drdsph_c(r, colat, lon, jacobi) - return stypes.cMatrixToNumpy(jacobi) + return stypes.c_matrix_to_numpy(jacobi) -@spiceErrorCheck +@spice_error_check def dskb02(handle, dladsc): """ Return bookkeeping data from a DSK type 2 segment. @@ -2861,37 +3012,64 @@ def dskb02(handle, dladsc): nv = ctypes.c_int(0) np = ctypes.c_int(0) nvxtot = ctypes.c_int(0) - vtxbds = stypes.emptyDoubleMatrix(3, 2) + vtxbds = stypes.empty_double_matrix(3, 2) voxsiz = ctypes.c_double(0.0) - voxori = stypes.emptyDoubleVector(3) - vgrext = stypes.emptyIntVector(3) + 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.cMatrixToNumpy(vtxbds), voxsiz.value, stypes.cVectorToPython(voxori), stypes.cVectorToPython(vgrext), cgscal.value, vtxnpl.value, voxnpt.value, voxnpl.value - -@spiceErrorCheck + 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, + ) + + +@spice_error_check def dskcls(handle, optmiz=False): """ - Close a DSK file. + 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. :type handle: int :param optmiz: Flag indicating whether to segregate the DSK. :type optmiz: bool - :return: + :return: """ handle = ctypes.c_int(handle) optmiz = ctypes.c_int(optmiz) libspice.dskcls_c(handle, optmiz) -@spiceErrorCheck -def dskd02(handle,dladsc,item,start,room): +@spice_error_check +def dskd02(handle, dladsc, item, start, room): """ Fetch double precision data from a type 2 DSK segment. @@ -2912,16 +3090,16 @@ def dskd02(handle,dladsc,item,start,room): """ 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.emptyDoubleVector(room) + 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.cVectorToPython(values) + return stypes.c_vector_to_python(values) -@spiceErrorCheck +@spice_error_check def dskgd(handle, dladsc): """ Return the DSK descriptor from a DSK segment identified @@ -2942,25 +3120,25 @@ def dskgd(handle, dladsc): return dskdsc -@spiceErrorCheck +@spice_error_check def dskgtl(keywrd): """ 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. + + :param keywrd: Code specifying parameter to retrieve. :type keywrd: int :return: Value of parameter. :rtype: float """ keywrd = ctypes.c_int(keywrd) - dpval = ctypes.c_double(0) + dpval = ctypes.c_double(0) libspice.dskgtl_c(keywrd, ctypes.byref(dpval)) return dpval.value -@spiceErrorCheck +@spice_error_check def dski02(handle, dladsc, item, start, room): """ Fetch integer data from a type 2 DSK segment. @@ -2985,12 +3163,12 @@ def dski02(handle, dladsc, item, start, room): start = ctypes.c_int(start) room = ctypes.c_int(room) n = ctypes.c_int() - values = stypes.emptyIntVector(room) + values = stypes.empty_int_vector(room) libspice.dski02_c(handle, dladsc, item, start, room, ctypes.byref(n), values) - return stypes.cMatrixToNumpy(values) + return stypes.c_matrix_to_numpy(values) -@spiceErrorCheck +@spice_error_check def dskmi2(vrtces, plates, finscl, corscl, worksz, voxpsz, voxlsz, makvtl, spxisz): """ Make spatial index for a DSK type 2 segment. The index is returned @@ -3021,10 +3199,10 @@ def dskmi2(vrtces, plates, finscl, corscl, worksz, voxpsz, voxlsz, makvtl, spxis :return: double precision and integer components of the spatial index of the segment. :rtype: tuple """ - nv = ctypes.c_int(len(vrtces)) - vrtces = stypes.toDoubleMatrix(vrtces) - np = ctypes.c_int(len(plates)) - plates = stypes.toIntMatrix(plates) + 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) @@ -3032,14 +3210,29 @@ def dskmi2(vrtces, plates, finscl, corscl, worksz, voxpsz, voxlsz, makvtl, spxis voxlsz = ctypes.c_int(voxlsz) makvtl = ctypes.c_int(makvtl) spxisz = ctypes.c_int(spxisz) - work = stypes.emptyIntMatrix(2, worksz) - spaixd = stypes.emptyDoubleVector(10) # SPICE_DSK02_SPADSZ - spaixi = stypes.emptyIntVector(spxisz) - libspice.dskmi2_c(nv, vrtces, np, plates, finscl, corscl, worksz, voxpsz, voxlsz, makvtl, spxisz, work, spaixd, spaixi) - return stypes.cVectorToPython(spaixd), stypes.cVectorToPython(spaixi) - - -@spiceErrorCheck + 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) + + +@spice_error_check def dskn02(handle, dladsc, plid): """ Compute the unit normal vector for a specified plate from a type @@ -3057,56 +3250,56 @@ def dskn02(handle, dladsc, plid): :rtype: 3-Element Array of floats. """ handle = ctypes.c_int(handle) - plid = ctypes.c_int(plid) - normal = stypes.emptyDoubleVector(3) + plid = ctypes.c_int(plid) + normal = stypes.empty_double_vector(3) libspice.dskn02_c(handle, dladsc, plid, normal) - return stypes.cVectorToPython(normal) + return stypes.c_vector_to_python(normal) -@spiceErrorCheck +@spice_error_check def dskobj(dsk): """ - Find the set of body ID codes of all objects for which - topographic data are provided in a specified DSK file. - + 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. + + :param dsk: Name of DSK file. :type dsk: str :return: Set of ID codes of objects in DSK file. :rtype: spiceypy.utils.support_types.SpiceCell """ - dsk = stypes.stringToCharP(dsk) + dsk = stypes.string_to_char_p(dsk) bodids = stypes.SPICEINT_CELL(10000) libspice.dskobj_c(dsk, ctypes.byref(bodids)) return bodids -@spiceErrorCheck +@spice_error_check def dskopn(fname, ifname, ncomch): """ - Open a new DSK file for subsequent write operations. - + 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 fname: Name of a DSK file to be opened. :type fname: str :param ifname: Internal file name. :type ifname: str - :param ncomch: Number of comment characters to allocate. + :param ncomch: Number of comment characters to allocate. :type ncomch: int :return: Handle assigned to the opened DSK file. :rtype: int """ - fname = stypes.stringToCharP(fname) - ifname = stypes.stringToCharP(ifname) + 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 -@spiceErrorCheck +@spice_error_check def dskp02(handle, dladsc, start, room): """ Fetch triangular plates from a type 2 DSK segment. @@ -3125,15 +3318,15 @@ def dskp02(handle, dladsc, start, room): """ handle = ctypes.c_int(handle) - start = ctypes.c_int(start) - room = ctypes.c_int(room) - n = ctypes.c_int(0) - plates = stypes.emptyIntMatrix(3, room) + 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.cMatrixToNumpy(plates) + return stypes.c_matrix_to_numpy(plates) -@spiceErrorCheck +@spice_error_check def dskrb2(vrtces, plates, corsys, corpar): """ Determine range bounds for a set of triangular plates to @@ -3152,58 +3345,68 @@ def dskrb2(vrtces, plates, corsys, corpar): :return: Lower and Upper bound on range of third coordinate :rtype: tuple """ - nv = ctypes.c_int(len(vrtces)) - vrtces = stypes.toDoubleMatrix(vrtces) - np = ctypes.c_int(len(plates)) - plates = stypes.toIntMatrix(plates) + 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.toDoubleVector(corpar) + 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)) + libspice.dskrb2_c( + nv, + vrtces, + np, + plates, + corsys, + corpar, + ctypes.byref(mncor3), + ctypes.byref(mxcor3), + ) return mncor3.value, mxcor3.value -@spiceErrorCheck + +@spice_error_check def dsksrf(dsk, bodyid): """ - Find the set of surface ID codes for all surfaces associated with - a given body in a specified DSK file. - + 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. :type dsk: str :param bodyid: Integer body ID code. :type bodyid: int - :return: Set of ID codes of surfaces in DSK file. + :return: Set of ID codes of surfaces in DSK file. """ - dsk = stypes.stringToCharP(dsk) + 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 -@spiceErrorCheck +@spice_error_check def dskstl(keywrd, dpval): """ 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. :type keywrd: int - :param dpval: Value of parameter. + :param dpval: Value of parameter. :type dpval: float - :return: + :return: """ keywrd = ctypes.c_int(keywrd) dpval = ctypes.c_double(dpval) libspice.dskstl_c(keywrd, dpval) -@spiceErrorCheck +@spice_error_check def dskv02(handle, dladsc, start, room): """ Fetch vertices from a type 2 DSK segment. @@ -3222,18 +3425,36 @@ def dskv02(handle, dladsc, start, room): :rtype: Room x 3-Element Array of floats """ handle = ctypes.c_int(handle) - start = ctypes.c_int(start) - room = ctypes.c_int(room) - n = ctypes.c_int() - vrtces = stypes.emptyDoubleMatrix(3, room) + 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.cMatrixToNumpy(vrtces) - - -@spiceErrorCheck -def dskw02(handle, center, surfid, dclass, fname, corsys, corpar, mncor1, - mxcor1, mncor2, mxcor2, mncor3, mxcor3, first, last, vrtces, - plates, spaixd, spaixi): + return stypes.c_matrix_to_numpy(vrtces) + + +@spice_error_check +def dskw02( + handle, + center, + surfid, + dclass, + fname, + corsys, + corpar, + mncor1, + mxcor1, + mncor2, + mxcor2, + mncor3, + mxcor3, + first, + last, + vrtces, + plates, + spaixd, + spaixi, +): """ Write a type 2 segment to a DSK file. @@ -3282,29 +3503,49 @@ def dskw02(handle, center, surfid, dclass, fname, corsys, corpar, mncor1, center = ctypes.c_int(center) surfid = ctypes.c_int(surfid) dclass = ctypes.c_int(dclass) - fname = stypes.stringToCharP(fname) + fname = stypes.string_to_char_p(fname) corsys = ctypes.c_int(corsys) - corpar = stypes.toDoubleVector(corpar) + 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.toDoubleMatrix(vrtces) - np = ctypes.c_int(len(plates)) - plates = stypes.toIntMatrix(plates) - spaixd = stypes.toDoubleVector(spaixd) - spaixi = stypes.toIntVector(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) - - -@spiceErrorCheck + 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, + ) + + +@spice_error_check def dskx02(handle, dladsc, vertex, raydir): """ Determine the plate ID and body-fixed coordinates of the @@ -3325,16 +3566,25 @@ def dskx02(handle, dladsc, vertex, raydir): :rtype: tuple """ handle = ctypes.c_int(handle) - vertex = stypes.toDoubleVector(vertex) - raydir = stypes.toDoubleVector(raydir) - plid = ctypes.c_int() - xpt = stypes.emptyDoubleVector(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.cVectorToPython(xpt), bool(found.value) - -@spiceErrorCheck -@spiceFoundExceptionThrower + 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) + + +@spice_error_check +@spice_found_exception_thrower def dskxsi(pri, target, srflst, et, fixref, vertex, raydir): """ Compute a ray-surface intercept using data provided by @@ -3363,27 +3613,53 @@ def dskxsi(pri, target, srflst, et, fixref, vertex, raydir): :rtype: tuple """ pri = ctypes.c_int(pri) - target = stypes.stringToCharP(target) + target = stypes.string_to_char_p(target) nsurf = ctypes.c_int(len(srflst)) - srflst = stypes.toIntVector(srflst) + srflst = stypes.to_int_vector(srflst) et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - vertex = stypes.toDoubleVector(vertex) - raydir = stypes.toDoubleVector(raydir) + 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.emptyDoubleVector(3) + xpt = stypes.empty_double_vector(3) handle = ctypes.c_int(0) dladsc = stypes.SpiceDLADescr() dskdsc = stypes.SpiceDSKDescr() - dc = stypes.emptyDoubleVector(1) - ic = stypes.emptyIntVector(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.cVectorToPython(xpt), handle.value, dladsc, dskdsc, stypes.cVectorToPython(dc), stypes.cVectorToPython(ic), bool(found.value) - - -@spiceErrorCheck + 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), + ) + + +@spice_error_check def dskxv(pri, target, srflst, et, fixref, vtxarr, dirarr): """ Compute ray-surface intercepts for a set of rays, using data @@ -3408,22 +3684,24 @@ def dskxv(pri, target, srflst, et, fixref, vtxarr, dirarr): :return: Intercept point array and Found flag array. :rtype: tuple """ - pri = ctypes.c_int(pri) - target = stypes.stringToCharP(target) - nsurf = ctypes.c_int(len(srflst)) - srflst = stypes.toIntVector(srflst) - et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - nray = ctypes.c_int(len(vtxarr)) - vtxarr = stypes.toDoubleMatrix(vtxarr) - dirarr = stypes.toDoubleMatrix(dirarr) - xptarr = stypes.emptyDoubleMatrix(y=nray) - fndarr = stypes.emptyIntVector(nray) - libspice.dskxv_c(pri, target, nsurf, srflst, et, fixref, nray, vtxarr, dirarr, xptarr, fndarr) - return stypes.cMatrixToNumpy(xptarr), stypes.cVectorToPython(fndarr) - - -@spiceErrorCheck + 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) + + +@spice_error_check def dskz02(handle, dladsc): """ Return plate model size parameters---plate count and @@ -3445,7 +3723,7 @@ def dskz02(handle, dladsc): return nv.value, np.value -@spiceErrorCheck +@spice_error_check def dsphdr(x, y, z): """ This routine computes the Jacobian of the transformation from @@ -3466,13 +3744,13 @@ def dsphdr(x, y, z): x = ctypes.c_double(x) y = ctypes.c_double(y) z = ctypes.c_double(z) - jacobi = stypes.emptyDoubleMatrix() + jacobi = stypes.empty_double_matrix() libspice.dsphdr_c(x, y, z, jacobi) - return stypes.cMatrixToNumpy(jacobi) + return stypes.c_matrix_to_numpy(jacobi) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def dtpool(name): """ Return the data about a kernel pool variable. @@ -3486,16 +3764,15 @@ def dtpool(name): Type of the variable "C", "N", or "X". :rtype: tuple """ - name = stypes.stringToCharP(name) + 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.toPythonString(typeout.value), bool(found.value) + 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) -@spiceErrorCheck +@spice_error_check def ducrss(s1, s2): """ Compute the unit vector parallel to the cross product of @@ -3511,14 +3788,14 @@ def ducrss(s1, s2): :rtype: 6-Element Array of floats """ assert len(s1) == 6 and len(s2) == 6 - s1 = stypes.toDoubleVector(s1) - s2 = stypes.toDoubleVector(s2) - sout = stypes.emptyDoubleVector(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.cVectorToPython(sout) + return stypes.c_vector_to_python(sout) -@spiceErrorCheck +@spice_error_check def dvcrss(s1, s2): """ Compute the cross product of two 3-dimensional vectors @@ -3534,14 +3811,14 @@ def dvcrss(s1, s2): :rtype: 6-Element Array of floats """ assert len(s1) == 6 and len(s2) == 6 - s1 = stypes.toDoubleVector(s1) - s2 = stypes.toDoubleVector(s2) - sout = stypes.emptyDoubleVector(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.cVectorToPython(sout) + return stypes.c_vector_to_python(sout) -@spiceErrorCheck +@spice_error_check def dvdot(s1, s2): """ Compute the derivative of the dot product of two double @@ -3557,12 +3834,12 @@ def dvdot(s1, s2): :rtype: float """ assert len(s1) == 6 and len(s2) == 6 - s1 = stypes.toDoubleVector(s1) - s2 = stypes.toDoubleVector(s2) + s1 = stypes.to_double_vector(s1) + s2 = stypes.to_double_vector(s2) return libspice.dvdot_c(s1, s2) -@spiceErrorCheck +@spice_error_check def dvhat(s1): """ Find the unit vector corresponding to a state vector and the @@ -3576,13 +3853,13 @@ def dvhat(s1): :rtype: 6-Element Array of floats """ assert len(s1) == 6 - s1 = stypes.toDoubleVector(s1) - sout = stypes.emptyDoubleVector(6) + s1 = stypes.to_double_vector(s1) + sout = stypes.empty_double_vector(6) libspice.dvhat_c(s1, sout) - return stypes.cVectorToPython(sout) + return stypes.c_vector_to_python(sout) -@spiceErrorCheck +@spice_error_check def dvnorm(state): """ Function to calculate the derivative of the norm of a 3-vector. @@ -3596,11 +3873,11 @@ def dvnorm(state): :rtype: float """ assert len(state) == 6 - state = stypes.toDoubleVector(state) + state = stypes.to_double_vector(state) return libspice.dvnorm_c(state) -@spiceErrorCheck +@spice_error_check def dvpool(name): """ Delete a variable from the kernel pool. @@ -3610,11 +3887,11 @@ def dvpool(name): :param name: Name of the kernel variable to be deleted. :type name: str """ - name = stypes.stringToCharP(name) + name = stypes.string_to_char_p(name) libspice.dvpool_c(name) -@spiceErrorCheck +@spice_error_check def dvsep(s1, s2): """ Calculate the time derivative of the separation angle between @@ -3630,8 +3907,8 @@ def dvsep(s1, s2): :rtype: float """ assert len(s1) == 6 and len(s2) == 6 - s1 = stypes.toDoubleVector(s1) - s2 = stypes.toDoubleVector(s2) + s1 = stypes.to_double_vector(s1) + s2 = stypes.to_double_vector(s2) return libspice.dvsep_c(s1, s2) @@ -3639,7 +3916,7 @@ def dvsep(s1, s2): # E -@spiceErrorCheck +@spice_error_check def edlimb(a, b, c, viewpt): """ Find the limb of a triaxial ellipsoid, viewed from a specified point. @@ -3661,12 +3938,12 @@ def edlimb(a, b, c, viewpt): a = ctypes.c_double(a) b = ctypes.c_double(b) c = ctypes.c_double(c) - viewpt = stypes.toDoubleVector(viewpt) + viewpt = stypes.to_double_vector(viewpt) libspice.edlimb_c(a, b, c, viewpt, ctypes.byref(limb)) return limb -@spiceErrorCheck +@spice_error_check def edterm(trmtyp, source, target, et, fixref, abcorr, obsrvr, npts): """ Compute a set of points on the umbral or penumbral terminator of @@ -3697,24 +3974,38 @@ def edterm(trmtyp, source, target, et, fixref, abcorr, obsrvr, npts): Terminator point set. :rtype: tuple """ - trmtyp = stypes.stringToCharP(trmtyp) - source = stypes.stringToCharP(source) - target = stypes.stringToCharP(target) + 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.stringToCharP(fixref) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) + 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.emptyDoubleVector(3) - trmpts = stypes.emptyDoubleMatrix(x=3, y=npts) + 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.cVectorToPython(obspos), stypes.cMatrixToNumpy( - trmpts) - - -@spiceErrorCheck + 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), + ) + + +@spice_error_check def ekacec(handle, segno, recno, column, nvals, cvals, isnull): """ Add data to a character column in a specified EK record. @@ -3739,15 +4030,15 @@ def ekacec(handle, segno, recno, column, nvals, cvals, isnull): handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) - column = stypes.stringToCharP(column) + column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) vallen = ctypes.c_int(len(max(cvals, key=len)) + 1) - cvals = stypes.listToCharArrayPtr(cvals) + cvals = stypes.list_to_char_array_ptr(cvals) isnull = ctypes.c_int(isnull) libspice.ekacec_c(handle, segno, recno, column, nvals, vallen, cvals, isnull) -@spiceErrorCheck +@spice_error_check def ekaced(handle, segno, recno, column, nvals, dvals, isnull): """ Add data to an double precision column in a specified EK record. @@ -3772,14 +4063,14 @@ def ekaced(handle, segno, recno, column, nvals, dvals, isnull): handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) - column = stypes.stringToCharP(column) + column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) - dvals = stypes.toDoubleVector(dvals) + dvals = stypes.to_double_vector(dvals) isnull = ctypes.c_int(isnull) libspice.ekaced_c(handle, segno, recno, column, nvals, dvals, isnull) -@spiceErrorCheck +@spice_error_check def ekacei(handle, segno, recno, column, nvals, ivals, isnull): """ Add data to an integer column in a specified EK record. @@ -3804,16 +4095,15 @@ def ekacei(handle, segno, recno, column, nvals, ivals, isnull): handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) - column = stypes.stringToCharP(column) + column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) - ivals = stypes.toIntVector(ivals) + ivals = stypes.to_int_vector(ivals) isnull = ctypes.c_int(isnull) libspice.ekacei_c(handle, segno, recno, column, nvals, ivals, isnull) -@spiceErrorCheck -def ekaclc(handle, segno, column, vallen, cvals, entszs, nlflgs, rcptrs, - wkindx): +@spice_error_check +def ekaclc(handle, segno, column, vallen, cvals, entszs, nlflgs, rcptrs, wkindx): """ Add an entire character column to an EK segment. @@ -3842,19 +4132,20 @@ def ekaclc(handle, segno, column, vallen, cvals, entszs, nlflgs, rcptrs, """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) - column = stypes.stringToCharP(column) + column = stypes.string_to_char_p(column) vallen = ctypes.c_int(vallen) - cvals = stypes.listToCharArrayPtr(cvals) - entszs = stypes.toIntVector(entszs) - nlflgs = stypes.toIntVector(nlflgs) - rcptrs = stypes.toIntVector(rcptrs) - wkindx = stypes.toIntVector(wkindx) - libspice.ekaclc_c(handle, segno, column, vallen, cvals, entszs, nlflgs, - rcptrs, wkindx) - return stypes.cVectorToPython(wkindx) - - -@spiceErrorCheck + 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) + + +@spice_error_check def ekacld(handle, segno, column, dvals, entszs, nlflgs, rcptrs, wkindx): """ Add an entire double precision column to an EK segment. @@ -3882,18 +4173,17 @@ def ekacld(handle, segno, column, dvals, entszs, nlflgs, rcptrs, wkindx): """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) - column = stypes.stringToCharP(column) - dvals = stypes.toDoubleVector(dvals) - entszs = stypes.toIntVector(entszs) - nlflgs = stypes.toIntVector(nlflgs) - rcptrs = stypes.toIntVector(rcptrs) - wkindx = stypes.toIntVector(wkindx) - libspice.ekacld_c(handle, segno, column, dvals, entszs, nlflgs, rcptrs, - wkindx) - return stypes.cVectorToPython(wkindx) - - -@spiceErrorCheck + 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) + + +@spice_error_check def ekacli(handle, segno, column, ivals, entszs, nlflgs, rcptrs, wkindx): """ Add an entire integer column to an EK segment. @@ -3920,18 +4210,17 @@ def ekacli(handle, segno, column, ivals, entszs, nlflgs, rcptrs, wkindx): """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) - column = stypes.stringToCharP(column) - ivals = stypes.toIntVector(ivals) - entszs = stypes.toIntVector(entszs) - nlflgs = stypes.toIntVector(nlflgs) - rcptrs = stypes.toIntVector(rcptrs) - wkindx = stypes.toIntVector(wkindx) - libspice.ekacli_c(handle, segno, column, ivals, entszs, nlflgs, rcptrs, - wkindx) - return stypes.cVectorToPython(wkindx) - - -@spiceErrorCheck + 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) + + +@spice_error_check def ekappr(handle, segno): """ Append a new, empty record at the end of a specified E-kernel segment. @@ -3952,7 +4241,7 @@ def ekappr(handle, segno): return recno.value -@spiceErrorCheck +@spice_error_check def ekbseg(handle, tabnam, cnames, decls): """ Start a new segment in an E-kernel. @@ -3971,18 +4260,22 @@ def ekbseg(handle, tabnam, cnames, decls): :rtype: int """ handle = ctypes.c_int(handle) - tabnam = stypes.stringToCharP(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.listToCharArrayPtr(cnames) + 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.listToCharArrayPtr(decls) + 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)) + libspice.ekbseg_c( + handle, tabnam, ncols, cnmlen, cnames, declen, decls, ctypes.byref(segno) + ) return segno.value -@spiceErrorCheck +@spice_error_check def ekccnt(table): """ Return the number of distinct columns in a specified, @@ -3995,13 +4288,13 @@ def ekccnt(table): :return: Count of distinct, currently loaded columns. :rtype: int """ - table = stypes.stringToCharP(table) + table = stypes.string_to_char_p(table) ccount = ctypes.c_int() libspice.ekccnt_c(table, ctypes.byref(ccount)) return ccount.value -@spiceErrorCheck +@spice_error_check def ekcii(table, cindex, lenout=_default_len_out): """ Return attribute information about a column belonging to a loaded @@ -4017,16 +4310,16 @@ def ekcii(table, cindex, lenout=_default_len_out): :return: Name of column, Column attribute descriptor. :rtype: tuple """ - table = stypes.stringToCharP(table) + table = stypes.string_to_char_p(table) cindex = ctypes.c_int(cindex) lenout = ctypes.c_int(lenout) - column = stypes.stringToCharP(lenout) + column = stypes.string_to_char_p(lenout) attdsc = stypes.SpiceEKAttDsc() libspice.ekcii_c(table, cindex, lenout, column, ctypes.byref(attdsc)) - return stypes.toPythonString(column), attdsc + return stypes.to_python_string(column), attdsc -@spiceErrorCheck +@spice_error_check def ekcls(handle): """ Close an E-kernel. @@ -4040,7 +4333,7 @@ def ekcls(handle): libspice.ekcls_c(handle) -@spiceErrorCheck +@spice_error_check def ekdelr(handle, segno, recno): """ Delete a specified record from a specified E-kernel segment. @@ -4060,7 +4353,7 @@ def ekdelr(handle, segno, recno): libspice.ekdelr_c(handle, segno, recno) -@spiceErrorCheck +@spice_error_check def ekffld(handle, segno, rcptrs): """ Complete a fast write operation on a new E-kernel segment. @@ -4076,12 +4369,11 @@ def ekffld(handle, segno, rcptrs): """ handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) - rcptrs = stypes.toIntVector(rcptrs) - libspice.ekffld_c(handle, segno, - ctypes.cast(rcptrs, ctypes.POINTER(ctypes.c_int))) + rcptrs = stypes.to_int_vector(rcptrs) + libspice.ekffld_c(handle, segno, ctypes.cast(rcptrs, ctypes.POINTER(ctypes.c_int))) -@spiceErrorCheck +@spice_error_check def ekfind(query, lenout=_default_len_out): """ Find E-kernel data that satisfy a set of constraints. @@ -4098,18 +4390,17 @@ def ekfind(query, lenout=_default_len_out): Parse error description. :rtype: tuple """ - query = stypes.stringToCharP(query) + query = stypes.string_to_char_p(query) lenout = ctypes.c_int(lenout) nmrows = ctypes.c_int() error = ctypes.c_int() - errmsg = stypes.stringToCharP(lenout) - libspice.ekfind_c(query, lenout, ctypes.byref(nmrows), ctypes.byref(error), - errmsg) - return nmrows.value, error.value, stypes.toPythonString(errmsg) + 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) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def ekgc(selidx, row, element, lenout=_default_len_out): """ Return an element of an entry in a column of character type in a specified @@ -4136,13 +4427,15 @@ def ekgc(selidx, row, element, lenout=_default_len_out): lenout = ctypes.c_int(lenout) null = ctypes.c_int() found = ctypes.c_int() - cdata = stypes.stringToCharP(lenout) - libspice.ekgc_c(selidx, row, element, lenout, cdata, ctypes.byref(null), ctypes.byref(found)) - return stypes.toPythonString(cdata), null.value, bool(found.value) + 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) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def ekgd(selidx, row, element): """ Return an element of an entry in a column of double precision type in a @@ -4167,13 +4460,19 @@ def ekgd(selidx, row, 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)) + libspice.ekgd_c( + selidx, + row, + element, + ctypes.byref(ddata), + ctypes.byref(null), + ctypes.byref(found), + ) return ddata.value, null.value, bool(found.value) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def ekgi(selidx, row, element): """ Return an element of an entry in a column of integer type in a specified @@ -4198,12 +4497,18 @@ def ekgi(selidx, row, 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)) + libspice.ekgi_c( + selidx, + row, + element, + ctypes.byref(idata), + ctypes.byref(null), + ctypes.byref(found), + ) return idata.value, null.value, bool(found.value) -@spiceErrorCheck +@spice_error_check def ekifld(handle, tabnam, ncols, nrows, cnmlen, cnames, declen, decls): """ Initialize a new E-kernel segment to allow fast writing. @@ -4230,21 +4535,31 @@ def ekifld(handle, tabnam, ncols, nrows, cnmlen, cnames, declen, decls): :rtype: tuple """ handle = ctypes.c_int(handle) - tabnam = stypes.stringToCharP(tabnam) + tabnam = stypes.string_to_char_p(tabnam) ncols = ctypes.c_int(ncols) nrows = ctypes.c_int(nrows) cnmlen = ctypes.c_int(cnmlen) - cnames = stypes.listToCharArray(cnames) + cnames = stypes.list_to_char_array(cnames) declen = ctypes.c_int(declen) - recptrs = stypes.emptyIntVector(nrows) - decls = stypes.listToCharArray(decls) + 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.cVectorToPython(recptrs) - - -@spiceErrorCheck + libspice.ekifld_c( + handle, + tabnam, + ncols, + nrows, + cnmlen, + cnames, + declen, + decls, + ctypes.byref(segno), + recptrs, + ) + return segno.value, stypes.c_vector_to_python(recptrs) + + +@spice_error_check def ekinsr(handle, segno, recno): """ Add a new, empty record to a specified E-kernel segment at a specified @@ -4265,7 +4580,7 @@ def ekinsr(handle, segno, recno): libspice.ekinsr_c(handle, segno, recno) -@spiceErrorCheck +@spice_error_check def eklef(fname): """ Load an EK file, making it accessible to the EK readers. @@ -4277,13 +4592,13 @@ def eklef(fname): :return: File handle of loaded EK file. :rtype: int """ - fname = stypes.stringToCharP(fname) + fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.eklef_c(fname, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def eknelt(selidx, row): """ Return the number of elements in a specified column entry in @@ -4303,7 +4618,7 @@ def eknelt(selidx, row): return libspice.eknelt_c(selidx, row) -@spiceErrorCheck +@spice_error_check def eknseg(handle): """ Return the number of segments in a specified EK. @@ -4319,7 +4634,7 @@ def eknseg(handle): return libspice.eknseg_c(handle) -@spiceErrorCheck +@spice_error_check def ekntab(): """ Return the number of loaded EK tables. @@ -4334,7 +4649,7 @@ def ekntab(): return n.value -@spiceErrorCheck +@spice_error_check def ekopn(fname, ifname, ncomch): """ Open a new E-kernel file and prepare the file for writing. @@ -4350,15 +4665,15 @@ def ekopn(fname, ifname, ncomch): :return: Handle attached to new EK file. :rtype: int """ - fname = stypes.stringToCharP(fname) - ifname = stypes.stringToCharP(ifname) + 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 -@spiceErrorCheck +@spice_error_check def ekopr(fname): """ Open an existing E-kernel file for reading. @@ -4370,13 +4685,13 @@ def ekopr(fname): :return: Handle attached to EK file. :rtype: int """ - fname = stypes.stringToCharP(fname) + fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.ekopr_c(fname, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def ekops(): """ Open a scratch (temporary) E-kernel file and prepare the file @@ -4392,7 +4707,7 @@ def ekops(): return handle.value -@spiceErrorCheck +@spice_error_check def ekopw(fname): """ Open an existing E-kernel file for writing. @@ -4404,13 +4719,13 @@ def ekopw(fname): :return: Handle attached to EK file. :rtype: int """ - fname = stypes.stringToCharP(fname) + fname = stypes.string_to_char_p(fname) handle = ctypes.c_int() libspice.ekopw_c(fname, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def ekpsel(query, msglen, tablen, collen): """ Parse the SELECT clause of an EK query, returning full particulars @@ -4438,34 +4753,48 @@ def ekpsel(query, msglen, tablen, collen): Parse error message. :rtype: tuple """ - query = stypes.stringToCharP(query) + 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.emptyIntVector(_SPICE_EK_MAXQSEL) - xends = stypes.emptyIntVector(_SPICE_EK_MAXQSEL) - xtypes = stypes.emptyIntVector(_SPICE_EK_MAXQSEL) - xclass = stypes.emptyIntVector(_SPICE_EK_MAXQSEL) - tabs = stypes.emptyCharArray(yLen=_SPICE_EK_MAXQSEL, xLen=tablen) - cols = stypes.emptyCharArray(yLen=_SPICE_EK_MAXQSEL, xLen=collen) + 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.stringToCharP(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.cVectorToPython(xbegs)[:n.value], - stypes.cVectorToPython(xends)[:n.value], - stypes.cVectorToPython(xtypes)[:n.value], - stypes.cVectorToPython(xclass)[:n.value], - stypes.cVectorToPython(tabs)[:n.value], - stypes.cVectorToPython(cols)[:n.value], - error.value, - stypes.toPythonString(errmsg)) - - -@spiceErrorCheck + 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), + ) + + +@spice_error_check def ekrcec(handle, segno, recno, column, lenout, nelts=_SPICE_EK_EKRCEX_ROOM_DEFAULT): """ Read data from a character column in a specified EK record. @@ -4493,17 +4822,30 @@ def ekrcec(handle, segno, recno, column, lenout, nelts=_SPICE_EK_EKRCEX_ROOM_DEF handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) - column = stypes.stringToCharP(column) + column = stypes.string_to_char_p(column) lenout = ctypes.c_int(lenout) nvals = ctypes.c_int() - cvals = stypes.emptyCharArray(yLen=nelts, xLen=lenout) + 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)) + 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.cVectorToPython(cvals)[:nvals.value], bool(isnull.value) + return ( + nvals.value, + stypes.c_vector_to_python(cvals)[: nvals.value], + bool(isnull.value), + ) -@spiceErrorCheck +@spice_error_check def ekrced(handle, segno, recno, column, nelts=_SPICE_EK_EKRCEX_ROOM_DEFAULT): """ Read data from a double precision column in a specified EK record. @@ -4527,17 +4869,22 @@ def ekrced(handle, segno, recno, column, nelts=_SPICE_EK_EKRCEX_ROOM_DEFAULT): handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) - column = stypes.stringToCharP(column) + column = stypes.string_to_char_p(column) nvals = ctypes.c_int(0) - dvals = stypes.emptyDoubleVector(nelts) + dvals = stypes.empty_double_vector(nelts) isnull = ctypes.c_int() - libspice.ekrced_c(handle, segno, recno, column, ctypes.byref(nvals), dvals, - ctypes.byref(isnull)) + libspice.ekrced_c( + handle, segno, recno, column, ctypes.byref(nvals), dvals, ctypes.byref(isnull) + ) assert failed() or (nvals.value <= nelts) - return nvals.value, stypes.cVectorToPython(dvals)[:nvals.value], bool(isnull.value) + return ( + nvals.value, + stypes.c_vector_to_python(dvals)[: nvals.value], + bool(isnull.value), + ) -@spiceErrorCheck +@spice_error_check def ekrcei(handle, segno, recno, column, nelts=_SPICE_EK_EKRCEX_ROOM_DEFAULT): """ Read data from an integer column in a specified EK record. @@ -4561,17 +4908,22 @@ def ekrcei(handle, segno, recno, column, nelts=_SPICE_EK_EKRCEX_ROOM_DEFAULT): handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) - column = stypes.stringToCharP(column) + column = stypes.string_to_char_p(column) nvals = ctypes.c_int() - ivals = stypes.emptyIntVector(nelts) + ivals = stypes.empty_int_vector(nelts) isnull = ctypes.c_int() - libspice.ekrcei_c(handle, segno, recno, column, ctypes.byref(nvals), ivals, - ctypes.byref(isnull)) + libspice.ekrcei_c( + handle, segno, recno, column, ctypes.byref(nvals), ivals, ctypes.byref(isnull) + ) assert failed() or (nvals.value <= nelts) - return nvals.value, stypes.cVectorToPython(ivals)[:nvals.value], bool(isnull.value) + return ( + nvals.value, + stypes.c_vector_to_python(ivals)[: nvals.value], + bool(isnull.value), + ) -@spiceErrorCheck +@spice_error_check def ekssum(handle, segno): """ Return summary information for a specified segment in a specified EK. @@ -4592,7 +4944,7 @@ def ekssum(handle, segno): return segsum -@spiceErrorCheck +@spice_error_check def ektnam(n, lenout=_default_len_out): """ Return the name of a specified, loaded table. @@ -4608,12 +4960,12 @@ def ektnam(n, lenout=_default_len_out): """ n = ctypes.c_int(n) lenout = ctypes.c_int(lenout) - table = stypes.stringToCharP(lenout) + table = stypes.string_to_char_p(lenout) libspice.ektnam_c(n, lenout, table) - return stypes.toPythonString(table) + return stypes.to_python_string(table) -@spiceErrorCheck +@spice_error_check def ekucec(handle, segno, recno, column, nvals, cvals, isnull): """ Update a character column entry in a specified EK record. @@ -4638,15 +4990,15 @@ def ekucec(handle, segno, recno, column, nvals, cvals, isnull): handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) - column = stypes.stringToCharP(column) + column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) vallen = ctypes.c_int(len(max(cvals, key=len)) + 1) - cvals = stypes.listToCharArrayPtr(cvals, xLen=vallen) + 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) -@spiceErrorCheck +@spice_error_check def ekuced(handle, segno, recno, column, nvals, dvals, isnull): """ Update a double precision column entry in a specified EK record. @@ -4671,14 +5023,14 @@ def ekuced(handle, segno, recno, column, nvals, dvals, isnull): handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) - column = stypes.stringToCharP(column) + column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) - dvals = stypes.toDoubleVector(dvals) + dvals = stypes.to_double_vector(dvals) isnull = ctypes.c_int(isnull) libspice.ekaced_c(handle, segno, recno, column, nvals, dvals, isnull) -@spiceErrorCheck +@spice_error_check def ekucei(handle, segno, recno, column, nvals, ivals, isnull): """ Update an integer column entry in a specified EK record. @@ -4703,14 +5055,14 @@ def ekucei(handle, segno, recno, column, nvals, ivals, isnull): handle = ctypes.c_int(handle) segno = ctypes.c_int(segno) recno = ctypes.c_int(recno) - column = stypes.stringToCharP(column) + column = stypes.string_to_char_p(column) nvals = ctypes.c_int(nvals) - ivals = stypes.toIntVector(ivals) + ivals = stypes.to_int_vector(ivals) isnull = ctypes.c_int(isnull) libspice.ekucei_c(handle, segno, recno, column, nvals, ivals, isnull) -@spiceErrorCheck +@spice_error_check def ekuef(handle): """ Unload an EK file, making its contents inaccessible to the @@ -4726,7 +5078,7 @@ def ekuef(handle): libspice.ekuef_c(handle) -@spiceErrorCheck +@spice_error_check def el2cgv(ellipse): """ Convert an ellipse to a center vector and two generating @@ -4740,16 +5092,19 @@ def el2cgv(ellipse): :return: Center and semi-axes of ellipse. :rtype: tuple """ - assert (isinstance(ellipse, stypes.Ellipse)) - center = stypes.emptyDoubleVector(3) - smajor = stypes.emptyDoubleVector(3) - sminor = stypes.emptyDoubleVector(3) + 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.cVectorToPython(center), stypes.cVectorToPython( - smajor), stypes.cVectorToPython(sminor) + return ( + stypes.c_vector_to_python(center), + stypes.c_vector_to_python(smajor), + stypes.c_vector_to_python(sminor), + ) -@spiceErrorCheck +@spice_error_check def elemc(item, inset): """ Determine whether an item is an element of a character set. @@ -4764,11 +5119,11 @@ def elemc(item, inset): :rtype: bool """ assert isinstance(inset, stypes.SpiceCell) - item = stypes.stringToCharP(item) + item = stypes.string_to_char_p(item) return bool(libspice.elemc_c(item, ctypes.byref(inset))) -@spiceErrorCheck +@spice_error_check def elemd(item, inset): """ Determine whether an item is an element of a double precision set. @@ -4788,7 +5143,7 @@ def elemd(item, inset): return bool(libspice.elemd_c(item, ctypes.byref(inset))) -@spiceErrorCheck +@spice_error_check def elemi(item, inset): """ Determine whether an item is an element of an integer set. @@ -4808,7 +5163,7 @@ def elemi(item, inset): return bool(libspice.elemi_c(item, ctypes.byref(inset))) -@spiceErrorCheck +@spice_error_check def eqncpv(et, epoch, eqel, rapol, decpol): """ Compute the state (position and velocity of an object whose @@ -4832,15 +5187,15 @@ def eqncpv(et, epoch, eqel, rapol, decpol): """ et = ctypes.c_double(et) epoch = ctypes.c_double(epoch) - eqel = stypes.toDoubleVector(eqel) + eqel = stypes.to_double_vector(eqel) rapol = ctypes.c_double(rapol) decpol = ctypes.c_double(decpol) - state = stypes.emptyDoubleVector(6) + state = stypes.empty_double_vector(6) libspice.eqncpv_c(et, epoch, eqel, rapol, decpol, state) - return stypes.cVectorToPython(state) + return stypes.c_vector_to_python(state) -@spiceErrorCheck +@spice_error_check def eqstr(a, b): """ Determine whether two strings are equivalent. @@ -4854,7 +5209,9 @@ def eqstr(a, b): :return: True if A and B are equivalent. :rtype: bool """ - return bool(libspice.eqstr_c(stypes.stringToCharP(a), stypes.stringToCharP(b))) + return bool( + libspice.eqstr_c(stypes.string_to_char_p(a), stypes.string_to_char_p(b)) + ) def erract(op, lenout, action=None): @@ -4876,11 +5233,11 @@ def erract(op, lenout, action=None): if action is None: action = "" lenout = ctypes.c_int(lenout) - op = stypes.stringToCharP(op) + 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.toPythonString(actionptr) + return stypes.to_python_string(actionptr) def errch(marker, string): @@ -4895,8 +5252,8 @@ def errch(marker, string): :param string: The character string to substitute for marker. :type string: str """ - marker = stypes.stringToCharP(marker) - string = stypes.stringToCharP(string) + marker = stypes.string_to_char_p(marker) + string = stypes.string_to_char_p(string) libspice.errch_c(marker, string) @@ -4916,11 +5273,11 @@ def errdev(op, lenout, device): :rtype: str """ lenout = ctypes.c_int(lenout) - op = stypes.stringToCharP(op) + 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.toPythonString(deviceptr) + return stypes.to_python_string(deviceptr) def errdp(marker, number): @@ -4935,7 +5292,7 @@ def errdp(marker, number): :param number: The d.p. number to substitute for marker. :type number: float """ - marker = stypes.stringToCharP(marker) + marker = stypes.string_to_char_p(marker) number = ctypes.c_double(number) libspice.errdp_c(marker, number) @@ -4952,7 +5309,7 @@ def errint(marker, number): :param number: The integer to substitute for marker. :type number: int """ - marker = stypes.stringToCharP(marker) + marker = stypes.string_to_char_p(marker) number = ctypes.c_int(number) libspice.errint_c(marker, number) @@ -4974,11 +5331,11 @@ def errprt(op, lenout, inlist): :rtype: list of str. """ lenout = ctypes.c_int(lenout) - op = stypes.stringToCharP(op) + 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.toPythonString(inlistptr) + return stypes.to_python_string(inlistptr) def esrchc(value, array): @@ -4998,14 +5355,14 @@ def esrchc(value, array): or -1 if none is found. :rtype: int """ - value = stypes.stringToCharP(value) + 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.listToCharArray(array, xLen=lenvals, yLen=ndim) + array = stypes.list_to_char_array(array, x_len=lenvals, y_len=ndim) return libspice.esrchc_c(value, ndim, lenvals, array) -@spiceErrorCheck +@spice_error_check def et2lst(et, body, lon, typein, timlen=_default_len_out, ampmlen=_default_len_out): """ Given an ephemeris epoch, compute the local solar time for @@ -5036,23 +5393,38 @@ def et2lst(et, body, lon, typein, timlen=_default_len_out, ampmlen=_default_len_ et = ctypes.c_double(et) body = ctypes.c_int(body) lon = ctypes.c_double(lon) - typein = stypes.stringToCharP(typein) + 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.stringToCharP(timlen) - ampm = stypes.stringToCharP(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.toPythonString( - time), stypes.toPythonString(ampm) - - -@spiceErrorCheck -def et2utc(et, formatStr, prec, lenout=_default_len_out): + 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), + ) + + +@spice_error_check +def et2utc(et, format_str, prec, lenout=_default_len_out): """ Convert an input time from ephemeris seconds past J2000 to Calendar, Day-of-Year, or Julian Date format, UTC. @@ -5061,8 +5433,8 @@ def et2utc(et, formatStr, prec, lenout=_default_len_out): :param et: Input epoch, given in ephemeris seconds past J2000. :type et: Union[float,Iterable[float]] - :param formatStr: Format of output epoch. - :type formatStr: str + :param format_str: Format of output epoch. + :type format_str: str :param prec: Digits of precision in fractional seconds or days. :type prec: int :param lenout: The length of the output string plus 1. @@ -5072,21 +5444,21 @@ def et2utc(et, formatStr, prec, lenout=_default_len_out): """ prec = ctypes.c_int(prec) lenout = ctypes.c_int(lenout) - formatStr = stypes.stringToCharP(formatStr) - utcstr = stypes.stringToCharP(lenout) - if stypes.isiterable(et): + 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), formatStr, prec, lenout, utcstr) - checkForSpiceError(None) - results.append(stypes.toPythonString(utcstr)) + 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 results else: - libspice.et2utc_c(ctypes.c_double(et), formatStr, prec, lenout, utcstr) - return stypes.toPythonString(utcstr) + libspice.et2utc_c(ctypes.c_double(et), format_str, prec, lenout, utcstr) + return stypes.to_python_string(utcstr) -@spiceErrorCheck +@spice_error_check def etcal(et, lenout=_default_len_out): """ Convert from an ephemeris epoch measured in seconds past @@ -5103,21 +5475,21 @@ def etcal(et, lenout=_default_len_out): :rtype: str """ lenout = ctypes.c_int(lenout) - string = stypes.stringToCharP(lenout) + string = stypes.string_to_char_p(lenout) if hasattr(et, "__iter__"): strings = [] for t in et: libspice.etcal_c(t, lenout, string) - checkForSpiceError(None) - strings.append(stypes.toPythonString(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.toPythonString(string) + return stypes.to_python_string(string) -@spiceErrorCheck +@spice_error_check def eul2m(angle3, angle2, angle1, axis3, axis2, axis1): """ Construct a rotation matrix from a set of Euler angles. @@ -5145,12 +5517,12 @@ def eul2m(angle3, angle2, angle1, axis3, axis2, axis1): axis3 = ctypes.c_int(axis3) axis2 = ctypes.c_int(axis2) axis1 = ctypes.c_int(axis1) - r = stypes.emptyDoubleMatrix() + r = stypes.empty_double_matrix() libspice.eul2m_c(angle3, angle2, angle1, axis3, axis2, axis1, r) - return stypes.cMatrixToNumpy(r) + return stypes.c_matrix_to_numpy(r) -@spiceErrorCheck +@spice_error_check def eul2xf(eulang, axisa, axisb, axisc): """ This routine computes a state transformation from an Euler angle @@ -5171,15 +5543,16 @@ def eul2xf(eulang, axisa, axisb, axisc): :rtype: 6x6-Element Array of floats """ assert len(eulang) == 6 - eulang = stypes.toDoubleVector(eulang) + eulang = stypes.to_double_vector(eulang) axisa = ctypes.c_int(axisa) axisb = ctypes.c_int(axisb) axisc = ctypes.c_int(axisc) - xform = stypes.emptyDoubleMatrix(x=6, y=6) + xform = stypes.empty_double_matrix(x=6, y=6) libspice.eul2xf_c(eulang, axisa, axisb, axisc, xform) - return stypes.cMatrixToNumpy(xform) + return stypes.c_matrix_to_numpy(xform) + -@spiceErrorCheck +@spice_error_check def ev2lin(et, geophs, elems): """ This routine evaluates NORAD two-line element data for @@ -5199,14 +5572,15 @@ def ev2lin(et, geophs, elems): """ et = ctypes.c_double(et) assert len(geophs) == 8 - geophs = stypes.toDoubleVector(geophs) + geophs = stypes.to_double_vector(geophs) assert len(elems) == 10 - elems = stypes.toDoubleVector(elems) - state = stypes.emptyDoubleVector(6) + elems = stypes.to_double_vector(elems) + state = stypes.empty_double_vector(6) libspice.ev2lin_(ctypes.byref(et), geophs, elems, state) - return stypes.cVectorToPython(state) + return stypes.c_vector_to_python(state) -@spiceErrorCheck + +@spice_error_check def exists(fname): """ Determine whether a file exists. @@ -5217,11 +5591,11 @@ def exists(fname): :return: True if the file exists, False otherwise. :rtype: bool """ - fname = stypes.stringToCharP(fname) + fname = stypes.string_to_char_p(fname) return bool(libspice.exists_c(fname)) -@spiceErrorCheck +@spice_error_check def expool(name): """ Confirm the existence of a kernel variable in the kernel pool. @@ -5233,7 +5607,7 @@ def expool(name): :return: True when the variable is in the pool. :rtype: bool """ - name = stypes.stringToCharP(name) + name = stypes.string_to_char_p(name) found = ctypes.c_int() libspice.expool_c(name, ctypes.byref(found)) return bool(found.value) @@ -5255,7 +5629,7 @@ def failed(): return bool(libspice.failed_c()) -@spiceErrorCheck +@spice_error_check def fn2lun(fname): """ Internal undocumented command for mapping name of open file to @@ -5268,14 +5642,14 @@ def fn2lun(fname): :return: the FORTRAN (F2C) logical unit associated with the filename. :rtype: int """ - fnameP = stypes.stringToCharP(fname) - unit_out = ctypes.c_int() - fname_len = ctypes.c_int(len(fname)+1) - libspice.fn2lun_(fnameP,ctypes.byref(unit_out),fname_len) + 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 -@spiceErrorCheck +@spice_error_check def fovray(inst, raydir, rframe, abcorr, observer, et): """ Determine if a specified ray is within the field-of-view (FOV) of a @@ -5298,19 +5672,20 @@ def fovray(inst, raydir, rframe, abcorr, observer, et): :return: Visibility flag :rtype: bool """ - inst = stypes.stringToCharP(inst) - raydir = stypes.toDoubleVector(raydir) - rframe = stypes.stringToCharP(rframe) - abcorr = stypes.stringToCharP(abcorr) - observer = stypes.stringToCharP(observer) + 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)) + libspice.fovray_c( + inst, raydir, rframe, abcorr, observer, ctypes.byref(et), ctypes.byref(visible) + ) return bool(visible.value) -@spiceErrorCheck +@spice_error_check def fovtrg(inst, target, tshape, tframe, abcorr, observer, et): """ Determine if a specified ephemeris object is within the field-of-view (FOV) @@ -5335,20 +5710,28 @@ def fovtrg(inst, target, tshape, tframe, abcorr, observer, et): :return: Visibility flag :rtype: bool """ - inst = stypes.stringToCharP(inst) - target = stypes.stringToCharP(target) - tshape = stypes.stringToCharP(tshape) - tframe = stypes.stringToCharP(tframe) - abcorr = stypes.stringToCharP(abcorr) - observer = stypes.stringToCharP(observer) + 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)) + libspice.fovtrg_c( + inst, + target, + tshape, + tframe, + abcorr, + observer, + ctypes.byref(et), + ctypes.byref(visible), + ) return bool(visible.value) -@spiceErrorCheck +@spice_error_check def frame(x): """ http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/frame_c.html @@ -5358,16 +5741,19 @@ def frame(x): :return: a tuple of 3 list[3] :rtype: tuple """ - x = stypes.toDoubleVector(x) - y = stypes.emptyDoubleVector(3) - z = stypes.emptyDoubleVector(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.cVectorToPython(x), stypes.cVectorToPython(y), stypes.cVectorToPython( - z) + return ( + stypes.c_vector_to_python(x), + stypes.c_vector_to_python(y), + stypes.c_vector_to_python(z), + ) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def frinfo(frcode): """ http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/frinfo_c.html @@ -5382,12 +5768,17 @@ def frinfo(frcode): 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)) + 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) -@spiceErrorCheck +@spice_error_check def frmnam(frcode, lenout=_default_len_out): """ Retrieve the name of a reference frame associated with a SPICE ID code. @@ -5403,12 +5794,12 @@ def frmnam(frcode, lenout=_default_len_out): """ frcode = ctypes.c_int(frcode) lenout = ctypes.c_int(lenout) - frname = stypes.stringToCharP(lenout) + frname = stypes.string_to_char_p(lenout) libspice.frmnam_c(frcode, lenout, frname) - return stypes.toPythonString(frname) + return stypes.to_python_string(frname) -@spiceErrorCheck +@spice_error_check def ftncls(unit): """ Close a file designated by a Fortran-style integer logical unit. @@ -5422,7 +5813,7 @@ def ftncls(unit): libspice.ftncls_c(unit) -@spiceErrorCheck +@spice_error_check def furnsh(path): """ Load one or more SPICE kernels into a program. @@ -5432,11 +5823,11 @@ def furnsh(path): :param path: one or more paths to kernels :type path: str or list of str """ - if stypes.isiterable(path): + if stypes.is_iterable(path): for p in path: - libspice.furnsh_c(stypes.stringToCharP(p)) + libspice.furnsh_c(stypes.string_to_char_p(p)) else: - path = stypes.stringToCharP(path) + path = stypes.string_to_char_p(path) libspice.furnsh_c(path) @@ -5444,8 +5835,8 @@ def furnsh(path): # G -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def gcpool(name, start, room, lenout=_default_len_out): """ Return the character value of a kernel variable from the kernel pool. @@ -5463,21 +5854,30 @@ def gcpool(name, start, room, lenout=_default_len_out): :return: Values associated with name. :rtype: list of str """ - name = stypes.stringToCharP(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.emptyCharArray(lenout, room) + 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.toPythonString(x.value) for x in - cvals[0:n.value]], bool(found.value) - - -@spiceErrorCheck -@spiceFoundExceptionThrower + 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), + ) + + +@spice_error_check +@spice_found_exception_thrower def gdpool(name, start, room): """ Return the d.p. value of a kernel variable from the kernel pool. @@ -5493,19 +5893,24 @@ def gdpool(name, start, room): :return: Values associated with name. :rtype: list of float """ - name = stypes.stringToCharP(name) + name = stypes.string_to_char_p(name) start = ctypes.c_int(start) - values = stypes.emptyDoubleVector(room) + 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.cVectorToPython(values)[0:n.value], bool(found.value) - - -@spiceErrorCheck + 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) + + +@spice_error_check def georec(lon, lat, alt, re, f): """ Convert geodetic coordinates to rectangular coordinates. @@ -5530,15 +5935,15 @@ def georec(lon, lat, alt, re, f): alt = ctypes.c_double(alt) re = ctypes.c_double(re) f = ctypes.c_double(f) - rectan = stypes.emptyDoubleVector(3) + rectan = stypes.empty_double_vector(3) libspice.georec_c(lon, lat, alt, re, f, rectan) - return stypes.cVectorToPython(rectan) + return stypes.c_vector_to_python(rectan) # getcml not really needed -@spiceErrorCheck +@spice_error_check def getelm(frstyr, lineln, lines): """ Given a the "lines" of a two-line element set, parse the @@ -5560,14 +5965,14 @@ def getelm(frstyr, lineln, lines): """ frstyr = ctypes.c_int(frstyr) lineln = ctypes.c_int(lineln) - lines = stypes.listToCharArrayPtr(lines, xLen=lineln, yLen=2) + lines = stypes.list_to_char_array_ptr(lines, x_len=lineln, y_len=2) epoch = ctypes.c_double() - elems = stypes.emptyDoubleVector(10) # guess for length + elems = stypes.empty_double_vector(10) # guess for length libspice.getelm_c(frstyr, lineln, lines, ctypes.byref(epoch), elems) - return epoch.value, stypes.cVectorToPython(elems) + return epoch.value, stypes.c_vector_to_python(elems) -@spiceErrorCheck +@spice_error_check def getfat(file): """ Determine the file architecture and file type of most SPICE kernel files. @@ -5579,16 +5984,16 @@ def getfat(file): :return: The architecture of the kernel file, The type of the kernel file. :rtype: tuple """ - file = stypes.stringToCharP(file) + file = stypes.string_to_char_p(file) arclen = ctypes.c_int(4) typlen = ctypes.c_int(4) - arch = stypes.stringToCharP(arclen) - rettype = stypes.stringToCharP(typlen) + arch = stypes.string_to_char_p(arclen) + rettype = stypes.string_to_char_p(typlen) libspice.getfat_c(file, arclen, typlen, arch, rettype) - return stypes.toPythonString(arch), stypes.toPythonString(rettype) + return stypes.to_python_string(arch), stypes.to_python_string(rettype) -@spiceErrorCheck +@spice_error_check def getfov(instid, room, shapelen=_default_len_out, framelen=_default_len_out): """ This routine returns the field-of-view (FOV) parameters for a @@ -5613,19 +6018,24 @@ def getfov(instid, room, shapelen=_default_len_out, framelen=_default_len_out): :rtype: tuple """ instid = ctypes.c_int(instid) - shape = stypes.stringToCharP(" " * shapelen) - framen = stypes.stringToCharP(" " * framelen) + 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.emptyDoubleVector(3) + bsight = stypes.empty_double_vector(3) n = ctypes.c_int() - bounds = stypes.emptyDoubleMatrix(x=3, y=room) + 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.toPythonString(shape), stypes.toPythonString( - framen), stypes.cVectorToPython( - bsight), n.value, stypes.cMatrixToNumpy(bounds)[0:n.value] + 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], + ) def getmsg(option, lenout=_default_len_out): @@ -5643,14 +6053,14 @@ def getmsg(option, lenout=_default_len_out): :return: The error message to be retrieved. :rtype: str """ - option = stypes.stringToCharP(option) + option = stypes.string_to_char_p(option) lenout = ctypes.c_int(lenout) - msg = stypes.stringToCharP(lenout) + msg = stypes.string_to_char_p(lenout) libspice.getmsg_c(option, lenout, msg) - return stypes.toPythonString(msg) + return stypes.to_python_string(msg) -@spiceErrorCheck +@spice_error_check def gfbail(): """ Indicate whether an interrupt signal (SIGINT) has been received. @@ -5663,7 +6073,7 @@ def gfbail(): return bool(libspice.gfbail_c()) -@spiceErrorCheck +@spice_error_check def gfclrh(): """ Clear the interrupt signal handler status, so that future calls @@ -5675,9 +6085,10 @@ def gfclrh(): libspice.gfclrh_c() -@spiceErrorCheck -def gfdist(target, abcorr, obsrvr, relate, refval, adjust, step, nintvls, - cnfine, result=None): +@spice_error_check +def gfdist( + target, abcorr, obsrvr, relate, refval, adjust, step, nintvls, cnfine, result=None +): """ Return the time window over which a specified constraint on observer-target distance is met. @@ -5712,24 +6123,55 @@ def gfdist(target, abcorr, obsrvr, relate, refval, adjust, step, nintvls, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - target = stypes.stringToCharP(target) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - relate = stypes.stringToCharP(relate) + 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)) + libspice.gfdist_c( + target, + abcorr, + obsrvr, + relate, + refval, + adjust, + step, + nintvls, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck -def gfevnt(udstep, udrefn, gquant, qnpars, lenvals, qpnams, - qcpars, qdpars, qipars, qlpars, op, refval, - tol, adjust, rpt, udrepi, udrepu, udrepf, - nintvls, bail, udbail, cnfine, result=None): +@spice_error_check +def gfevnt( + udstep, + udrefn, + gquant, + qnpars, + lenvals, + qpnams, + qcpars, + qdpars, + qipars, + qlpars, + op, + refval, + tol, + adjust, + rpt, + udrepi, + udrepu, + udrepf, + nintvls, + bail, + udbail, + cnfine, + result=None, +): """ Determine time intervals when a specified geometric quantity satisfies a specified mathematical condition. @@ -5790,31 +6232,70 @@ def gfevnt(udstep, udrefn, gquant, qnpars, lenvals, qpnams, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - gquant = stypes.stringToCharP(gquant) - qnpars = ctypes.c_int(qnpars) + gquant = stypes.string_to_char_p(gquant) + qnpars = ctypes.c_int(qnpars) lenvals = ctypes.c_int(lenvals) - qpnams = stypes.listToCharArrayPtr(qpnams, xLen=lenvals, yLen=qnpars) - qcpars = stypes.listToCharArrayPtr(qcpars, xLen=lenvals, yLen=qnpars) - qdpars = stypes.toDoubleVector(qdpars) - qipars = stypes.toIntVector(qipars) - qlpars = stypes.toIntVector(qlpars) - op = stypes.stringToCharP(op) - refval = ctypes.c_double(refval) - tol = ctypes.c_double(tol) - adjust = ctypes.c_double(adjust) - rpt = ctypes.c_int(rpt) + 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)) + 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 -@spiceErrorCheck -def gffove(inst, tshape, raydir, target, tframe, abcorr, obsrvr, - tol, udstep, udrefn, rpt, udrepi, udrepu, udrepf, bail, udbail, cnfine, result=None): +@spice_error_check +def gffove( + inst, + tshape, + raydir, + target, + tframe, + abcorr, + obsrvr, + tol, + udstep, + udrefn, + rpt, + udrepi, + udrepu, + udrepf, + bail, + udbail, + cnfine, + result=None, +): """ Determine time intervals when a specified target body or ray intersects the space bounded by the field-of-view (FOV) of a @@ -5867,27 +6348,57 @@ def gffove(inst, tshape, raydir, target, tframe, abcorr, obsrvr, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - inst = stypes.stringToCharP(inst) - tshape = stypes.stringToCharP(tshape) - raydir = stypes.toDoubleVector(raydir) - target = stypes.stringToCharP(target) - tframe = stypes.stringToCharP(tframe) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) + 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)) + 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 -@spiceErrorCheck -def gfilum(method, angtyp, target, illumn, - fixref, abcorr, obsrvr, spoint, - relate, refval, adjust, step, nintvls, cnfine, result=None): +@spice_error_check +def gfilum( + method, + angtyp, + target, + illumn, + fixref, + abcorr, + obsrvr, + spoint, + relate, + refval, + adjust, + step, + nintvls, + cnfine, + result=None, +): """ Return the time window over which a specified constraint on the observed phase, solar incidence, or emission angle at @@ -5931,27 +6442,40 @@ def gfilum(method, angtyp, target, illumn, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - method = stypes.stringToCharP(method) - angtyp = stypes.stringToCharP(angtyp) - target = stypes.stringToCharP(target) - illumn = stypes.stringToCharP(illumn) - fixref = stypes.stringToCharP(fixref) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - spoint = stypes.toDoubleVector(spoint) - relate = stypes.stringToCharP(relate) + 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) + 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)) + libspice.gfilum_c( + method, + angtyp, + target, + illumn, + fixref, + abcorr, + obsrvr, + spoint, + relate, + refval, + adjust, + step, + nintvls, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck +@spice_error_check def gfinth(sigcode): """ Respond to the interrupt signal SIGINT: save an indication @@ -5967,11 +6491,29 @@ def gfinth(sigcode): libspice.gfinth_c(sigcode) -@spiceErrorCheck -def gfocce(occtyp, front, fshape, fframe, back, - bshape, bframe, abcorr, obsrvr, tol, - udstep, udrefn, rpt, udrepi, udrepu, - udrepf, bail, udbail, cnfine, result=None): +@spice_error_check +def gfocce( + occtyp, + front, + fshape, + fframe, + back, + bshape, + bframe, + abcorr, + obsrvr, + tol, + udstep, + udrefn, + rpt, + udrepi, + udrepu, + udrepf, + bail, + udbail, + cnfine, + result=None, +): """ Determine time intervals when an observer sees one target occulted by another. Report progress and handle interrupts @@ -6030,27 +6572,58 @@ def gfocce(occtyp, front, fshape, fframe, back, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - occtyp = stypes.stringToCharP(occtyp) - front = stypes.stringToCharP(front) - fshape = stypes.stringToCharP(fshape) - fframe = stypes.stringToCharP(fframe) - back = stypes.stringToCharP(back) - bshape = stypes.stringToCharP(bshape) - bframe = stypes.stringToCharP(bframe) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) + 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)) + 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 -@spiceErrorCheck -def gfoclt(occtyp, front, fshape, fframe, back, bshape, bframe, abcorr, obsrvr, - step, cnfine, result=None): + +@spice_error_check +def gfoclt( + occtyp, + front, + fshape, + fframe, + back, + bshape, + bframe, + abcorr, + obsrvr, + step, + cnfine, + result=None, +): """ Determine time intervals when an observer sees one target occulted by, or in transit across, another. @@ -6089,25 +6662,47 @@ def gfoclt(occtyp, front, fshape, fframe, back, bshape, bframe, abcorr, obsrvr, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - occtyp = stypes.stringToCharP(occtyp) - front = stypes.stringToCharP(front) - fshape = stypes.stringToCharP(fshape) - fframe = stypes.stringToCharP(fframe) - back = stypes.stringToCharP(back) - bshape = stypes.stringToCharP(bshape) - bframe = stypes.stringToCharP(bframe) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) + 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)) + libspice.gfoclt_c( + occtyp, + front, + fshape, + fframe, + back, + bshape, + bframe, + abcorr, + obsrvr, + step, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck -def gfpa(target, illmin, abcorr, obsrvr, relate, refval, adjust, step, nintvals, - cnfine, result=None): +@spice_error_check +def gfpa( + target, + illmin, + abcorr, + obsrvr, + relate, + refval, + adjust, + step, + nintvals, + cnfine, + result=None, +): """ Determine time intervals for which a specified constraint on the phase angle between an illumination source, a target, @@ -6145,24 +6740,47 @@ def gfpa(target, illmin, abcorr, obsrvr, relate, refval, adjust, step, nintvals, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - target = stypes.stringToCharP(target) - illmin = stypes.stringToCharP(illmin) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - relate = stypes.stringToCharP(relate) + 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) nintvals = ctypes.c_int(nintvals) - libspice.gfpa_c(target, illmin, abcorr, obsrvr, relate, refval, - adjust, step, nintvals, ctypes.byref(cnfine), - ctypes.byref(result)) + libspice.gfpa_c( + target, + illmin, + abcorr, + obsrvr, + relate, + refval, + adjust, + step, + nintvals, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck -def gfposc(target, inframe, abcorr, obsrvr, crdsys, coord, relate, refval, - adjust, step, nintvals, cnfine, result=None): +@spice_error_check +def gfposc( + target, + inframe, + abcorr, + obsrvr, + crdsys, + coord, + relate, + refval, + adjust, + step, + nintvals, + cnfine, + result=None, +): """ Determine time intervals for which a coordinate of an observer-target position vector satisfies a numerical constraint. @@ -6203,24 +6821,36 @@ def gfposc(target, inframe, abcorr, obsrvr, crdsys, coord, relate, refval, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - target = stypes.stringToCharP(target) - inframe = stypes.stringToCharP(inframe) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - crdsys = stypes.stringToCharP(crdsys) - coord = stypes.stringToCharP(coord) - relate = stypes.stringToCharP(relate) + 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) nintvals = ctypes.c_int(nintvals) - libspice.gfposc_c(target, inframe, abcorr, obsrvr, crdsys, coord, - relate, refval, adjust, step, nintvals, - ctypes.byref(cnfine), ctypes.byref(result)) + libspice.gfposc_c( + target, + inframe, + abcorr, + obsrvr, + crdsys, + coord, + relate, + refval, + adjust, + step, + nintvals, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck +@spice_error_check def gfrefn(t1, t2, s1, s2): """ For those times when we can't do better, we use a bisection @@ -6248,7 +6878,7 @@ def gfrefn(t1, t2, s1, s2): return t.value -@spiceErrorCheck +@spice_error_check def gfrepf(): """ Finish a GF progress report. @@ -6259,7 +6889,7 @@ def gfrepf(): libspice.gfrepf_c() -@spiceErrorCheck +@spice_error_check def gfrepi(window, begmss, endmss): """ This entry point initializes a search progress report. @@ -6273,8 +6903,8 @@ def gfrepi(window, begmss, endmss): :param endmss: End of the text portion of the output message. :type endmss: str """ - begmss = stypes.stringToCharP(begmss) - endmss = stypes.stringToCharP(endmss) + 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, ctypes.POINTER(stypes.SpiceCell)): assert isinstance(window, stypes.SpiceCell) @@ -6283,7 +6913,7 @@ def gfrepi(window, begmss, endmss): libspice.gfrepi_c(window, begmss, endmss) -@spiceErrorCheck +@spice_error_check def gfrepu(ivbeg, ivend, time): """ This function tells the progress reporting system @@ -6304,7 +6934,7 @@ def gfrepu(ivbeg, ivend, time): libspice.gfrepu_c(ivbeg, ivend, time) -@spiceErrorCheck +@spice_error_check def gfrfov(inst, raydir, rframe, abcorr, obsrvr, step, cnfine, result=None): """ Determine time intervals when a specified ray intersects the @@ -6337,20 +6967,29 @@ def gfrfov(inst, raydir, rframe, abcorr, obsrvr, step, cnfine, result=None): else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - inst = stypes.stringToCharP(inst) - raydir = stypes.toDoubleVector(raydir) - rframe = stypes.stringToCharP(rframe) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) + 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)) + libspice.gfrfov_c( + inst, + raydir, + rframe, + abcorr, + obsrvr, + step, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck -def gfrr(target, abcorr, obsrvr, relate, refval, adjust, step, nintvals, cnfine, - result): +@spice_error_check +def gfrr( + target, abcorr, obsrvr, relate, refval, adjust, step, nintvals, cnfine, result +): """ Determine time intervals for which a specified constraint on the observer-target range rate is met. @@ -6385,23 +7024,47 @@ def gfrr(target, abcorr, obsrvr, relate, refval, adjust, step, nintvals, cnfine, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - target = stypes.stringToCharP(target) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - relate = stypes.stringToCharP(relate) + 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) nintvals = ctypes.c_int(nintvals) - libspice.gfrr_c(target, abcorr, obsrvr, relate, refval, - adjust, step, nintvals, ctypes.byref(cnfine), - ctypes.byref(result)) + libspice.gfrr_c( + target, + abcorr, + obsrvr, + relate, + refval, + adjust, + step, + nintvals, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck -def gfsep(targ1, shape1, inframe1, targ2, shape2, inframe2, abcorr, obsrvr, - relate, refval, adjust, step, nintvals, cnfine, result=None): +@spice_error_check +def gfsep( + targ1, + shape1, + inframe1, + targ2, + shape2, + inframe2, + abcorr, + obsrvr, + relate, + refval, + adjust, + step, + nintvals, + cnfine, + result=None, +): """ Determine time intervals when the angular separation between the position vectors of two target bodies relative to an observer @@ -6447,29 +7110,58 @@ def gfsep(targ1, shape1, inframe1, targ2, shape2, inframe2, abcorr, obsrvr, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - targ1 = stypes.stringToCharP(targ1) - shape1 = stypes.stringToCharP(shape1) - inframe1 = stypes.stringToCharP(inframe1) - targ2 = stypes.stringToCharP(targ2) - shape2 = stypes.stringToCharP(shape2) - inframe2 = stypes.stringToCharP(inframe2) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - relate = stypes.stringToCharP(relate) + 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) nintvals = ctypes.c_int(nintvals) - libspice.gfsep_c(targ1, shape1, inframe1, targ2, shape2, inframe2, - abcorr, obsrvr, relate, refval, adjust, step, nintvals, - ctypes.byref(cnfine), ctypes.byref(result)) + libspice.gfsep_c( + targ1, + shape1, + inframe1, + targ2, + shape2, + inframe2, + abcorr, + obsrvr, + relate, + refval, + adjust, + step, + nintvals, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck -def gfsntc(target, fixref, method, abcorr, obsrvr, dref, dvec, crdsys, coord, - relate, refval, adjust, step, nintvals, - cnfine, result=None): +@spice_error_check +def gfsntc( + target, + fixref, + method, + abcorr, + obsrvr, + dref, + dvec, + crdsys, + coord, + relate, + refval, + adjust, + step, + nintvals, + cnfine, + result=None, +): """ Determine time intervals for which a coordinate of an surface intercept position vector satisfies a numerical constraint. @@ -6516,28 +7208,42 @@ def gfsntc(target, fixref, method, abcorr, obsrvr, dref, dvec, crdsys, coord, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - target = stypes.stringToCharP(target) - fixref = stypes.stringToCharP(fixref) - method = stypes.stringToCharP(method) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - dref = stypes.stringToCharP(dref) - dvec = stypes.toDoubleVector(dvec) - crdsys = stypes.stringToCharP(crdsys) - coord = stypes.stringToCharP(coord) - relate = stypes.stringToCharP(relate) + 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) nintvals = ctypes.c_int(nintvals) - libspice.gfsntc_c(target, fixref, method, abcorr, obsrvr, - dref, dvec, crdsys, coord, relate, refval, - adjust, step, nintvals, ctypes.byref(cnfine), - ctypes.byref(result)) + libspice.gfsntc_c( + target, + fixref, + method, + abcorr, + obsrvr, + dref, + dvec, + crdsys, + coord, + relate, + refval, + adjust, + step, + nintvals, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck +@spice_error_check def gfsstp(step): """ Set the step size to be returned by :func:`gfstep`. @@ -6551,7 +7257,7 @@ def gfsstp(step): libspice.gfsstp_c(step) -@spiceErrorCheck +@spice_error_check def gfstep(time): """ Return the time step set by the most recent call to :func:`gfsstp`. @@ -6569,7 +7275,7 @@ def gfstep(time): return step.value -@spiceErrorCheck +@spice_error_check def gfstol(value): """ Override the default GF convergence @@ -6586,10 +7292,23 @@ def gfstol(value): libspice.gfstol_c(value) -@spiceErrorCheck -def gfsubc(target, fixref, method, abcorr, obsrvr, crdsys, coord, relate, - refval, adjust, step, nintvals, cnfine, - result): +@spice_error_check +def gfsubc( + target, + fixref, + method, + abcorr, + obsrvr, + crdsys, + coord, + relate, + refval, + adjust, + step, + nintvals, + cnfine, + result, +): """ Determine time intervals for which a coordinate of an subpoint position vector satisfies a numerical constraint. @@ -6632,25 +7351,38 @@ def gfsubc(target, fixref, method, abcorr, obsrvr, crdsys, coord, relate, else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - target = stypes.stringToCharP(target) - fixref = stypes.stringToCharP(fixref) - method = stypes.stringToCharP(method) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - crdsys = stypes.stringToCharP(crdsys) - coord = stypes.stringToCharP(coord) - relate = stypes.stringToCharP(relate) + 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) nintvals = ctypes.c_int(nintvals) - libspice.gfsubc_c(target, fixref, method, abcorr, obsrvr, crdsys, - coord, relate, refval, adjust, step, nintvals, - ctypes.byref(cnfine), ctypes.byref(result)) + libspice.gfsubc_c( + target, + fixref, + method, + abcorr, + obsrvr, + crdsys, + coord, + relate, + refval, + adjust, + step, + nintvals, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck +@spice_error_check def gftfov(inst, target, tshape, tframe, abcorr, obsrvr, step, cnfine, result=None): """ Determine time intervals when a specified ephemeris object @@ -6685,19 +7417,28 @@ def gftfov(inst, target, tshape, tframe, abcorr, obsrvr, step, cnfine, result=No else: assert isinstance(result, stypes.SpiceCell) assert result.is_double() - inst = stypes.stringToCharP(inst) - target = stypes.stringToCharP(target) - tshape = stypes.stringToCharP(tshape) - tframe = stypes.stringToCharP(tframe) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) + 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)) + libspice.gftfov_c( + inst, + target, + tshape, + tframe, + abcorr, + obsrvr, + step, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck +@spice_error_check def gfudb(udfuns, udfunb, step, cnfine, result): """ Perform a GF search on a user defined boolean quantity. @@ -6721,7 +7462,7 @@ def gfudb(udfuns, udfunb, step, cnfine, result): libspice.gfudb_c(udfuns, udfunb, step, ctypes.byref(cnfine), ctypes.byref(result)) -@spiceErrorCheck +@spice_error_check def gfuds(udfuns, udqdec, relate, refval, adjust, step, nintvls, cnfine, result): """ Perform a GF search on a user defined scalar quantity. @@ -6749,17 +7490,27 @@ def gfuds(udfuns, udqdec, relate, refval, adjust, step, nintvls, cnfine, result) :return: result :rtype: spiceypy.utils.support_types.SpiceCell """ - relate = stypes.stringToCharP(relate) - refval = ctypes.c_double(refval) - adjust = ctypes.c_double(adjust) - step = ctypes.c_double(step) + 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)) + libspice.gfuds_c( + udfuns, + udqdec, + relate, + refval, + adjust, + step, + nintvls, + ctypes.byref(cnfine), + ctypes.byref(result), + ) return result -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def gipool(name, start, room): """ Return the integer value of a kernel variable from the kernel pool. @@ -6775,19 +7526,18 @@ def gipool(name, start, room): :return: Values associated with name. :rtype: list of int """ - name = stypes.stringToCharP(name) + name = stypes.string_to_char_p(name) start = ctypes.c_int(start) - ivals = stypes.emptyIntVector(room) + 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.cVectorToPython(ivals)[0:n.value], bool(found.value) + 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) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def gnpool(name, start, room, lenout=_default_len_out): """ Return names of kernel variables matching a specified template. @@ -6805,23 +7555,24 @@ def gnpool(name, start, room, lenout=_default_len_out): :return: Kernel pool variables whose names match name. :rtype: list of str """ - name = stypes.stringToCharP(name) + name = stypes.string_to_char_p(name) start = ctypes.c_int(start) - kvars = stypes.emptyCharArray(yLen=room, xLen=lenout) + 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.cVectorToPython(kvars)[0:n.value], bool(found.value) + 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 -@spiceErrorCheck +@spice_error_check def halfpi(): """ Return half the value of pi (the ratio of the circumference of @@ -6835,35 +7586,35 @@ def halfpi(): return libspice.halfpi_c() -@spiceErrorCheck +@spice_error_check def hrmint(xvals, yvals, x): """ 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. :type xvals: Array of floats :param yvals: Ordinate and derivative values. :type yvals: Array of floats :param x: Point at which to interpolate the polynomial. :type x: int - :return: Interpolated function value at x and the Interpolated function's derivative at x + :return: Interpolated function value at x and the Interpolated function's derivative at x :rtype: tuple """ - work = stypes.emptyDoubleVector(int(2*len(yvals)+1)) - n = ctypes.c_int(len(xvals)) - xvals = stypes.toDoubleVector(xvals) - yvals = stypes.toDoubleVector(yvals) - x = ctypes.c_double(x) - f = ctypes.c_double(0) - df = ctypes.c_double(0) + 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 -@spiceErrorCheck +@spice_error_check def hx2dp(string): """ Convert a string representing a double precision number in a @@ -6877,24 +7628,23 @@ def hx2dp(string): :return: Double precision value to be returned, Or Error Message. :rtype: float or str """ - string = stypes.stringToCharP(string) + string = stypes.string_to_char_p(string) lenout = ctypes.c_int(80) - errmsg = stypes.stringToCharP(lenout) + 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) + libspice.hx2dp_c(string, lenout, ctypes.byref(number), ctypes.byref(error), errmsg) if not error.value: return number.value else: - return stypes.toPythonString(errmsg) + return stypes.to_python_string(errmsg) ################################################################################ # I -@spiceErrorCheck +@spice_error_check def ident(): """ This routine returns the 3x3 identity matrix. @@ -6904,12 +7654,12 @@ def ident(): :return: The 3x3 identity matrix. :rtype: 3x3-Element Array of floats """ - matrix = stypes.emptyDoubleMatrix() + matrix = stypes.empty_double_matrix() libspice.ident_c(matrix) - return stypes.cMatrixToNumpy(matrix) + return stypes.c_matrix_to_numpy(matrix) -@spiceErrorCheck +@spice_error_check def illum(target, et, abcorr, obsrvr, spoint): """ Deprecated: This routine has been superseded by the CSPICE @@ -6937,20 +7687,28 @@ def illum(target, et, abcorr, obsrvr, spoint): and Emission angle at the surface point. :rtype: tuple """ - target = stypes.stringToCharP(target) + target = stypes.string_to_char_p(target) et = ctypes.c_double(et) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - spoint = stypes.toDoubleVector(spoint) + 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)) + libspice.illum_c( + target, + et, + abcorr, + obsrvr, + spoint, + ctypes.byref(phase), + ctypes.byref(solar), + ctypes.byref(emissn), + ) return phase.value, solar.value, emissn.value -@spiceErrorCheck +@spice_error_check def illumf(method, target, ilusrc, et, fixref, abcorr, obsrvr, spoint): """ Compute the illumination angles---phase, incidence, and @@ -6963,13 +7721,13 @@ def illumf(method, target, ilusrc, et, fixref, abcorr, obsrvr, spoint): 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. :type method: str :param target: Name of target body. - :type target: str + :type target: str :param ilusrc: Name of illumination source. :type ilusrc: str :param et: Epoch in ephemeris seconds past J2000. @@ -6983,51 +7741,71 @@ def illumf(method, target, ilusrc, et, fixref, abcorr, obsrvr, spoint): :param spoint: Body-fixed coordinates of a target surface point. :type spoint: 3-Element Array of floats :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, + 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 :rtype: tuple """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) - ilusrc = stypes.stringToCharP(ilusrc) - et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - spoint = stypes.toDoubleVector(spoint) + 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.emptyDoubleVector(3) - phase = 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.cVectorToPython(srfvec), \ - phase.value, incdnc.value, emissn.value, bool(visibl.value), bool(lit.value) - - -@spiceErrorCheck + 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), + ) + + +@spice_error_check def illumg(method, target, ilusrc, et, fixref, abcorr, obsrvr, spoint): """ - 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. - + 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 - + :type method: str :param target: Name of target body. - :type target: str + :type target: str :param ilusrc: Name of illumination source. :type ilusrc: str :param et: Epoch in ephemeris seconds past J2000. @@ -7041,31 +7819,48 @@ def illumg(method, target, ilusrc, et, fixref, abcorr, obsrvr, spoint): :param spoint: Body-fixed coordinates of a target surface point. :type spoint: 3-Element Array of floats :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, + surface point, Phase angle at the surface point, Source incidence + angle at the surface point, Emission angle at the surface point, :rtype: tuple """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) - ilusrc = stypes.stringToCharP(ilusrc) - et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - spoint = stypes.toDoubleVector(spoint) + 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.emptyDoubleVector(3) - phase = 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.cVectorToPython(srfvec), \ - phase.value, incdnc.value, emissn.value - - -@spiceErrorCheck + 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, + ) + + +@spice_error_check def ilumin(method, target, et, fixref, abcorr, obsrvr, spoint): """ Find the illumination angles (phase, solar incidence, and @@ -7094,28 +7889,43 @@ def ilumin(method, target, et, fixref, abcorr, obsrvr, spoint): angle at the surface point. :rtype: tuple """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) + method = stypes.string_to_char_p(method) + target = stypes.string_to_char_p(target) et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - spoint = stypes.toDoubleVector(spoint) + 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.emptyDoubleVector(3) + 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.cVectorToPython( - srfvec), phase.value, solar.value, emissn.value - - -@spiceErrorCheck -@spiceFoundExceptionThrower + 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, + ) + + +@spice_error_check +@spice_found_exception_thrower def inedpl(a, b, c, plane): """ Find the intersection of a triaxial ellipsoid and a plane. @@ -7133,18 +7943,19 @@ def inedpl(a, b, c, plane): :return: Intersection ellipse. :rtype: spiceypy.utils.support_types.Ellipse """ - assert (isinstance(plane, stypes.Plane)) + 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)) + libspice.inedpl_c( + a, b, c, ctypes.byref(plane), ctypes.byref(ellipse), ctypes.byref(found) + ) return ellipse, bool(found.value) -@spiceErrorCheck +@spice_error_check def inelpl(ellips, plane): """ Find the intersection of an ellipse and a plane. @@ -7161,17 +7972,18 @@ def inelpl(ellips, plane): Point 2. :rtype: tuple """ - assert (isinstance(plane, stypes.Plane)) - assert (isinstance(ellips, stypes.Ellipse)) + assert isinstance(plane, stypes.Plane) + assert isinstance(ellips, stypes.Ellipse) nxpts = ctypes.c_int() - xpt1 = stypes.emptyDoubleVector(3) - xpt2 = stypes.emptyDoubleVector(3) - libspice.inelpl_c(ctypes.byref(ellips), ctypes.byref(plane), - ctypes.byref(nxpts), xpt1, xpt2) - return nxpts.value, stypes.cVectorToPython(xpt1), stypes.cVectorToPython(xpt2) + 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) -@spiceErrorCheck +@spice_error_check def inrypl(vertex, direct, plane): """ Find the intersection of a ray and a plane. @@ -7190,17 +8002,16 @@ def inrypl(vertex, direct, plane): if nxpts == 1. :rtype: tuple """ - assert (isinstance(plane, stypes.Plane)) - vertex = stypes.toDoubleVector(vertex) - direct = stypes.toDoubleVector(direct) + assert isinstance(plane, stypes.Plane) + vertex = stypes.to_double_vector(vertex) + direct = stypes.to_double_vector(direct) nxpts = ctypes.c_int() - xpt = stypes.emptyDoubleVector(3) - libspice.inrypl_c(vertex, direct, ctypes.byref(plane), ctypes.byref(nxpts), - xpt) - return nxpts.value, stypes.cVectorToPython(xpt) + 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) -@spiceErrorCheck +@spice_error_check def insrtc(item, inset): """ Insert an item into a character set. @@ -7213,15 +8024,15 @@ def insrtc(item, inset): :type inset: spiceypy.utils.support_types.SpiceCell """ assert isinstance(inset, stypes.SpiceCell) - if stypes.isiterable(item): + if stypes.is_iterable(item): for c in item: - libspice.insrtc_c(stypes.stringToCharP(c), ctypes.byref(inset)) + libspice.insrtc_c(stypes.string_to_char_p(c), ctypes.byref(inset)) else: - item = stypes.stringToCharP(item) + item = stypes.string_to_char_p(item) libspice.insrtc_c(item, ctypes.byref(inset)) -@spiceErrorCheck +@spice_error_check def insrtd(item, inset): """ Insert an item into a double precision set. @@ -7242,7 +8053,7 @@ def insrtd(item, inset): libspice.insrtd_c(item, ctypes.byref(inset)) -@spiceErrorCheck +@spice_error_check def insrti(item, inset): """ Insert an item into an integer set. @@ -7263,7 +8074,7 @@ def insrti(item, inset): libspice.insrti_c(item, ctypes.byref(inset)) -@spiceErrorCheck +@spice_error_check def inter(a, b): """ Intersect two sets of any data type to form a third set. @@ -7294,7 +8105,7 @@ def inter(a, b): return c -@spiceErrorCheck +@spice_error_check def intmax(): """ Return the value of the largest (positive) number representable @@ -7308,7 +8119,7 @@ def intmax(): return libspice.intmax_c() -@spiceErrorCheck +@spice_error_check def intmin(): """ Return the value of the smallest (negative) number representable @@ -7322,7 +8133,7 @@ def intmin(): return libspice.intmin_c() -@spiceErrorCheck +@spice_error_check def invert(m): """ Generate the inverse of a 3x3 matrix. @@ -7334,13 +8145,13 @@ def invert(m): :return: Inverted matrix (m1)^-1 :rtype: 3x3-Element Array of floats """ - m = stypes.toDoubleMatrix(m) - mout = stypes.emptyDoubleMatrix() + m = stypes.to_double_matrix(m) + mout = stypes.empty_double_matrix() libspice.invert_c(m, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def invort(m): """ Given a matrix, construct the matrix whose rows are the @@ -7354,13 +8165,13 @@ def invort(m): :return: m after transposition and scaling of rows. :rtype: 3x3-Element Array of floats """ - m = stypes.toDoubleMatrix(m) - mout = stypes.emptyDoubleMatrix() + m = stypes.to_double_matrix(m) + mout = stypes.empty_double_matrix() libspice.invort_c(m, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def isordv(array, n): """ Determine whether an array of n items contains the integers @@ -7377,12 +8188,12 @@ def isordv(array, n): integers 0 through n-1, otherwise it returns False. :rtype: bool """ - array = stypes.toIntVector(array) + array = stypes.to_int_vector(array) n = ctypes.c_int(n) return bool(libspice.isordv_c(array, n)) -@spiceErrorCheck +@spice_error_check def isrchc(value, ndim, lenvals, array): """ Search for a given value within a character string array. Return @@ -7404,14 +8215,14 @@ def isrchc(value, ndim, lenvals, array): if the value is not found. :rtype: int """ - value = stypes.stringToCharP(value) - array = stypes.listToCharArrayPtr(array, xLen=lenvals, yLen=ndim) + 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) -@spiceErrorCheck +@spice_error_check def isrchd(value, ndim, array): """ Search for a given value within a double precision array. Return @@ -7433,11 +8244,11 @@ def isrchd(value, ndim, array): """ value = ctypes.c_double(value) ndim = ctypes.c_int(ndim) - array = stypes.toDoubleVector(array) + array = stypes.to_double_vector(array) return libspice.isrchd_c(value, ndim, array) -@spiceErrorCheck +@spice_error_check def isrchi(value, ndim, array): """ Search for a given value within an integer array. Return @@ -7459,11 +8270,11 @@ def isrchi(value, ndim, array): """ value = ctypes.c_int(value) ndim = ctypes.c_int(ndim) - array = stypes.toIntVector(array) + array = stypes.to_int_vector(array) return libspice.isrchi_c(value, ndim, array) -@spiceErrorCheck +@spice_error_check def isrot(m, ntol, dtol): """ Indicate whether a 3x3 matrix is a rotation matrix. @@ -7481,13 +8292,13 @@ def isrot(m, ntol, dtol): :return: True if and only if m is a rotation matrix. :rtype: bool """ - m = stypes.toDoubleMatrix(m) + m = stypes.to_double_matrix(m) ntol = ctypes.c_double(ntol) dtol = ctypes.c_double(dtol) return bool(libspice.isrot_c(m, ntol, dtol)) -@spiceErrorCheck +@spice_error_check def iswhsp(string): """ Return a boolean value indicating whether a string contains @@ -7502,7 +8313,7 @@ def iswhsp(string): only white space characters; otherwise it returns the value False. :rtype: bool """ - string = stypes.stringToCharP(string) + string = stypes.string_to_char_p(string) return bool(libspice.iswhsp_c(string)) @@ -7510,7 +8321,7 @@ def iswhsp(string): # J -@spiceErrorCheck +@spice_error_check def j1900(): """ http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/j1900_c.html @@ -7521,7 +8332,7 @@ def j1900(): return libspice.j1900_c() -@spiceErrorCheck +@spice_error_check def j1950(): """ http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/j1950_c.html @@ -7532,7 +8343,7 @@ def j1950(): return libspice.j1950_c() -@spiceErrorCheck +@spice_error_check def j2000(): """ http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/j2000_c.html @@ -7543,7 +8354,7 @@ def j2000(): return libspice.j2000_c() -@spiceErrorCheck +@spice_error_check def j2100(): """ http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/j2100_c.html @@ -7554,7 +8365,7 @@ def j2100(): return libspice.j2100_c() -@spiceErrorCheck +@spice_error_check def jyear(): """ http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/jyear_c.html @@ -7569,7 +8380,7 @@ def jyear(): # K -@spiceErrorCheck +@spice_error_check def kclear(): """ Clear the KEEPER subsystem: unload all kernels, clear the kernel @@ -7582,9 +8393,15 @@ def kclear(): libspice.kclear_c() -@spiceErrorCheck -@spiceFoundExceptionThrower -def kdata(which, kind, fillen=_default_len_out, typlen=_default_len_out, srclen=_default_len_out): +@spice_error_check +@spice_found_exception_thrower +def kdata( + which, + kind, + fillen=_default_len_out, + typlen=_default_len_out, + srclen=_default_len_out, +): """ Return data for the nth kernel that is among a list of specified kernel types. @@ -7608,23 +8425,38 @@ def kdata(which, kind, fillen=_default_len_out, typlen=_default_len_out, srclen= :rtype: tuple """ which = ctypes.c_int(which) - kind = stypes.stringToCharP(kind) + kind = stypes.string_to_char_p(kind) fillen = ctypes.c_int(fillen) typlen = ctypes.c_int(typlen) srclen = ctypes.c_int(srclen) - file = stypes.stringToCharP(fillen) - filtyp = stypes.stringToCharP(typlen) - source = stypes.stringToCharP(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.toPythonString(file), stypes.toPythonString( - filtyp), stypes.toPythonString(source), handle.value, bool(found.value) - - -@spiceErrorCheck -@spiceFoundExceptionThrower + 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), + ) + + +@spice_error_check +@spice_found_exception_thrower def kinfo(file, typlen=_default_len_out, srclen=_default_len_out): """ Return information about a loaded kernel specified by name. @@ -7645,19 +8477,24 @@ def kinfo(file, typlen=_default_len_out, srclen=_default_len_out): """ typlen = ctypes.c_int(typlen) srclen = ctypes.c_int(srclen) - file = stypes.stringToCharP(file) - filtyp = stypes.stringToCharP(" " * typlen.value) - source = stypes.stringToCharP(" " * srclen.value) + 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.toPythonString(filtyp), stypes.toPythonString( - source), handle.value, bool(found.value) + 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), + ) -@spiceErrorCheck -def kplfrm(frmcls, outCell=None): +@spice_error_check +def kplfrm(frmcls, out_cell=None): """ Return a SPICE set containing the frame IDs of all reference frames of a given class having specifications in the kernel pool. @@ -7666,19 +8503,19 @@ def kplfrm(frmcls, outCell=None): :param frmcls: Frame class. :type frmcls: int - :param outCell: Optional output Spice Int Cell - :type outCell: spiceypy.utils.support_types.SpiceCell + :param out_cell: Optional output Spice Int Cell + :type out_cell: spiceypy.utils.support_types.SpiceCell :return: Set of ID codes of frames of the specified class. :rtype: spiceypy.utils.support_types.SpiceCell """ - if not outCell: - outCell = stypes.SPICEINT_CELL(1000) + if not out_cell: + out_cell = stypes.SPICEINT_CELL(1000) frmcls = ctypes.c_int(frmcls) - libspice.kplfrm_c(frmcls, ctypes.byref(outCell)) - return outCell + libspice.kplfrm_c(frmcls, ctypes.byref(out_cell)) + return out_cell -@spiceErrorCheck +@spice_error_check def ktotal(kind): """ Return the current number of kernels that have been loaded @@ -7691,15 +8528,23 @@ def ktotal(kind): :return: The number of kernels of type kind. :rtype: int """ - kind = stypes.stringToCharP(kind) + kind = stypes.string_to_char_p(kind) count = ctypes.c_int() libspice.ktotal_c(kind, ctypes.byref(count)) return count.value -@spiceErrorCheck -@spiceFoundExceptionThrower -def kxtrct(keywd, terms, nterms, instring, termlen=_default_len_out, stringlen=_default_len_out, substrlen=_default_len_out): +@spice_error_check +@spice_found_exception_thrower +def kxtrct( + keywd, + terms, + nterms, + instring, + termlen=_default_len_out, + stringlen=_default_len_out, + substrlen=_default_len_out, +): """ Locate a keyword in a string and extract the substring from the beginning of the first word following the keyword to the @@ -7728,28 +8573,41 @@ def kxtrct(keywd, terms, nterms, instring, termlen=_default_len_out, stringlen=_ """ assert nterms <= len(terms) # Python strings and string arrays => to C char pointers - keywd = stypes.stringToCharP(keywd) - terms = stypes.listToCharArrayPtr([s[:termlen-1] for s in terms[:nterms]],xLen=termlen,yLen=nterms) - instring = stypes.stringToCharP(instring[:stringlen-1],inlen=stringlen) - substr = stypes.stringToCharP(substrlen) + 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.toPythonString(instring), stypes.toPythonString( - substr), bool(found.value) + 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 -@spiceErrorCheck +@spice_error_check def lastnb(string): """ Return the zero based index of the last non-blank character in @@ -7761,11 +8619,11 @@ def lastnb(string): :type string: str :return: :rtype: """ - string = stypes.stringToCharP(string) + string = stypes.string_to_char_p(string) return libspice.lastnb_c(string) -@spiceErrorCheck +@spice_error_check def latcyl(radius, lon, lat): """ Convert from latitudinal coordinates to cylindrical coordinates. @@ -7785,12 +8643,13 @@ def latcyl(radius, lon, 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)) + libspice.latcyl_c( + radius, lon, lat, ctypes.byref(r), ctypes.byref(lonc), ctypes.byref(z) + ) return r.value, lonc.value, z.value -@spiceErrorCheck +@spice_error_check def latrec(radius, longitude, latitude): """ Convert from latitudinal coordinates to rectangular coordinates. @@ -7809,12 +8668,12 @@ def latrec(radius, longitude, latitude): radius = ctypes.c_double(radius) longitude = ctypes.c_double(longitude) latitude = ctypes.c_double(latitude) - rectan = stypes.emptyDoubleVector(3) + rectan = stypes.empty_double_vector(3) libspice.latrec_c(radius, longitude, latitude, rectan) - return stypes.cVectorToPython(rectan) + return stypes.c_vector_to_python(rectan) -@spiceErrorCheck +@spice_error_check def latsph(radius, lon, lat): """ Convert from latitudinal coordinates to spherical coordinates. @@ -7833,47 +8692,48 @@ def latsph(radius, lon, 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)) + libspice.latsph_c( + radius, lon, lat, ctypes.byref(rho), ctypes.byref(colat), ctypes.byref(lons) + ) return rho.value, colat.value, lons.value -@spiceErrorCheck +@spice_error_check def latsrf(method, target, et, fixref, lonlat): """ - 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 + 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. :type method: str :param target: Name of target body. :type target: str - :param et: Epoch in TDB seconds past J2000 TDB. + :param et: Epoch in TDB seconds past J2000 TDB. :type et: float :param fixref: Body-fixed, body-centered target body frame. :type fixref: str :param lonlat: Array of longitude/latitude coordinate pairs. :type lonlat: A 2xM-Element Array of floats - :return: Array of surface points. + :return: Array of surface points. :rtype: A 3xM-Element Array of floats """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) - et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - npts = ctypes.c_int(len(lonlat)) - lonlat = stypes.toDoubleMatrix(lonlat) - srfpts = stypes.emptyDoubleMatrix(3, npts.value) + 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.cMatrixToNumpy(srfpts) + return stypes.c_matrix_to_numpy(srfpts) -@spiceErrorCheck +@spice_error_check def lcase(instr, lenout=_default_len_out): """ Convert the characters in a string to lowercase. @@ -7887,14 +8747,14 @@ def lcase(instr, lenout=_default_len_out): :return: Output string, all lowercase. :rtype: str """ - instr = stypes.stringToCharP(instr) + instr = stypes.string_to_char_p(instr) lenout = ctypes.c_int(lenout) - outstr = stypes.stringToCharP(lenout) + outstr = stypes.string_to_char_p(lenout) libspice.lcase_c(instr, lenout, outstr) - return stypes.toPythonString(outstr) + return stypes.to_python_string(outstr) -@spiceErrorCheck +@spice_error_check def ldpool(filename): """ Load the variables contained in a NAIF ASCII kernel file into the @@ -7905,24 +8765,38 @@ def ldpool(filename): :param filename: Name of the kernel file. :type filename: str """ - filename = stypes.stringToCharP(filename) + filename = stypes.string_to_char_p(filename) libspice.ldpool_c(filename) -@spiceErrorCheck -def limbpt(method, target, et, fixref, abcorr, corloc, obsrvr, refvec, rolstp, ncuts, schstp, soltol, maxn): - """ - 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. - +@spice_error_check +def limbpt( + method, + target, + et, + fixref, + abcorr, + corloc, + obsrvr, + refvec, + rolstp, + ncuts, + schstp, + soltol, + maxn, +): + """ + 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 method: Computation method. :type method: str :param target: Name of target body. :type target: str @@ -7930,7 +8804,7 @@ def limbpt(method, target, et, fixref, abcorr, corloc, obsrvr, refvec, rolstp, n :type et: float :param fixref: Body-fixed, body-centered target body frame. :type fixref: str - :param abcorr: Aberration correction. + :param abcorr: Aberration correction. :type abcorr: str :param corloc: Aberration correction locus. :type corloc: str @@ -7938,53 +8812,73 @@ def limbpt(method, target, et, fixref, abcorr, corloc, obsrvr, refvec, rolstp, n :type obsrvr: str :param refvec: Reference vector for cutting half-planes. :type refvec: 3-Element Array of floats - :param rolstp: Roll angular step for cutting half-planes. + :param rolstp: Roll angular step for cutting half-planes. :type rolstp: float - :param ncuts: Number of cutting half-planes. + :param ncuts: Number of cutting half-planes. :type ncuts: int - :param schstp: Angular step size for searching. + :param schstp: Angular step size for searching. :type schstp: float - :param soltol: Solution convergence tolerance. + :param soltol: Solution convergence tolerance. :type soltol: float - :param maxn: Maximum number of entries in output arrays. + :param maxn: Maximum number of entries in output arrays. :type maxn: int :return: Counts of limb points corresponding to cuts, Limb points, Times associated with limb points, Tangent vectors emanating from the observer :rtype: tuple """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) - et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - abcorr = stypes.stringToCharP(abcorr) - corloc = stypes.stringToCharP(corloc) - obsrvr = stypes.stringToCharP(obsrvr) - refvec = stypes.toDoubleVector(refvec) + 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) + ncuts = ctypes.c_int(ncuts) schstp = ctypes.c_double(schstp) soltol = ctypes.c_double(soltol) - maxn = ctypes.c_int(maxn) - npts = stypes.emptyIntVector(maxn.value) - points = stypes.emptyDoubleMatrix(3, maxn.value) - epochs = stypes.emptyDoubleVector(maxn) - tangts = stypes.emptyDoubleMatrix(3, maxn.value) - libspice.limbpt_c(method, target, et, fixref, - abcorr, corloc, obsrvr, refvec, - rolstp, ncuts, schstp, soltol, - maxn, npts, points, epochs, tangts) + 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.cVectorToPython(npts) + npts = stypes.c_vector_to_python(npts) valid_points = numpy.where(npts >= 1) - return npts[valid_points], stypes.cMatrixToNumpy(points)[valid_points], stypes.cVectorToPython(epochs)[valid_points], stypes.cMatrixToNumpy(tangts)[valid_points] + 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], + ) -@spiceErrorCheck +@spice_error_check def lgrind(xvals, yvals, x): """ 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. @@ -7997,17 +8891,17 @@ def lgrind(xvals, yvals, x): :rtype: tuple """ n = ctypes.c_int(len(xvals)) - xvals = stypes.toDoubleVector(xvals) - yvals = stypes.toDoubleVector(yvals) - work = stypes.emptyDoubleVector(n.value*2) - x = ctypes.c_double(x) - p = ctypes.c_double(0) + 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 -@spiceErrorCheck +@spice_error_check def lmpool(cvals): """ Load the variables contained in an internal buffer into the @@ -8020,11 +8914,11 @@ def lmpool(cvals): """ lenvals = ctypes.c_int(len(max(cvals, key=len)) + 1) n = ctypes.c_int(len(cvals)) - cvals = stypes.listToCharArrayPtr(cvals, xLen=lenvals, yLen=n) + cvals = stypes.list_to_char_array_ptr(cvals, x_len=lenvals, y_len=n) libspice.lmpool_c(cvals, lenvals, n) -@spiceErrorCheck +@spice_error_check def lparse(inlist, delim, nmax): """ Parse a list of items delimited by a single character. @@ -8040,18 +8934,17 @@ def lparse(inlist, delim, nmax): :return: Items in the list, left justified. :rtype: list of str """ - delim = stypes.stringToCharP(delim) + delim = stypes.string_to_char_p(delim) lenout = ctypes.c_int(len(inlist)) - inlist = stypes.stringToCharP(inlist) + inlist = stypes.string_to_char_p(inlist) nmax = ctypes.c_int(nmax) - items = stypes.emptyCharArray(lenout, 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.toPythonString(x.value) for x in items[0:n.value]] + 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]] -@spiceErrorCheck +@spice_error_check def lparsm(inlist, delims, nmax, lenout=None): """ Parse a list of items separated by multiple delimiters. @@ -8073,17 +8966,17 @@ def lparsm(inlist, delims, nmax, lenout=None): lenout = ctypes.c_int(len(inlist) + 1) else: lenout = ctypes.c_int(lenout) - inlist = stypes.stringToCharP(inlist) - delims = stypes.stringToCharP(delims) - items = stypes.emptyCharArray(lenout.value, nmax) + 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.toPythonString(x.value) for x in items][0:n.value] + return [stypes.to_python_string(x.value) for x in items][0 : n.value] -@spiceErrorCheck -def lparss(inlist, delims, NMAX=20, LENGTH=50): +@spice_error_check +def lparss(inlist, delims, nmax=20, length=50): """ Parse a list of items separated by multiple delimiters, placing the resulting items into a set. @@ -8094,21 +8987,21 @@ def lparss(inlist, delims, NMAX=20, LENGTH=50): :type inlist: :param delims: Single characters which delimit items. :type delims: str - :param NMAX: Optional nmax of spice set. - :type NMAX: int - :param LENGTH: Optional length of strings in spice set - :type LENGTH: int + :param nmax: Optional nmax of spice set. + :type nmax: int + :param length: Optional length of strings in spice set + :type length: int :return: Set containing items in the list, left justified. :rtype: """ - inlist = stypes.stringToCharP(inlist) - delims = stypes.stringToCharP(delims) - returnSet = stypes.SPICECHAR_CELL(NMAX, LENGTH) - libspice.lparss_c(inlist, delims, ctypes.byref(returnSet)) - return returnSet + 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 -@spiceErrorCheck +@spice_error_check def lspcn(body, et, abcorr): """ Compute L_s, the planetocentric longitude of the sun, as seen @@ -8125,13 +9018,13 @@ def lspcn(body, et, abcorr): :return: planetocentric longitude of the sun :rtype: float """ - body = stypes.stringToCharP(body) + body = stypes.string_to_char_p(body) et = ctypes.c_double(et) - abcorr = stypes.stringToCharP(abcorr) + abcorr = stypes.string_to_char_p(abcorr) return libspice.lspcn_c(body, et, abcorr) -@spiceErrorCheck +@spice_error_check def lstlec(string, n, lenvals, array): """ Given a character string and an ordered array of character @@ -8153,14 +9046,14 @@ def lstlec(string, n, lenvals, array): lexically less than or equal to string. :rtype: int """ - string = stypes.stringToCharP(string) - array = stypes.listToCharArrayPtr(array, xLen=lenvals, yLen=n) + 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) -@spiceErrorCheck +@spice_error_check def lstled(x, n, array): """ Given a number x and an array of non-decreasing floats @@ -8177,13 +9070,13 @@ def lstled(x, n, array): :return: index of the last element of array that is less than or equal to x. :rtype: int """ - array = stypes.toDoubleVector(array) + array = stypes.to_double_vector(array) x = ctypes.c_double(x) n = ctypes.c_int(n) return libspice.lstled_c(x, n, array) -@spiceErrorCheck +@spice_error_check def lstlei(x, n, array): """ Given a number x and an array of non-decreasing ints, @@ -8200,13 +9093,13 @@ def lstlei(x, n, array): :return: index of the last element of array that is less than or equal to x. :rtype: int """ - array = stypes.toIntVector(array) + array = stypes.to_int_vector(array) x = ctypes.c_int(x) n = ctypes.c_int(n) return libspice.lstlei_c(x, n, array) -@spiceErrorCheck +@spice_error_check def lstltc(string, n, lenvals, array): """ Given a character string and an ordered array of character @@ -8228,14 +9121,14 @@ def lstltc(string, n, lenvals, array): is lexically less than string. :rtype: int """ - string = stypes.stringToCharP(string) - array = stypes.listToCharArrayPtr(array, xLen=lenvals, yLen=n) + 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) -@spiceErrorCheck +@spice_error_check def lstltd(x, n, array): """ Given a number x and an array of non-decreasing floats @@ -8252,13 +9145,13 @@ def lstltd(x, n, array): :return: index of the last element of array that is less than x. :rtype: int """ - array = stypes.toDoubleVector(array) + array = stypes.to_double_vector(array) x = ctypes.c_double(x) n = ctypes.c_int(n) return libspice.lstltd_c(x, n, array) -@spiceErrorCheck +@spice_error_check def lstlti(x, n, array): """ Given a number x and an array of non-decreasing int, @@ -8275,13 +9168,13 @@ def lstlti(x, n, array): :return: index of the last element of array that is less than x. :rtype: int """ - array = stypes.toIntVector(array) + array = stypes.to_int_vector(array) x = ctypes.c_int(x) n = ctypes.c_int(n) return libspice.lstlti_c(x, n, array) -@spiceErrorCheck +@spice_error_check def ltime(etobs, obs, direct, targ): """ This routine computes the transmit (or receive) time @@ -8304,16 +9197,17 @@ def ltime(etobs, obs, direct, targ): """ etobs = ctypes.c_double(etobs) obs = ctypes.c_int(obs) - direct = stypes.stringToCharP(direct) + 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)) + libspice.ltime_c( + etobs, obs, direct, targ, ctypes.byref(ettarg), ctypes.byref(elapsd) + ) return ettarg.value, elapsd.value -@spiceErrorCheck +@spice_error_check def lx4dec(string, first): """ Scan a string from a specified starting position for the @@ -8328,7 +9222,7 @@ def lx4dec(string, first): :return: last and nchar :rtype: tuple """ - string = stypes.stringToCharP(string) + string = stypes.string_to_char_p(string) first = ctypes.c_int(first) last = ctypes.c_int() nchar = ctypes.c_int() @@ -8336,7 +9230,7 @@ def lx4dec(string, first): return last.value, nchar.value -@spiceErrorCheck +@spice_error_check def lx4num(string, first): """ Scan a string from a specified starting position for the @@ -8351,7 +9245,7 @@ def lx4num(string, first): :return: last and nchar :rtype: tuple """ - string = stypes.stringToCharP(string) + string = stypes.string_to_char_p(string) first = ctypes.c_int(first) last = ctypes.c_int() nchar = ctypes.c_int() @@ -8359,7 +9253,7 @@ def lx4num(string, first): return last.value, nchar.value -@spiceErrorCheck +@spice_error_check def lx4sgn(string, first): """ Scan a string from a specified starting position for the @@ -8374,7 +9268,7 @@ def lx4sgn(string, first): :return: last and nchar :rtype: tuple """ - string = stypes.stringToCharP(string) + string = stypes.string_to_char_p(string) first = ctypes.c_int(first) last = ctypes.c_int() nchar = ctypes.c_int() @@ -8382,7 +9276,7 @@ def lx4sgn(string, first): return last.value, nchar.value -@spiceErrorCheck +@spice_error_check def lx4uns(string, first): """ Scan a string from a specified starting position for the @@ -8397,7 +9291,7 @@ def lx4uns(string, first): :return: last and nchar :rtype: tuple """ - string = stypes.stringToCharP(string) + string = stypes.string_to_char_p(string) first = ctypes.c_int(first) last = ctypes.c_int() nchar = ctypes.c_int() @@ -8405,7 +9299,7 @@ def lx4uns(string, first): return last.value, nchar.value -@spiceErrorCheck +@spice_error_check def lxqstr(string, qchar, first): """ Lex (scan) a quoted string. @@ -8421,13 +9315,12 @@ def lxqstr(string, qchar, first): :return: last and nchar :rtype: tuple """ - string = stypes.stringToCharP(string) - qchar = ctypes.c_char(qchar.encode(encoding='UTF-8')) + string = stypes.string_to_char_p(string) + qchar = ctypes.c_char(qchar.encode(encoding="UTF-8")) first = ctypes.c_int(first) last = ctypes.c_int() nchar = ctypes.c_int() - libspice.lxqstr_c(string, qchar, first, ctypes.byref(last), - ctypes.byref(nchar)) + libspice.lxqstr_c(string, qchar, first, ctypes.byref(last), ctypes.byref(nchar)) return last.value, nchar.value @@ -8435,7 +9328,7 @@ def lxqstr(string, qchar, first): # M -@spiceErrorCheck +@spice_error_check def m2eul(r, axis3, axis2, axis1): """ Factor a rotation matrix as a product of three rotations @@ -8454,19 +9347,26 @@ def m2eul(r, axis3, axis2, axis1): :return: Third, second, and first Euler angles, in radians. :rtype: tuple """ - r = stypes.toDoubleMatrix(r) + r = stypes.to_double_matrix(r) axis3 = ctypes.c_int(axis3) axis2 = ctypes.c_int(axis2) axis1 = ctypes.c_int(axis1) angle3 = ctypes.c_double() angle2 = ctypes.c_double() angle1 = ctypes.c_double() - libspice.m2eul_c(r, axis3, axis2, axis1, ctypes.byref(angle3), - ctypes.byref(angle2), ctypes.byref(angle1)) + libspice.m2eul_c( + r, + axis3, + axis2, + axis1, + ctypes.byref(angle3), + ctypes.byref(angle2), + ctypes.byref(angle1), + ) return angle3.value, angle2.value, angle1.value -@spiceErrorCheck +@spice_error_check def m2q(r): """ Find a unit quaternion corresponding to a specified rotation matrix. @@ -8478,13 +9378,13 @@ def m2q(r): :return: A unit quaternion representing the rotation matrix :rtype: 4-Element Array of floats """ - r = stypes.toDoubleMatrix(r) - q = stypes.emptyDoubleVector(4) + r = stypes.to_double_matrix(r) + q = stypes.empty_double_vector(4) libspice.m2q_c(r, q) - return stypes.cVectorToPython(q) + return stypes.c_vector_to_python(q) -@spiceErrorCheck +@spice_error_check def matchi(string, templ, wstr, wchr): """ Determine whether a string is matched by a template containing wild cards. @@ -8503,14 +9403,14 @@ def matchi(string, templ, wstr, wchr): :return: The function returns True if string matches templ, else False :rtype: bool """ - string = stypes.stringToCharP(string) - templ = stypes.stringToCharP(templ) - wstr = ctypes.c_char(wstr.encode(encoding='UTF-8')) - wchr = ctypes.c_char(wchr.encode(encoding='UTF-8')) + string = stypes.string_to_char_p(string) + templ = stypes.string_to_char_p(templ) + wstr = ctypes.c_char(wstr.encode(encoding="UTF-8")) + wchr = ctypes.c_char(wchr.encode(encoding="UTF-8")) return bool(libspice.matchi_c(string, templ, wstr, wchr)) -@spiceErrorCheck +@spice_error_check def matchw(string, templ, wstr, wchr): # ctypes.c_char(wstr.encode(encoding='UTF-8') """ @@ -8529,10 +9429,10 @@ def matchw(string, templ, wstr, wchr): :return: The function returns True if string matches templ, else False :rtype: bool """ - string = stypes.stringToCharP(string) - templ = stypes.stringToCharP(templ) - wstr = ctypes.c_char(wstr.encode(encoding='UTF-8')) - wchr = ctypes.c_char(wchr.encode(encoding='UTF-8')) + string = stypes.string_to_char_p(string) + templ = stypes.string_to_char_p(templ) + wstr = ctypes.c_char(wstr.encode(encoding="UTF-8")) + wchr = ctypes.c_char(wchr.encode(encoding="UTF-8")) return bool(libspice.matchw_c(string, templ, wstr, wchr)) @@ -8544,7 +9444,7 @@ def matchw(string, templ, wstr, wchr): # odd as arguments must be parsed and not really important -@spiceErrorCheck +@spice_error_check def mequ(m1): """ Set one double precision 3x3 matrix equal to another. @@ -8556,13 +9456,13 @@ def mequ(m1): :return: Output matrix equal to m1. :rtype: 3x3-Element Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - mout = stypes.emptyDoubleMatrix() + m1 = stypes.to_double_matrix(m1) + mout = stypes.empty_double_matrix() libspice.mequ_c(m1, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def mequg(m1, nr, nc): """ Set one double precision matrix of arbitrary size equal to another. @@ -8578,12 +9478,12 @@ def mequg(m1, nr, nc): :return: Output matrix equal to m1 :rtype: NxM-Element Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - mout = stypes.emptyDoubleMatrix(x=nc, y=nr) + m1 = stypes.to_double_matrix(m1) + mout = stypes.empty_double_matrix(x=nc, y=nr) nc = ctypes.c_int(nc) nr = ctypes.c_int(nr) libspice.mequg_c(m1, nc, nr, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) # skiping for now mind_c, @@ -8594,7 +9494,7 @@ def mequg(m1, nr, nc): # odd as arguments must be parsed and not really important -@spiceErrorCheck +@spice_error_check def mtxm(m1, m2): """ Multiply the transpose of a 3x3 matrix and a 3x3 matrix. @@ -8608,14 +9508,14 @@ def mtxm(m1, m2): :return: The produce m1 transpose times m2. :rtype: 3x3-Element Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - m2 = stypes.toDoubleMatrix(m2) - mout = stypes.emptyDoubleMatrix() + m1 = stypes.to_double_matrix(m1) + m2 = stypes.to_double_matrix(m2) + mout = stypes.empty_double_matrix() libspice.mtxm_c(m1, m2, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def mtxmg(m1, m2, ncol1, nr1r2, ncol2): """ Multiply the transpose of a matrix with @@ -8636,17 +9536,17 @@ def mtxmg(m1, m2, ncol1, nr1r2, ncol2): :return: Transpose of m1 times m2. :rtype: NxM-Element Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - m2 = stypes.toDoubleMatrix(m2) - mout = stypes.emptyDoubleMatrix(x=ncol2, y=ncol1) + m1 = stypes.to_double_matrix(m1) + m2 = stypes.to_double_matrix(m2) + mout = stypes.empty_double_matrix(x=ncol2, y=ncol1) ncol1 = ctypes.c_int(ncol1) nr1r2 = ctypes.c_int(nr1r2) ncol2 = ctypes.c_int(ncol2) libspice.mtxmg_c(m1, m2, ncol1, nr1r2, ncol2, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def mtxv(m1, vin): """ Multiplies the transpose of a 3x3 matrix @@ -8661,14 +9561,14 @@ def mtxv(m1, vin): :return: 3-dimensional double precision vector. :rtype: 3-Element Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - vin = stypes.toDoubleVector(vin) - vout = stypes.emptyDoubleVector(3) + m1 = stypes.to_double_matrix(m1) + vin = stypes.to_double_vector(vin) + vout = stypes.empty_double_vector(3) libspice.mtxv_c(m1, vin, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def mtxvg(m1, v2, ncol1, nr1r2): """ Multiply the transpose of a matrix and @@ -8687,16 +9587,16 @@ def mtxvg(m1, v2, ncol1, nr1r2): :return: Product vector m1 transpose * v2. :rtype: Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - v2 = stypes.toDoubleVector(v2) + m1 = stypes.to_double_matrix(m1) + v2 = stypes.to_double_vector(v2) ncol1 = ctypes.c_int(ncol1) nr1r2 = ctypes.c_int(nr1r2) - vout = stypes.emptyDoubleVector(ncol1.value) + vout = stypes.empty_double_vector(ncol1.value) libspice.mtxvg_c(m1, v2, ncol1, nr1r2, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def mxm(m1, m2): """ Multiply two 3x3 matrices. @@ -8710,14 +9610,14 @@ def mxm(m1, m2): :return: 3x3 double precision matrix. :rtype: 3x3-Element Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - m2 = stypes.toDoubleMatrix(m2) - mout = stypes.emptyDoubleMatrix() + m1 = stypes.to_double_matrix(m1) + m2 = stypes.to_double_matrix(m2) + mout = stypes.empty_double_matrix() libspice.mxm_c(m1, m2, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def mxmg(m1, m2, nrow1, ncol1, ncol2): """ Multiply two double precision matrices of arbitrary size. @@ -8737,17 +9637,17 @@ def mxmg(m1, m2, nrow1, ncol1, ncol2): :return: nrow1 X ncol2 double precision matrix. :rtype: NxM-Element Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - m2 = stypes.toDoubleMatrix(m2) - mout = stypes.emptyDoubleMatrix(x=ncol2, y=nrow1) + m1 = stypes.to_double_matrix(m1) + m2 = stypes.to_double_matrix(m2) + mout = stypes.empty_double_matrix(x=ncol2, y=nrow1) nrow1 = ctypes.c_int(nrow1) ncol1 = ctypes.c_int(ncol1) ncol2 = ctypes.c_int(ncol2) libspice.mxmg_c(m1, m2, nrow1, ncol1, ncol2, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def mxmt(m1, m2): """ Multiply a 3x3 matrix and the transpose of another 3x3 matrix. @@ -8761,14 +9661,14 @@ def mxmt(m1, m2): :return: The product m1 times m2 transpose. :rtype: float """ - m1 = stypes.toDoubleMatrix(m1) - m2 = stypes.toDoubleMatrix(m2) - mout = stypes.emptyDoubleMatrix() + m1 = stypes.to_double_matrix(m1) + m2 = stypes.to_double_matrix(m2) + mout = stypes.empty_double_matrix() libspice.mxmt_c(m1, m2, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def mxmtg(m1, m2, nrow1, nc1c2, nrow2): """ Multiply a matrix and the transpose of a matrix, both of arbitrary size. @@ -8788,17 +9688,17 @@ def mxmtg(m1, m2, nrow1, nc1c2, nrow2): :return: Product matrix. :rtype: NxM-Element Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - m2 = stypes.toDoubleMatrix(m2) - mout = stypes.emptyDoubleMatrix(x=nrow2, y=nrow1) + m1 = stypes.to_double_matrix(m1) + m2 = stypes.to_double_matrix(m2) + mout = stypes.empty_double_matrix(x=nrow2, y=nrow1) nrow1 = ctypes.c_int(nrow1) nc1c2 = ctypes.c_int(nc1c2) nrow2 = ctypes.c_int(nrow2) libspice.mxmtg_c(m1, m2, nrow1, nc1c2, nrow2, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def mxv(m1, vin): """ Multiply a 3x3 double precision matrix with a @@ -8813,14 +9713,14 @@ def mxv(m1, vin): :return: 3-dimensional double precision vector. :rtype: 3-Element Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - vin = stypes.toDoubleVector(vin) - vout = stypes.emptyDoubleVector(3) + m1 = stypes.to_double_matrix(m1) + vin = stypes.to_double_vector(vin) + vout = stypes.empty_double_vector(3) libspice.mxv_c(m1, vin, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def mxvg(m1, v2, nrow1, nc1r2): """ Multiply a matrix and a vector of arbitrary size. @@ -8838,20 +9738,20 @@ def mxvg(m1, v2, nrow1, nc1r2): :return: Product vector m1*v2 :rtype: Array of floats """ - m1 = stypes.toDoubleMatrix(m1) - v2 = stypes.toDoubleVector(v2) + m1 = stypes.to_double_matrix(m1) + v2 = stypes.to_double_vector(v2) nrow1 = ctypes.c_int(nrow1) nc1r2 = ctypes.c_int(nc1r2) - vout = stypes.emptyDoubleVector(nrow1.value) + vout = stypes.empty_double_vector(nrow1.value) libspice.mxvg_c(m1, v2, nrow1, nc1r2, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) ################################################################################ # N -@spiceErrorCheck +@spice_error_check def namfrm(frname): """ Look up the frame ID code associated with a string. @@ -8863,13 +9763,13 @@ def namfrm(frname): :return: The SPICE ID code of the frame. :rtype: int """ - frname = stypes.stringToCharP(frname) + frname = stypes.string_to_char_p(frname) frcode = ctypes.c_int() libspice.namfrm_c(frname, ctypes.byref(frcode)) return frcode.value -@spiceErrorCheck +@spice_error_check def ncpos(string, chars, start): """ Find the first occurrence in a string of a character NOT belonging @@ -8887,13 +9787,13 @@ def ncpos(string, chars, start): :return: index :rtype: int """ - string = stypes.stringToCharP(string) - chars = stypes.stringToCharP(chars) + string = stypes.string_to_char_p(string) + chars = stypes.string_to_char_p(chars) start = ctypes.c_int(start) return libspice.ncpos_c(string, chars, start) -@spiceErrorCheck +@spice_error_check def ncposr(string, chars, start): """ Find the first occurrence in a string of a character NOT belonging to a @@ -8911,13 +9811,13 @@ def ncposr(string, chars, start): :return: index :rtype: int """ - string = stypes.stringToCharP(string) - chars = stypes.stringToCharP(chars) + string = stypes.string_to_char_p(string) + chars = stypes.string_to_char_p(chars) start = ctypes.c_int(start) return libspice.ncposr_c(string, chars, start) -@spiceErrorCheck +@spice_error_check def nearpt(positn, a, b, c): """ locates the point on the surface of an ellipsoid that is nearest to a @@ -8939,17 +9839,17 @@ def nearpt(positn, a, b, c): Altitude of positn above the ellipsoid. :rtype: tuple """ - positn = stypes.toDoubleVector(positn) + positn = stypes.to_double_vector(positn) a = ctypes.c_double(a) b = ctypes.c_double(b) c = ctypes.c_double(c) - npoint = stypes.emptyDoubleVector(3) + npoint = stypes.empty_double_vector(3) alt = ctypes.c_double() libspice.nearpt_c(positn, a, b, c, npoint, ctypes.byref(alt)) - return stypes.cVectorToPython(npoint), alt.value + return stypes.c_vector_to_python(npoint), alt.value -@spiceErrorCheck +@spice_error_check def npedln(a, b, c, linept, linedr): """ Find nearest point on a triaxial ellipsoid to a specified @@ -8973,15 +9873,15 @@ def npedln(a, b, c, linept, linedr): a = ctypes.c_double(a) b = ctypes.c_double(b) c = ctypes.c_double(c) - linept = stypes.toDoubleVector(linept) - linedr = stypes.toDoubleVector(linedr) - pnear = stypes.emptyDoubleVector(3) + linept = stypes.to_double_vector(linept) + linedr = stypes.to_double_vector(linedr) + pnear = stypes.empty_double_vector(3) dist = ctypes.c_double() libspice.npedln_c(a, b, c, linept, linedr, pnear, ctypes.byref(dist)) - return stypes.cVectorToPython(pnear), dist.value + return stypes.c_vector_to_python(pnear), dist.value -@spiceErrorCheck +@spice_error_check def npelpt(point, ellips): """ Find the nearest point on an ellipse to a specified point, both @@ -8996,15 +9896,15 @@ def npelpt(point, ellips): :return: Nearest point on ellipsoid to line, Distance of ellipsoid from line :rtype: tuple """ - assert (isinstance(ellips, stypes.Ellipse)) - point = stypes.toDoubleVector(point) - pnear = stypes.emptyDoubleVector(3) + assert isinstance(ellips, stypes.Ellipse) + point = stypes.to_double_vector(point) + pnear = stypes.empty_double_vector(3) dist = ctypes.c_double() libspice.npelpt_c(point, ctypes.byref(ellips), pnear, ctypes.byref(dist)) - return stypes.cVectorToPython(pnear), dist.value + return stypes.c_vector_to_python(pnear), dist.value -@spiceErrorCheck +@spice_error_check def nplnpt(linpt, lindir, point): """ Find the nearest point on a line to a specified point, @@ -9023,16 +9923,16 @@ def nplnpt(linpt, lindir, point): Distance between point and pnear :rtype: tuple """ - linpt = stypes.toDoubleVector(linpt) - lindir = stypes.toDoubleVector(lindir) - point = stypes.toDoubleVector(point) - pnear = stypes.emptyDoubleVector(3) + linpt = stypes.to_double_vector(linpt) + lindir = stypes.to_double_vector(lindir) + point = stypes.to_double_vector(point) + pnear = stypes.empty_double_vector(3) dist = ctypes.c_double() libspice.nplnpt_c(linpt, lindir, point, pnear, ctypes.byref(dist)) - return stypes.cVectorToPython(pnear), dist.value + return stypes.c_vector_to_python(pnear), dist.value -@spiceErrorCheck +@spice_error_check def nvc2pl(normal, constant): """ Make a plane from a normal vector and a constant. @@ -9047,13 +9947,13 @@ def nvc2pl(normal, constant): :rtype: spiceypy.utils.support_types.Plane """ plane = stypes.Plane() - normal = stypes.toDoubleVector(normal) + normal = stypes.to_double_vector(normal) constant = ctypes.c_double(constant) libspice.nvc2pl_c(normal, constant, ctypes.byref(plane)) return plane -@spiceErrorCheck +@spice_error_check def nvp2pl(normal, point): """ Make a plane from a normal vector and a point. @@ -9067,8 +9967,8 @@ def nvp2pl(normal, point): :return: plane :rtype: spiceypy.utils.support_types.Plane """ - normal = stypes.toDoubleVector(normal) - point = stypes.toDoubleVector(point) + normal = stypes.to_double_vector(normal) + point = stypes.to_double_vector(point) plane = stypes.Plane() libspice.nvp2pl_c(normal, point, ctypes.byref(plane)) return plane @@ -9077,9 +9977,9 @@ def nvp2pl(normal, point): ################################################################################ # O -@spiceErrorCheck -def occult(target1, shape1, frame1, target2, shape2, frame2, abcorr, observer, - et): + +@spice_error_check +def occult(target1, shape1, frame1, target2, shape2, frame2, abcorr, observer, et): """ Determines the occultation condition (not occulted, partially, etc.) of one target relative to another target as seen by @@ -9108,22 +10008,32 @@ def occult(target1, shape1, frame1, target2, shape2, frame2, abcorr, observer, :return: Occultation identification code. :rtype: int """ - target1 = stypes.stringToCharP(target1) - shape1 = stypes.stringToCharP(shape1) - frame1 = stypes.stringToCharP(frame1) - target2 = stypes.stringToCharP(target2) - shape2 = stypes.stringToCharP(shape2) - frame2 = stypes.stringToCharP(frame2) - abcorr = stypes.stringToCharP(abcorr) - observer = stypes.stringToCharP(observer) + target1 = stypes.string_to_char_p(target1) + shape1 = stypes.string_to_char_p(shape1) + frame1 = stypes.string_to_char_p(frame1) + target2 = stypes.string_to_char_p(target2) + shape2 = stypes.string_to_char_p(shape2) + frame2 = stypes.string_to_char_p(frame2) + abcorr = stypes.string_to_char_p(abcorr) + observer = stypes.string_to_char_p(observer) et = ctypes.c_double(et) occult_code = ctypes.c_int() - libspice.occult_c(target1, shape1, frame1, target2, shape2, frame2, abcorr, - observer, et, ctypes.byref(occult_code)) + libspice.occult_c( + target1, + shape1, + frame1, + target2, + shape2, + frame2, + abcorr, + observer, + et, + ctypes.byref(occult_code), + ) return occult_code.value -@spiceErrorCheck +@spice_error_check def ordc(item, inset): """ The function returns the ordinal position of any given item in a @@ -9142,11 +10052,11 @@ def ordc(item, inset): assert isinstance(inset, stypes.SpiceCell) assert inset.is_char() assert isinstance(item, str) - item = stypes.stringToCharP(item) + item = stypes.string_to_char_p(item) return libspice.ordc_c(item, ctypes.byref(inset)) -@spiceErrorCheck +@spice_error_check def ordd(item, inset): """ The function returns the ordinal position of any given item in a @@ -9168,7 +10078,7 @@ def ordd(item, inset): return libspice.ordd_c(item, ctypes.byref(inset)) -@spiceErrorCheck +@spice_error_check def ordi(item, inset): """ The function returns the ordinal position of any given item in an @@ -9191,7 +10101,7 @@ def ordi(item, inset): return libspice.ordi_c(item, ctypes.byref(inset)) -@spiceErrorCheck +@spice_error_check def orderc(array, ndim=None): """ Determine the order of elements in an array of character strings. @@ -9210,13 +10120,13 @@ def orderc(array, ndim=None): else: ndim = ctypes.c_int(ndim) lenvals = ctypes.c_int(len(max(array, key=len)) + 1) - iorder = stypes.emptyIntVector(ndim) - array = stypes.listToCharArray(array, lenvals, ndim) + iorder = stypes.empty_int_vector(ndim) + array = stypes.list_to_char_array(array, lenvals, ndim) libspice.orderc_c(lenvals, array, ndim, iorder) - return stypes.cVectorToPython(iorder) + return stypes.c_vector_to_python(iorder) -@spiceErrorCheck +@spice_error_check def orderd(array, ndim=None): """ Determine the order of elements in a double precision array. @@ -9234,13 +10144,13 @@ def orderd(array, ndim=None): ndim = ctypes.c_int(len(array)) else: ndim = ctypes.c_int(ndim) - array = stypes.toDoubleVector(array) - iorder = stypes.emptyIntVector(ndim) + array = stypes.to_double_vector(array) + iorder = stypes.empty_int_vector(ndim) libspice.orderd_c(array, ndim, iorder) - return stypes.cVectorToPython(iorder) + return stypes.c_vector_to_python(iorder) -@spiceErrorCheck +@spice_error_check def orderi(array, ndim=None): """ Determine the order of elements in an integer array. @@ -9258,13 +10168,13 @@ def orderi(array, ndim=None): ndim = ctypes.c_int(len(array)) else: ndim = ctypes.c_int(ndim) - array = stypes.toIntVector(array) - iorder = stypes.emptyIntVector(ndim) + array = stypes.to_int_vector(array) + iorder = stypes.empty_int_vector(ndim) libspice.orderi_c(array, ndim, iorder) - return stypes.cVectorToPython(iorder) + return stypes.c_vector_to_python(iorder) -@spiceErrorCheck +@spice_error_check def oscelt(state, et, mu): """ Determine the set of osculating conic orbital elements that @@ -9282,48 +10192,48 @@ def oscelt(state, et, mu): :return: Equivalent conic elements :rtype: Float Array of 8 elements. """ - state = stypes.toDoubleVector(state) + state = stypes.to_double_vector(state) et = ctypes.c_double(et) mu = ctypes.c_double(mu) - elts = stypes.emptyDoubleVector(8) + elts = stypes.empty_double_vector(8) libspice.oscelt_c(state, et, mu, elts) - return stypes.cVectorToPython(elts) + return stypes.c_vector_to_python(elts) def oscltx(state, et, mu): """ - Determine the set of osculating conic orbital elements that - corresponds to the state (position, velocity) of a body at some - epoch. In additional to the classical elements, return the true - anomaly, semi-major axis, and period, if applicable. - + Determine the set of osculating conic orbital elements that + corresponds to the state (position, velocity) of a body at some + epoch. In additional to the classical elements, return the true + anomaly, semi-major axis, and period, if applicable. + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/oscltx_c.html - - :param state: State of body at epoch of elements. + + :param state: State of body at epoch of elements. :type state: 6-Element Array of floats - :param et: Epoch of elements. + :param et: Epoch of elements. :type et: float - :param mu: Gravitational parameter (GM) of primary body. + :param mu: Gravitational parameter (GM) of primary body. :type mu: float - :return: Extended set of classical conic elements. + :return: Extended set of classical conic elements. """ - state = stypes.toDoubleVector(state) + state = stypes.to_double_vector(state) et = ctypes.c_double(et) mu = ctypes.c_double(mu) - elts = stypes.emptyDoubleVector(20) + elts = stypes.empty_double_vector(20) libspice.oscltx_c(state, et, mu, elts) - return stypes.cVectorToPython(elts)[0:11] + return stypes.c_vector_to_python(elts)[0:11] ################################################################################ # P -@spiceErrorCheck +@spice_error_check def pckcls(handle): """ - Close an open PCK file. - + Close an open PCK file. + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pckcls_c.html - + :param handle: Handle of the PCK file to be closed. :type handle: int """ @@ -9331,7 +10241,7 @@ def pckcls(handle): libspice.pckcls_c(handle) -@spiceErrorCheck +@spice_error_check def pckcov(pck, idcode, cover): """ Find the coverage window for a specified reference frame in a @@ -9346,14 +10256,14 @@ def pckcov(pck, idcode, cover): :param cover: Window giving coverage in pck for idcode. :type cover: SpiceCell """ - pck = stypes.stringToCharP(pck) + pck = stypes.string_to_char_p(pck) idcode = ctypes.c_int(idcode) assert isinstance(cover, stypes.SpiceCell) assert cover.dtype == 1 libspice.pckcov_c(pck, idcode, ctypes.byref(cover)) -@spiceErrorCheck +@spice_error_check def pckfrm(pck, ids): """ Find the set of reference frame class ID codes of all frames @@ -9366,13 +10276,13 @@ def pckfrm(pck, ids): :param ids: Set of frame class ID codes of frames in PCK file. :type ids: SpiceCell """ - pck = stypes.stringToCharP(pck) + pck = stypes.string_to_char_p(pck) assert isinstance(ids, stypes.SpiceCell) assert ids.dtype == 2 libspice.pckfrm_c(pck, ctypes.byref(ids)) -@spiceErrorCheck +@spice_error_check def pcklof(filename): """ Load a binary PCK file for use by the readers. Return the @@ -9386,37 +10296,37 @@ def pcklof(filename): :return: Loaded file's handle. :rtype: int """ - filename = stypes.stringToCharP(filename) + filename = stypes.string_to_char_p(filename) handle = ctypes.c_int() libspice.pcklof_c(filename, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def pckopn(name, ifname, ncomch): """ - Create a new PCK file, returning the handle of the opened file. - + Create a new PCK file, returning the handle of the opened file. + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pckopn_c.html - - :param name: The name of the PCK file to be opened. + + :param name: The name of the PCK file to be opened. :type name: str :param ifname: The internal filename for the PCK. :type ifname: str - :param ncomch: The number of characters to reserve for comments. + :param ncomch: The number of characters to reserve for comments. :type ncomch: int :return: The handle of the opened PCK file. :rtype: int """ - name = stypes.stringToCharP(name) - ifname = stypes.stringToCharP(ifname) + name = stypes.string_to_char_p(name) + ifname = stypes.string_to_char_p(ifname) ncomch = ctypes.c_int(ncomch) handle = ctypes.c_int() libspice.pckopn_c(name, ifname, ncomch, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def pckuof(handle): """ Unload a binary PCK file so that it will no longer be searched by @@ -9431,22 +10341,24 @@ def pckuof(handle): libspice.pckuof_c(handle) -@spiceErrorCheck -def pckw02(handle, classid, frname, first, last, segid, intlen, n, polydg, cdata, btime): +@spice_error_check +def pckw02( + handle, classid, frname, first, last, segid, intlen, n, polydg, cdata, btime +): """ Write a type 2 segment to a PCK binary file given the file handle, frame class ID, base frame, time range covered by the segment, and the Chebyshev polynomial coefficients. - + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pckw02_c.html - + :param handle: Handle of binary PCK file open for writing. :type handle: int :param classid: Frame class ID of body-fixed frame. :type classid: int :param frname: Name of base reference frame. :type frname: str - :param first: Start time of interval covered by segment. + :param first: Start time of interval covered by segment. :type first: float :param last: End time of interval covered by segment. :type last: float @@ -9456,7 +10368,7 @@ def pckw02(handle, classid, frname, first, last, segid, intlen, n, polydg, cdata :type intlen: float :param n: Number of logical records in segment. :type n: int - :param polydg: Chebyshev polynomial degree. + :param polydg: Chebyshev polynomial degree. :type polydg: int :param cdata: Array of Chebyshev coefficients. :type cdata: N-Element Array of floats @@ -9465,19 +10377,21 @@ def pckw02(handle, classid, frname, first, last, segid, intlen, n, polydg, cdata """ handle = ctypes.c_int(handle) classid = ctypes.c_int(classid) - frame = stypes.stringToCharP(frname) + frname = stypes.string_to_char_p(frname) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) intlen = ctypes.c_double(intlen) n = ctypes.c_int(n) polydg = ctypes.c_int(polydg) - cdata = stypes.toDoubleVector(cdata) + cdata = stypes.to_double_vector(cdata) btime = ctypes.c_double(btime) - libspice.pckw02_c(handle, classid, frame, first, last, segid, intlen, n, polydg, cdata, btime) + libspice.pckw02_c( + handle, classid, frname, first, last, segid, intlen, n, polydg, cdata, btime + ) -@spiceErrorCheck +@spice_error_check def pcpool(name, cvals): """ This entry point provides toolkit programmers a method for @@ -9491,14 +10405,14 @@ def pcpool(name, cvals): :param cvals: An array of strings to insert into the kernel pool. :type cvals: Array of str """ - name = stypes.stringToCharP(name) + name = stypes.string_to_char_p(name) lenvals = ctypes.c_int(len(max(cvals, key=len)) + 1) n = ctypes.c_int(len(cvals)) - cvals = stypes.listToCharArray(cvals, lenvals, n) + cvals = stypes.list_to_char_array(cvals, lenvals, n) libspice.pcpool_c(name, n, lenvals, cvals) -@spiceErrorCheck +@spice_error_check def pdpool(name, dvals): """ This entry point provides toolkit programmers a method for @@ -9512,13 +10426,13 @@ def pdpool(name, dvals): :param dvals: An array of values to insert into the kernel pool. :type dvals: SpiceCell """ - name = stypes.stringToCharP(name) + name = stypes.string_to_char_p(name) n = ctypes.c_int(len(dvals)) - dvals = stypes.toDoubleVector(dvals) + dvals = stypes.to_double_vector(dvals) libspice.pdpool_c(name, n, dvals) -@spiceErrorCheck +@spice_error_check def pgrrec(body, lon, lat, alt, re, f): """ Convert planetographic coordinates to rectangular coordinates. @@ -9540,18 +10454,18 @@ def pgrrec(body, lon, lat, alt, re, f): :return: Rectangular coordinates of the point. :rtype: 3-Element Array of floats """ - body = stypes.stringToCharP(body) + 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) - rectan = stypes.emptyDoubleVector(3) + rectan = stypes.empty_double_vector(3) libspice.pgrrec_c(body, lon, lat, alt, re, f, rectan) - return stypes.cVectorToPython(rectan) + return stypes.c_vector_to_python(rectan) -@spiceErrorCheck +@spice_error_check def phaseq(et, target, illmn, obsrvr, abcorr): """ Compute the apparent phase angle for a target, observer, @@ -9573,14 +10487,14 @@ def phaseq(et, target, illmn, obsrvr, abcorr): :rtype: float """ et = ctypes.c_double(et) - target = stypes.stringToCharP(target) - illmn = stypes.stringToCharP(illmn) - obsrvr = stypes.stringToCharP(obsrvr) - abcorr = stypes.stringToCharP(abcorr) + target = stypes.string_to_char_p(target) + illmn = stypes.string_to_char_p(illmn) + obsrvr = stypes.string_to_char_p(obsrvr) + abcorr = stypes.string_to_char_p(abcorr) return libspice.phaseq_c(et, target, illmn, obsrvr, abcorr) -@spiceErrorCheck +@spice_error_check def pi(): """ Return the value of pi (the ratio of the circumference of @@ -9594,7 +10508,7 @@ def pi(): return libspice.pi_c() -@spiceErrorCheck +@spice_error_check def pipool(name, ivals): """ This entry point provides toolkit programmers a method for @@ -9607,13 +10521,13 @@ def pipool(name, ivals): :param ivals: An array of integers to insert into the pool. :type ivals: Array of ints """ - name = stypes.stringToCharP(name) + name = stypes.string_to_char_p(name) n = ctypes.c_int(len(ivals)) - ivals = stypes.toIntVector(ivals) + ivals = stypes.to_int_vector(ivals) libspice.pipool_c(name, n, ivals) -@spiceErrorCheck +@spice_error_check def pjelpl(elin, plane): """ Project an ellipse onto a plane, orthogonally. @@ -9627,15 +10541,14 @@ def pjelpl(elin, plane): :return: A SPICE ellipse resulting from the projection. :rtype: spiceypy.utils.support_types.Ellipse """ - assert (isinstance(elin, stypes.Ellipse)) - assert (isinstance(plane, stypes.Plane)) + assert isinstance(elin, stypes.Ellipse) + assert isinstance(plane, stypes.Plane) elout = stypes.Ellipse() - libspice.pjelpl_c(ctypes.byref(elin), ctypes.byref(plane), - ctypes.byref(elout)) + libspice.pjelpl_c(ctypes.byref(elin), ctypes.byref(plane), ctypes.byref(elout)) return elout -@spiceErrorCheck +@spice_error_check def pl2nvc(plane): """ Return a unit normal vector and constant that define a specified plane. @@ -9649,14 +10562,14 @@ def pl2nvc(plane): the geometric plane represented by plane. :rtype: tuple """ - assert (isinstance(plane, stypes.Plane)) - normal = stypes.emptyDoubleVector(3) + assert isinstance(plane, stypes.Plane) + normal = stypes.empty_double_vector(3) constant = ctypes.c_double() libspice.pl2nvc_c(ctypes.byref(plane), normal, ctypes.byref(constant)) - return stypes.cVectorToPython(normal), constant.value + return stypes.c_vector_to_python(normal), constant.value -@spiceErrorCheck +@spice_error_check def pl2nvp(plane): """ Return a unit normal vector and point that define a specified plane. @@ -9669,14 +10582,14 @@ def pl2nvp(plane): :return: A unit normal vector and point that define plane. :rtype: tuple """ - assert (isinstance(plane, stypes.Plane)) - normal = stypes.emptyDoubleVector(3) - point = stypes.emptyDoubleVector(3) + assert isinstance(plane, stypes.Plane) + normal = stypes.empty_double_vector(3) + point = stypes.empty_double_vector(3) libspice.pl2nvp_c(ctypes.byref(plane), normal, point) - return stypes.cVectorToPython(normal), stypes.cVectorToPython(point) + return stypes.c_vector_to_python(normal), stypes.c_vector_to_python(point) -@spiceErrorCheck +@spice_error_check def pl2psv(plane): """ Return a point and two orthogonal spanning vectors that generate @@ -9691,142 +10604,145 @@ def pl2psv(plane): spanning the input plane. :rtype: tuple """ - assert (isinstance(plane, stypes.Plane)) - point = stypes.emptyDoubleVector(3) - span1 = stypes.emptyDoubleVector(3) - span2 = stypes.emptyDoubleVector(3) + assert isinstance(plane, stypes.Plane) + point = stypes.empty_double_vector(3) + span1 = stypes.empty_double_vector(3) + span2 = stypes.empty_double_vector(3) libspice.pl2psv_c(ctypes.byref(plane), point, span1, span2) - return stypes.cVectorToPython(point), stypes.cVectorToPython( - span1), stypes.cVectorToPython(span2) + return ( + stypes.c_vector_to_python(point), + stypes.c_vector_to_python(span1), + stypes.c_vector_to_python(span2), + ) -@spiceErrorCheck +@spice_error_check def pltar(vrtces, plates): """ Compute the total area of a collection of triangular plates. - + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pltar_c.html - + :param vrtces: Array of vertices. :type vrtces: Nx3-Element Array of floats - :param plates: Array of plates. + :param plates: Array of plates. :type plates: Nx3-Element Array of ints :return: total area of the set of plates :rtype: float """ nv = ctypes.c_int(len(vrtces)) - vrtces = stypes.toDoubleMatrix(vrtces) + vrtces = stypes.to_double_matrix(vrtces) np = ctypes.c_int(len(plates)) - plates = stypes.toIntMatrix(plates) + plates = stypes.to_int_matrix(plates) return libspice.pltar_c(nv, vrtces, np, plates) -@spiceErrorCheck +@spice_error_check def pltexp(iverts, delta): """ - Expand a triangular plate by a specified amount. The expanded - plate is co-planar with, and has the same orientation as, the - original. The centroids of the two plates coincide. - + Expand a triangular plate by a specified amount. The expanded + plate is co-planar with, and has the same orientation as, the + original. The centroids of the two plates coincide. + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pltexp_c.html - - :param iverts: Vertices of the plate to be expanded. + + :param iverts: Vertices of the plate to be expanded. :type iverts: 3x3-Element Array of floats :param delta: Fraction by which the plate is to be expanded. :type delta: double - :return: Vertices of the expanded plate. + :return: Vertices of the expanded plate. :rtype: 3x3-Element Array of floats """ - iverts = stypes.toDoubleMatrix(iverts) + iverts = stypes.to_double_matrix(iverts) delta = ctypes.c_double(delta) - overts = stypes.emptyDoubleMatrix() + overts = stypes.empty_double_matrix() libspice.pltexp_c(iverts, delta, overts) - return stypes.cMatrixToNumpy(overts) + return stypes.c_matrix_to_numpy(overts) -@spiceErrorCheck +@spice_error_check def pltnp(point, v1, v2, v3): """ - Find the nearest point on a triangular plate to a given point. - + Find the nearest point on a triangular plate to a given point. + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pltnp_c.html - - :param point: A point in 3-dimensional space. + + :param point: A point in 3-dimensional space. :type point: 3-Element Array of floats :param v1: Vertices of a triangular plate. :type v1: 3-Element Array of floats - :param v2: Vertices of a triangular plate. + :param v2: Vertices of a triangular plate. :type v2: 3-Element Array of floats - :param v3: Vertices of a triangular plate. + :param v3: Vertices of a triangular plate. :type v3: 3-Element Array of floats :return: the nearest point on a triangular plate to a given point and distance :rtype: tuple """ - point = stypes.toDoubleVector(point) - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - v3 = stypes.toDoubleVector(v3) - pnear = stypes.emptyDoubleVector(3) + point = stypes.to_double_vector(point) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + v3 = stypes.to_double_vector(v3) + pnear = stypes.empty_double_vector(3) dist = ctypes.c_double() libspice.pltnp_c(point, v1, v2, v3, pnear, ctypes.byref(dist)) - return stypes.cVectorToPython(pnear), dist.value + return stypes.c_vector_to_python(pnear), dist.value -@spiceErrorCheck +@spice_error_check def pltnrm(v1, v2, v3): """ - Compute an outward normal vector of a triangular plate. - The vector does not necessarily have unit length. - + Compute an outward normal vector of a triangular plate. + The vector does not necessarily have unit length. + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pltnrm_c.html - + :param v1: Vertices of a plate. :type v1: 3-Element Array of floats - :param v2: Vertices of a plate. + :param v2: Vertices of a plate. :type v2: 3-Element Array of floats - :param v3: Vertices of a plate. + :param v3: Vertices of a plate. :type v3: 3-Element Array of floats :return: Plate's outward normal vector. :rtype: 3-Element Array of floats """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - v3 = stypes.toDoubleVector(v3) - normal = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + v3 = stypes.to_double_vector(v3) + normal = stypes.empty_double_vector(3) libspice.pltnrm_c(v1, v2, v3, normal) - return stypes.cVectorToPython(normal) + return stypes.c_vector_to_python(normal) -@spiceErrorCheck +@spice_error_check def pltvol(vrtces, plates): """ - Compute the volume of a three-dimensional region bounded by a - collection of triangular plates. - + Compute the volume of a three-dimensional region bounded by a + collection of triangular plates. + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pltvol_c.html - + :param vrtces: Array of vertices. :type vrtces: Nx3-Element Array of floats - :param plates: Array of plates. - :type plates: Nx3-Element Array of ints - :return: the volume of the spatial region bounded by the plates. + :param plates: Array of plates. + :type plates: Nx3-Element Array of ints + :return: the volume of the spatial region bounded by the plates. :rtype: float """ nv = ctypes.c_int(len(vrtces)) - vrtces = stypes.toDoubleMatrix(vrtces) + vrtces = stypes.to_double_matrix(vrtces) np = ctypes.c_int(len(plates)) - plates = stypes.toIntMatrix(plates) + plates = stypes.to_int_matrix(plates) return libspice.pltvol_c(nv, vrtces, np, plates) -@spiceErrorCheck +@spice_error_check def polyds(coeffs, deg, nderiv, t): """ Compute the value of a polynomial and it's first n derivatives at the value t. - + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/polyds_c.html - + :param coeffs: Coefficients of the polynomial to be evaluated. :type coeffs: N-Element Array of floats :param deg: Degree of the polynomial to be evaluated. @@ -9838,16 +10754,16 @@ def polyds(coeffs, deg, nderiv, t): :return: Value of polynomial and derivatives. :rtype: nderiv-Element Array of floats """ - coeffs = stypes.toDoubleVector(coeffs) + coeffs = stypes.to_double_vector(coeffs) deg = ctypes.c_int(deg) - p = stypes.emptyDoubleVector(nderiv + 1) + p = stypes.empty_double_vector(nderiv + 1) nderiv = ctypes.c_int(nderiv) t = ctypes.c_double(t) libspice.polyds_c(ctypes.byref(coeffs), deg, nderiv, t, p) - return stypes.cVectorToPython(p) + return stypes.c_vector_to_python(p) -@spiceErrorCheck +@spice_error_check def pos(string, substr, start): """ Find the first occurrence in a string of a substring, starting at @@ -9866,13 +10782,13 @@ def pos(string, substr, start): in string at or following index start. :rtype: int """ - string = stypes.stringToCharP(string) - substr = stypes.stringToCharP(substr) + string = stypes.string_to_char_p(string) + substr = stypes.string_to_char_p(substr) start = ctypes.c_int(start) return libspice.pos_c(string, substr, start) -@spiceErrorCheck +@spice_error_check def posr(string, substr, start): """ Find the first occurrence in a string of a substring, starting at @@ -9891,8 +10807,8 @@ def posr(string, substr, start): in string at or preceding index start. :rtype: int """ - string = stypes.stringToCharP(string) - substr = stypes.stringToCharP(substr) + string = stypes.string_to_char_p(string) + substr = stypes.string_to_char_p(substr) start = ctypes.c_int(start) return libspice.posr_c(string, substr, start) @@ -9901,7 +10817,7 @@ def posr(string, substr, start): # skip for no as this is not really an important function for python users -@spiceErrorCheck +@spice_error_check def prop2b(gm, pvinit, dt): """ Given a central mass and the state of massless body at time t_0, @@ -9920,14 +10836,14 @@ def prop2b(gm, pvinit, dt): :rtype: 6-Element Array of floats """ gm = ctypes.c_double(gm) - pvinit = stypes.toDoubleVector(pvinit) + pvinit = stypes.to_double_vector(pvinit) dt = ctypes.c_double(dt) - pvprop = stypes.emptyDoubleVector(6) + pvprop = stypes.empty_double_vector(6) libspice.prop2b_c(gm, pvinit, dt, pvprop) - return stypes.cVectorToPython(pvprop) + return stypes.c_vector_to_python(pvprop) -@spiceErrorCheck +@spice_error_check def prsdp(string): """ Parse a string as a double precision number, encapsulating error handling. @@ -9939,13 +10855,13 @@ def prsdp(string): :return: D.p. value obtained by parsing string. :rtype: float """ - string = stypes.stringToCharP(string) + string = stypes.string_to_char_p(string) dpval = ctypes.c_double() libspice.prsdp_c(string, ctypes.byref(dpval)) return dpval.value -@spiceErrorCheck +@spice_error_check def prsint(string): """ Parse a string as an integer, encapsulating error handling. @@ -9957,13 +10873,13 @@ def prsint(string): :return: Integer value obtained by parsing string. :rtype: int """ - string = stypes.stringToCharP(string) + string = stypes.string_to_char_p(string) intval = ctypes.c_int() libspice.prsint_c(string, ctypes.byref(intval)) return intval.value -@spiceErrorCheck +@spice_error_check def psv2pl(point, span1, span2): """ Make a CSPICE plane from a point and two spanning vectors. @@ -9979,9 +10895,9 @@ def psv2pl(point, span1, span2): :return: A SPICE plane. :rtype: supportypes.Plane """ - point = stypes.toDoubleVector(point) - span1 = stypes.toDoubleVector(span1) - span2 = stypes.toDoubleVector(span2) + point = stypes.to_double_vector(point) + span1 = stypes.to_double_vector(span1) + span2 = stypes.to_double_vector(span2) plane = stypes.Plane() libspice.psv2pl_c(point, span1, span2, ctypes.byref(plane)) return plane @@ -9990,7 +10906,7 @@ def psv2pl(point, span1, span2): # skip putcml, is this really needed for python users? -@spiceErrorCheck +@spice_error_check def pxform(fromstr, tostr, et): """ Return the matrix that transforms position vectors from one @@ -10008,14 +10924,14 @@ def pxform(fromstr, tostr, et): :rtype: 3x3 Element Array of floats """ et = ctypes.c_double(et) - tostr = stypes.stringToCharP(tostr) - fromstr = stypes.stringToCharP(fromstr) - rotatematrix = stypes.emptyDoubleMatrix() + tostr = stypes.string_to_char_p(tostr) + fromstr = stypes.string_to_char_p(fromstr) + rotatematrix = stypes.empty_double_matrix() libspice.pxform_c(fromstr, tostr, et, rotatematrix) - return stypes.cMatrixToNumpy(rotatematrix) + return stypes.c_matrix_to_numpy(rotatematrix) -@spiceErrorCheck +@spice_error_check def pxfrm2(frame_from, frame_to, etfrom, etto): """ Return the 3x3 matrix that transforms position vectors from one @@ -10035,20 +10951,20 @@ def pxfrm2(frame_from, frame_to, etfrom, etto): :return: A position transformation matrix from frame_from to frame_to :rtype: 3x3 Element Array of floats """ - frame_from = stypes.stringToCharP(frame_from) - frame_to = stypes.stringToCharP(frame_to) + frame_from = stypes.string_to_char_p(frame_from) + frame_to = stypes.string_to_char_p(frame_to) etfrom = ctypes.c_double(etfrom) etto = ctypes.c_double(etto) - outmatrix = stypes.emptyDoubleMatrix() + outmatrix = stypes.empty_double_matrix() libspice.pxfrm2_c(frame_from, frame_to, etfrom, etto, outmatrix) - return stypes.cMatrixToNumpy(outmatrix) + return stypes.c_matrix_to_numpy(outmatrix) ################################################################################ # Q -@spiceErrorCheck +@spice_error_check def q2m(q): """ Find the rotation matrix corresponding to a specified unit quaternion. @@ -10060,13 +10976,13 @@ def q2m(q): :return: A rotation matrix corresponding to q :rtype: 3x3-Element Array of floats """ - q = stypes.toDoubleVector(q) - mout = stypes.emptyDoubleMatrix() + q = stypes.to_double_vector(q) + mout = stypes.empty_double_matrix() libspice.q2m_c(q, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -# @spiceErrorCheck +# @spice_error_check def qcktrc(tracelen=_default_len_out): """ Return a string containing a traceback. @@ -10078,13 +10994,13 @@ def qcktrc(tracelen=_default_len_out): :return: A traceback string. :rtype: str """ - tracestr = stypes.stringToCharP(tracelen) + tracestr = stypes.string_to_char_p(tracelen) tracelen = ctypes.c_int(tracelen) libspice.qcktrc_c(tracelen, tracestr) - return stypes.toPythonString(tracestr) + return stypes.to_python_string(tracestr) -@spiceErrorCheck +@spice_error_check def qdq2av(q, dq): """ Derive angular velocity from a unit quaternion and its derivative @@ -10099,14 +11015,14 @@ def qdq2av(q, dq): :return: Angular velocity defined by q and dq. :rtype: 3-Element Array of floats """ - q = stypes.toDoubleVector(q) - dq = stypes.toDoubleVector(dq) - vout = stypes.emptyDoubleVector(3) + q = stypes.to_double_vector(q) + dq = stypes.to_double_vector(dq) + vout = stypes.empty_double_vector(3) libspice.qdq2av_c(q, dq, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def qxq(q1, q2): """ Multiply two quaternions. @@ -10120,18 +11036,18 @@ def qxq(q1, q2): :return: Product of q1 and q2. :rtype: 4-Element Array of floats """ - q1 = stypes.toDoubleVector(q1) - q2 = stypes.toDoubleVector(q2) - vout = stypes.emptyDoubleVector(4) + q1 = stypes.to_double_vector(q1) + q2 = stypes.to_double_vector(q2) + vout = stypes.empty_double_vector(4) libspice.qxq_c(q1, q2, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) ################################################################################ # R -@spiceErrorCheck +@spice_error_check def radrec(inrange, re, dec): """ Convert from range, right ascension, and declination to rectangular @@ -10151,12 +11067,12 @@ def radrec(inrange, re, dec): inrange = ctypes.c_double(inrange) re = ctypes.c_double(re) dec = ctypes.c_double(dec) - rectan = stypes.emptyDoubleVector(3) + rectan = stypes.empty_double_vector(3) libspice.radrec_c(inrange, re, dec, rectan) - return stypes.cVectorToPython(rectan) + return stypes.c_vector_to_python(rectan) -@spiceErrorCheck +@spice_error_check def rav2xf(rot, av): """ This routine determines a state transformation matrix @@ -10172,14 +11088,14 @@ def rav2xf(rot, av): :return: State transformation associated with rot and av. :rtype: 6x6-Element Array of floats """ - rot = stypes.toDoubleMatrix(rot) - av = stypes.toDoubleVector(av) - xform = stypes.emptyDoubleMatrix(x=6, y=6) + rot = stypes.to_double_matrix(rot) + av = stypes.to_double_vector(av) + xform = stypes.empty_double_matrix(x=6, y=6) libspice.rav2xf_c(rot, av, xform) - return stypes.cMatrixToNumpy(xform) + return stypes.c_matrix_to_numpy(xform) -@spiceErrorCheck +@spice_error_check def raxisa(matrix): """ Compute the axis of the rotation given by an input matrix @@ -10192,14 +11108,14 @@ def raxisa(matrix): :return: Axis of the rotation, Angle through which the rotation is performed :rtype: tuple """ - matrix = stypes.toDoubleMatrix(matrix) - axis = stypes.emptyDoubleVector(3) + matrix = stypes.to_double_matrix(matrix) + axis = stypes.empty_double_vector(3) angle = ctypes.c_double() libspice.raxisa_c(matrix, axis, ctypes.byref(angle)) - return stypes.cVectorToPython(axis), angle.value + return stypes.c_vector_to_python(axis), angle.value -@spiceErrorCheck +@spice_error_check def rdtext(file, lenout=_default_len_out): # pragma: no cover """ Read the next line of text from a text file. @@ -10213,15 +11129,15 @@ def rdtext(file, lenout=_default_len_out): # pragma: no cover :return: Next line from the text file, End-of-file indicator :rtype: tuple """ - file = stypes.stringToCharP(file) - line = stypes.stringToCharP(lenout) + file = stypes.string_to_char_p(file) + line = stypes.string_to_char_p(lenout) lenout = ctypes.c_int(lenout) eof = ctypes.c_int() libspice.rdtext_c(file, lenout, line, ctypes.byref(eof)) - return stypes.toPythonString(line), bool(eof.value) + return stypes.to_python_string(line), bool(eof.value) -@spiceErrorCheck +@spice_error_check def reccyl(rectan): """ Convert from rectangular to cylindrical coordinates. @@ -10236,16 +11152,15 @@ def reccyl(rectan): Height above xY plane. :rtype: tuple """ - rectan = stypes.toDoubleVector(rectan) + rectan = stypes.to_double_vector(rectan) radius = ctypes.c_double(0) lon = ctypes.c_double(0) z = ctypes.c_double(0) - libspice.reccyl_c(rectan, ctypes.byref(radius), ctypes.byref(lon), - ctypes.byref(z)) + libspice.reccyl_c(rectan, ctypes.byref(radius), ctypes.byref(lon), ctypes.byref(z)) return radius.value, lon.value, z.value -@spiceErrorCheck +@spice_error_check def recgeo(rectan, re, f): """ Convert from rectangular coordinates to geodetic coordinates. @@ -10264,18 +11179,24 @@ def recgeo(rectan, re, f): Altitude above reference spheroid :rtype: tuple """ - rectan = stypes.toDoubleVector(rectan) + rectan = stypes.to_double_vector(rectan) re = ctypes.c_double(re) f = ctypes.c_double(f) longitude = ctypes.c_double(0) latitude = ctypes.c_double(0) alt = ctypes.c_double(0) - libspice.recgeo_c(rectan, re, f, ctypes.byref(longitude), - ctypes.byref(latitude), ctypes.byref(alt)) + libspice.recgeo_c( + rectan, + re, + f, + ctypes.byref(longitude), + ctypes.byref(latitude), + ctypes.byref(alt), + ) return longitude.value, latitude.value, alt.value -@spiceErrorCheck +@spice_error_check def reclat(rectan): """ Convert from rectangular coordinates to latitudinal coordinates. @@ -10287,16 +11208,17 @@ def reclat(rectan): :return: Distance from the origin, Longitude in radians, Latitude in radians :rtype: tuple """ - rectan = stypes.toDoubleVector(rectan) + rectan = stypes.to_double_vector(rectan) radius = ctypes.c_double(0) longitude = ctypes.c_double(0) latitude = ctypes.c_double(0) - libspice.reclat_c(rectan, ctypes.byref(radius), ctypes.byref(longitude), - ctypes.byref(latitude)) + libspice.reclat_c( + rectan, ctypes.byref(radius), ctypes.byref(longitude), ctypes.byref(latitude) + ) return radius.value, longitude.value, latitude.value -@spiceErrorCheck +@spice_error_check def recpgr(body, rectan, re, f): """ Convert rectangular coordinates to planetographic coordinates. @@ -10317,19 +11239,20 @@ def recpgr(body, rectan, re, f): Altitude above reference spheroid :rtype: tuple """ - body = stypes.stringToCharP(body) - rectan = stypes.toDoubleVector(rectan) + body = stypes.string_to_char_p(body) + rectan = stypes.to_double_vector(rectan) re = ctypes.c_double(re) f = ctypes.c_double(f) lon = ctypes.c_double() lat = ctypes.c_double() alt = ctypes.c_double() - libspice.recpgr_c(body, rectan, re, f, ctypes.byref(lon), ctypes.byref(lat), - ctypes.byref(alt)) + libspice.recpgr_c( + body, rectan, re, f, ctypes.byref(lon), ctypes.byref(lat), ctypes.byref(alt) + ) return lon.value, lat.value, alt.value -@spiceErrorCheck +@spice_error_check def recrad(rectan): """ Convert rectangular coordinates to range, right ascension, and declination. @@ -10344,16 +11267,17 @@ def recrad(rectan): Declination in radians :rtype: tuple """ - rectan = stypes.toDoubleVector(rectan) + rectan = stypes.to_double_vector(rectan) outrange = ctypes.c_double() ra = ctypes.c_double() dec = ctypes.c_double() - libspice.recrad_c(rectan, ctypes.byref(outrange), ctypes.byref(ra), - ctypes.byref(dec)) + libspice.recrad_c( + rectan, ctypes.byref(outrange), ctypes.byref(ra), ctypes.byref(dec) + ) return outrange.value, ra.value, dec.value -@spiceErrorCheck +@spice_error_check def recsph(rectan): """ Convert from rectangular coordinates to spherical coordinates. @@ -10368,16 +11292,15 @@ def recsph(rectan): Longitude in radians. :rtype: tuple """ - rectan = stypes.toDoubleVector(rectan) + rectan = stypes.to_double_vector(rectan) r = ctypes.c_double() colat = ctypes.c_double() lon = ctypes.c_double() - libspice.recsph_c(rectan, ctypes.byref(r), ctypes.byref(colat), - ctypes.byref(lon)) + libspice.recsph_c(rectan, ctypes.byref(r), ctypes.byref(colat), ctypes.byref(lon)) return r.value, colat.value, lon.value -@spiceErrorCheck +@spice_error_check def removc(item, inset): """ Remove an item from a character set. @@ -10391,11 +11314,11 @@ def removc(item, inset): """ assert isinstance(inset, stypes.SpiceCell) assert inset.dtype == 0 - item = stypes.stringToCharP(item) + item = stypes.string_to_char_p(item) libspice.removc_c(item, ctypes.byref(inset)) -@spiceErrorCheck +@spice_error_check def removd(item, inset): """ Remove an item from a double precision set. @@ -10413,7 +11336,7 @@ def removd(item, inset): libspice.removd_c(item, ctypes.byref(inset)) -@spiceErrorCheck +@spice_error_check def removi(item, inset): """ Remove an item from an integer set. @@ -10431,7 +11354,7 @@ def removi(item, inset): libspice.removi_c(item, ctypes.byref(inset)) -@spiceErrorCheck +@spice_error_check def reordc(iorder, ndim, lenvals, array): """ Re-order the elements of an array of character strings @@ -10450,15 +11373,15 @@ def reordc(iorder, ndim, lenvals, array): :return: Re-ordered Array. :rtype: Array of strs """ - iorder = stypes.toIntVector(iorder) + iorder = stypes.to_int_vector(iorder) ndim = ctypes.c_int(ndim) lenvals = ctypes.c_int(lenvals + 1) - array = stypes.listToCharArray(array, xLen=lenvals, yLen=ndim) + array = stypes.list_to_char_array(array, x_len=lenvals, y_len=ndim) libspice.reordc_c(iorder, ndim, lenvals, array) - return [stypes.toPythonString(x.value) for x in array] + return [stypes.to_python_string(x.value) for x in array] -@spiceErrorCheck +@spice_error_check def reordd(iorder, ndim, array): """ Re-order the elements of a double precision array according to @@ -10475,14 +11398,14 @@ def reordd(iorder, ndim, array): :return: Re-ordered Array. :rtype: Array of floats """ - iorder = stypes.toIntVector(iorder) + iorder = stypes.to_int_vector(iorder) ndim = ctypes.c_int(ndim) - array = stypes.toDoubleVector(array) + array = stypes.to_double_vector(array) libspice.reordd_c(iorder, ndim, array) - return stypes.cVectorToPython(array) + return stypes.c_vector_to_python(array) -@spiceErrorCheck +@spice_error_check def reordi(iorder, ndim, array): """ Re-order the elements of an integer array according to @@ -10499,14 +11422,14 @@ def reordi(iorder, ndim, array): :return: Re-ordered Array. :rtype: Array of ints """ - iorder = stypes.toIntVector(iorder) + iorder = stypes.to_int_vector(iorder) ndim = ctypes.c_int(ndim) - array = stypes.toIntVector(array) + array = stypes.to_int_vector(array) libspice.reordi_c(iorder, ndim, array) - return stypes.cVectorToPython(array) + return stypes.c_vector_to_python(array) -@spiceErrorCheck +@spice_error_check def reordl(iorder, ndim, array): """ Re-order the elements of a logical (Boolean) array according to @@ -10523,14 +11446,14 @@ def reordl(iorder, ndim, array): :return: Re-ordered Array. :rtype: Array of bools """ - iorder = stypes.toIntVector(iorder) + iorder = stypes.to_int_vector(iorder) ndim = ctypes.c_int(ndim) - array = stypes.toIntVector(array) + array = stypes.to_int_vector(array) libspice.reordl_c(iorder, ndim, array) - return stypes.cIntVectorToBoolPython(array) + return stypes.c_int_vector_to_bool_python(array) -@spiceErrorCheck +@spice_error_check def repmc(instr, marker, value, lenout=None): """ Replace a marker with a character string. @@ -10550,15 +11473,15 @@ def repmc(instr, marker, value, lenout=None): """ if lenout is None: lenout = ctypes.c_int(len(instr) + len(value) + len(marker) + 15) - instr = stypes.stringToCharP(instr) - marker = stypes.stringToCharP(marker) - value = stypes.stringToCharP(value) - out = stypes.stringToCharP(lenout) + instr = stypes.string_to_char_p(instr) + marker = stypes.string_to_char_p(marker) + value = stypes.string_to_char_p(value) + out = stypes.string_to_char_p(lenout) libspice.repmc_c(instr, marker, value, lenout, out) - return stypes.toPythonString(out) + return stypes.to_python_string(out) -@spiceErrorCheck +@spice_error_check def repmct(instr, marker, value, repcase, lenout=None): """ Replace a marker with the text representation of a @@ -10581,16 +11504,16 @@ def repmct(instr, marker, value, repcase, lenout=None): """ if lenout is None: lenout = ctypes.c_int(len(instr) + len(marker) + 15) - instr = stypes.stringToCharP(instr) - marker = stypes.stringToCharP(marker) + instr = stypes.string_to_char_p(instr) + marker = stypes.string_to_char_p(marker) value = ctypes.c_int(value) - repcase = ctypes.c_char(repcase.encode(encoding='UTF-8')) - out = stypes.stringToCharP(lenout) + repcase = ctypes.c_char(repcase.encode(encoding="UTF-8")) + out = stypes.string_to_char_p(lenout) libspice.repmct_c(instr, marker, value, repcase, lenout, out) - return stypes.toPythonString(out) + return stypes.to_python_string(out) -@spiceErrorCheck +@spice_error_check def repmd(instr, marker, value, sigdig): """ Replace a marker with a double precision number. @@ -10609,16 +11532,16 @@ def repmd(instr, marker, value, sigdig): :rtype: str """ lenout = ctypes.c_int(len(instr) + len(marker) + 15) - instr = stypes.stringToCharP(instr) - marker = stypes.stringToCharP(marker) + instr = stypes.string_to_char_p(instr) + marker = stypes.string_to_char_p(marker) value = ctypes.c_double(value) sigdig = ctypes.c_int(sigdig) - out = stypes.stringToCharP(lenout) + out = stypes.string_to_char_p(lenout) libspice.repmd_c(instr, marker, value, sigdig, lenout, out) - return stypes.toPythonString(out) + return stypes.to_python_string(out) -@spiceErrorCheck +@spice_error_check def repmf(instr, marker, value, sigdig, informat, lenout=None): """ Replace a marker in a string with a formatted double precision value. @@ -10642,17 +11565,17 @@ def repmf(instr, marker, value, sigdig, informat, lenout=None): """ if lenout is None: lenout = ctypes.c_int(len(instr) + len(marker) + 15) - instr = stypes.stringToCharP(instr) - marker = stypes.stringToCharP(marker) + instr = stypes.string_to_char_p(instr) + marker = stypes.string_to_char_p(marker) value = ctypes.c_double(value) sigdig = ctypes.c_int(sigdig) - informat = ctypes.c_char(informat.encode(encoding='UTF-8')) - out = stypes.stringToCharP(lenout) + informat = ctypes.c_char(informat.encode(encoding="UTF-8")) + out = stypes.string_to_char_p(lenout) libspice.repmf_c(instr, marker, value, sigdig, informat, lenout, out) - return stypes.toPythonString(out) + return stypes.to_python_string(out) -@spiceErrorCheck +@spice_error_check def repmi(instr, marker, value, lenout=None): """ Replace a marker with an integer. @@ -10672,15 +11595,15 @@ def repmi(instr, marker, value, lenout=None): """ if lenout is None: lenout = ctypes.c_int(len(instr) + len(marker) + 15) - instr = stypes.stringToCharP(instr) - marker = stypes.stringToCharP(marker) + instr = stypes.string_to_char_p(instr) + marker = stypes.string_to_char_p(marker) value = ctypes.c_int(value) - out = stypes.stringToCharP(lenout) + out = stypes.string_to_char_p(lenout) libspice.repmi_c(instr, marker, value, lenout, out) - return stypes.toPythonString(out) + return stypes.to_python_string(out) -@spiceErrorCheck +@spice_error_check def repmot(instr, marker, value, repcase, lenout=None): """ Replace a marker with the text representation of an ordinal number. @@ -10702,13 +11625,13 @@ def repmot(instr, marker, value, repcase, lenout=None): """ if lenout is None: lenout = ctypes.c_int(len(instr) + len(marker) + 15) - instr = stypes.stringToCharP(instr) - marker = stypes.stringToCharP(marker) + instr = stypes.string_to_char_p(instr) + marker = stypes.string_to_char_p(marker) value = ctypes.c_int(value) - repcase = ctypes.c_char(repcase.encode(encoding='UTF-8')) - out = stypes.stringToCharP(lenout) + repcase = ctypes.c_char(repcase.encode(encoding="UTF-8")) + out = stypes.string_to_char_p(lenout) libspice.repmot_c(instr, marker, value, repcase, lenout, out) - return stypes.toPythonString(out) + return stypes.to_python_string(out) def reset(): @@ -10723,7 +11646,7 @@ def reset(): libspice.reset_c() -@spiceErrorCheck +@spice_error_check def return_c(): """ True if SPICE routines should return immediately upon entry. @@ -10736,7 +11659,7 @@ def return_c(): return bool(libspice.return_c()) -@spiceErrorCheck +@spice_error_check def rotate(angle, iaxis): """ Calculate the 3x3 rotation matrix generated by a rotation @@ -10754,12 +11677,12 @@ def rotate(angle, iaxis): """ angle = ctypes.c_double(angle) iaxis = ctypes.c_int(iaxis) - mout = stypes.emptyDoubleMatrix() + mout = stypes.empty_double_matrix() libspice.rotate_c(angle, iaxis, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def rotmat(m1, angle, iaxis): """ Rotmat applies a rotation of angle radians about axis iaxis to a @@ -10777,15 +11700,15 @@ def rotmat(m1, angle, iaxis): :return: Resulting rotated matrix. :rtype: 3x3-Element Array of floats """ - m1 = stypes.toDoubleMatrix(m1) + m1 = stypes.to_double_matrix(m1) angle = ctypes.c_double(angle) iaxis = ctypes.c_int(iaxis) - mout = stypes.emptyDoubleMatrix() + mout = stypes.empty_double_matrix() libspice.rotmat_c(m1, angle, iaxis, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def rotvec(v1, angle, iaxis): """ Transform a vector to a new coordinate system rotated by angle @@ -10803,15 +11726,15 @@ def rotvec(v1, angle, iaxis): :return: the vector expressed in the new coordinate system. :rtype: 3-Element Array of floats """ - v1 = stypes.toDoubleVector(v1) + v1 = stypes.to_double_vector(v1) angle = ctypes.c_double(angle) iaxis = ctypes.c_int(iaxis) - vout = stypes.emptyDoubleVector(3) + vout = stypes.empty_double_vector(3) libspice.rotvec_c(v1, angle, iaxis, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def rpd(): """ Return the number of radians per degree. @@ -10824,7 +11747,7 @@ def rpd(): return libspice.rpd_c() -@spiceErrorCheck +@spice_error_check def rquad(a, b, c): """ Find the roots of a quadratic equation. @@ -10843,17 +11766,17 @@ def rquad(a, b, c): a = ctypes.c_double(a) b = ctypes.c_double(b) c = ctypes.c_double(c) - root1 = stypes.emptyDoubleVector(2) - root2 = stypes.emptyDoubleVector(2) + root1 = stypes.empty_double_vector(2) + root2 = stypes.empty_double_vector(2) libspice.rquad_c(a, b, c, root1, root2) - return stypes.cVectorToPython(root1), stypes.cVectorToPython(root2) + return stypes.c_vector_to_python(root1), stypes.c_vector_to_python(root2) ################################################################################ # S -@spiceErrorCheck +@spice_error_check def saelgv(vec1, vec2): """ Find semi-axis vectors of an ellipse generated by two arbitrary @@ -10868,15 +11791,15 @@ def saelgv(vec1, vec2): :return: Semi-major axis of ellipse, Semi-minor axis of ellipse. :rtype: tuple """ - vec1 = stypes.toDoubleVector(vec1) - vec2 = stypes.toDoubleVector(vec2) - smajor = stypes.emptyDoubleVector(3) - sminor = stypes.emptyDoubleVector(3) + vec1 = stypes.to_double_vector(vec1) + vec2 = stypes.to_double_vector(vec2) + smajor = stypes.empty_double_vector(3) + sminor = stypes.empty_double_vector(3) libspice.saelgv_c(vec1, vec2, smajor, sminor) - return stypes.cVectorToPython(smajor), stypes.cVectorToPython(sminor) + return stypes.c_vector_to_python(smajor), stypes.c_vector_to_python(sminor) -@spiceErrorCheck +@spice_error_check def scard(incard, cell): """ Set the cardinality of a SPICE cell of any data type. @@ -10896,8 +11819,8 @@ def scard(incard, cell): return cell -@spiceErrorCheck -def scdecd(sc, sclkdp, lenout=_default_len_out, MXPART=None): +@spice_error_check +def scdecd(sc, sclkdp, lenout=_default_len_out, mxpart=None): # todo: figure out how to use mxpart """ Convert double precision encoding of spacecraft clock time into @@ -10911,20 +11834,20 @@ def scdecd(sc, sclkdp, lenout=_default_len_out, MXPART=None): :type sclkdp: float :param lenout: Maximum allowed length of output SCLK string. :type lenout: int - :param MXPART: Maximum number of spacecraft clock partitions. - :type MXPART: int + :param mxpart: Maximum number of spacecraft clock partitions. + :type mxpart: int :return: Character representation of a clock count. :rtype: str """ sc = ctypes.c_int(sc) sclkdp = ctypes.c_double(sclkdp) - sclkch = stypes.stringToCharP(" " * lenout) + sclkch = stypes.string_to_char_p(" " * lenout) lenout = ctypes.c_int(lenout) libspice.scdecd_c(sc, sclkdp, lenout, sclkch) - return stypes.toPythonString(sclkch) + return stypes.to_python_string(sclkch) -@spiceErrorCheck +@spice_error_check def sce2c(sc, et): """ Convert ephemeris seconds past J2000 (ET) to continuous encoded @@ -10949,7 +11872,7 @@ def sce2c(sc, et): return sclkdp.value -@spiceErrorCheck +@spice_error_check def sce2s(sc, et, lenout=_default_len_out): """ Convert an epoch specified as ephemeris seconds past J2000 (ET) to a @@ -10968,13 +11891,13 @@ def sce2s(sc, et, lenout=_default_len_out): """ sc = ctypes.c_int(sc) et = ctypes.c_double(et) - sclkch = stypes.stringToCharP(" " * lenout) + sclkch = stypes.string_to_char_p(" " * lenout) lenout = ctypes.c_int(lenout) libspice.sce2s_c(sc, et, lenout, sclkch) - return stypes.toPythonString(sclkch) + return stypes.to_python_string(sclkch) -@spiceErrorCheck +@spice_error_check def sce2t(sc, et): """ Convert ephemeris seconds past J2000 (ET) to integral @@ -10998,8 +11921,8 @@ def sce2t(sc, et): return sclkdp.value -@spiceErrorCheck -def scencd(sc, sclkch, MXPART=None): +@spice_error_check +def scencd(sc, sclkch, mxpart=None): """ Encode character representation of spacecraft clock time into a double precision number. @@ -11010,26 +11933,26 @@ def scencd(sc, sclkch, MXPART=None): :type sc: int :param sclkch: Character representation of a spacecraft clock. :type sclkch: Union[str,Iterable[str]] - :param MXPART: Maximum number of spacecraft clock partitions. - :type MXPART: int + :param mxpart: Maximum number of spacecraft clock partitions. + :type mxpart: int :return: Encoded representation of the clock count. :rtype: Union[float,Iterable[float]] """ sc = ctypes.c_int(sc) sclkdp = ctypes.c_double() - if stypes.isiterable(sclkch): + if stypes.is_iterable(sclkch): results = [] for chars in sclkch: - libspice.scencd_c(sc, stypes.stringToCharP(chars), ctypes.byref(sclkdp)) - checkForSpiceError(None) + libspice.scencd_c(sc, stypes.string_to_char_p(chars), ctypes.byref(sclkdp)) + check_for_spice_error(None) results.append(sclkdp.value) return results else: - libspice.scencd_c(sc, stypes.stringToCharP(sclkch), ctypes.byref(sclkdp)) + libspice.scencd_c(sc, stypes.string_to_char_p(sclkch), ctypes.byref(sclkdp)) return sclkdp.value -@spiceErrorCheck +@spice_error_check def scfmt(sc, ticks, lenout=_default_len_out): """ Convert encoded spacecraft clock ticks to character clock format. @@ -11047,13 +11970,13 @@ def scfmt(sc, ticks, lenout=_default_len_out): """ sc = ctypes.c_int(sc) ticks = ctypes.c_double(ticks) - clkstr = stypes.stringToCharP(lenout) + clkstr = stypes.string_to_char_p(lenout) lenout = ctypes.c_int(lenout) libspice.scfmt_c(sc, ticks, lenout, clkstr) - return stypes.toPythonString(clkstr) + return stypes.to_python_string(clkstr) -@spiceErrorCheck +@spice_error_check def scpart(sc): """ Get spacecraft clock partition information from a spacecraft @@ -11071,14 +11994,16 @@ def scpart(sc): """ sc = ctypes.c_int(sc) nparts = ctypes.c_int() - pstart = stypes.emptyDoubleVector(9999) - pstop = stypes.emptyDoubleVector(9999) + pstart = stypes.empty_double_vector(9999) + pstop = stypes.empty_double_vector(9999) libspice.scpart_c(sc, nparts, pstart, pstop) - return stypes.cVectorToPython(pstart)[0:nparts.value], stypes.cVectorToPython( - pstop)[0:nparts.value] + return ( + stypes.c_vector_to_python(pstart)[0 : nparts.value], + stypes.c_vector_to_python(pstop)[0 : nparts.value], + ) -@spiceErrorCheck +@spice_error_check def scs2e(sc, sclkch): """ Convert a spacecraft clock string to ephemeris seconds past J2000 (ET). @@ -11093,13 +12018,13 @@ def scs2e(sc, sclkch): :rtype: float """ sc = ctypes.c_int(sc) - sclkch = stypes.stringToCharP(sclkch) + sclkch = stypes.string_to_char_p(sclkch) et = ctypes.c_double() libspice.scs2e_c(sc, sclkch, ctypes.byref(et)) return et.value -@spiceErrorCheck +@spice_error_check def sct2e(sc, sclkdp): """ Convert encoded spacecraft clock ("ticks") to ephemeris @@ -11116,11 +12041,11 @@ def sct2e(sc, sclkdp): """ sc = ctypes.c_int(sc) et = ctypes.c_double() - if stypes.isiterable(sclkdp): + if stypes.is_iterable(sclkdp): results = [] for sclk in sclkdp: - libspice.sct2e_c(sc, ctypes.c_double(sclk), ctypes.byref(et)) - checkForSpiceError(None) + libspice.sct2e_c(sc, ctypes.c_double(sclk), ctypes.byref(et)) + check_for_spice_error(None) results.append(et.value) return results else: @@ -11129,7 +12054,7 @@ def sct2e(sc, sclkdp): return et.value -@spiceErrorCheck +@spice_error_check def sctiks(sc, clkstr): """ Convert a spacecraft clock format string to number of "ticks". @@ -11144,13 +12069,13 @@ def sctiks(sc, clkstr): :rtype: float """ sc = ctypes.c_int(sc) - clkstr = stypes.stringToCharP(clkstr) + clkstr = stypes.string_to_char_p(clkstr) ticks = ctypes.c_double() libspice.sctiks_c(sc, clkstr, ctypes.byref(ticks)) return ticks.value -@spiceErrorCheck +@spice_error_check def sdiff(a, b): """ Take the symmetric difference of two sets of any data type to form a @@ -11182,7 +12107,7 @@ def sdiff(a, b): return c -@spiceErrorCheck +@spice_error_check def set_c(a, op, b): """ Given a relational operator, compare two sets of any data type. @@ -11202,11 +12127,11 @@ def set_c(a, op, b): assert isinstance(b, stypes.SpiceCell) assert a.dtype == b.dtype assert isinstance(op, str) - op = stypes.stringToCharP(op) + op = stypes.string_to_char_p(op) return bool(libspice.set_c(ctypes.byref(a), op, ctypes.byref(b))) -@spiceErrorCheck +@spice_error_check def setmsg(message): """ Set the value of the current long error message. @@ -11216,11 +12141,11 @@ def setmsg(message): :param message: A long error message. :type message: str """ - message = stypes.stringToCharP(message) + message = stypes.string_to_char_p(message) libspice.setmsg_c(message) -@spiceErrorCheck +@spice_error_check def shellc(ndim, lenvals, array): # This works! looks like this is a mutable 2d char array """ @@ -11238,14 +12163,14 @@ def shellc(ndim, lenvals, array): :return: The sorted array. :rtype: list of str. """ - array = stypes.listToCharArray(array, xLen=lenvals, yLen=ndim) + array = stypes.list_to_char_array(array, x_len=lenvals, y_len=ndim) ndim = ctypes.c_int(ndim) lenvals = ctypes.c_int(lenvals) libspice.shellc_c(ndim, lenvals, ctypes.byref(array)) - return stypes.cVectorToPython(array) + return stypes.c_vector_to_python(array) -@spiceErrorCheck +@spice_error_check def shelld(ndim, array): # Works!, use this as example for "I/O" parameters """ @@ -11260,13 +12185,13 @@ def shelld(ndim, array): :return: The sorted array. :rtype: Array of floats """ - array = stypes.toDoubleVector(array) + array = stypes.to_double_vector(array) ndim = ctypes.c_int(ndim) libspice.shelld_c(ndim, ctypes.cast(array, ctypes.POINTER(ctypes.c_double))) - return stypes.cVectorToPython(array) + return stypes.c_vector_to_python(array) -@spiceErrorCheck +@spice_error_check def shelli(ndim, array): # Works!, use this as example for "I/O" parameters """ @@ -11281,10 +12206,10 @@ def shelli(ndim, array): :return: The sorted array. :rtype: Array of ints """ - array = stypes.toIntVector(array) + array = stypes.to_int_vector(array) ndim = ctypes.c_int(ndim) libspice.shelli_c(ndim, ctypes.cast(array, ctypes.POINTER(ctypes.c_int))) - return stypes.cVectorToPython(array) + return stypes.c_vector_to_python(array) def sigerr(message): @@ -11297,12 +12222,12 @@ def sigerr(message): :param message: A short error message. :type message: str """ - message = stypes.stringToCharP(message) + message = stypes.string_to_char_p(message) libspice.sigerr_c(message) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def sincpt(method, target, et, fixref, abcorr, obsrvr, dref, dvec): """ Given an observer and a direction vector defining a ray, compute @@ -11336,25 +12261,41 @@ def sincpt(method, target, et, fixref, abcorr, obsrvr, dref, dvec): Vector from observer to intercept point. :rtype: tuple """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) + method = stypes.string_to_char_p(method) + target = stypes.string_to_char_p(target) et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - dref = stypes.stringToCharP(dref) - dvec = stypes.toDoubleVector(dvec) - spoint = stypes.emptyDoubleVector(3) + fixref = stypes.string_to_char_p(fixref) + 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) + spoint = stypes.empty_double_vector(3) trgepc = ctypes.c_double(0) - srfvec = stypes.emptyDoubleVector(3) + srfvec = stypes.empty_double_vector(3) found = ctypes.c_int(0) - libspice.sincpt_c(method, target, et, fixref, abcorr, obsrvr, dref, dvec, - spoint, ctypes.byref(trgepc), srfvec, ctypes.byref(found)) - return stypes.cVectorToPython(spoint), trgepc.value, stypes.cVectorToPython( - srfvec), bool(found.value) - - -@spiceErrorCheck + libspice.sincpt_c( + method, + target, + et, + fixref, + abcorr, + obsrvr, + dref, + dvec, + spoint, + ctypes.byref(trgepc), + srfvec, + ctypes.byref(found), + ) + return ( + stypes.c_vector_to_python(spoint), + trgepc.value, + stypes.c_vector_to_python(srfvec), + bool(found.value), + ) + + +@spice_error_check def size(cell): """ Return the size (maximum cardinality) of a SPICE cell of any @@ -11371,7 +12312,7 @@ def size(cell): return libspice.size_c(ctypes.byref(cell)) -@spiceErrorCheck +@spice_error_check def spd(): """ Return the number of seconds in a day. @@ -11384,7 +12325,7 @@ def spd(): return libspice.spd_c() -@spiceErrorCheck +@spice_error_check def sphcyl(radius, colat, slon): """ This routine converts from spherical coordinates to cylindrical @@ -11410,12 +12351,13 @@ def sphcyl(radius, colat, slon): r = ctypes.c_double() lon = ctypes.c_double() z = ctypes.c_double() - libspice.sphcyl_c(radius, colat, slon, ctypes.byref(r), ctypes.byref(lon), - ctypes.byref(z)) + libspice.sphcyl_c( + radius, colat, slon, ctypes.byref(r), ctypes.byref(lon), ctypes.byref(z) + ) return r.value, lon.value, z.value -@spiceErrorCheck +@spice_error_check def sphlat(r, colat, lons): """ Convert from spherical coordinates to latitudinal coordinates. @@ -11440,12 +12382,13 @@ def sphlat(r, colat, lons): radius = ctypes.c_double() lon = ctypes.c_double() lat = ctypes.c_double() - libspice.sphcyl_c(r, colat, lons, ctypes.byref(radius), ctypes.byref(lon), - ctypes.byref(lat)) + libspice.sphcyl_c( + r, colat, lons, ctypes.byref(radius), ctypes.byref(lon), ctypes.byref(lat) + ) return radius.value, lon.value, lat.value -@spiceErrorCheck +@spice_error_check def sphrec(r, colat, lon): """ Convert from spherical coordinates to rectangular coordinates. @@ -11464,12 +12407,12 @@ def sphrec(r, colat, lon): r = ctypes.c_double(r) colat = ctypes.c_double(colat) lon = ctypes.c_double(lon) - rectan = stypes.emptyDoubleVector(3) + rectan = stypes.empty_double_vector(3) libspice.sphrec_c(r, colat, lon, rectan) - return stypes.cVectorToPython(rectan) + return stypes.c_vector_to_python(rectan) -@spiceErrorCheck +@spice_error_check def spkacs(targ, et, ref, abcorr, obs): """ Return the state (position and velocity) of a target body @@ -11497,18 +12440,19 @@ def spkacs(targ, et, ref, abcorr, obs): """ targ = ctypes.c_int(targ) et = ctypes.c_double(et) - ref = stypes.stringToCharP(ref) - abcorr = stypes.stringToCharP(abcorr) + ref = stypes.string_to_char_p(ref) + abcorr = stypes.string_to_char_p(abcorr) obs = ctypes.c_int(obs) - starg = stypes.emptyDoubleVector(6) + starg = stypes.empty_double_vector(6) lt = ctypes.c_double() dlt = ctypes.c_double() - libspice.spkacs_c(targ, et, ref, abcorr, obs, starg, ctypes.byref(lt), - ctypes.byref(dlt)) - return stypes.cVectorToPython(starg), lt.value, dlt.value + libspice.spkacs_c( + targ, et, ref, abcorr, obs, starg, ctypes.byref(lt), ctypes.byref(dlt) + ) + return stypes.c_vector_to_python(starg), lt.value, dlt.value -@spiceErrorCheck +@spice_error_check def spkapo(targ, et, ref, sobs, abcorr): """ Return the position of a target body relative to an observer, @@ -11533,16 +12477,16 @@ def spkapo(targ, et, ref, sobs, abcorr): """ targ = ctypes.c_int(targ) et = ctypes.c_double(et) - ref = stypes.stringToCharP(ref) - abcorr = stypes.stringToCharP(abcorr) - sobs = stypes.toDoubleVector(sobs) - ptarg = stypes.emptyDoubleVector(3) + ref = stypes.string_to_char_p(ref) + abcorr = stypes.string_to_char_p(abcorr) + sobs = stypes.to_double_vector(sobs) + ptarg = stypes.empty_double_vector(3) lt = ctypes.c_double() libspice.spkapo_c(targ, et, ref, sobs, abcorr, ptarg, ctypes.byref(lt)) - return stypes.cVectorToPython(ptarg), lt.value + return stypes.c_vector_to_python(ptarg), lt.value -@spiceErrorCheck +@spice_error_check def spkapp(targ, et, ref, sobs, abcorr): """ Deprecated: This routine has been superseded by :func:`spkaps`. This @@ -11571,16 +12515,16 @@ def spkapp(targ, et, ref, sobs, abcorr): """ targ = ctypes.c_int(targ) et = ctypes.c_double(et) - ref = stypes.stringToCharP(ref) - abcorr = stypes.stringToCharP(abcorr) - sobs = stypes.toDoubleVector(sobs) - starg = stypes.emptyDoubleVector(6) + ref = stypes.string_to_char_p(ref) + abcorr = stypes.string_to_char_p(abcorr) + sobs = stypes.to_double_vector(sobs) + starg = stypes.empty_double_vector(6) lt = ctypes.c_double() libspice.spkapp_c(targ, et, ref, sobs, abcorr, starg, ctypes.byref(lt)) - return stypes.cVectorToPython(starg), lt.value + return stypes.c_vector_to_python(starg), lt.value -@spiceErrorCheck +@spice_error_check def spkaps(targ, et, ref, abcorr, stobs, accobs): """ Given the state and acceleration of an observer relative to the @@ -11615,19 +12559,20 @@ def spkaps(targ, et, ref, abcorr, stobs, accobs): """ targ = ctypes.c_int(targ) et = ctypes.c_double(et) - ref = stypes.stringToCharP(ref) - abcorr = stypes.stringToCharP(abcorr) - stobs = stypes.toDoubleVector(stobs) - accobs = stypes.toDoubleVector(accobs) - starg = stypes.emptyDoubleVector(6) + ref = stypes.string_to_char_p(ref) + abcorr = stypes.string_to_char_p(abcorr) + stobs = stypes.to_double_vector(stobs) + accobs = stypes.to_double_vector(accobs) + starg = stypes.empty_double_vector(6) lt = ctypes.c_double() dlt = ctypes.c_double() - libspice.spkaps_c(targ, et, ref, abcorr, stobs, accobs, starg, - ctypes.byref(lt), ctypes.byref(dlt)) - return stypes.cVectorToPython(starg), lt.value, dlt.value + libspice.spkaps_c( + targ, et, ref, abcorr, stobs, accobs, starg, ctypes.byref(lt), ctypes.byref(dlt) + ) + return stypes.c_vector_to_python(starg), lt.value, dlt.value -@spiceErrorCheck +@spice_error_check def spk14a(handle, ncsets, coeffs, epochs): """ Add data to a type 14 SPK segment associated with handle. See @@ -11646,12 +12591,12 @@ def spk14a(handle, ncsets, coeffs, epochs): """ handle = ctypes.c_int(handle) ncsets = ctypes.c_int(ncsets) - coeffs = stypes.toDoubleVector(coeffs) - epochs = stypes.toDoubleVector(epochs) + coeffs = stypes.to_double_vector(coeffs) + epochs = stypes.to_double_vector(epochs) libspice.spk14a_c(handle, ncsets, coeffs, epochs) -@spiceErrorCheck +@spice_error_check def spk14b(handle, segid, body, center, framename, first, last, chbdeg): """ Begin a type 14 SPK segment in the SPK file associated with @@ -11677,18 +12622,17 @@ def spk14b(handle, segid, body, center, framename, first, last, chbdeg): :type chbdeg: int """ handle = ctypes.c_int(handle) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) body = ctypes.c_int(body) center = ctypes.c_int(center) - framename = stypes.stringToCharP(framename) + framename = stypes.string_to_char_p(framename) first = ctypes.c_double(first) last = ctypes.c_double(last) chbdeg = ctypes.c_int(chbdeg) - libspice.spk14b_c(handle, segid, body, center, framename, first, last, - chbdeg) + libspice.spk14b_c(handle, segid, body, center, framename, first, last, chbdeg) -@spiceErrorCheck +@spice_error_check def spk14e(handle): """ End the type 14 SPK segment currently being written to the SPK @@ -11703,7 +12647,7 @@ def spk14e(handle): libspice.spk14e_c(handle) -@spiceErrorCheck +@spice_error_check def spkcls(handle): """ Close an open SPK file. @@ -11717,7 +12661,7 @@ def spkcls(handle): libspice.spkcls_c(handle) -@spiceErrorCheck +@spice_error_check def spkcov(spk, idcode, cover=None): """ Find the coverage window for a specified ephemeris object in a @@ -11732,7 +12676,7 @@ def spkcov(spk, idcode, cover=None): :param cover: Optional SPICE Window giving coverage in "spk" for "idcode". :type cover: spiceypy.utils.support_types.SpiceCell """ - spk = stypes.stringToCharP(spk) + spk = stypes.string_to_char_p(spk) idcode = ctypes.c_int(idcode) if cover is None: cover = stypes.SPICEDOUBLE_CELL(2000) @@ -11743,7 +12687,7 @@ def spkcov(spk, idcode, cover=None): return cover -@spiceErrorCheck +@spice_error_check def spkcpo(target, et, outref, refloc, abcorr, obspos, obsctr, obsref): """ Return the state of a specified target relative to an "observer," @@ -11774,22 +12718,32 @@ def spkcpo(target, et, outref, refloc, abcorr, obspos, obsctr, obsref): One way light time between target and observer. :rtype: tuple """ - target = stypes.stringToCharP(target) + target = stypes.string_to_char_p(target) et = ctypes.c_double(et) - outref = stypes.stringToCharP(outref) - refloc = stypes.stringToCharP(refloc) - abcorr = stypes.stringToCharP(abcorr) - obspos = stypes.toDoubleVector(obspos) - obsctr = stypes.stringToCharP(obsctr) - obsref = stypes.stringToCharP(obsref) - state = stypes.emptyDoubleVector(6) + outref = stypes.string_to_char_p(outref) + refloc = stypes.string_to_char_p(refloc) + abcorr = stypes.string_to_char_p(abcorr) + obspos = stypes.to_double_vector(obspos) + obsctr = stypes.string_to_char_p(obsctr) + obsref = stypes.string_to_char_p(obsref) + state = stypes.empty_double_vector(6) lt = ctypes.c_double() - libspice.spkcpo_c(target, et, outref, refloc, abcorr, obspos, obsctr, - obsref, state, ctypes.byref(lt)) - return stypes.cVectorToPython(state), lt.value - - -@spiceErrorCheck + libspice.spkcpo_c( + target, + et, + outref, + refloc, + abcorr, + obspos, + obsctr, + obsref, + state, + ctypes.byref(lt), + ) + return stypes.c_vector_to_python(state), lt.value + + +@spice_error_check def spkcpt(trgpos, trgctr, trgref, et, outref, refloc, abcorr, obsrvr): """ Return the state, relative to a specified observer, of a target @@ -11819,22 +12773,32 @@ def spkcpt(trgpos, trgctr, trgref, et, outref, refloc, abcorr, obsrvr): One way light time between target and observer. :rtype: tuple """ - trgpos = stypes.toDoubleVector(trgpos) - trgctr = stypes.stringToCharP(trgctr) - trgref = stypes.stringToCharP(trgref) + trgpos = stypes.to_double_vector(trgpos) + trgctr = stypes.string_to_char_p(trgctr) + trgref = stypes.string_to_char_p(trgref) et = ctypes.c_double(et) - outref = stypes.stringToCharP(outref) - refloc = stypes.stringToCharP(refloc) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - state = stypes.emptyDoubleVector(6) + outref = stypes.string_to_char_p(outref) + refloc = stypes.string_to_char_p(refloc) + abcorr = stypes.string_to_char_p(abcorr) + obsrvr = stypes.string_to_char_p(obsrvr) + state = stypes.empty_double_vector(6) lt = ctypes.c_double() - libspice.spkcpt_c(trgpos, trgctr, trgref, et, outref, refloc, abcorr, - obsrvr, state, ctypes.byref(lt)) - return stypes.cVectorToPython(state), lt.value - - -@spiceErrorCheck + libspice.spkcpt_c( + trgpos, + trgctr, + trgref, + et, + outref, + refloc, + abcorr, + obsrvr, + state, + ctypes.byref(lt), + ) + return stypes.c_vector_to_python(state), lt.value + + +@spice_error_check def spkcvo(target, et, outref, refloc, abcorr, obssta, obsepc, obsctr, obsref): """ Return the state of a specified target relative to an "observer," @@ -11867,23 +12831,34 @@ def spkcvo(target, et, outref, refloc, abcorr, obssta, obsepc, obsctr, obsref): One way light time between target and observer. :rtype: tuple """ - target = stypes.stringToCharP(target) + target = stypes.string_to_char_p(target) et = ctypes.c_double(et) - outref = stypes.stringToCharP(outref) - refloc = stypes.stringToCharP(refloc) - abcorr = stypes.stringToCharP(abcorr) - obssta = stypes.toDoubleVector(obssta) + outref = stypes.string_to_char_p(outref) + refloc = stypes.string_to_char_p(refloc) + abcorr = stypes.string_to_char_p(abcorr) + obssta = stypes.to_double_vector(obssta) obsepc = ctypes.c_double(obsepc) - obsctr = stypes.stringToCharP(obsctr) - obsref = stypes.stringToCharP(obsref) - state = stypes.emptyDoubleVector(6) + obsctr = stypes.string_to_char_p(obsctr) + obsref = stypes.string_to_char_p(obsref) + state = stypes.empty_double_vector(6) lt = ctypes.c_double() - libspice.spkcvo_c(target, et, outref, refloc, abcorr, obssta, obsepc, - obsctr, obsref, state, ctypes.byref(lt)) - return stypes.cVectorToPython(state), lt.value - - -@spiceErrorCheck + libspice.spkcvo_c( + target, + et, + outref, + refloc, + abcorr, + obssta, + obsepc, + obsctr, + obsref, + state, + ctypes.byref(lt), + ) + return stypes.c_vector_to_python(state), lt.value + + +@spice_error_check def spkcvt(trgsta, trgepc, trgctr, trgref, et, outref, refloc, abcorr, obsrvr): """ Return the state, relative to a specified observer, of a target @@ -11916,23 +12891,34 @@ def spkcvt(trgsta, trgepc, trgctr, trgref, et, outref, refloc, abcorr, obsrvr): One way light time between target and observer. :rtype: tuple """ - trgpos = stypes.toDoubleVector(trgsta) + trgpos = stypes.to_double_vector(trgsta) trgepc = ctypes.c_double(trgepc) - trgctr = stypes.stringToCharP(trgctr) - trgref = stypes.stringToCharP(trgref) + trgctr = stypes.string_to_char_p(trgctr) + trgref = stypes.string_to_char_p(trgref) et = ctypes.c_double(et) - outref = stypes.stringToCharP(outref) - refloc = stypes.stringToCharP(refloc) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - state = stypes.emptyDoubleVector(6) + outref = stypes.string_to_char_p(outref) + refloc = stypes.string_to_char_p(refloc) + abcorr = stypes.string_to_char_p(abcorr) + obsrvr = stypes.string_to_char_p(obsrvr) + state = stypes.empty_double_vector(6) lt = ctypes.c_double() - libspice.spkcvt_c(trgpos, trgepc, trgctr, trgref, et, outref, refloc, - abcorr, obsrvr, state, ctypes.byref(lt)) - return stypes.cVectorToPython(state), lt.value - - -@spiceErrorCheck + libspice.spkcvt_c( + trgpos, + trgepc, + trgctr, + trgref, + et, + outref, + refloc, + abcorr, + obsrvr, + state, + ctypes.byref(lt), + ) + return stypes.c_vector_to_python(state), lt.value + + +@spice_error_check def spkez(targ, et, ref, abcorr, obs): """ Return the state (position and velocity) of a target body @@ -11958,16 +12944,16 @@ def spkez(targ, et, ref, abcorr, obs): """ targ = ctypes.c_int(targ) et = ctypes.c_double(et) - ref = stypes.stringToCharP(ref) - abcorr = stypes.stringToCharP(abcorr) + ref = stypes.string_to_char_p(ref) + abcorr = stypes.string_to_char_p(abcorr) obs = ctypes.c_int(obs) - starg = stypes.emptyDoubleVector(6) + starg = stypes.empty_double_vector(6) lt = ctypes.c_double() libspice.spkez_c(targ, et, ref, abcorr, obs, starg, ctypes.byref(lt)) - return stypes.cVectorToPython(starg), lt.value + return stypes.c_vector_to_python(starg), lt.value -@spiceErrorCheck +@spice_error_check def spkezp(targ, et, ref, abcorr, obs): """ Return the position of a target body relative to an observing @@ -11993,16 +12979,16 @@ def spkezp(targ, et, ref, abcorr, obs): """ targ = ctypes.c_int(targ) et = ctypes.c_double(et) - ref = stypes.stringToCharP(ref) - abcorr = stypes.stringToCharP(abcorr) + ref = stypes.string_to_char_p(ref) + abcorr = stypes.string_to_char_p(abcorr) obs = ctypes.c_int(obs) - ptarg = stypes.emptyDoubleVector(3) + ptarg = stypes.empty_double_vector(3) lt = ctypes.c_double() libspice.spkezp_c(targ, et, ref, abcorr, obs, ptarg, ctypes.byref(lt)) - return stypes.cVectorToPython(ptarg), lt.value + return stypes.c_vector_to_python(ptarg), lt.value -@spiceErrorCheck +@spice_error_check def spkezr(targ, et, ref, abcorr, obs): """ Return the state (position and velocity) of a target body @@ -12026,26 +13012,31 @@ def spkezr(targ, et, ref, abcorr, obs): One way light time between observer and target. :rtype: tuple """ - targ = stypes.stringToCharP(targ) - ref = stypes.stringToCharP(ref) - abcorr = stypes.stringToCharP(abcorr) - obs = stypes.stringToCharP(obs) - starg = stypes.emptyDoubleVector(6) + targ = stypes.string_to_char_p(targ) + ref = stypes.string_to_char_p(ref) + abcorr = stypes.string_to_char_p(abcorr) + obs = stypes.string_to_char_p(obs) + starg = stypes.empty_double_vector(6) lt = ctypes.c_double() if hasattr(et, "__iter__"): states = [] times = [] for t in et: - libspice.spkezr_c(targ, ctypes.c_double(t), ref, abcorr, obs, starg, ctypes.byref(lt)) - checkForSpiceError(None) - states.append(stypes.cVectorToPython(starg)) + libspice.spkezr_c( + targ, ctypes.c_double(t), ref, abcorr, obs, starg, ctypes.byref(lt) + ) + check_for_spice_error(None) + states.append(stypes.c_vector_to_python(starg)) times.append(lt.value) return states, times else: - libspice.spkezr_c(targ, ctypes.c_double(et), ref, abcorr, obs, starg, ctypes.byref(lt)) - return stypes.cVectorToPython(starg), lt.value + libspice.spkezr_c( + targ, ctypes.c_double(et), ref, abcorr, obs, starg, ctypes.byref(lt) + ) + return stypes.c_vector_to_python(starg), lt.value -@spiceErrorCheck + +@spice_error_check def spkgeo(targ, et, ref, obs): """ Compute the geometric state (position and velocity) of a target @@ -12066,15 +13057,15 @@ def spkgeo(targ, et, ref, obs): """ targ = ctypes.c_int(targ) et = ctypes.c_double(et) - ref = stypes.stringToCharP(ref) + ref = stypes.string_to_char_p(ref) obs = ctypes.c_int(obs) - state = stypes.emptyDoubleVector(6) + state = stypes.empty_double_vector(6) lt = ctypes.c_double() libspice.spkgeo_c(targ, et, ref, obs, state, ctypes.byref(lt)) - return stypes.cVectorToPython(state), lt.value + return stypes.c_vector_to_python(state), lt.value -@spiceErrorCheck +@spice_error_check def spkgps(targ, et, ref, obs): """ Compute the geometric position of a target body relative to an @@ -12095,15 +13086,15 @@ def spkgps(targ, et, ref, obs): """ targ = ctypes.c_int(targ) et = ctypes.c_double(et) - ref = stypes.stringToCharP(ref) + ref = stypes.string_to_char_p(ref) obs = ctypes.c_int(obs) - position = stypes.emptyDoubleVector(3) + position = stypes.empty_double_vector(3) lt = ctypes.c_double() libspice.spkgps_c(targ, et, ref, obs, position, ctypes.byref(lt)) - return stypes.cVectorToPython(position), lt.value + return stypes.c_vector_to_python(position), lt.value -@spiceErrorCheck +@spice_error_check def spklef(filename): """ Load an ephemeris file for use by the readers. Return that file's @@ -12116,13 +13107,13 @@ def spklef(filename): :return: Loaded file's handle. :rtype: int """ - filename = stypes.stringToCharP(filename) + filename = stypes.string_to_char_p(filename) handle = ctypes.c_int() libspice.spklef_c(filename, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def spkltc(targ, et, ref, abcorr, stobs): """ Return the state (position and velocity) of a target body @@ -12149,19 +13140,20 @@ def spkltc(targ, et, ref, abcorr, stobs): assert len(stobs) == 6 targ = stypes.c_int(targ) et = ctypes.c_double(et) - ref = stypes.stringToCharP(ref) - abcorr = stypes.stringToCharP(abcorr) - stobs = stypes.toDoubleVector(stobs) - starg = stypes.emptyDoubleVector(6) + ref = stypes.string_to_char_p(ref) + abcorr = stypes.string_to_char_p(abcorr) + stobs = stypes.to_double_vector(stobs) + starg = stypes.empty_double_vector(6) lt = ctypes.c_double() dlt = ctypes.c_double() - libspice.spkltc_c(targ, et, ref, abcorr, stobs, starg, ctypes.byref(lt), - ctypes.byref(dlt)) - return stypes.cVectorToPython(starg), lt.value, dlt.value + libspice.spkltc_c( + targ, et, ref, abcorr, stobs, starg, ctypes.byref(lt), ctypes.byref(dlt) + ) + return stypes.c_vector_to_python(starg), lt.value, dlt.value -@spiceErrorCheck -def spkobj(spk, outCell=None): +@spice_error_check +def spkobj(spk, out_cell=None): """ Find the set of ID codes of all objects in a specified SPK file. @@ -12169,19 +13161,19 @@ def spkobj(spk, outCell=None): :param spk: Name of SPK file. :type spk: str - :param outCell: Optional Spice Int Cell. - :type outCell: spiceypy.utils.support_types.SpiceCell + :param out_cell: Optional Spice Int Cell. + :type out_cell: spiceypy.utils.support_types.SpiceCell """ - spk = stypes.stringToCharP(spk) - if not outCell: - outCell = stypes.SPICEINT_CELL(1000) - assert isinstance(outCell, stypes.SpiceCell) - assert outCell.dtype == 2 - libspice.spkobj_c(spk, ctypes.byref(outCell)) - return outCell + spk = stypes.string_to_char_p(spk) + if not out_cell: + out_cell = stypes.SPICEINT_CELL(1000) + assert isinstance(out_cell, stypes.SpiceCell) + assert out_cell.dtype == 2 + libspice.spkobj_c(spk, ctypes.byref(out_cell)) + return out_cell -@spiceErrorCheck +@spice_error_check def spkopa(filename): """ Open an existing SPK file for subsequent write. @@ -12193,13 +13185,13 @@ def spkopa(filename): :return: A handle attached to the SPK file opened to append. :rtype: int """ - filename = stypes.stringToCharP(filename) + filename = stypes.string_to_char_p(filename) handle = ctypes.c_int() libspice.spkopa_c(filename, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def spkopn(filename, ifname, ncomch): """ Create a new SPK file, returning the handle of the opened file. @@ -12215,15 +13207,15 @@ def spkopn(filename, ifname, ncomch): :return: The handle of the opened SPK file. :rtype: int """ - filename = stypes.stringToCharP(filename) - ifname = stypes.stringToCharP(ifname) + filename = stypes.string_to_char_p(filename) + ifname = stypes.string_to_char_p(ifname) ncomch = ctypes.c_int(ncomch) handle = ctypes.c_int() libspice.spkopn_c(filename, ifname, ncomch, ctypes.byref(handle)) return handle.value -@spiceErrorCheck +@spice_error_check def spkpds(body, center, framestr, typenum, first, last): """ Perform routine error checks and if all check pass, pack the @@ -12248,16 +13240,16 @@ def spkpds(body, center, framestr, typenum, first, last): """ body = ctypes.c_int(body) center = ctypes.c_int(center) - framestr = stypes.stringToCharP(framestr) + framestr = stypes.string_to_char_p(framestr) typenum = ctypes.c_int(typenum) first = ctypes.c_double(first) last = ctypes.c_double(last) - descr = stypes.emptyDoubleVector(5) + descr = stypes.empty_double_vector(5) libspice.spkpds_c(body, center, framestr, typenum, first, last, descr) - return stypes.cVectorToPython(descr) + return stypes.c_vector_to_python(descr) -@spiceErrorCheck +@spice_error_check def spkpos(targ, et, ref, abcorr, obs): """ Return the position of a target body relative to an observing @@ -12281,27 +13273,27 @@ def spkpos(targ, et, ref, abcorr, obs): One way light time between observer and target. :rtype: tuple """ - targ = stypes.stringToCharP(targ) - ref = stypes.stringToCharP(ref) - abcorr = stypes.stringToCharP(abcorr) - obs = stypes.stringToCharP(obs) - ptarg = stypes.emptyDoubleVector(3) + targ = stypes.string_to_char_p(targ) + ref = stypes.string_to_char_p(ref) + abcorr = stypes.string_to_char_p(abcorr) + obs = stypes.string_to_char_p(obs) + ptarg = stypes.empty_double_vector(3) lt = ctypes.c_double() if hasattr(et, "__iter__"): ptargs = [] - lts = [] + lts = [] for t in et: libspice.spkpos_c(targ, t, ref, abcorr, obs, ptarg, ctypes.byref(lt)) - checkForSpiceError(None) - ptargs.append(stypes.cVectorToPython(ptarg)) + check_for_spice_error(None) + ptargs.append(stypes.c_vector_to_python(ptarg)) lts.append(lt.value) return ptargs, lts else: libspice.spkpos_c(targ, et, ref, abcorr, obs, ptarg, ctypes.byref(lt)) - return stypes.cVectorToPython(ptarg), lt.value + return stypes.c_vector_to_python(ptarg), lt.value -@spiceErrorCheck +@spice_error_check def spkpvn(handle, descr, et): """ For a specified SPK segment and time, return the state (position and @@ -12323,18 +13315,17 @@ def spkpvn(handle, descr, et): :rtype: tuple """ handle = ctypes.c_int(handle) - descr = stypes.toDoubleVector(descr) + descr = stypes.to_double_vector(descr) et = ctypes.c_double(et) ref = ctypes.c_int() - state = stypes.emptyDoubleVector(6) + state = stypes.empty_double_vector(6) center = ctypes.c_int() - libspice.spkpvn_c(handle, descr, et, ctypes.byref(ref), state, - ctypes.byref(center)) - return ref.value, stypes.cVectorToPython(state), center.value + libspice.spkpvn_c(handle, descr, et, ctypes.byref(ref), state, ctypes.byref(center)) + return ref.value, stypes.c_vector_to_python(state), center.value -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def spksfs(body, et, idlen): # spksfs has a Parameter SIDLEN, # sounds like an optional but is that possible? @@ -12360,16 +13351,21 @@ def spksfs(body, et, idlen): et = ctypes.c_double(et) idlen = ctypes.c_int(idlen) handle = ctypes.c_int() - descr = stypes.emptyDoubleVector(5) - identstring = stypes.stringToCharP(idlen) + descr = stypes.empty_double_vector(5) + identstring = stypes.string_to_char_p(idlen) found = ctypes.c_int() - libspice.spksfs_c(body, et, idlen, ctypes.byref(handle), descr, identstring, - ctypes.byref(found)) - return handle.value, stypes.cVectorToPython(descr), \ - stypes.toPythonString(identstring), bool(found.value) - - -@spiceErrorCheck + libspice.spksfs_c( + body, et, idlen, ctypes.byref(handle), descr, identstring, ctypes.byref(found) + ) + return ( + handle.value, + stypes.c_vector_to_python(descr), + stypes.to_python_string(identstring), + bool(found.value), + ) + + +@spice_error_check def spkssb(targ, et, ref): """ Return the state (position and velocity) of a target body @@ -12388,13 +13384,13 @@ def spkssb(targ, et, ref): """ targ = ctypes.c_int(targ) et = ctypes.c_double(et) - ref = stypes.stringToCharP(ref) - starg = stypes.emptyDoubleVector(6) + ref = stypes.string_to_char_p(ref) + starg = stypes.empty_double_vector(6) libspice.spkssb_c(targ, et, ref, starg) - return stypes.cVectorToPython(starg) + return stypes.c_vector_to_python(starg) -@spiceErrorCheck +@spice_error_check def spksub(handle, descr, identin, begin, end, newh): """ Extract a subset of the data in an SPK segment into a @@ -12417,15 +13413,15 @@ def spksub(handle, descr, identin, begin, end, newh): """ assert len(descr) == 5 handle = ctypes.c_int(handle) - descr = stypes.toDoubleVector(descr) - identin = stypes.stringToCharP(identin) + descr = stypes.to_double_vector(descr) + identin = stypes.string_to_char_p(identin) begin = ctypes.c_double(begin) end = ctypes.c_double(end) newh = ctypes.c_int(newh) libspice.spksub_c(handle, descr, identin, begin, end, newh) -@spiceErrorCheck +@spice_error_check def spkuds(descr): """ Unpack the contents of an SPK segment descriptor. @@ -12446,7 +13442,7 @@ def spkuds(descr): :rtype: tuple """ assert len(descr) == 5 - descr = stypes.toDoubleVector(descr) + descr = stypes.to_double_vector(descr) body = ctypes.c_int() center = ctypes.c_int() framenum = ctypes.c_int() @@ -12455,15 +13451,30 @@ def spkuds(descr): last = ctypes.c_double() begin = ctypes.c_int() end = ctypes.c_int() - libspice.spkuds_c(descr, ctypes.byref(body), ctypes.byref(center), - ctypes.byref(framenum), ctypes.byref(typenum), - ctypes.byref(first), ctypes.byref(last), - ctypes.byref(begin), ctypes.byref(end)) - return body.value, center.value, framenum.value, typenum.value, \ - first.value, last.value, begin.value, end.value - - -@spiceErrorCheck + libspice.spkuds_c( + descr, + ctypes.byref(body), + ctypes.byref(center), + ctypes.byref(framenum), + ctypes.byref(typenum), + ctypes.byref(first), + ctypes.byref(last), + ctypes.byref(begin), + ctypes.byref(end), + ) + return ( + body.value, + center.value, + framenum.value, + typenum.value, + first.value, + last.value, + begin.value, + end.value, + ) + + +@spice_error_check def spkuef(handle): """ Unload an ephemeris file so that it will no longer be searched by @@ -12478,9 +13489,10 @@ def spkuef(handle): libspice.spkuef_c(handle) -@spiceErrorCheck -def spkw02(handle, body, center, inframe, first, last, segid, intlen, n, polydg, - cdata, btime): +@spice_error_check +def spkw02( + handle, body, center, inframe, first, last, segid, intlen, n, polydg, cdata, btime +): """ Write a type 2 segment to an SPK file. @@ -12514,22 +13526,35 @@ def spkw02(handle, body, center, inframe, first, last, segid, intlen, n, polydg, handle = ctypes.c_int(handle) body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) + inframe = stypes.string_to_char_p(inframe) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) intlen = ctypes.c_double(intlen) n = ctypes.c_int(n) polydg = ctypes.c_int(polydg) - cdata = stypes.toDoubleVector(cdata) + cdata = stypes.to_double_vector(cdata) btime = ctypes.c_double(btime) - libspice.spkw02_c(handle, body, center, inframe, first, last, segid, intlen, - n, polydg, cdata, btime) - - -@spiceErrorCheck -def spkw03(handle, body, center, inframe, first, last, segid, intlen, n, polydg, - cdata, btime): + libspice.spkw02_c( + handle, + body, + center, + inframe, + first, + last, + segid, + intlen, + n, + polydg, + cdata, + btime, + ) + + +@spice_error_check +def spkw03( + handle, body, center, inframe, first, last, segid, intlen, n, polydg, cdata, btime +): """ Write a type 3 segment to an SPK file. @@ -12563,22 +13588,33 @@ def spkw03(handle, body, center, inframe, first, last, segid, intlen, n, polydg, handle = ctypes.c_int(handle) body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) + inframe = stypes.string_to_char_p(inframe) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) intlen = ctypes.c_double(intlen) n = ctypes.c_int(n) polydg = ctypes.c_int(polydg) - cdata = stypes.toDoubleVector(cdata) + cdata = stypes.to_double_vector(cdata) btime = ctypes.c_double(btime) - libspice.spkw03_c(handle, body, center, inframe, first, last, segid, intlen, - n, polydg, cdata, btime) - - -@spiceErrorCheck -def spkw05(handle, body, center, inframe, first, last, segid, gm, n, states, - epochs): + libspice.spkw03_c( + handle, + body, + center, + inframe, + first, + last, + segid, + intlen, + n, + polydg, + cdata, + btime, + ) + + +@spice_error_check +def spkw05(handle, body, center, inframe, first, last, segid, gm, n, states, epochs): # see libspice args for solution to array[][N] problem """ Write an SPK segment of type 5 given a time-ordered set of @@ -12613,21 +13649,23 @@ def spkw05(handle, body, center, inframe, first, last, segid, gm, n, states, handle = ctypes.c_int(handle) body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) + inframe = stypes.string_to_char_p(inframe) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) gm = ctypes.c_double(gm) n = ctypes.c_int(n) - states = stypes.toDoubleMatrix(states) - epochs = stypes.toDoubleVector(epochs) - libspice.spkw05_c(handle, body, center, inframe, first, last, segid, gm, n, - states, epochs) + states = stypes.to_double_matrix(states) + epochs = stypes.to_double_vector(epochs) + libspice.spkw05_c( + handle, body, center, inframe, first, last, segid, gm, n, states, epochs + ) -@spiceErrorCheck -def spkw08(handle, body, center, inframe, first, last, segid, degree, n, states, - epoch1, step): +@spice_error_check +def spkw08( + handle, body, center, inframe, first, last, segid, degree, n, states, epoch1, step +): # see libspice args for solution to array[][N] problem """ Write a type 8 segment to an SPK file. @@ -12662,22 +13700,35 @@ def spkw08(handle, body, center, inframe, first, last, segid, degree, n, states, handle = ctypes.c_int(handle) body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) + inframe = stypes.string_to_char_p(inframe) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) degree = ctypes.c_int(degree) n = ctypes.c_int(n) - states = stypes.toDoubleMatrix(states) # X by 6 array + states = stypes.to_double_matrix(states) # X by 6 array epoch1 = ctypes.c_double(epoch1) step = ctypes.c_double(step) - libspice.spkw08_c(handle, body, center, inframe, first, last, segid, degree, - n, states, epoch1, step) - - -@spiceErrorCheck -def spkw09(handle, body, center, inframe, first, last, segid, degree, n, states, - epochs): + libspice.spkw08_c( + handle, + body, + center, + inframe, + first, + last, + segid, + degree, + n, + states, + epoch1, + step, + ) + + +@spice_error_check +def spkw09( + handle, body, center, inframe, first, last, segid, degree, n, states, epochs +): """ Write a type 9 segment to an SPK file. @@ -12709,21 +13760,21 @@ def spkw09(handle, body, center, inframe, first, last, segid, degree, n, states, handle = ctypes.c_int(handle) body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) + inframe = stypes.string_to_char_p(inframe) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) degree = ctypes.c_int(degree) n = ctypes.c_int(n) - states = stypes.toDoubleMatrix(states) # X by 6 array - epochs = stypes.toDoubleVector(epochs) - libspice.spkw09_c(handle, body, center, inframe, first, last, segid, degree, - n, states, epochs) + states = stypes.to_double_matrix(states) # X by 6 array + epochs = stypes.to_double_vector(epochs) + libspice.spkw09_c( + handle, body, center, inframe, first, last, segid, degree, n, states, epochs + ) -@spiceErrorCheck -def spkw10(handle, body, center, inframe, first, last, segid, consts, n, elems, - epochs): +@spice_error_check +def spkw10(handle, body, center, inframe, first, last, segid, consts, n, elems, epochs): """ Write an SPK type 10 segment to the DAF open and attached to the input handle. @@ -12756,21 +13807,23 @@ def spkw10(handle, body, center, inframe, first, last, segid, consts, n, elems, handle = ctypes.c_int(handle) body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) + inframe = stypes.string_to_char_p(inframe) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) - consts = stypes.toDoubleVector(consts) + segid = stypes.string_to_char_p(segid) + consts = stypes.to_double_vector(consts) n = ctypes.c_int(n) - elems = stypes.toDoubleVector(elems) - epochs = stypes.toDoubleVector(epochs) - libspice.spkw10_c(handle, body, center, inframe, first, last, segid, consts, - n, elems, epochs) + elems = stypes.to_double_vector(elems) + epochs = stypes.to_double_vector(epochs) + libspice.spkw10_c( + handle, body, center, inframe, first, last, segid, consts, n, elems, epochs + ) -@spiceErrorCheck -def spkw12(handle, body, center, inframe, first, last, segid, degree, n, states, - epoch0, step): +@spice_error_check +def spkw12( + handle, body, center, inframe, first, last, segid, degree, n, states, epoch0, step +): """ Write a type 12 segment to an SPK file. @@ -12804,22 +13857,35 @@ def spkw12(handle, body, center, inframe, first, last, segid, degree, n, states, handle = ctypes.c_int(handle) body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) + inframe = stypes.string_to_char_p(inframe) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) degree = ctypes.c_int(degree) n = ctypes.c_int(n) - states = stypes.toDoubleMatrix(states) # X by 6 array + states = stypes.to_double_matrix(states) # X by 6 array epoch0 = ctypes.c_double(epoch0) step = ctypes.c_double(step) - libspice.spkw12_c(handle, body, center, inframe, first, last, segid, degree, - n, states, epoch0, step) - - -@spiceErrorCheck -def spkw13(handle, body, center, inframe, first, last, segid, degree, n, states, - epochs): + libspice.spkw12_c( + handle, + body, + center, + inframe, + first, + last, + segid, + degree, + n, + states, + epoch0, + step, + ) + + +@spice_error_check +def spkw13( + handle, body, center, inframe, first, last, segid, degree, n, states, epochs +): """ Write a type 13 segment to an SPK file. @@ -12851,21 +13917,39 @@ def spkw13(handle, body, center, inframe, first, last, segid, degree, n, states, handle = ctypes.c_int(handle) body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) + inframe = stypes.string_to_char_p(inframe) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) degree = ctypes.c_int(degree) n = ctypes.c_int(n) - states = stypes.toDoubleMatrix(states) # X by 6 array - epochs = stypes.toDoubleVector(epochs) - libspice.spkw13_c(handle, body, center, inframe, first, last, segid, degree, - n, states, epochs) - - -@spiceErrorCheck -def spkw15(handle, body, center, inframe, first, last, segid, epoch, tp, pa, p, - ecc, j2flg, pv, gm, j2, radius): + states = stypes.to_double_matrix(states) # X by 6 array + epochs = stypes.to_double_vector(epochs) + libspice.spkw13_c( + handle, body, center, inframe, first, last, segid, degree, n, states, epochs + ) + + +@spice_error_check +def spkw15( + handle, + body, + center, + inframe, + first, + last, + segid, + epoch, + tp, + pa, + p, + ecc, + j2flg, + pv, + gm, + j2, + radius, +): """ Write an SPK segment of type 15 given a type 15 data record. @@ -12909,27 +13993,45 @@ def spkw15(handle, body, center, inframe, first, last, segid, epoch, tp, pa, p, handle = ctypes.c_int(handle) body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) + inframe = stypes.string_to_char_p(inframe) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) epoch = ctypes.c_double(epoch) - tp = stypes.toDoubleVector(tp) - pa = stypes.toDoubleVector(pa) + tp = stypes.to_double_vector(tp) + pa = stypes.to_double_vector(pa) p = ctypes.c_double(p) ecc = ctypes.c_double(ecc) j2flg = ctypes.c_double(j2flg) - pv = stypes.toDoubleVector(pv) + pv = stypes.to_double_vector(pv) gm = ctypes.c_double(gm) j2 = ctypes.c_double(j2) radius = ctypes.c_double(radius) - libspice.spkw15_c(handle, body, center, inframe, first, last, segid, epoch, - tp, pa, p, ecc, j2flg, pv, gm, j2, radius) - - -@spiceErrorCheck -def spkw17(handle, body, center, inframe, first, last, segid, epoch, eqel, - rapol, decpol): + libspice.spkw15_c( + handle, + body, + center, + inframe, + first, + last, + segid, + epoch, + tp, + pa, + p, + ecc, + j2flg, + pv, + gm, + j2, + radius, + ) + + +@spice_error_check +def spkw17( + handle, body, center, inframe, first, last, segid, epoch, eqel, rapol, decpol +): """ Write an SPK segment of type 17 given a type 17 data record. @@ -12961,20 +14063,23 @@ def spkw17(handle, body, center, inframe, first, last, segid, epoch, eqel, handle = ctypes.c_int(handle) body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) + inframe = stypes.string_to_char_p(inframe) first = ctypes.c_double(first) last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + segid = stypes.string_to_char_p(segid) epoch = ctypes.c_double(epoch) - eqel = stypes.toDoubleVector(eqel) + eqel = stypes.to_double_vector(eqel) rapol = ctypes.c_double(rapol) decpol = ctypes.c_double(decpol) - libspice.spkw17_c(handle, body, center, inframe, first, last, segid, epoch, - eqel, rapol, decpol) + libspice.spkw17_c( + handle, body, center, inframe, first, last, segid, epoch, eqel, rapol, decpol + ) -@spiceErrorCheck -def spkw18(handle, subtyp, body, center, inframe, first, last, segid, degree, packts, epochs): +@spice_error_check +def spkw18( + handle, subtyp, body, center, inframe, first, last, segid, degree, packts, epochs +): """ Write a type 18 segment to an SPK file. @@ -13005,21 +14110,50 @@ def spkw18(handle, subtyp, body, center, inframe, first, last, segid, degree, pa """ handle = ctypes.c_int(handle) subtyp = ctypes.c_int(subtyp) - body = ctypes.c_int(body) + body = ctypes.c_int(body) center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) - first = ctypes.c_double(first) - last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) + inframe = stypes.string_to_char_p(inframe) + first = ctypes.c_double(first) + last = ctypes.c_double(last) + segid = stypes.string_to_char_p(segid) degree = ctypes.c_int(degree) n = ctypes.c_int(len(packts)) - packts = stypes.toDoubleMatrix(packts) - epochs = stypes.toDoubleVector(epochs) - libspice.spkw18_c(handle, subtyp, body, center, inframe, first, last, segid, degree, n, packts, epochs) - - -@spiceErrorCheck -def spkw20(handle, body, center, inframe, first, last, segid, intlen, n, polydg, cdata, dscale, tscale, initjd, initfr): + packts = stypes.to_double_matrix(packts) + epochs = stypes.to_double_vector(epochs) + libspice.spkw18_c( + handle, + subtyp, + body, + center, + inframe, + first, + last, + segid, + degree, + n, + packts, + epochs, + ) + + +@spice_error_check +def spkw20( + handle, + body, + center, + inframe, + first, + last, + segid, + intlen, + n, + polydg, + cdata, + dscale, + tscale, + initjd, + initfr, +): """ Write a type 20 segment to an SPK file. @@ -13048,65 +14182,81 @@ def spkw20(handle, body, center, inframe, first, last, segid, intlen, n, polydg, :param initjd: Integer part of begin time (TDB Julian date) of first record. :param initfr: Fractional part of begin time (TDB Julian date) of first record. """ - handle = ctypes.c_int(handle) - body = ctypes.c_int(body) - center = ctypes.c_int(center) - inframe = stypes.stringToCharP(inframe) - first = ctypes.c_double(first) - last = ctypes.c_double(last) - segid = stypes.stringToCharP(segid) - intlen = ctypes.c_double(intlen) - n = ctypes.c_int(n) - polydg = ctypes.c_int(polydg) - cdata = stypes.toDoubleVector(cdata) - dscale = ctypes.c_double(dscale) - tscale = ctypes.c_double(tscale) - initjd = ctypes.c_double(initjd) - initfr = ctypes.c_double(initfr) - libspice.spkw20_c(handle, body, center, inframe, first, last, segid, intlen, n, polydg, cdata, dscale, tscale, initjd, initfr) - - -@spiceErrorCheck -@spiceFoundExceptionThrower + handle = ctypes.c_int(handle) + body = ctypes.c_int(body) + center = ctypes.c_int(center) + inframe = stypes.string_to_char_p(inframe) + first = ctypes.c_double(first) + last = ctypes.c_double(last) + segid = stypes.string_to_char_p(segid) + intlen = ctypes.c_double(intlen) + n = ctypes.c_int(n) + polydg = ctypes.c_int(polydg) + cdata = stypes.to_double_vector(cdata) + dscale = ctypes.c_double(dscale) + tscale = ctypes.c_double(tscale) + initjd = ctypes.c_double(initjd) + initfr = ctypes.c_double(initfr) + libspice.spkw20_c( + handle, + body, + center, + inframe, + first, + last, + segid, + intlen, + n, + polydg, + cdata, + dscale, + tscale, + initjd, + initfr, + ) + + +@spice_error_check +@spice_found_exception_thrower def srfc2s(code, bodyid, srflen=_default_len_out): """ - Translate a surface ID code, together with a body ID code, to the - corresponding surface name. If no such name exists, return a - string representation of the surface ID code. - + Translate a surface ID code, together with a body ID code, to the + corresponding surface name. If no such name exists, return a + string representation of the surface ID code. + note: from NAIF if isname is false, this case is not treated as an error. - + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/srfc2s_c.html - - :param code: Integer surface ID code to translate to a string. + + :param code: Integer surface ID code to translate to a string. :type code: int - :param bodyid: ID code of body associated with surface. + :param bodyid: ID code of body associated with surface. :type bodyid: int :param srflen: Available space in output string. - :param srflen: int + :param srflen: int :return: String corresponding to surface ID code. :rtype: str """ - code = ctypes.c_int(code) + code = ctypes.c_int(code) bodyid = ctypes.c_int(bodyid) - srfstr = stypes.stringToCharP(srflen) + srfstr = stypes.string_to_char_p(srflen) srflen = ctypes.c_int(srflen) isname = ctypes.c_int() libspice.srfc2s_c(code, bodyid, srflen, srfstr, ctypes.byref(isname)) - return stypes.toPythonString(srfstr), bool(isname.value) + return stypes.to_python_string(srfstr), bool(isname.value) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def srfcss(code, bodstr, srflen=_default_len_out): """ - Translate a surface ID code, together with a body string, to the - corresponding surface name. If no such surface name exists, - return a string representation of the surface ID code. - + Translate a surface ID code, together with a body string, to the + corresponding surface name. If no such surface name exists, + return a string representation of the surface ID code. + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/srfcss_c.html - - :param code: Integer surface ID code to translate to a string. + + :param code: Integer surface ID code to translate to a string. :type code: int :param bodstr: Name or ID of body associated with surface. :type bodstr: str @@ -13116,50 +14266,50 @@ def srfcss(code, bodstr, srflen=_default_len_out): :rtype: str """ code = ctypes.c_int(code) - bodstr = stypes.stringToCharP(bodstr) - srfstr = stypes.stringToCharP(srflen) + bodstr = stypes.string_to_char_p(bodstr) + srfstr = stypes.string_to_char_p(srflen) srflen = ctypes.c_int(srflen) isname = ctypes.c_int() libspice.srfcss_c(code, bodstr, srflen, srfstr, ctypes.byref(isname)) - return stypes.toPythonString(srfstr), bool(isname.value) + return stypes.to_python_string(srfstr), bool(isname.value) -@spiceErrorCheck +@spice_error_check def srfnrm(method, target, et, fixref, srfpts): """ - Map array of surface points on a specified target body to - the corresponding unit length outward surface normal vectors. - - The surface of the target body may be represented by a triaxial - ellipsoid or by topographic data provided by DSK files. - + Map array of surface points on a specified target body to + the corresponding unit length outward surface normal vectors. + + 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/srfnrm_c.html - + :param method: Computation method. :type method: str - :param target: Name of target body. + :param target: Name of target body. :type target: str - :param et: Epoch in TDB seconds past J2000 TDB. + :param et: Epoch in TDB seconds past J2000 TDB. :type et: float - :param fixref: Body-fixed, body-centered target body frame. + :param fixref: Body-fixed, body-centered target body frame. :type fixref: str :param srfpts: Array of surface points. :type srfpts: 3xM-Element Array of floats :return: Array of outward, unit length normal vectors. :rtype: 3xM-Element Array of floats """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) - et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - npts = ctypes.c_int(len(srfpts)) - srfpts = stypes.toDoubleMatrix(srfpts) - normls = stypes.emptyDoubleMatrix(3, npts.value) + 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(srfpts)) + srfpts = stypes.to_double_matrix(srfpts) + normls = stypes.empty_double_matrix(3, npts.value) libspice.srfnrm_c(method, target, et, fixref, npts, srfpts, normls) - return stypes.cMatrixToNumpy(normls) + return stypes.c_matrix_to_numpy(normls) -@spiceErrorCheck +@spice_error_check def srfrec(body, longitude, latitude): """ Convert planetocentric latitude and longitude of a surface @@ -13179,21 +14329,21 @@ def srfrec(body, longitude, latitude): body = ctypes.c_int(body) longitude = ctypes.c_double(longitude) latitude = ctypes.c_double(latitude) - rectan = stypes.emptyDoubleVector(3) + rectan = stypes.empty_double_vector(3) libspice.srfrec_c(body, longitude, latitude, rectan) - return stypes.cVectorToPython(rectan) + return stypes.c_vector_to_python(rectan) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def srfs2c(srfstr, bodstr): """ - Translate a surface string, together with a body string, to the - corresponding surface ID code. The input strings may contain + Translate a surface string, together with a body string, to the + corresponding surface ID code. The input strings may contain names or integer ID codes. - + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/srfs2c_c.html - + :param srfstr: Surface name or ID string. :type srfstr: str :param bodstr: Body name or ID string. @@ -13201,32 +14351,32 @@ def srfs2c(srfstr, bodstr): :return: Integer surface ID code. :rtype: int """ - srfstr = stypes.stringToCharP(srfstr) - bodstr = stypes.stringToCharP(bodstr) - code = ctypes.c_int() + srfstr = stypes.string_to_char_p(srfstr) + bodstr = stypes.string_to_char_p(bodstr) + code = ctypes.c_int() isname = ctypes.c_int() libspice.srfs2c_c(srfstr, bodstr, ctypes.byref(code), ctypes.byref(isname)) return code.value, bool(isname.value) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def srfscc(srfstr, bodyid): """ - Translate a surface string, together with a body ID code, to the - corresponding surface ID code. The input surface string may - contain a name or an integer ID code. - + Translate a surface string, together with a body ID code, to the + corresponding surface ID code. The input surface string may + contain a name or an integer ID code. + https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/srfscc_c.html - + :param srfstr: Surface name or ID string. :type srfstr: str - :param bodyid: ID code of body associated with surface. - :type bodyid: int + :param bodyid: ID code of body associated with surface. + :type bodyid: int :return: Integer surface ID code. :rtype: int """ - srfstr = stypes.stringToCharP(srfstr) + srfstr = stypes.string_to_char_p(srfstr) bodyid = ctypes.c_int(bodyid) code = ctypes.c_int() isname = ctypes.c_int() @@ -13234,8 +14384,8 @@ def srfscc(srfstr, bodyid): return code.value, bool(isname.value) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def srfxpt(method, target, et, abcorr, obsrvr, dref, dvec): """ Deprecated: This routine has been superseded by the CSPICE @@ -13269,16 +14419,16 @@ def srfxpt(method, target, et, abcorr, obsrvr, dref, dvec): Observer position relative to target center. :rtype: tuple """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - dref = stypes.stringToCharP(dref) - dvec = stypes.toDoubleVector(dvec) - spoint = stypes.emptyDoubleVector(3) + method = stypes.string_to_char_p(method) + target = stypes.string_to_char_p(target) + 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) + spoint = stypes.empty_double_vector(3) trgepc = ctypes.c_double() dist = ctypes.c_double() - obspos = stypes.emptyDoubleVector(3) + obspos = stypes.empty_double_vector(3) found = ctypes.c_int() if hasattr(et, "__iter__"): spoints = [] @@ -13287,24 +14437,53 @@ def srfxpt(method, target, et, abcorr, obsrvr, dref, dvec): obsposs = [] founds = [] for t in et: - libspice.srfxpt_c(method, target, t, abcorr, obsrvr, dref, dvec, - spoint, ctypes.byref(dist), ctypes.byref(trgepc), - obspos, ctypes.byref(found)) - checkForSpiceError(None) - spoints.append(stypes.cVectorToPython(spoint)) + libspice.srfxpt_c( + method, + target, + t, + abcorr, + obsrvr, + dref, + dvec, + spoint, + ctypes.byref(dist), + ctypes.byref(trgepc), + obspos, + ctypes.byref(found), + ) + check_for_spice_error(None) + spoints.append(stypes.c_vector_to_python(spoint)) dists.append(dist.value) trgepcs.append(trgepc.value) - obsposs.append(stypes.cVectorToPython(obspos)) + obsposs.append(stypes.c_vector_to_python(obspos)) founds.append(bool(found.value)) return spoints, dists, trgepcs, obsposs, founds else: et = ctypes.c_double(et) - libspice.srfxpt_c(method, target, et, abcorr, obsrvr, dref, dvec, spoint, - ctypes.byref(dist), ctypes.byref(trgepc), obspos, ctypes.byref(found)) - return stypes.cVectorToPython(spoint), dist.value, trgepc.value, stypes.cVectorToPython(obspos), bool(found.value) - - -@spiceErrorCheck + libspice.srfxpt_c( + method, + target, + et, + abcorr, + obsrvr, + dref, + dvec, + spoint, + ctypes.byref(dist), + ctypes.byref(trgepc), + obspos, + ctypes.byref(found), + ) + return ( + stypes.c_vector_to_python(spoint), + dist.value, + trgepc.value, + stypes.c_vector_to_python(obspos), + bool(found.value), + ) + + +@spice_error_check def ssize(newsize, cell): """ Set the size (maximum cardinality) of a CSPICE cell of any data type. @@ -13324,7 +14503,7 @@ def ssize(newsize, cell): return cell -@spiceErrorCheck +@spice_error_check def stelab(pobj, vobs): """ Correct the apparent position of an object for stellar @@ -13343,15 +14522,15 @@ def stelab(pobj, vobs): the observer, corrected for stellar aberration. :rtype: 3-Element Array of floats """ - pobj = stypes.toDoubleVector(pobj) - vobs = stypes.toDoubleVector(vobs) - appobj = stypes.emptyDoubleVector(3) + pobj = stypes.to_double_vector(pobj) + vobs = stypes.to_double_vector(vobs) + appobj = stypes.empty_double_vector(3) libspice.stelab_c(pobj, vobs, appobj) - return stypes.cVectorToPython(appobj) + return stypes.c_vector_to_python(appobj) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def stpool(item, nth, contin, lenout=_default_len_out): """ Retrieve the nth string from the kernel pool variable, where the @@ -13373,19 +14552,20 @@ def stpool(item, nth, contin, lenout=_default_len_out): The number of characters in the full string value. :rtype: tuple """ - item = stypes.stringToCharP(item) - contin = stypes.stringToCharP(contin) + item = stypes.string_to_char_p(item) + contin = stypes.string_to_char_p(contin) nth = ctypes.c_int(nth) - strout = stypes.stringToCharP(lenout) + strout = stypes.string_to_char_p(lenout) lenout = ctypes.c_int(lenout) found = ctypes.c_int() sizet = ctypes.c_int() - libspice.stpool_c(item, nth, contin, lenout, strout, ctypes.byref(sizet), - ctypes.byref(found)) - return stypes.toPythonString(strout), sizet.value, bool(found.value) + libspice.stpool_c( + item, nth, contin, lenout, strout, ctypes.byref(sizet), ctypes.byref(found) + ) + return stypes.to_python_string(strout), sizet.value, bool(found.value) -@spiceErrorCheck +@spice_error_check def str2et(time): """ Convert a string representing an epoch to a double precision @@ -13399,41 +14579,43 @@ def str2et(time): :return: The equivalent value in seconds past J2000, TDB. :rtype: float """ - if stypes.isiterable(time): + if stypes.is_iterable(time): return numpy.array([str2et(t) for t in time]) - time = stypes.stringToCharP(time) + time = stypes.string_to_char_p(time) et = ctypes.c_double() libspice.str2et_c(time, ctypes.byref(et)) return et.value -@spiceErrorCheck + +@spice_error_check def datetime2et(dt): """ - Converts a standard Python datetime to a double precision value - representing the number of TDB seconds past the J2000 epoch + Converts a standard Python datetime to a double precision value + representing the number of TDB seconds past the J2000 epoch corresponding to the input epoch. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/time.html#The%20J2000%20Epoch :param dt: A standard Python datetime - :type time: datetime + :type dt: Union[datetime, Iterable[datetime]] :return: The equivalent value in seconds past J2000, TDB. :rtype: float """ lt = ctypes.c_double() if hasattr(dt, "__iter__"): - ets = [] + ets = [] for t in dt: - libspice.utc2et_c(stypes.stringToCharP(t.isoformat()),ctypes.byref(lt)) - checkForSpiceError(None) + libspice.utc2et_c(stypes.string_to_char_p(t.isoformat()), ctypes.byref(lt)) + check_for_spice_error(None) ets.append(lt.value) return ets - dt = stypes.stringToCharP(dt.isoformat()) + dt = stypes.string_to_char_p(dt.isoformat()) et = ctypes.c_double() libspice.utc2et_c(dt, ctypes.byref(et)) return et.value -@spiceErrorCheck + +@spice_error_check def subpnt(method, target, et, fixref, abcorr, obsrvr): """ Compute the rectangular coordinates of the sub-observer point on @@ -13462,22 +14644,26 @@ def subpnt(method, target, et, fixref, abcorr, obsrvr): Vector from observer to sub-observer point. :rtype: tuple """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) + method = stypes.string_to_char_p(method) + target = stypes.string_to_char_p(target) et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - spoint = stypes.emptyDoubleVector(3) + fixref = stypes.string_to_char_p(fixref) + abcorr = stypes.string_to_char_p(abcorr) + obsrvr = stypes.string_to_char_p(obsrvr) + spoint = stypes.empty_double_vector(3) trgepc = ctypes.c_double(0) - srfvec = stypes.emptyDoubleVector(3) - libspice.subpnt_c(method, target, et, fixref, abcorr, obsrvr, spoint, - ctypes.byref(trgepc), srfvec) - return stypes.cVectorToPython(spoint), trgepc.value, stypes.cVectorToPython( - srfvec) - - -@spiceErrorCheck + srfvec = stypes.empty_double_vector(3) + libspice.subpnt_c( + method, target, et, fixref, abcorr, obsrvr, spoint, ctypes.byref(trgepc), srfvec + ) + return ( + stypes.c_vector_to_python(spoint), + trgepc.value, + stypes.c_vector_to_python(srfvec), + ) + + +@spice_error_check def subpt(method, target, et, abcorr, obsrvr): """ Deprecated: This routine has been superseded by the CSPICE @@ -13508,28 +14694,36 @@ def subpt(method, target, et, abcorr, obsrvr): Altitude of the observer above the target body. :rtype: tuple """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - spoint = stypes.emptyDoubleVector(3) + method = stypes.string_to_char_p(method) + target = stypes.string_to_char_p(target) + abcorr = stypes.string_to_char_p(abcorr) + obsrvr = stypes.string_to_char_p(obsrvr) + spoint = stypes.empty_double_vector(3) alt = ctypes.c_double() if hasattr(et, "__iter__"): points = [] alts = [] for t in et: - libspice.subpt_c(method, target, ctypes.c_double(t), abcorr, obsrvr, spoint, ctypes.byref(alt)) - checkForSpiceError(None) - points.append(stypes.cVectorToPython(spoint)) + libspice.subpt_c( + method, + target, + ctypes.c_double(t), + abcorr, + obsrvr, + spoint, + ctypes.byref(alt), + ) + check_for_spice_error(None) + points.append(stypes.c_vector_to_python(spoint)) alts.append(alt.value) return points, alts else: et = ctypes.c_double(et) libspice.subpt_c(method, target, et, abcorr, obsrvr, spoint, ctypes.byref(alt)) - return stypes.cVectorToPython(spoint), alt.value + return stypes.c_vector_to_python(spoint), alt.value -@spiceErrorCheck +@spice_error_check def subslr(method, target, et, fixref, abcorr, obsrvr): """ Compute the rectangular coordinates of the sub-solar point on @@ -13558,22 +14752,26 @@ def subslr(method, target, et, fixref, abcorr, obsrvr): Vector from observer to sub-solar point. :rtype: tuple """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) + method = stypes.string_to_char_p(method) + target = stypes.string_to_char_p(target) et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - spoint = stypes.emptyDoubleVector(3) + fixref = stypes.string_to_char_p(fixref) + abcorr = stypes.string_to_char_p(abcorr) + obsrvr = stypes.string_to_char_p(obsrvr) + spoint = stypes.empty_double_vector(3) trgepc = ctypes.c_double(0) - srfvec = stypes.emptyDoubleVector(3) - libspice.subslr_c(method, target, et, fixref, abcorr, obsrvr, spoint, - ctypes.byref(trgepc), srfvec) - return stypes.cVectorToPython(spoint), trgepc.value, stypes.cVectorToPython( - srfvec) - - -@spiceErrorCheck + srfvec = stypes.empty_double_vector(3) + libspice.subslr_c( + method, target, et, fixref, abcorr, obsrvr, spoint, ctypes.byref(trgepc), srfvec + ) + return ( + stypes.c_vector_to_python(spoint), + trgepc.value, + stypes.c_vector_to_python(srfvec), + ) + + +@spice_error_check def subsol(method, target, et, abcorr, obsrvr): """ Deprecated: This routine has been superseded by the CSPICE @@ -13600,17 +14798,17 @@ def subsol(method, target, et, abcorr, obsrvr): :return: Sub-solar point on the target body. :rtype: 3-Element Array of floats """ - method = stypes.stringToCharP(method) - target = stypes.stringToCharP(target) + method = stypes.string_to_char_p(method) + target = stypes.string_to_char_p(target) et = ctypes.c_double(et) - abcorr = stypes.stringToCharP(abcorr) - obsrvr = stypes.stringToCharP(obsrvr) - spoint = stypes.emptyDoubleVector(3) + abcorr = stypes.string_to_char_p(abcorr) + obsrvr = stypes.string_to_char_p(obsrvr) + spoint = stypes.empty_double_vector(3) libspice.subsol_c(method, target, et, abcorr, obsrvr, spoint) - return stypes.cVectorToPython(spoint) + return stypes.c_vector_to_python(spoint) -@spiceErrorCheck +@spice_error_check def sumad(array): """ Return the sum of the elements of a double precision array. @@ -13623,11 +14821,11 @@ def sumad(array): :rtype: float """ n = ctypes.c_int(len(array)) - array = stypes.toDoubleVector(array) + array = stypes.to_double_vector(array) return libspice.sumad_c(array, n) -@spiceErrorCheck +@spice_error_check def sumai(array): """ Return the sum of the elements of an integer array. @@ -13640,11 +14838,11 @@ def sumai(array): :rtype: int """ n = ctypes.c_int(len(array)) - array = stypes.toIntVector(array) + array = stypes.to_int_vector(array) return libspice.sumai_c(array, n) -@spiceErrorCheck +@spice_error_check def surfnm(a, b, c, point): """ This routine computes the outward-pointing, unit normal vector @@ -13666,14 +14864,14 @@ def surfnm(a, b, c, point): a = ctypes.c_double(a) b = ctypes.c_double(b) c = ctypes.c_double(c) - point = stypes.toDoubleVector(point) - normal = stypes.emptyDoubleVector(3) + point = stypes.to_double_vector(point) + normal = stypes.empty_double_vector(3) libspice.surfnm_c(a, b, c, point, normal) - return stypes.cVectorToPython(normal) + return stypes.c_vector_to_python(normal) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def surfpt(positn, u, a, b, c): """ Determine the intersection of a line-of-sight vector with the @@ -13697,16 +14895,16 @@ def surfpt(positn, u, a, b, c): a = ctypes.c_double(a) b = ctypes.c_double(b) c = ctypes.c_double(c) - positn = stypes.toDoubleVector(positn) - u = stypes.toDoubleVector(u) - point = stypes.emptyDoubleVector(3) + positn = stypes.to_double_vector(positn) + u = stypes.to_double_vector(u) + point = stypes.empty_double_vector(3) found = ctypes.c_int() libspice.surfpt_c(positn, u, a, b, c, point, ctypes.byref(found)) - return stypes.cVectorToPython(point), bool(found.value) + return stypes.c_vector_to_python(point), bool(found.value) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def surfpv(stvrtx, stdir, a, b, c): """ Find the state (position and velocity) of the surface intercept @@ -13730,15 +14928,15 @@ def surfpv(stvrtx, stdir, a, b, c): a = ctypes.c_double(a) b = ctypes.c_double(b) c = ctypes.c_double(c) - stvrtx = stypes.toDoubleVector(stvrtx) - stdir = stypes.toDoubleVector(stdir) - stx = stypes.emptyDoubleVector(6) + stvrtx = stypes.to_double_vector(stvrtx) + stdir = stypes.to_double_vector(stdir) + stx = stypes.empty_double_vector(6) found = ctypes.c_int() libspice.surfpv_c(stvrtx, stdir, a, b, c, stx, ctypes.byref(found)) - return stypes.cVectorToPython(stx), bool(found.value) + return stypes.c_vector_to_python(stx), bool(found.value) -@spiceErrorCheck +@spice_error_check def swpool(agent, nnames, lenvals, names): """ Add a name to the list of agents to notify whenever a member of @@ -13755,14 +14953,14 @@ def swpool(agent, nnames, lenvals, names): :param names: Variable names whose update causes the notice. :type names: list of strs. """ - agent = stypes.stringToCharP(agent) + agent = stypes.string_to_char_p(agent) nnames = ctypes.c_int(nnames) lenvals = ctypes.c_int(lenvals) - names = stypes.listToCharArray(names) + names = stypes.list_to_char_array(names) libspice.swpool_c(agent, nnames, lenvals, names) -@spiceErrorCheck +@spice_error_check def sxform(instring, tostring, et): """ Return the state transformation matrix from one frame to @@ -13780,24 +14978,24 @@ def sxform(instring, tostring, et): :return: A state transformation matrix. :rtype: 6x6-Element Array of floats """ - instring = stypes.stringToCharP(instring) - tostring = stypes.stringToCharP(tostring) - xform = stypes.emptyDoubleMatrix(x=6, y=6) + instring = stypes.string_to_char_p(instring) + tostring = stypes.string_to_char_p(tostring) + xform = stypes.empty_double_matrix(x=6, y=6) if hasattr(et, "__iter__"): xforms = [] for t in et: libspice.sxform_c(instring, tostring, ctypes.c_double(t), xform) - checkForSpiceError(None) - xforms.append(stypes.cMatrixToNumpy(xform)) + check_for_spice_error(None) + xforms.append(stypes.c_matrix_to_numpy(xform)) return xforms else: et = ctypes.c_double(et) libspice.sxform_c(instring, tostring, et, xform) - return stypes.cMatrixToNumpy(xform) + return stypes.c_matrix_to_numpy(xform) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def szpool(name): """ Return the kernel pool size limitations. @@ -13809,7 +15007,7 @@ def szpool(name): :return: Value of parameter specified by name, :rtype: int """ - name = stypes.stringToCharP(name) + name = stypes.string_to_char_p(name) n = ctypes.c_int() found = ctypes.c_int(0) libspice.szpool_c(name, ctypes.byref(n), ctypes.byref(found)) @@ -13820,27 +15018,41 @@ def szpool(name): # T -@spiceErrorCheck -def termpt(method, ilusrc, target, et, fixref, abcorr, corloc, obsrvr, refvec, rolstp, - ncuts, schstp, soltol, maxn): +@spice_error_check +def termpt( + method, + ilusrc, + target, + et, + fixref, + abcorr, + corloc, + obsrvr, + refvec, + rolstp, + ncuts, + schstp, + soltol, + maxn, +): """ Find terminator points on a target body. The caller specifies half-planes, bounded by the illumination source center-target center vector, in which to search for terminator points. - The terminator can be either umbral or penumbral. The umbral - terminator is the boundary of the region on the target surface - where no light from the source is visible. The penumbral - terminator is the boundary of the region on the target surface - where none of the light from the source is blocked by the target + The terminator can be either umbral or penumbral. The umbral + terminator is the boundary of the region on the target surface + where no light from the source is visible. The penumbral + terminator is the boundary of the region on the target surface + where none of the light from the source is blocked by the target itself. - The surface of the target body may be represented either by a - triaxial ellipsoid or by topographic data. + 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/termpt_c.html - :param method: Computation method. + :param method: Computation method. :type method: str :param ilusrc: Illumination source. :type ilusrc: str @@ -13850,7 +15062,7 @@ def termpt(method, ilusrc, target, et, fixref, abcorr, corloc, obsrvr, refvec, r :type et: float :param fixref: Body-fixed, body-centered target body frame. :type fixref: str - :param abcorr: Aberration correction. + :param abcorr: Aberration correction. :type abcorr: str :param corloc: Aberration correction locus. :type corloc: str @@ -13858,50 +15070,69 @@ def termpt(method, ilusrc, target, et, fixref, abcorr, corloc, obsrvr, refvec, r :type obsrvr: str :param refvec: Reference vector for cutting half-planes. :type refvec: 3-Element Array of floats - :param rolstp: Roll angular step for cutting half-planes. + :param rolstp: Roll angular step for cutting half-planes. :type rolstp: float - :param ncuts: Number of cutting half-planes. + :param ncuts: Number of cutting half-planes. :type ncuts: int - :param schstp: Angular step size for searching. + :param schstp: Angular step size for searching. :type schstp: float - :param soltol: Solution convergence tolerance. + :param soltol: Solution convergence tolerance. :type soltol: float - :param maxn: Maximum number of entries in output arrays. + :param maxn: Maximum number of entries in output arrays. :type maxn: int :return: Counts of terminator points corresponding to cuts, Terminator points, Times associated with terminator points, Terminator vectors emanating from the observer :rtype: tuple """ - method = stypes.stringToCharP(method) - ilusrc = stypes.stringToCharP(ilusrc) - target = stypes.stringToCharP(target) + method = stypes.string_to_char_p(method) + ilusrc = stypes.string_to_char_p(ilusrc) + target = stypes.string_to_char_p(target) et = ctypes.c_double(et) - fixref = stypes.stringToCharP(fixref) - abcorr = stypes.stringToCharP(abcorr) - corloc = stypes.stringToCharP(corloc) - obsrvr = stypes.stringToCharP(obsrvr) - refvec = stypes.toDoubleVector(refvec) + 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.emptyIntVector(maxn.value) - points = stypes.emptyDoubleMatrix(3, maxn.value) - epochs = stypes.emptyDoubleVector(maxn) - trmvcs = stypes.emptyDoubleMatrix(3, maxn.value) - libspice.termpt_c(method, ilusrc, target, et, fixref, - abcorr, corloc, obsrvr, refvec, - rolstp, ncuts, schstp, soltol, - maxn, npts, points, epochs, trmvcs) + npts = stypes.empty_int_vector(maxn.value) + points = stypes.empty_double_matrix(3, maxn.value) + epochs = stypes.empty_double_vector(maxn) + trmvcs = stypes.empty_double_matrix(3, maxn.value) + libspice.termpt_c( + method, + ilusrc, + target, + et, + fixref, + abcorr, + corloc, + obsrvr, + refvec, + rolstp, + ncuts, + schstp, + soltol, + maxn, + npts, + points, + epochs, + trmvcs, + ) # Clip the empty elements out of returned results - npts = stypes.cVectorToPython(npts) + npts = stypes.c_vector_to_python(npts) valid_points = numpy.where(npts >= 1) - return npts[valid_points], stypes.cMatrixToNumpy(points)[valid_points], \ - stypes.cVectorToPython(epochs)[valid_points], \ - stypes.cMatrixToNumpy(trmvcs)[valid_points] + 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(trmvcs)[valid_points], + ) -@spiceErrorCheck +@spice_error_check def timdef(action, item, lenout, value=None): """ Set and retrieve the defaults associated with calendar input strings. @@ -13919,18 +15150,18 @@ def timdef(action, item, lenout, value=None): :return: the value associated with the default item. :rtype: str """ - action = stypes.stringToCharP(action) - item = stypes.stringToCharP(item) + action = stypes.string_to_char_p(action) + item = stypes.string_to_char_p(item) lenout = ctypes.c_int(lenout) if value is None: - value = stypes.stringToCharP(lenout) + value = stypes.string_to_char_p(lenout) else: - value = stypes.stringToCharP(value) + value = stypes.string_to_char_p(value) libspice.timdef_c(action, item, lenout, value) - return stypes.toPythonString(value) + return stypes.to_python_string(value) -@spiceErrorCheck +@spice_error_check def timout(et, pictur, lenout=_default_len_out): """ This vectorized routine converts an input epoch represented in TDB seconds @@ -13948,23 +15179,23 @@ def timout(et, pictur, lenout=_default_len_out): :return: A string representation of the input epoch. :rtype: str or array of str """ - pictur = stypes.stringToCharP(pictur) - output = stypes.stringToCharP(lenout) + pictur = stypes.string_to_char_p(pictur) + output = stypes.string_to_char_p(lenout) lenout = ctypes.c_int(lenout) if hasattr(et, "__iter__"): times = [] for t in et: libspice.timout_c(ctypes.c_double(t), pictur, lenout, output) - checkForSpiceError(None) - times.append(stypes.toPythonString(output)) + check_for_spice_error(None) + times.append(stypes.to_python_string(output)) return times else: et = ctypes.c_double(et) libspice.timout_c(et, pictur, lenout, output) - return stypes.toPythonString(output) + return stypes.to_python_string(output) -@spiceErrorCheck +@spice_error_check def tipbod(ref, body, et): """ Return a 3x3 matrix that transforms positions in inertial @@ -13982,15 +15213,15 @@ def tipbod(ref, body, et): :return: Transformation (position), inertial to prime meridian. :rtype: 3x3-Element Array of floats """ - ref = stypes.stringToCharP(ref) + ref = stypes.string_to_char_p(ref) body = ctypes.c_int(body) et = ctypes.c_double(et) - retmatrix = stypes.emptyDoubleMatrix() + retmatrix = stypes.empty_double_matrix() libspice.tipbod_c(ref, body, et, retmatrix) - return stypes.cMatrixToNumpy(retmatrix) + return stypes.c_matrix_to_numpy(retmatrix) -@spiceErrorCheck +@spice_error_check def tisbod(ref, body, et): """ Return a 6x6 matrix that transforms states in inertial coordinates to @@ -14007,15 +15238,16 @@ def tisbod(ref, body, et): :return: Transformation (state), inertial to prime meridian. :rtype: 6x6-Element Array of floats """ - ref = stypes.stringToCharP(ref) + ref = stypes.string_to_char_p(ref) body = ctypes.c_int(body) et = ctypes.c_double(et) - retmatrix = stypes.emptyDoubleMatrix(x=6, y=6) + retmatrix = stypes.empty_double_matrix(x=6, y=6) libspice.tisbod_c(ref, body, et, retmatrix) - return stypes.cMatrixToNumpy(retmatrix) + return stypes.c_matrix_to_numpy(retmatrix) + -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def tkfram(typid): """ This routine returns the rotation from the input frame @@ -14029,14 +15261,16 @@ def tkfram(typid): :rtype: tuple """ code = ctypes.c_int(typid) - matrix = stypes.emptyDoubleMatrix(x=3, y=3) - nextFrame = ctypes.c_int() + matrix = stypes.empty_double_matrix(x=3, y=3) + next_frame = ctypes.c_int() found = ctypes.c_int() - libspice.tkfram_(ctypes.byref(code), matrix, ctypes.byref(nextFrame), ctypes.byref(found)) + libspice.tkfram_( + ctypes.byref(code), matrix, ctypes.byref(next_frame), ctypes.byref(found) + ) + return stypes.c_matrix_to_numpy(matrix), next_frame.value, bool(found.value) - return stypes.cMatrixToNumpy(matrix), nextFrame.value, bool(found.value) -# @spiceErrorCheck +# @spice_error_check def tkvrsn(item): """ Given an item such as the Toolkit or an entry point name, return @@ -14049,11 +15283,11 @@ def tkvrsn(item): :return: the latest version string. :rtype: str """ - item = stypes.stringToCharP(item) - return stypes.toPythonString(libspice.tkvrsn_c(item)) + item = stypes.string_to_char_p(item) + return stypes.to_python_string(libspice.tkvrsn_c(item)) -@spiceErrorCheck +@spice_error_check def tparse(instring, lenout=_default_len_out): """ Parse a time string and return seconds past the J2000 @@ -14068,15 +15302,15 @@ def tparse(instring, lenout=_default_len_out): :return: Equivalent UTC seconds past J2000, Descriptive error message. :rtype: tuple """ - errmsg = stypes.stringToCharP(lenout) + errmsg = stypes.string_to_char_p(lenout) lenout = ctypes.c_int(lenout) - instring = stypes.stringToCharP(instring) + instring = stypes.string_to_char_p(instring) sp2000 = ctypes.c_double() libspice.tparse_c(instring, lenout, ctypes.byref(sp2000), errmsg) - return sp2000.value, stypes.toPythonString(errmsg) + return sp2000.value, stypes.to_python_string(errmsg) -@spiceErrorCheck +@spice_error_check def tpictr(sample, lenout=_default_len_out, lenerr=_default_len_out): """ Given a sample time string, create a time format picture @@ -14096,18 +15330,17 @@ def tpictr(sample, lenout=_default_len_out, lenerr=_default_len_out): Diagnostic returned if sample cannot be parsed :rtype: tuple """ - sample = stypes.stringToCharP(sample) - pictur = stypes.stringToCharP(lenout) - errmsg = stypes.stringToCharP(lenerr) + sample = stypes.string_to_char_p(sample) + pictur = stypes.string_to_char_p(lenout) + errmsg = stypes.string_to_char_p(lenerr) lenout = ctypes.c_int(lenout) lenerr = ctypes.c_int(lenerr) ok = ctypes.c_int() libspice.tpictr_c(sample, lenout, lenerr, pictur, ctypes.byref(ok), errmsg) - return stypes.toPythonString(pictur), ok.value, stypes.toPythonString( - errmsg) + return stypes.to_python_string(pictur), ok.value, stypes.to_python_string(errmsg) -@spiceErrorCheck +@spice_error_check def trace(matrix): """ Return the trace of a 3x3 matrix. @@ -14119,11 +15352,11 @@ def trace(matrix): :return: The trace of matrix. :rtype: float """ - matrix = stypes.toDoubleMatrix(matrix) + matrix = stypes.to_double_matrix(matrix) return libspice.trace_c(matrix) -@spiceErrorCheck +@spice_error_check def trcdep(): """ Return the number of modules in the traceback representation. @@ -14138,7 +15371,7 @@ def trcdep(): return depth.value -@spiceErrorCheck +@spice_error_check def trcnam(index, namlen=_default_len_out): """ Return the name of the module having the specified position in @@ -14155,13 +15388,13 @@ def trcnam(index, namlen=_default_len_out): :rtype: str """ index = ctypes.c_int(index) - name = stypes.stringToCharP(namlen) + name = stypes.string_to_char_p(namlen) namlen = ctypes.c_int(namlen) libspice.trcnam_c(index, namlen, name) - return stypes.toPythonString(name) + return stypes.to_python_string(name) -@spiceErrorCheck +@spice_error_check def trcoff(): """ Disable tracing. @@ -14172,7 +15405,7 @@ def trcoff(): libspice.trcoff_c() -@spiceErrorCheck +@spice_error_check def tsetyr(year): """ Set the lower bound on the 100 year range. @@ -14188,7 +15421,7 @@ def tsetyr(year): libspice.tsetyr_c(year) -@spiceErrorCheck +@spice_error_check def twopi(): """ Return twice the value of pi @@ -14202,7 +15435,7 @@ def twopi(): return libspice.twopi_c() -@spiceErrorCheck +@spice_error_check def twovec(axdef, indexa, plndef, indexp): """ Find the transformation to the right-handed frame having a @@ -14222,16 +15455,16 @@ def twovec(axdef, indexa, plndef, indexp): :return: Output rotation matrix. :rtype: 3x3-Element Array of floats """ - axdef = stypes.toDoubleVector(axdef) + axdef = stypes.to_double_vector(axdef) indexa = ctypes.c_int(indexa) - plndef = stypes.toDoubleVector(plndef) + plndef = stypes.to_double_vector(plndef) indexp = ctypes.c_int(indexp) - mout = stypes.emptyDoubleMatrix() + mout = stypes.empty_double_matrix() libspice.twovec_c(axdef, indexa, plndef, indexp, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def txtopn(fname): """ Internal undocumented command for opening a new text file for @@ -14245,14 +15478,14 @@ def txtopn(fname): :return: FORTRAN logical unit of opened file :rtype: int """ - fnameP = stypes.stringToCharP(fname) - unit_out = ctypes.c_int() + fname_p = stypes.string_to_char_p(fname) + unit_out = ctypes.c_int() fname_len = ctypes.c_int(len(fname)) - libspice.txtopn_(fnameP, ctypes.byref(unit_out), fname_len) + libspice.txtopn_(fname_p, ctypes.byref(unit_out), fname_len) return unit_out.value -@spiceErrorCheck +@spice_error_check def tyear(): """ Return the number of seconds in a tropical year. @@ -14268,7 +15501,8 @@ def tyear(): ################################################################################ # U -@spiceErrorCheck + +@spice_error_check def ucase(inchar, lenout=None): """ Convert the characters in a string to uppercase. @@ -14284,14 +15518,14 @@ def ucase(inchar, lenout=None): """ if lenout is None: lenout = len(inchar) + 1 - inchar = stypes.stringToCharP(inchar) - outchar = stypes.stringToCharP(" " * lenout) + inchar = stypes.string_to_char_p(inchar) + outchar = stypes.string_to_char_p(" " * lenout) lenout = ctypes.c_int(lenout) libspice.ucase_c(inchar, lenout, outchar) - return stypes.toPythonString(outchar) + return stypes.to_python_string(outchar) -@spiceErrorCheck +@spice_error_check def ucrss(v1, v2): """ Compute the normalized cross product of two 3-vectors. @@ -14305,11 +15539,11 @@ def ucrss(v1, v2): :return: Normalized cross product v1xv2 / abs(v1xv2). :rtype: Array of floats """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - vout = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + vout = stypes.empty_double_vector(3) libspice.ucrss_c(v1, v2, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) def uddc(udfunc, x, dx): @@ -14351,7 +15585,7 @@ def udfunc(et_in): return bool(isdescr.value) -@spiceErrorCheck +@spice_error_check def uddf(udfunc, x, dx): """ Routine to calculate the first derivative of a caller-specified @@ -14404,7 +15638,7 @@ def udf(x): return value.value -@spiceErrorCheck +@spice_error_check def union(a, b): """ Compute the union of two sets of any data type to form a third set. @@ -14435,7 +15669,7 @@ def union(a, b): return c -@spiceErrorCheck +@spice_error_check def unitim(epoch, insys, outsys): """ Transform time from one uniform scale to another. The uniform @@ -14455,12 +15689,12 @@ def unitim(epoch, insys, outsys): :rtype: float """ epoch = ctypes.c_double(epoch) - insys = stypes.stringToCharP(insys) - outsys = stypes.stringToCharP(outsys) + insys = stypes.string_to_char_p(insys) + outsys = stypes.string_to_char_p(outsys) return libspice.unitim_c(epoch, insys, outsys) -@spiceErrorCheck +@spice_error_check def unload(filename): """ Unload a SPICE kernel. @@ -14470,34 +15704,34 @@ def unload(filename): :param filename: The name of a kernel to unload. :type filename: str """ - if stypes.isiterable(filename): + if stypes.is_iterable(filename): for f in filename: - libspice.unload_c(stypes.stringToCharP(f)) + libspice.unload_c(stypes.string_to_char_p(f)) return - filename = stypes.stringToCharP(filename) + filename = stypes.string_to_char_p(filename) libspice.unload_c(filename) -@spiceErrorCheck +@spice_error_check def unorm(v1): """ Normalize a double precision 3-vector and return its magnitude. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/unorm_c.html - :param v1: Vector to be normalized. + :param v1: Vector to be normalized. :type v1: 3-Element Array of floats :return: Unit vector of v1, Magnitude of v1. :rtype: tuple """ - v1 = stypes.toDoubleVector(v1) - vout = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + vout = stypes.empty_double_vector(3) vmag = ctypes.c_double() libspice.unorm_c(v1, vout, ctypes.byref(vmag)) - return stypes.cVectorToPython(vout), vmag.value + return stypes.c_vector_to_python(vout), vmag.value -@spiceErrorCheck +@spice_error_check def unormg(v1, ndim): """ Normalize a double precision vector of arbitrary dimension and @@ -14505,22 +15739,22 @@ def unormg(v1, ndim): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/unormg_c.html - :param v1: Vector to be normalized. + :param v1: Vector to be normalized. :type v1: Array of floats - :param ndim: This is the dimension of v1 and vout. + :param ndim: This is the dimension of v1 and vout. :type ndim: int :return: Unit vector of v1, Magnitude of v1. :rtype: tuple """ - v1 = stypes.toDoubleVector(v1) - vout = stypes.emptyDoubleVector(ndim) + v1 = stypes.to_double_vector(v1) + vout = stypes.empty_double_vector(ndim) vmag = ctypes.c_double() ndim = ctypes.c_int(ndim) libspice.unormg_c(v1, ndim, vout, ctypes.byref(vmag)) - return stypes.cVectorToPython(vout), vmag.value + return stypes.c_vector_to_python(vout), vmag.value -@spiceErrorCheck +@spice_error_check def utc2et(utcstr): """ Convert an input time from Calendar or Julian Date format, UTC, @@ -14528,12 +15762,12 @@ def utc2et(utcstr): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/utc2et_c.html - :param utcstr: Input time string, UTC. + :param utcstr: Input time string, UTC. :type utcstr: str :return: Output epoch, ephemeris seconds past J2000. :rtype: float """ - utcstr = stypes.stringToCharP(utcstr) + utcstr = stypes.string_to_char_p(utcstr) et = ctypes.c_double() libspice.utc2et_c(utcstr, ctypes.byref(et)) return et.value @@ -14543,57 +15777,57 @@ def utc2et(utcstr): # V -@spiceErrorCheck +@spice_error_check def vadd(v1, v2): """ Add two 3 dimensional vectors. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vadd_c.html - :param v1: First vector to be added. + :param v1: First vector to be added. :type v1: 3-Element Array of floats - :param v2: Second vector to be added. + :param v2: Second vector to be added. :type v2: 3-Element Array of floats :return: v1+v2 :rtype: 3-Element Array of floats """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - vout = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + vout = stypes.empty_double_vector(3) libspice.vadd_c(v1, v2, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vaddg(v1, v2, ndim): """ Add two n-dimensional vectors http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vaddg_c.html - :param v1: First vector to be added. + :param v1: First vector to be added. :type v1: list[ndim] - :param v2: Second vector to be added. + :param v2: Second vector to be added. :type v2: list[ndim] - :param ndim: Dimension of v1 and v2. + :param ndim: Dimension of v1 and v2. :type ndim: int :return: v1+v2 :rtype: list[ndim] """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - vout = stypes.emptyDoubleVector(ndim) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + vout = stypes.empty_double_vector(ndim) ndim = ctypes.c_int(ndim) libspice.vaddg_c(v1, v2, ndim, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def valid(insize, n, inset): """ Create a valid CSPICE set from a CSPICE Cell of any data type. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/valid_c.html - :param insize: Size (maximum cardinality) of the set. + :param insize: Size (maximum cardinality) of the set. :type insize: int - :param n: Initial no. of (possibly non-distinct) elements. + :param n: Initial no. of (possibly non-distinct) elements. :type n: int :param inset: Set to be validated. :return: validated set @@ -14606,88 +15840,88 @@ def valid(insize, n, inset): return inset -@spiceErrorCheck +@spice_error_check def vcrss(v1, v2): """ Compute the cross product of two 3-dimensional vectors. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vcrss_c.html - :param v1: Left hand vector for cross product. + :param v1: Left hand vector for cross product. :type v1: 3-Element Array of floats - :param v2: Right hand vector for cross product. + :param v2: Right hand vector for cross product. :type v2: 3-Element Array of floats :return: Cross product v1 x v2. :rtype: 3-Element Array of floats """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - vout = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + vout = stypes.empty_double_vector(3) libspice.vcrss_c(v1, v2, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vdist(v1, v2): """ Return the distance between two three-dimensional vectors. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vdist_c.html - :param v1: First vector in the dot product. + :param v1: First vector in the dot product. :type v1: 3-Element Array of floats - :param v2: Second vector in the dot product. + :param v2: Second vector in the dot product. :type v2: 3-Element Array of floats :return: the distance between v1 and v2 :rtype: float """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) return libspice.vdist_c(v1, v2) -@spiceErrorCheck +@spice_error_check def vdistg(v1, v2, ndim): """ Return the distance between two vectors of arbitrary dimension. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vdistg_c.html - :param v1: ndim-dimensional double precision vector. + :param v1: ndim-dimensional double precision vector. :type v1: list[ndim] - :param v2: ndim-dimensional double precision vector. + :param v2: ndim-dimensional double precision vector. :type v2: list[ndim] - :param ndim: Dimension of v1 and v2. + :param ndim: Dimension of v1 and v2. :type ndim: int :return: the distance between v1 and v2 :rtype: float """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) ndim = ctypes.c_int(ndim) return libspice.vdistg_c(v1, v2, ndim) -@spiceErrorCheck +@spice_error_check def vdot(v1, v2): """ Compute the dot product of two double precision, 3-dimensional vectors. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vdot_c.html - :param v1: First vector in the dot product. + :param v1: First vector in the dot product. :type v1: 3-Element Array of floats - :param v2: Second vector in the dot product. + :param v2: Second vector in the dot product. :type v2: 3-Element Array of floats :return: dot product of v1 and v2. :rtype: float """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) return libspice.vdot_c(v1, v2) -@spiceErrorCheck +@spice_error_check def vdotg(v1, v2, ndim): """ Compute the dot product of two double precision vectors of @@ -14695,100 +15929,100 @@ def vdotg(v1, v2, ndim): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vdotg_c.html - :param v1: First vector in the dot product. + :param v1: First vector in the dot product. :type v1: list[ndim] - :param v2: Second vector in the dot product. + :param v2: Second vector in the dot product. :type v2: list[ndim] - :param ndim: Dimension of v1 and v2. + :param ndim: Dimension of v1 and v2. :type ndim: int :return: dot product of v1 and v2. :rtype: float """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) ndim = ctypes.c_int(ndim) return libspice.vdotg_c(v1, v2, ndim) -@spiceErrorCheck +@spice_error_check def vequ(v1): """ Make one double precision 3-dimensional vector equal to another. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vequ_c.html - :param v1: 3-dimensional double precision vector. + :param v1: 3-dimensional double precision vector. :type v1: 3-Element Array of floats :return: 3-dimensional double precision vector set equal to vin. :rtype: 3-Element Array of floats """ - v1 = stypes.toDoubleVector(v1) - vout = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + vout = stypes.empty_double_vector(3) libspice.vequ_c(v1, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vequg(v1, ndim): """ Make one double precision vector of arbitrary dimension equal to another. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vequg_c.html - :param v1: ndim-dimensional double precision vector. + :param v1: ndim-dimensional double precision vector. :type v1: list[ndim] - :param ndim: Dimension of vin (and also vout). + :param ndim: Dimension of vin (and also vout). :type ndim: int :return: ndim-dimensional double precision vector set equal to vin. :rtype: list[ndim] """ - v1 = stypes.toDoubleVector(v1) - vout = stypes.emptyDoubleVector(ndim) + v1 = stypes.to_double_vector(v1) + vout = stypes.empty_double_vector(ndim) ndim = ctypes.c_int(ndim) libspice.vequg_c(v1, ndim, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vhat(v1): """ Find the unit vector along a double precision 3-dimensional vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vhat_c.html - :param v1: Vector to be unitized. + :param v1: Vector to be unitized. :type v1: 3-Element Array of floats :return: Unit vector v / abs(v). :rtype: 3-Element Array of floats """ - v1 = stypes.toDoubleVector(v1) - vout = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + vout = stypes.empty_double_vector(3) libspice.vhat_c(v1, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vhatg(v1, ndim): """ Find the unit vector along a double precision vector of arbitrary dimension. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vhatg_c.html - :param v1: Vector to be normalized. + :param v1: Vector to be normalized. :type v1: list[ndim] - :param ndim: Dimension of v1 (and also vout). + :param ndim: Dimension of v1 (and also vout). :type ndim: int :return: Unit vector v / abs(v). :rtype: list[ndim] """ - v1 = stypes.toDoubleVector(v1) - vout = stypes.emptyDoubleVector(ndim) + v1 = stypes.to_double_vector(v1) + vout = stypes.empty_double_vector(ndim) ndim = ctypes.c_int(ndim) libspice.vhatg_c(v1, ndim, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vlcom(a, v1, b, v2): """ Compute a vector linear combination of two double precision, @@ -14796,27 +16030,27 @@ def vlcom(a, v1, b, v2): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vlcom_c.html - :param a: Coefficient of v1 + :param a: Coefficient of v1 :type a: float - :param v1: Vector in 3-space + :param v1: Vector in 3-space :type v1: 3-Element Array of floats - :param b: Coefficient of v2 + :param b: Coefficient of v2 :type b: float - :param v2: Vector in 3-space + :param v2: Vector in 3-space :type v2: 3-Element Array of floats :return: Linear Vector Combination a*v1 + b*v2. :rtype: 3-Element Array of floats """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - sumv = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + sumv = stypes.empty_double_vector(3) a = ctypes.c_double(a) b = ctypes.c_double(b) libspice.vlcom_c(a, v1, b, v2, sumv) - return stypes.cVectorToPython(sumv) + return stypes.c_vector_to_python(sumv) -@spiceErrorCheck +@spice_error_check def vlcom3(a, v1, b, v2, c, v3): """ This subroutine computes the vector linear combination @@ -14824,33 +16058,33 @@ def vlcom3(a, v1, b, v2, c, v3): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vlcom3_c.html - :param a: Coefficient of v1 + :param a: Coefficient of v1 :type a: float - :param v1: Vector in 3-space + :param v1: Vector in 3-space :type v1: 3-Element Array of floats - :param b: Coefficient of v2 + :param b: Coefficient of v2 :type b: float - :param v2: Vector in 3-space + :param v2: Vector in 3-space :type v2: 3-Element Array of floats - :param c: Coefficient of v3 + :param c: Coefficient of v3 :type c: float - :param v3: Vector in 3-space + :param v3: Vector in 3-space :type v3: 3-Element Array of floats :return: Linear Vector Combination a*v1 + b*v2 + c*v3 :rtype: 3-Element Array of floats """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - v3 = stypes.toDoubleVector(v3) - sumv = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + v3 = stypes.to_double_vector(v3) + sumv = stypes.empty_double_vector(3) a = ctypes.c_double(a) b = ctypes.c_double(b) c = ctypes.c_double(c) libspice.vlcom3_c(a, v1, b, v2, c, v3, sumv) - return stypes.cVectorToPython(sumv) + return stypes.c_vector_to_python(sumv) -@spiceErrorCheck +@spice_error_check def vlcomg(n, a, v1, b, v2): """ Compute a vector linear combination of two double precision @@ -14858,115 +16092,115 @@ def vlcomg(n, a, v1, b, v2): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vlcomg_c.html - :param n: Dimension of vector space + :param n: Dimension of vector space :type n: int - :param a: Coefficient of v1 + :param a: Coefficient of v1 :type a: float - :param v1: Vector in n-space + :param v1: Vector in n-space :type v1: list[n] - :param b: Coefficient of v2 + :param b: Coefficient of v2 :type b: float - :param v2: Vector in n-space + :param v2: Vector in n-space :type v2: list[n] :return: Linear Vector Combination a*v1 + b*v2 :rtype: list[n] """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - sumv = stypes.emptyDoubleVector(n) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + sumv = stypes.empty_double_vector(n) a = ctypes.c_double(a) b = ctypes.c_double(b) n = ctypes.c_int(n) libspice.vlcomg_c(n, a, v1, b, v2, sumv) - return stypes.cVectorToPython(sumv) + return stypes.c_vector_to_python(sumv) -@spiceErrorCheck +@spice_error_check def vminug(vin, ndim): """ Negate a double precision vector of arbitrary dimension. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vminug_c.html - :param vin: ndim-dimensional double precision vector to be negated. + :param vin: ndim-dimensional double precision vector to be negated. :type vin: Array of floats - :param ndim: Dimension of vin. + :param ndim: Dimension of vin. :type ndim: int :return: ndim-dimensional double precision vector equal to -vin. :rtype: list[ndim] """ - vin = stypes.toDoubleVector(vin) - vout = stypes.emptyDoubleVector(ndim) + vin = stypes.to_double_vector(vin) + vout = stypes.empty_double_vector(ndim) ndim = ctypes.c_int(ndim) libspice.vminug_c(vin, ndim, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vminus(vin): """ Negate a double precision 3-dimensional vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vminus_c.html - :param vin: Vector to be negated. + :param vin: Vector to be negated. :type vin: 3-Element Array of floats :return: Negated vector -v1. :rtype: 3-Element Array of floats """ - vin = stypes.toDoubleVector(vin) - vout = stypes.emptyDoubleVector(3) + vin = stypes.to_double_vector(vin) + vout = stypes.empty_double_vector(3) libspice.vminus_c(vin, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vnorm(v): """ Compute the magnitude of a double precision, 3-dimensional vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vnorm_c.html - :param v: Vector whose magnitude is to be found. + :param v: Vector whose magnitude is to be found. :type v: 3-Element Array of floats :return: magnitude of v calculated in a numerically stable way :rtype: float """ - v = stypes.toDoubleVector(v) + v = stypes.to_double_vector(v) return libspice.vnorm_c(v) -@spiceErrorCheck +@spice_error_check def vnormg(v, ndim): """ Compute the magnitude of a double precision vector of arbitrary dimension. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vnormg_c.html - :param v: Vector whose magnitude is to be found. + :param v: Vector whose magnitude is to be found. :type v: Array of floats - :param ndim: Dimension of v + :param ndim: Dimension of v :type ndim: int :return: magnitude of v calculated in a numerically stable way :rtype: float """ - v = stypes.toDoubleVector(v) + v = stypes.to_double_vector(v) ndim = ctypes.c_int(ndim) return libspice.vnormg_c(v, ndim) -@spiceErrorCheck +@spice_error_check def vpack(x, y, z): """ Pack three scalar components into a vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vpack_c.html - :param x: first scalar component + :param x: first scalar component :type x: float - :param y: second scalar component + :param y: second scalar component :type y: float - :param z: third scalar component + :param z: third scalar component :type z: float :return: Equivalent 3-vector. :rtype: 3-Element Array of floats @@ -14974,12 +16208,12 @@ def vpack(x, y, z): x = ctypes.c_double(x) y = ctypes.c_double(y) z = ctypes.c_double(z) - vout = stypes.emptyDoubleVector(3) + vout = stypes.empty_double_vector(3) libspice.vpack_c(x, y, z, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vperp(a, b): """ Find the component of a vector that is perpendicular to a second @@ -14987,42 +16221,42 @@ def vperp(a, b): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vperp_c.html - :param a: The vector whose orthogonal component is sought. + :param a: The vector whose orthogonal component is sought. :type a: 3-Element Array of floats - :param b: The vector used as the orthogonal reference. + :param b: The vector used as the orthogonal reference. :type b: 3-Element Array of floats :return: The component of a orthogonal to b. :rtype: 3-Element Array of floats """ - a = stypes.toDoubleVector(a) - b = stypes.toDoubleVector(b) - vout = stypes.emptyDoubleVector(3) + a = stypes.to_double_vector(a) + b = stypes.to_double_vector(b) + vout = stypes.empty_double_vector(3) libspice.vperp_c(a, b, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vprjp(vin, plane): """ Project a vector onto a specified plane, orthogonally. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vprjp_c.html - :param vin: The projected vector. + :param vin: The projected vector. :type vin: 3-Element Array of floats - :param plane: Plane containing vin. + :param plane: Plane containing vin. :type plane: spiceypy.utils.support_types.Plane :return: Vector resulting from projection. :rtype: 3-Element Array of floats """ - vin = stypes.toDoubleVector(vin) - vout = stypes.emptyDoubleVector(3) + vin = stypes.to_double_vector(vin) + vout = stypes.empty_double_vector(3) libspice.vprjp_c(vin, ctypes.byref(plane), vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck -@spiceFoundExceptionThrower +@spice_error_check +@spice_found_exception_thrower def vprjpi(vin, projpl, invpl): """ Find the vector in a specified plane that maps to a specified @@ -15030,86 +16264,87 @@ def vprjpi(vin, projpl, invpl): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vprjpi_c.html - :param vin: The projected vector. + :param vin: The projected vector. :type vin: 3-Element Array of floats - :param projpl: Plane containing vin. + :param projpl: Plane containing vin. :type projpl: spiceypy.utils.support_types.Plane - :param invpl: Plane containing inverse image of vin. + :param invpl: Plane containing inverse image of vin. :type invpl: spiceypy.utils.support_types.Plane :return: Inverse projection of vin. :rtype: list """ - vin = stypes.toDoubleVector(vin) - vout = stypes.emptyDoubleVector(3) + vin = stypes.to_double_vector(vin) + vout = stypes.empty_double_vector(3) found = ctypes.c_int() - libspice.vprjpi_c(vin, ctypes.byref(projpl), ctypes.byref(invpl), vout, - ctypes.byref(found)) - return stypes.cVectorToPython(vout), bool(found.value) + libspice.vprjpi_c( + vin, ctypes.byref(projpl), ctypes.byref(invpl), vout, ctypes.byref(found) + ) + return stypes.c_vector_to_python(vout), bool(found.value) -@spiceErrorCheck +@spice_error_check def vproj(a, b): """ Find the projection of one vector onto another vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vproj_c.html - :param a: The vector to be projected. + :param a: The vector to be projected. :type a: 3-Element Array of floats - :param b: The vector onto which a is to be projected. + :param b: The vector onto which a is to be projected. :type b: 3-Element Array of floats :return: The projection of a onto b. :rtype: 3-Element Array of floats """ - a = stypes.toDoubleVector(a) - b = stypes.toDoubleVector(b) - vout = stypes.emptyDoubleVector(3) + a = stypes.to_double_vector(a) + b = stypes.to_double_vector(b) + vout = stypes.empty_double_vector(3) libspice.vproj_c(a, b, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vrel(v1, v2): """ Return the relative difference between two 3-dimensional vectors. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vrel_c.html - :param v1: First vector + :param v1: First vector :type v1: 3-Element Array of floats - :param v2: Second vector + :param v2: Second vector :type v2: 3-Element Array of floats :return: the relative difference between v1 and v2. :rtype: float """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) return libspice.vrel_c(v1, v2) -@spiceErrorCheck +@spice_error_check def vrelg(v1, v2, ndim): """ Return the relative difference between two vectors of general dimension. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vrelg_c.html - :param v1: First vector + :param v1: First vector :type v1: Array of floats - :param v2: Second vector + :param v2: Second vector :type v2: Array of floats :param ndim: Dimension of v1 and v2. :type ndim: int :return: the relative difference between v1 and v2. :rtype: float """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) ndim = ctypes.c_int(ndim) return libspice.vrelg_c(v1, v2, ndim) -@spiceErrorCheck +@spice_error_check def vrotv(v, axis, theta): """ Rotate a vector about a specified axis vector by a @@ -15117,69 +16352,69 @@ def vrotv(v, axis, theta): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vrotv_c.html - :param v: Vector to be rotated. + :param v: Vector to be rotated. :type v: 3-Element Array of floats - :param axis: Axis of the rotation. + :param axis: Axis of the rotation. :type axis: 3-Element Array of floats - :param theta: Angle of rotation (radians). + :param theta: Angle of rotation (radians). :type theta: float :return: Result of rotating v about axis by theta :rtype: 3-Element Array of floats """ - v = stypes.toDoubleVector(v) - axis = stypes.toDoubleVector(axis) + v = stypes.to_double_vector(v) + axis = stypes.to_double_vector(axis) theta = ctypes.c_double(theta) - r = stypes.emptyDoubleVector(3) + r = stypes.empty_double_vector(3) libspice.vrotv_c(v, axis, theta, r) - return stypes.cVectorToPython(r) + return stypes.c_vector_to_python(r) -@spiceErrorCheck +@spice_error_check def vscl(s, v1): """ Multiply a scalar and a 3-dimensional double precision vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vscl_c.html - :param s: Scalar to multiply a vector + :param s: Scalar to multiply a vector :type s: float - :param v1: Vector to be multiplied + :param v1: Vector to be multiplied :type v1: 3-Element Array of floats :return: Product vector, s*v1. :rtype: 3-Element Array of floats """ s = ctypes.c_double(s) - v1 = stypes.toDoubleVector(v1) - vout = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + vout = stypes.empty_double_vector(3) libspice.vscl_c(s, v1, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vsclg(s, v1, ndim): """ Multiply a scalar and a double precision vector of arbitrary dimension. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vsclg_c.html - :param s: Scalar to multiply a vector + :param s: Scalar to multiply a vector :type s: float - :param v1: Vector to be multiplied + :param v1: Vector to be multiplied :type v1: Array of floats - :param ndim: Dimension of v1 + :param ndim: Dimension of v1 :type ndim: int :return: Product vector, s*v1. :rtype: Array of floats """ s = ctypes.c_double(s) - v1 = stypes.toDoubleVector(v1) - vout = stypes.emptyDoubleVector(ndim) + v1 = stypes.to_double_vector(v1) + vout = stypes.empty_double_vector(ndim) ndim = ctypes.c_int(ndim) libspice.vsclg_c(s, v1, ndim, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vsep(v1, v2): """ Find the separation angle in radians between two double @@ -15188,19 +16423,19 @@ def vsep(v1, v2): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vsep_c.html - :param v1: First vector + :param v1: First vector :type v1: 3-Element Array of floats - :param v2: Second vector + :param v2: Second vector :type v2: 3-Element Array of floats :return: separation angle in radians :rtype: float """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) return libspice.vsep_c(v1, v2) -@spiceErrorCheck +@spice_error_check def vsepg(v1, v2, ndim): """ Find the separation angle in radians between two double @@ -15209,22 +16444,22 @@ def vsepg(v1, v2, ndim): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vsepg_c.html - :param v1: First vector + :param v1: First vector :type v1: Array of floats - :param v2: Second vector + :param v2: Second vector :type v2: Array of floats - :param ndim: The number of elements in v1 and v2. + :param ndim: The number of elements in v1 and v2. :type ndim: int :return: separation angle in radians :rtype: float """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) ndim = ctypes.c_int(ndim) return libspice.vsepg_c(v1, v2, ndim) -@spiceErrorCheck +@spice_error_check def vsub(v1, v2): """ Compute the difference between two 3-dimensional, @@ -15232,21 +16467,21 @@ def vsub(v1, v2): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vsub_c.html - :param v1: First vector (minuend). + :param v1: First vector (minuend). :type v1: 3-Element Array of floats - :param v2: Second vector (subtrahend). + :param v2: Second vector (subtrahend). :type v2: 3-Element Array of floats :return: Difference vector, v1 - v2. :rtype: 3-Element Array of floats """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - vout = stypes.emptyDoubleVector(3) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + vout = stypes.empty_double_vector(3) libspice.vsub_c(v1, v2, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vsubg(v1, v2, ndim): """ Compute the difference between two double precision @@ -15254,24 +16489,24 @@ def vsubg(v1, v2, ndim): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vsubg_c.html - :param v1: First vector (minuend). + :param v1: First vector (minuend). :type v1: Array of floats - :param v2: Second vector (subtrahend). + :param v2: Second vector (subtrahend). :type v2: Array of floats - :param ndim: Dimension of v1, v2, and vout. + :param ndim: Dimension of v1, v2, and vout. :type ndim: int :return: Difference vector, v1 - v2. :rtype: Array of floats """ - v1 = stypes.toDoubleVector(v1) - v2 = stypes.toDoubleVector(v2) - vout = stypes.emptyDoubleVector(ndim) + v1 = stypes.to_double_vector(v1) + v2 = stypes.to_double_vector(v2) + vout = stypes.empty_double_vector(ndim) ndim = ctypes.c_int(ndim) libspice.vsubg_c(v1, v2, ndim, vout) - return stypes.cVectorToPython(vout) + return stypes.c_vector_to_python(vout) -@spiceErrorCheck +@spice_error_check def vtmv(v1, matrix, v2): """ Multiply the transpose of a 3-dimensional column vector @@ -15279,22 +16514,22 @@ def vtmv(v1, matrix, v2): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vtmv_c.html - :param v1: 3 dimensional double precision column vector. + :param v1: 3 dimensional double precision column vector. :type v1: 3-Element Array of floats - :param matrix: 3x3 double precision matrix. + :param matrix: 3x3 double precision matrix. :type matrix: 3x3-Element Array of floats - :param v2: 3 dimensional double precision column vector. + :param v2: 3 dimensional double precision column vector. :type v2: 3-Element Array of floats :return: the result of (v1**t * matrix * v2 ). :rtype: float """ - v1 = stypes.toDoubleVector(v1) - matrix = stypes.toDoubleMatrix(matrix) - v2 = stypes.toDoubleVector(v2) + v1 = stypes.to_double_vector(v1) + matrix = stypes.to_double_matrix(matrix) + v2 = stypes.to_double_vector(v2) return libspice.vtmv_c(v1, matrix, v2) -@spiceErrorCheck +@spice_error_check def vtmvg(v1, matrix, v2, nrow, ncol): """ Multiply the transpose of a n-dimensional @@ -15303,40 +16538,40 @@ def vtmvg(v1, matrix, v2, nrow, ncol): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vtmvg_c.html - :param v1: n-dimensional double precision column vector. + :param v1: n-dimensional double precision column vector. :type v1: Array of floats - :param matrix: nxm double precision matrix. + :param matrix: nxm double precision matrix. :type matrix: NxM-Element Array of floats - :param v2: m-dimensional double porecision column vector. + :param v2: m-dimensional double porecision column vector. :type v2: Array of floats - :param nrow: Number of rows in matrix (number of rows in v1.) + :param nrow: Number of rows in matrix (number of rows in v1.) :type nrow: int - :param ncol: Number of columns in matrix (number of rows in v2.) + :param ncol: Number of columns in matrix (number of rows in v2.) :type ncol: int :return: the result of (v1**t * matrix * v2 ) :rtype: float """ - v1 = stypes.toDoubleVector(v1) - matrix = stypes.toDoubleMatrix(matrix) - v2 = stypes.toDoubleVector(v2) + v1 = stypes.to_double_vector(v1) + matrix = stypes.to_double_matrix(matrix) + v2 = stypes.to_double_vector(v2) nrow = ctypes.c_int(nrow) ncol = ctypes.c_int(ncol) return libspice.vtmvg_c(v1, matrix, v2, nrow, ncol) -@spiceErrorCheck +@spice_error_check def vupack(v): """ Unpack three scalar components from a vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vupack_c.html - :param v: Vector + :param v: Vector :type v: 3-Element Array of floats :return: (x, y, z) :rtype: tuple """ - v1 = stypes.toDoubleVector(v) + v1 = stypes.to_double_vector(v) x = ctypes.c_double() y = ctypes.c_double() z = ctypes.c_double() @@ -15344,37 +16579,37 @@ def vupack(v): return x.value, y.value, z.value -@spiceErrorCheck +@spice_error_check def vzero(v): """ Indicate whether a 3-vector is the zero vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vzero_c.html - :param v: Vector to be tested + :param v: Vector to be tested :type v: 3-Element Array of floats :return: true if and only if v is the zero vector :rtype: bool """ - v = stypes.toDoubleVector(v) + v = stypes.to_double_vector(v) return bool(libspice.vzero_c(v)) -@spiceErrorCheck +@spice_error_check def vzerog(v, ndim): """ Indicate whether a general-dimensional vector is the zero vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vzerog_c.html - :param v: Vector to be tested + :param v: Vector to be tested :type v: Array of floats - :param ndim: Dimension of v + :param ndim: Dimension of v :type ndim: int :return: true if and only if v is the zero vector :rtype: bool """ - v = stypes.toDoubleVector(v) + v = stypes.to_double_vector(v) ndim = ctypes.c_int(ndim) return bool(libspice.vzerog_c(v, ndim)) @@ -15383,7 +16618,7 @@ def vzerog(v, ndim): # W -@spiceErrorCheck +@spice_error_check def wncard(window): """ Return the cardinality (number of intervals) of a double @@ -15391,7 +16626,7 @@ def wncard(window): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wncard_c.html - :param window: Input window + :param window: Input window :type window: spiceypy.utils.support_types.SpiceCell :return: the cardinality of the input window. :rtype: int @@ -15400,7 +16635,7 @@ def wncard(window): return libspice.wncard_c(window) -@spiceErrorCheck +@spice_error_check def wncomd(left, right, window): """ Determine the complement of a double precision window with @@ -15408,11 +16643,11 @@ def wncomd(left, right, window): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wncomd_c.html - :param left: left endpoints of complement interval. + :param left: left endpoints of complement interval. :type left: float - :param right: right endpoints of complement interval. + :param right: right endpoints of complement interval. :type right: float - :param window: Input window + :param window: Input window :type window: spiceypy.utils.support_types.SpiceCell :return: Complement of window with respect to left and right. :rtype: spiceypy.utils.support_types.SpiceCell @@ -15426,18 +16661,18 @@ def wncomd(left, right, window): return result -@spiceErrorCheck +@spice_error_check def wncond(left, right, window): """ Contract each of the intervals of a double precision window. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wncond_c.html - :param left: Amount added to each left endpoint. + :param left: Amount added to each left endpoint. :type left: float - :param right: Amount subtracted from each right endpoint. + :param right: Amount subtracted from each right endpoint. :type right: float - :param window: Window to be contracted + :param window: Window to be contracted :type window: spiceypy.utils.support_types.SpiceCell :return: Contracted Window. :rtype: spiceypy.utils.support_types.SpiceCell @@ -15450,7 +16685,7 @@ def wncond(left, right, window): return window -@spiceErrorCheck +@spice_error_check def wndifd(a, b): """ Place the difference of two double precision windows into @@ -15458,9 +16693,9 @@ def wndifd(a, b): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wndifd_c.html - :param a: Input window A. + :param a: Input window A. :type a: spiceypy.utils.support_types.SpiceCell - :param b: Input window B. + :param b: Input window B. :type b: spiceypy.utils.support_types.SpiceCell :return: Difference of a and b. :rtype: spiceypy.utils.support_types.SpiceCell @@ -15474,7 +16709,7 @@ def wndifd(a, b): return c -@spiceErrorCheck +@spice_error_check def wnelmd(point, window): """ Determine whether a point is an element of a double precision @@ -15482,9 +16717,9 @@ def wnelmd(point, window): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnelmd_c.html - :param point: Input point. + :param point: Input point. :type point: float - :param window: Input window + :param window: Input window :type window: spiceypy.utils.support_types.SpiceCell :return: returns True if point is an element of window. :rtype: bool @@ -15495,18 +16730,18 @@ def wnelmd(point, window): return bool(libspice.wnelmd_c(point, ctypes.byref(window))) -@spiceErrorCheck +@spice_error_check def wnexpd(left, right, window): """ Expand each of the intervals of a double precision window. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnexpd_c.html - :param left: Amount subtracted from each left endpoint. + :param left: Amount subtracted from each left endpoint. :type left: float - :param right: Amount added to each right endpoint. + :param right: Amount added to each right endpoint. :type right: float - :param window: Window to be expanded. + :param window: Window to be expanded. :type window: spiceypy.utils.support_types.SpiceCell :return: Expanded Window. :rtype: spiceypy.utils.support_types.SpiceCell @@ -15519,7 +16754,7 @@ def wnexpd(left, right, window): return window -@spiceErrorCheck +@spice_error_check def wnextd(side, window): """ Extract the left or right endpoints from a double precision @@ -15527,31 +16762,31 @@ def wnextd(side, window): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnextd_c.html - :param side: Extract left "L" or right "R" endpoints. + :param side: Extract left "L" or right "R" endpoints. :type side: str - :param window: Window to be extracted. + :param window: Window to be extracted. :type window: spiceypy.utils.support_types.SpiceCell :return: Extracted Window. :rtype: spiceypy.utils.support_types.SpiceCell """ assert isinstance(window, stypes.SpiceCell) assert window.dtype == 1 - assert side == 'L' or side == 'R' - side = ctypes.c_char(side.encode(encoding='UTF-8')) + assert side == "L" or side == "R" + side = ctypes.c_char(side.encode(encoding="UTF-8")) libspice.wnextd_c(side, ctypes.byref(window)) return window -@spiceErrorCheck +@spice_error_check def wnfetd(window, n): """ Fetch a particular interval from a double precision window. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnfetd_c.html - :param window: Input window + :param window: Input window :type window: spiceypy.utils.support_types.SpiceCell - :param n: Index of interval to be fetched. + :param n: Index of interval to be fetched. :type n: int :return: Left, right endpoints of the nth interval. :rtype: tuple @@ -15561,21 +16796,20 @@ def wnfetd(window, n): n = ctypes.c_int(n) left = ctypes.c_double() right = ctypes.c_double() - libspice.wnfetd_c(ctypes.byref(window), n, ctypes.byref(left), - ctypes.byref(right)) + libspice.wnfetd_c(ctypes.byref(window), n, ctypes.byref(left), ctypes.byref(right)) return left.value, right.value -@spiceErrorCheck +@spice_error_check def wnfild(small, window): """ Fill small gaps between adjacent intervals of a double precision window. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnfild_c.html - :param small: Limiting measure of small gaps. + :param small: Limiting measure of small gaps. :type small: float - :param window: Window to be filled + :param window: Window to be filled :type window: spiceypy.utils.support_types.SpiceCell :return: Filled Window. :rtype: spiceypy.utils.support_types.SpiceCell @@ -15587,16 +16821,16 @@ def wnfild(small, window): return window -@spiceErrorCheck +@spice_error_check def wnfltd(small, window): """ Filter (remove) small intervals from a double precision window. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnfltd_c.html - :param small: Limiting measure of small intervals. + :param small: Limiting measure of small intervals. :type small: float - :param window: Window to be filtered. + :param window: Window to be filtered. :type window: spiceypy.utils.support_types.SpiceCell :return: Filtered Window. :rtype: spiceypy.utils.support_types.SpiceCell @@ -15608,18 +16842,18 @@ def wnfltd(small, window): return window -@spiceErrorCheck +@spice_error_check def wnincd(left, right, window): """ Determine whether an interval is included in a double precision window. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnincd_c.html - :param left: Left interval + :param left: Left interval :type left: float - :param right: Right interval + :param right: Right interval :type right: float - :param window: Input window + :param window: Input window :type window: spiceypy.utils.support_types.SpiceCell :return: Returns True if the input interval is included in window. :rtype: bool @@ -15631,18 +16865,18 @@ def wnincd(left, right, window): return bool(libspice.wnincd_c(left, right, ctypes.byref(window))) -@spiceErrorCheck +@spice_error_check def wninsd(left, right, window): """ Insert an interval into a double precision window. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wninsd_c.html - :param left: Left endpoints of new interval. + :param left: Left endpoints of new interval. :type left: float - :param right: Right endpoints of new interval. + :param right: Right endpoints of new interval. :type right: float - :param window: Input window. + :param window: Input window. :type window: spiceypy.utils.support_types.SpiceCell """ assert isinstance(window, stypes.SpiceCell) @@ -15652,7 +16886,7 @@ def wninsd(left, right, window): libspice.wninsd_c(left, right, ctypes.byref(window)) -@spiceErrorCheck +@spice_error_check def wnintd(a, b): """ Place the intersection of two double precision windows into @@ -15661,9 +16895,9 @@ def wnintd(a, b): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnintd_c.html - :param a: Input window A. + :param a: Input window A. :type a: spiceypy.utils.support_types.SpiceCell - :param b: Input window B. + :param b: Input window B. :type b: spiceypy.utils.support_types.SpiceCell :return: Intersection of a and b. :rtype: spiceypy.utils.support_types.SpiceCell @@ -15677,18 +16911,18 @@ def wnintd(a, b): return c -@spiceErrorCheck +@spice_error_check def wnreld(a, op, b): """ Compare two double precision windows. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnreld_c.html - :param a: First window. + :param a: First window. :type a: spiceypy.utils.support_types.SpiceCell - :param op: Comparison operator. + :param op: Comparison operator. :type op: str - :param b: Second window. + :param b: Second window. :type b: spiceypy.utils.support_types.SpiceCell :return: The result of comparison: a (op) b. :rtype: bool @@ -15698,18 +16932,18 @@ def wnreld(a, op, b): assert isinstance(b, stypes.SpiceCell) assert a.dtype == 1 assert isinstance(op, str) - op = stypes.stringToCharP(op.encode(encoding='UTF-8')) + op = stypes.string_to_char_p(op.encode(encoding="UTF-8")) return bool(libspice.wnreld_c(ctypes.byref(a), op, ctypes.byref(b))) -@spiceErrorCheck +@spice_error_check def wnsumd(window): """ Summarize the contents of a double precision window. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnsumd_c.html - :param window: Window to be summarized. + :param window: Window to be summarized. :type window: spiceypy.utils.support_types.SpiceCell :return: Total measure of intervals in window, @@ -15725,22 +16959,27 @@ def wnsumd(window): stddev = ctypes.c_double() shortest = ctypes.c_int() longest = ctypes.c_int() - libspice.wnsumd_c(ctypes.byref(window), ctypes.byref(meas), - ctypes.byref(avg), ctypes.byref(stddev), - ctypes.byref(shortest), ctypes.byref(longest)) + libspice.wnsumd_c( + ctypes.byref(window), + ctypes.byref(meas), + ctypes.byref(avg), + ctypes.byref(stddev), + ctypes.byref(shortest), + ctypes.byref(longest), + ) return meas.value, avg.value, stddev.value, shortest.value, longest.value -@spiceErrorCheck +@spice_error_check def wnunid(a, b): """ Place the union of two double precision windows into a third window. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnunid_c.html - :param a: Input window A. + :param a: Input window A. :type a: spiceypy.utils.support_types.SpiceCell - :param b: Input window B. + :param b: Input window B. :type b: spiceypy.utils.support_types.SpiceCell :return: Union of a and b. :rtype: spiceypy.utils.support_types.SpiceCell @@ -15754,7 +16993,7 @@ def wnunid(a, b): return c -@spiceErrorCheck +@spice_error_check def wnvald(insize, n, window): """ Form a valid double precision window from the contents @@ -15762,11 +17001,11 @@ def wnvald(insize, n, window): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnvald_c.html - :param insize: Size of window. + :param insize: Size of window. :type insize: int - :param n: Original number of endpoints. + :param n: Original number of endpoints. :type n: int - :param window: Input window. + :param window: Input window. :type window: spiceypy.utils.support_types.SpiceCell :return: The union of the intervals in the input cell. :rtype: spiceypy.utils.support_types.SpiceCell @@ -15779,7 +17018,7 @@ def wnvald(insize, n, window): return window -@spiceErrorCheck +@spice_error_check def writln(line, unit): """ Internal undocumented command for writing a text line to a logical unit @@ -15808,74 +17047,75 @@ def writln(line, unit): :param unit: The Fortran unit number to use for output. :type unit: int """ - lineP = stypes.stringToCharP(line) - unit = ctypes.c_int(unit) + line_p = stypes.string_to_char_p(line) + unit = ctypes.c_int(unit) line_len = ctypes.c_int(len(line)) - libspice.writln_(lineP, ctypes.byref(unit), line_len) + libspice.writln_(line_p, ctypes.byref(unit), line_len) ################################################################################ # X -@spiceErrorCheck + +@spice_error_check def xf2eul(xform, axisa, axisb, axisc): """ http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/xf2eul_c.html - :param xform: state transformation matrix + :param xform: state transformation matrix :type xform: list[6][6] - :param axisa: Axis A of the Euler angle factorization. + :param axisa: Axis A of the Euler angle factorization. :type axisa: int - :param axisb: Axis B of the Euler angle factorization. + :param axisb: Axis B of the Euler angle factorization. :type axisb: int - :param axisc: Axis C of the Euler angle factorization. + :param axisc: Axis C of the Euler angle factorization. :type axisc: int :return: (eulang, unique) :rtype: tuple """ - xform = stypes.toDoubleMatrix(xform) + xform = stypes.to_double_matrix(xform) axisa = ctypes.c_int(axisa) axisb = ctypes.c_int(axisb) axisc = ctypes.c_int(axisc) - eulang = stypes.emptyDoubleVector(6) + eulang = stypes.empty_double_vector(6) unique = ctypes.c_int() libspice.xf2eul_c(xform, axisa, axisb, axisc, eulang, unique) - return stypes.cVectorToPython(eulang), unique.value + return stypes.c_vector_to_python(eulang), unique.value -@spiceErrorCheck +@spice_error_check def xf2rav(xform): """ This routine determines the rotation matrix and angular velocity of the rotation from a state transformation matrix. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/xf2rav_c.html - :param xform: state transformation matrix + :param xform: state transformation matrix :type xform: list[6][6] :return: rotation associated with xform, angular velocity associated with xform. :rtype: tuple """ - xform = stypes.toDoubleMatrix(xform) - rot = stypes.emptyDoubleMatrix() - av = stypes.emptyDoubleVector(3) + xform = stypes.to_double_matrix(xform) + rot = stypes.empty_double_matrix() + av = stypes.empty_double_vector(3) libspice.xf2rav_c(xform, rot, av) - return stypes.cMatrixToNumpy(rot), stypes.cVectorToPython(av) + return stypes.c_matrix_to_numpy(rot), stypes.c_vector_to_python(av) -@spiceErrorCheck +@spice_error_check def xfmsta(input_state, input_coord_sys, output_coord_sys, body): """ Transform a state between coordinate systems. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/xfmsta_c.html - :param input_state: Input state. + :param input_state: Input state. :type input_state: 6-Element Array of floats - :param input_coord_sys: Current (input) coordinate system. + :param input_coord_sys: Current (input) coordinate system. :type input_coord_sys: str - :param output_coord_sys: Desired (output) coordinate system. + :param output_coord_sys: Desired (output) coordinate system. :type output_coord_sys: str :param body: Name or NAIF ID of body with which coordinates @@ -15884,53 +17124,54 @@ def xfmsta(input_state, input_coord_sys, output_coord_sys, body): :return: Converted output state :rtype: 6-Element Array of floats """ - input_state = stypes.toDoubleVector(input_state) - input_coord_sys = stypes.stringToCharP(input_coord_sys) - output_coord_sys = stypes.stringToCharP(output_coord_sys) - body = stypes.stringToCharP(body) - output_state = stypes.emptyDoubleVector(6) - libspice.xfmsta_c(input_state, input_coord_sys, output_coord_sys, body, - output_state) - return stypes.cVectorToPython(output_state) + input_state = stypes.to_double_vector(input_state) + input_coord_sys = stypes.string_to_char_p(input_coord_sys) + output_coord_sys = stypes.string_to_char_p(output_coord_sys) + body = stypes.string_to_char_p(body) + output_state = stypes.empty_double_vector(6) + libspice.xfmsta_c( + input_state, input_coord_sys, output_coord_sys, body, output_state + ) + return stypes.c_vector_to_python(output_state) -@spiceErrorCheck +@spice_error_check def xpose(m): """ Transpose a 3x3 matrix http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/xpose_c.html - :param m: Matrix to be transposed + :param m: Matrix to be transposed :type m: 3x3-Element Array of floats :return: Transposed matrix :rtype: 3x3-Element Array of floats """ - m = stypes.toDoubleMatrix(m) - mout = stypes.emptyDoubleMatrix(x=3, y=3) + m = stypes.to_double_matrix(m) + mout = stypes.empty_double_matrix(x=3, y=3) libspice.xpose_c(m, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def xpose6(m): """ Transpose a 6x6 matrix http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/xpose6_c.html - :param m: Matrix to be transposed + :param m: Matrix to be transposed :type m: list[6][6] :return: Transposed matrix :rtype: list[6][6] """ - m = stypes.toDoubleMatrix(m) - mout = stypes.emptyDoubleMatrix(x=6, y=6) + m = stypes.to_double_matrix(m) + mout = stypes.empty_double_matrix(x=6, y=6) libspice.xpose6_c(m, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def xposeg(matrix, nrow, ncol): """ Transpose a matrix of arbitrary size @@ -15938,7 +17179,7 @@ def xposeg(matrix, nrow, ncol): http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/xposeg_c.html - :param matrix: Matrix to be transposed + :param matrix: Matrix to be transposed :type matrix: NxM-Element Array of floats :param nrow: Number of rows of input matrix. :type nrow: int @@ -15947,15 +17188,15 @@ def xposeg(matrix, nrow, ncol): :return: Transposed matrix :rtype: NxM-Element Array of floats """ - matrix = stypes.toDoubleMatrix(matrix) - mout = stypes.emptyDoubleMatrix(x=ncol, y=nrow) + matrix = stypes.to_double_matrix(matrix) + mout = stypes.empty_double_matrix(x=ncol, y=nrow) ncol = ctypes.c_int(ncol) nrow = ctypes.c_int(nrow) libspice.xposeg_c(matrix, nrow, ncol, mout) - return stypes.cMatrixToNumpy(mout) + return stypes.c_matrix_to_numpy(mout) -@spiceErrorCheck +@spice_error_check def zzdynrot(typid, center, et): """ Find the rotation from a dynamic frame ID to the associated frame at the time requested @@ -15972,8 +17213,13 @@ def zzdynrot(typid, center, et): typid = ctypes.c_int(typid) center = ctypes.c_int(center) et = ctypes.c_double(et) - matrix = stypes.emptyDoubleMatrix(x=3, y=3) - nextFrame = ctypes.c_int() - libspice.zzdynrot_(ctypes.byref(typid), ctypes.byref(center), ctypes.byref(et), matrix, ctypes.byref(nextFrame)) - return stypes.cMatrixToNumpy(matrix), nextFrame.value - + matrix = stypes.empty_double_matrix(x=3, y=3) + next_frame = ctypes.c_int() + libspice.zzdynrot_( + ctypes.byref(typid), + ctypes.byref(center), + ctypes.byref(et), + matrix, + ctypes.byref(next_frame), + ) + return stypes.c_matrix_to_numpy(matrix), next_frame.value diff --git a/spiceypy/tests/gettestkernels.py b/spiceypy/tests/gettestkernels.py index fc03fd1a..34350a30 100644 --- a/spiceypy/tests/gettestkernels.py +++ b/spiceypy/tests/gettestkernels.py @@ -28,170 +28,197 @@ import tempfile import six.moves.urllib as urllib from six import print_ as six_print +import sys +cwd = "/tmp" if platform.system() == "Darwin" else tempfile.gettempdir() -cwd = '/tmp' if platform.system() == 'Darwin' else tempfile.gettempdir() -def getKernelNameFromURL(url): - return url.split('/')[-1] +def get_kernel_name_from_url(url): + return url.split("/")[-1] -def getPathFromUrl(url): - return os.path.join(cwd, getKernelNameFromURL(url)) -def cleanupFile(path): +def get_path_from_url(url): + return os.path.join(cwd, get_kernel_name_from_url(url)) + + +def cleanup_file(path): if os.path.exists(path): os.remove(path) + class CassiniKernels(object): - cassPck_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/cpck05Mar2004.tpc" - satSpk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/130220AP_SE_13043_13073.bsp" + cassPck_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/cpck05Mar2004.tpc" + satSpk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/130220AP_SE_13043_13073.bsp" cassTourSpk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/130212AP_SK_13043_13058.bsp" - cassFk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/cas_v40.tf" - cassCk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/13056_13057ra.bc" - cassSclk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/cas00167.tsc" - cassIk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/cas_iss_v10.ti" - cassPck = getPathFromUrl(cassPck_url) - satSpk = getPathFromUrl(satSpk_url) - cassTourSpk = getPathFromUrl(cassTourSpk_url) - cassFk = getPathFromUrl(cassFk_url) - cassCk = getPathFromUrl(cassCk_url) - cassSclk = getPathFromUrl(cassSclk_url) - cassIk = getPathFromUrl(cassIk_url) - -def cleanup_Cassini_Kernels(): - cleanupFile(CassiniKernels.cassPck) - cleanupFile(CassiniKernels.satSpk) - cleanupFile(CassiniKernels.cassTourSpk) - cleanupFile(CassiniKernels.cassFk) - cleanupFile(CassiniKernels.cassCk) - cleanupFile(CassiniKernels.cassSclk) - cleanupFile(CassiniKernels.cassIk) + cassFk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/cas_v40.tf" + cassCk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/13056_13057ra.bc" + cassSclk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/cas00167.tsc" + cassIk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/cas_iss_v10.ti" + cassPck = get_path_from_url(cassPck_url) + satSpk = get_path_from_url(satSpk_url) + cassTourSpk = get_path_from_url(cassTourSpk_url) + cassFk = get_path_from_url(cassFk_url) + cassCk = get_path_from_url(cassCk_url) + cassSclk = get_path_from_url(cassSclk_url) + cassIk = get_path_from_url(cassIk_url) + + +def cleanup_cassini_kernels(): + cleanup_file(CassiniKernels.cassPck) + cleanup_file(CassiniKernels.satSpk) + cleanup_file(CassiniKernels.cassTourSpk) + cleanup_file(CassiniKernels.cassFk) + cleanup_file(CassiniKernels.cassCk) + cleanup_file(CassiniKernels.cassSclk) + cleanup_file(CassiniKernels.cassIk) class ExtraKernels(object): - voyagerSclk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/vg200022.tsc" - earthTopoTf_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/earth_topo_050714.tf" - earthStnSpk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/earthstns_itrf93_050714.bsp" + voyagerSclk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/vg200022.tsc" + earthTopoTf_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/earth_topo_050714.tf" + earthStnSpk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/earthstns_itrf93_050714.bsp" earthHighPerPck_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/earth_031228_231229_predict.bpc" - phobosDsk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/phobos_lores.bds" - marsSpk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/mar022-1.bsp" - mroFk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/mro_v15.tf" - voyagerSclk = getPathFromUrl(voyagerSclk_url) - earthTopoTf = getPathFromUrl(earthTopoTf_url) - earthStnSpk = getPathFromUrl(earthStnSpk_url) - earthHighPerPck = getPathFromUrl(earthHighPerPck_url) - phobosDsk = getPathFromUrl(phobosDsk_url) - marsSpk = getPathFromUrl(marsSpk_url) - mroFk = getPathFromUrl(mroFk_url) - -def cleanup_Extra_Kernels(): - cleanupFile(ExtraKernels.voyagerSclk) - cleanupFile(ExtraKernels.earthTopoTf) - cleanupFile(ExtraKernels.earthStnSpk) - cleanupFile(ExtraKernels.earthHighPerPck) - cleanupFile(ExtraKernels.phobosDsk) - cleanupFile(ExtraKernels.marsSpk) - cleanupFile(ExtraKernels.mroFk) + phobosDsk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/phobos_lores.bds" + marsSpk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/mar022-1.bsp" + mroFk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/mro_v15.tf" + voyagerSclk = get_path_from_url(voyagerSclk_url) + earthTopoTf = get_path_from_url(earthTopoTf_url) + earthStnSpk = get_path_from_url(earthStnSpk_url) + earthHighPerPck = get_path_from_url(earthHighPerPck_url) + phobosDsk = get_path_from_url(phobosDsk_url) + marsSpk = get_path_from_url(marsSpk_url) + mroFk = get_path_from_url(mroFk_url) + + +def cleanup_extra_kernels(): + cleanup_file(ExtraKernels.voyagerSclk) + cleanup_file(ExtraKernels.earthTopoTf) + cleanup_file(ExtraKernels.earthStnSpk) + cleanup_file(ExtraKernels.earthHighPerPck) + cleanup_file(ExtraKernels.phobosDsk) + cleanup_file(ExtraKernels.marsSpk) + cleanup_file(ExtraKernels.mroFk) class CoreKernels(object): - import sys # note this gets updated - currentLSK = 'naif0012.tls' + currentLSK = "naif0012.tls" # - pck_url = 'https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/pck00010.tpc' - spk_url = 'https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/de405s_{}endian.bsp'.format(sys.byteorder) - gm_pck_url = 'https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/gm_de431.tpc' - lsk_url = 'https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/{}'.format(currentLSK) - pck = getPathFromUrl(pck_url) - spk = getPathFromUrl(spk_url) - gm_pck = getPathFromUrl(gm_pck_url) - lsk = getPathFromUrl(lsk_url) + pck_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/pck00010.tpc" + spk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/de405s_{}endian.bsp".format( + sys.byteorder + ) + gm_pck_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/gm_de431.tpc" + lsk_url = "https://raw.githubusercontent.com/AndrewAnnex/SpiceyPyTestKernels/master/{}".format( + currentLSK + ) + pck = get_path_from_url(pck_url) + spk = get_path_from_url(spk_url) + gm_pck = get_path_from_url(gm_pck_url) + lsk = get_path_from_url(lsk_url) standardKernelList = [pck, spk, gm_pck, lsk] - testMetaKernel = os.path.join(cwd, "exampleKernels.txt") + testMetaKernel = os.path.join(cwd, "exampleKernels.txt") -def cleanup_Core_Kernels(): - cleanupFile(CoreKernels.pck) - cleanupFile(CoreKernels.spk) - cleanupFile(CoreKernels.gm_pck) - cleanupFile(CoreKernels.lsk) -def getKernel(url): - kernelName = getKernelNameFromURL(url) - kernelFile = os.path.join(cwd, kernelName) +def cleanup_core_kernels(): + cleanup_file(CoreKernels.pck) + cleanup_file(CoreKernels.spk) + cleanup_file(CoreKernels.gm_pck) + cleanup_file(CoreKernels.lsk) + + +def get_kernel(url): + kernel_name = get_kernel_name_from_url(url) + kernel_file = os.path.join(cwd, kernel_name) # does not download if files are present, which allows us to potentially cache kernels - if not os.path.isfile(kernelFile): - attemptDownload(url, kernelName, kernelFile, 5) + if not os.path.isfile(kernel_file): + attempt_download(url, kernel_name, kernel_file, 5) -def attemptDownload(url, kernelName, targetFileName, num_attempts): +def attempt_download(url, kernel_name, target_file_name, num_attempts): current_attempt = 0 while current_attempt < num_attempts: try: - six_print("Attempting to Download kernel: {}".format(kernelName), flush=True) + six_print( + "Attempting to Download kernel: {}".format(kernel_name), flush=True + ) current_kernel = urllib.request.urlopen(url, timeout=10) - with open(targetFileName, "wb") as kernel: + with open(target_file_name, "wb") as kernel: kernel.write(current_kernel.read()) - six_print("Downloaded kernel: {}".format(kernelName), flush=True) + six_print("Downloaded kernel: {}".format(kernel_name), flush=True) break # N.B. .HTTPError inherits from .URLError, so [except:....HTTPError] # must be listed before [except:....URLError], otherwise the # .HTTPError exception cannot be caught except urllib.error.HTTPError as h: - print("Some http error when downloading kernel {}, error: ".format(kernelName), h, ", trying again after a bit.") + print( + "Some http error when downloading kernel {}, error: ".format( + kernel_name + ), + h, + ", trying again after a bit.", + ) except urllib.error.URLError: - six_print("Download of kernel: {} failed with URLError, trying again after a bit.".format(kernelName), flush=True) + six_print( + "Download of kernel: {} failed with URLError, trying again after a bit.".format( + kernel_name + ), + flush=True, + ) current_attempt += 1 six_print("\t Attempting to Download kernel again...", flush=True) time.sleep(2 + current_attempt) if current_attempt >= num_attempts: - raise BaseException("Error Downloading kernel: {}, check if kernel exists at url: {}".format(kernelName, url)) + raise BaseException( + "Error Downloading kernel: {}, check if kernel exists at url: {}".format( + kernel_name, url + ) + ) -def getStandardKernels(): +def get_standard_kernels(): six_print("\tChecking for kernels...\n", flush=True) - getKernel(CoreKernels.pck_url) - getKernel(CoreKernels.spk_url) - getKernel(CoreKernels.gm_pck_url) - getKernel(CoreKernels.lsk_url) + get_kernel(CoreKernels.pck_url) + get_kernel(CoreKernels.spk_url) + get_kernel(CoreKernels.gm_pck_url) + get_kernel(CoreKernels.lsk_url) -def getExtraTestKernels(): +def get_extra_test_kernels(): # these are test kernels not included in the standard meta kernel - getKernel(ExtraKernels.voyagerSclk_url) - getKernel(ExtraKernels.earthTopoTf_url) - getKernel(ExtraKernels.earthStnSpk_url) - getKernel(ExtraKernels.earthHighPerPck_url) - getKernel(ExtraKernels.phobosDsk_url) - getKernel(ExtraKernels.marsSpk_url) - getKernel(ExtraKernels.mroFk_url) - - -def getCassiniTestKernels(): - getKernel(CassiniKernels.cassPck_url) - getKernel(CassiniKernels.satSpk_url) - getKernel(CassiniKernels.cassTourSpk_url) - getKernel(CassiniKernels.cassFk_url) - getKernel(CassiniKernels.cassCk_url) - getKernel(CassiniKernels.cassSclk_url) - getKernel(CassiniKernels.cassIk_url) - - -def writeTestMetaKernel(): + get_kernel(ExtraKernels.voyagerSclk_url) + get_kernel(ExtraKernels.earthTopoTf_url) + get_kernel(ExtraKernels.earthStnSpk_url) + get_kernel(ExtraKernels.earthHighPerPck_url) + get_kernel(ExtraKernels.phobosDsk_url) + get_kernel(ExtraKernels.marsSpk_url) + get_kernel(ExtraKernels.mroFk_url) + + +def get_cassini_test_kernels(): + get_kernel(CassiniKernels.cassPck_url) + get_kernel(CassiniKernels.satSpk_url) + get_kernel(CassiniKernels.cassTourSpk_url) + get_kernel(CassiniKernels.cassFk_url) + get_kernel(CassiniKernels.cassCk_url) + get_kernel(CassiniKernels.cassSclk_url) + get_kernel(CassiniKernels.cassIk_url) + + +def write_test_meta_kernel(): # Update the paths! - with open(os.path.join(cwd, "exampleKernels.txt"), 'w') as kernelFile: - kernelFile.write('\\begindata\n') - kernelFile.write('KERNELS_TO_LOAD = (\n') + with open(os.path.join(cwd, "exampleKernels.txt"), "w") as kernelFile: + kernelFile.write("\\begindata\n") + kernelFile.write("KERNELS_TO_LOAD = (\n") for kernel in CoreKernels.standardKernelList: - kernelFile.write('\'{0}\'\n'.format(os.path.join(cwd, kernel))) - kernelFile.write(')\n') - kernelFile.write('\\begintext') - six_print('\nDone writing test meta kernel.', flush=True) - + kernelFile.write("'{0}'\n".format(os.path.join(cwd, kernel))) + kernelFile.write(")\n") + kernelFile.write("\\begintext") + six_print("\nDone writing test meta kernel.", flush=True) -def downloadKernels(): - getStandardKernels() # Download the kernels listed in kernelList and kernelURLlist - getCassiniTestKernels() # Download Cassini kernels - getExtraTestKernels() # Download any extra test kernels we need - writeTestMetaKernel() # Create the meta kernel file for tests +def download_kernels(): + get_standard_kernels() # Download the kernels listed in kernelList and kernelURLlist + get_cassini_test_kernels() # Download Cassini kernels + get_extra_test_kernels() # Download any extra test kernels we need + write_test_meta_kernel() # Create the meta kernel file for tests diff --git a/spiceypy/tests/test_gettestkernels.py b/spiceypy/tests/test_gettestkernels.py index 255dd218..59bd9656 100644 --- a/spiceypy/tests/test_gettestkernels.py +++ b/spiceypy/tests/test_gettestkernels.py @@ -25,7 +25,7 @@ import os import pytest -from spiceypy.tests.gettestkernels import attemptDownload +from spiceypy.tests.gettestkernels import attempt_download def test_gettestkernels(): @@ -33,8 +33,14 @@ def test_gettestkernels(): # To complete code coverage in spiceypy.tests.gettestkernels.py with pytest.raises(BaseException): # Generate .HTTPError, return BaseException - attemptDownload('https://naif.jpl.nasa.gov/404', 'httperror.txt', 'httperror.txt', 1) + attempt_download( + "https://naif.jpl.nasa.gov/404", "httperror.txt", "httperror.txt", 1 + ) with pytest.raises(BaseException): # Generate .URLError, return BaseException - attemptDownload('https://no_such_host.naif.jpl.nasa.gov/404', 'urlerror.txt', 'urlerror.txt', 1) - + attempt_download( + "https://no_such_host.naif.jpl.nasa.gov/404", + "urlerror.txt", + "urlerror.txt", + 1, + ) diff --git a/spiceypy/tests/test_spiceerrors.py b/spiceypy/tests/test_spiceerrors.py index 21c01819..6573ddb9 100644 --- a/spiceypy/tests/test_spiceerrors.py +++ b/spiceypy/tests/test_spiceerrors.py @@ -27,6 +27,7 @@ from spiceypy.tests.gettestkernels import cwd import os + def test_geterror(): spice.setmsg("some error occured") spice.sigerr("error") @@ -36,19 +37,19 @@ def test_geterror(): spice.reset() -def test_getSpiceyException(): +def test_get_spicey_exception(): with pytest.raises(spice.stypes.SpiceyError): spice.furnsh(os.path.join(cwd, "_null_kernel.txt")) spice.reset() -def test_emptyKernelPoolException(): +def test_empty_kernel_pool_exception(): with pytest.raises(spice.stypes.SpiceyError): spice.ckgp(0, 0, 0, "blah") spice.reset() -def test_foundErrorChecker(): +def test_found_error_checker(): with pytest.raises(spice.stypes.SpiceyError): spice.bodc2n(-9991) spice.reset() @@ -72,6 +73,7 @@ def test_disable_found_catch(): def test_recursive_disable_found_catch(): spice.kclear() assert spice.config.catch_false_founds + def _recursive_call(i): if i <= 0: return @@ -79,7 +81,8 @@ def _recursive_call(i): with spice.no_found_check(): name, found = spice.bodc2n(-9991) assert not found - _recursive_call(i-1) + _recursive_call(i - 1) + assert spice.config.catch_false_founds _recursive_call(100) spice.kclear() @@ -109,13 +112,13 @@ def test_found_check(): def test_multiple_founds(): success = spice.stypes.SpiceyError(value="test", found=(True, True)) assert all(success.found) - failed = spice.stypes.SpiceyError(value="test",found=(True, False)) + failed = spice.stypes.SpiceyError(value="test", found=(True, False)) assert not all(failed.found) # def test_fun - @spice.spiceFoundExceptionThrower + @spice.spice_found_exception_thrower def test_fun(): return [0, 0], [False, True] + # test it with pytest.raises(spice.stypes.SpiceyError): a = test_fun() - diff --git a/spiceypy/tests/test_support_types.py b/spiceypy/tests/test_support_types.py index ce5b5623..d50a0c64 100644 --- a/spiceypy/tests/test_support_types.py +++ b/spiceypy/tests/test_support_types.py @@ -36,12 +36,12 @@ def test_SpiceEllipse(): spice.reset() viewpt = [2.0, 0.0, 0.0] limb = spice.edlimb(np.sqrt(2), 2.0 * np.sqrt(2), np.sqrt(2), viewpt) - expectedSMinor = [0.0, 0.0, -1.0] - expectedSMajor = [0.0, 2.0, 0.0] + expected_s_minor = [0.0, 0.0, -1.0] + expected_s_major = [0.0, 2.0, 0.0] expectedCenter = [1.0, 0.0, 0.0] npt.assert_array_almost_equal(limb.center, expectedCenter) - npt.assert_array_almost_equal(limb.semi_major, expectedSMajor) - npt.assert_array_almost_equal(limb.semi_minor, expectedSMinor) + npt.assert_array_almost_equal(limb.semi_major, expected_s_major) + npt.assert_array_almost_equal(limb.semi_minor, expected_s_minor) assert str(limb).startswith("= 126 + out_cell = spice.bltfrm(-1) + assert out_cell.size >= 126 def test_bodc2n(): @@ -201,7 +207,7 @@ def test_bodvar(): spice.furnsh(CoreKernels.testMetaKernel) radii = spice.bodvar(399, "RADII", 3) expected = np.array([6378.140, 6378.140, 6356.755]) - np.testing.assert_array_almost_equal(expected, radii, decimal = 1) + np.testing.assert_array_almost_equal(expected, radii, decimal=1) spice.kclear() @@ -211,7 +217,7 @@ def test_bodvcd(): dim, values = spice.bodvcd(399, "RADII", 3) assert dim == 3 expected = np.array([6378.140, 6378.140, 6356.755]) - np.testing.assert_array_almost_equal(expected, values, decimal = 1) + np.testing.assert_array_almost_equal(expected, values, decimal=1) spice.kclear() @@ -221,7 +227,7 @@ def test_bodvrd(): dim, values = spice.bodvrd("EARTH", "RADII", 3) assert dim == 3 expected = np.array([6378.140, 6378.140, 6356.755]) - np.testing.assert_array_almost_equal(expected, values, decimal = 1) + np.testing.assert_array_almost_equal(expected, values, decimal=1) spice.kclear() @@ -247,7 +253,7 @@ def test_bschoc(): assert spice.bschoc("EINSTEIN", 5, lenvals, array, order) == 2 assert spice.bschoc("GALILEO", 5, lenvals, array, order) == 4 assert spice.bschoc("Galileo", 5, lenvals, array, order) == -1 - assert spice.bschoc("BETHE", 5, lenvals, array, order) == -1 + assert spice.bschoc("OBETHE", 5, lenvals, array, order) == -1 def test_bschoc_numpy(): @@ -255,7 +261,7 @@ def test_bschoc_numpy(): order = [1, 2, 0, 4, 3] lenvals = 10 assert spice.bschoc("NEWTON", 5, lenvals, array, order) == 3 - assert spice.bschoc(np.array(["NEWTON","_"])[0], 5, lenvals, array, order) == 3 + assert spice.bschoc(np.array(["NEWTON", "_"])[0], 5, lenvals, array, order) == 3 assert spice.bschoc("EINSTEIN", 5, lenvals, array, order) == 2 assert spice.bschoc("GALILEO", 5, lenvals, array, order) == 4 assert spice.bschoc("Galileo", 5, lenvals, array, order) == -1 @@ -298,14 +304,14 @@ def test_bsrchi(): def test_card(): - testCell = spice.cell_double(8) - assert spice.card(testCell) == 0 - spice.appndd(1.0, testCell) - assert spice.card(testCell) == 1 - spice.appndd(2.0, testCell) - assert spice.card(testCell) == 2 - spice.appndd(3.0, testCell) - assert spice.card(testCell) == 3 + test_cell = spice.cell_double(8) + assert spice.card(test_cell) == 0 + spice.appndd(1.0, test_cell) + assert spice.card(test_cell) == 1 + spice.appndd(2.0, test_cell) + assert spice.card(test_cell) == 2 + spice.appndd(3.0, test_cell) + assert spice.card(test_cell) == 3 def test_ccifrm(): @@ -320,16 +326,16 @@ def test_cgv2el(): vec2 = [1.0, -1.0, 1.0] center = [-1.0, 1.0, -1.0] ellipse = spice.cgv2el(center, vec1, vec2) - expectedSmajor = [np.sqrt(2.0), 0.0, np.sqrt(2.0)] - expectedSminor = [0.0, np.sqrt(2.0), 0.0] - expectedCenter = [-1.0, 1.0, -1.0] - npt.assert_array_almost_equal(expectedCenter, ellipse.center) - npt.assert_array_almost_equal(expectedSmajor, ellipse.semi_major) - npt.assert_array_almost_equal(expectedSminor, ellipse.semi_minor) + expected_s_major = [np.sqrt(2.0), 0.0, np.sqrt(2.0)] + expected_s_minor = [0.0, np.sqrt(2.0), 0.0] + expected_center = [-1.0, 1.0, -1.0] + npt.assert_array_almost_equal(expected_center, ellipse.center) + npt.assert_array_almost_equal(expected_s_major, ellipse.semi_major) + npt.assert_array_almost_equal(expected_s_minor, ellipse.semi_minor) def test_chbder(): - cp = [ 1., 3., 0.5, 1., 0.5, -1., 1.] + cp = [1.0, 3.0, 0.5, 1.0, 0.5, -1.0, 1.0] x2s = [0.5, 3.0] dpdxs = spice.chbder(cp, 6, x2s, 1.0, 3) npt.assert_array_almost_equal([-0.340878, 0.382716, 4.288066, -1.514403], dpdxs) @@ -366,33 +372,43 @@ def test_chkout(): def test_cidfrm(): frcode, frname = spice.cidfrm(501) assert frcode == 10023 - assert frname == 'IAU_IO' + assert frname == "IAU_IO" frcode, frname = spice.cidfrm(399) assert frcode == 10013 - assert frname == 'IAU_EARTH' + assert frname == "IAU_EARTH" frcode, frname = spice.cidfrm(301) assert frcode == 10020 - assert frname == 'IAU_MOON' + assert frname == "IAU_MOON" def test_ckcls(): # Spice crashes if ckcls detects nothing written to ck1 spice.kclear() - CK1 = os.path.join(cwd, "ckopenkernel.bc") - if spice.exists(CK1): - os.remove(CK1) # pragma: no cover - IFNAME = "Test CK type 1 segment created by cspice_ckw01" - handle = spice.ckopn(CK1, IFNAME, 10) - spice.ckw01(handle, 1.0, 10.0, -77701, "J2000", True, "Test type 1 CK segment", - 2 - 1, [1.1, 4.1], [[1.0, 1.0, 1.0, 1.0], [2.0, 2.0, 2.0, 2.0]], - [[0.0, 0.0, 1.0], [0.0, 0.0, 2.0]]) + ck1 = os.path.join(cwd, "ckopenkernel.bc") + if spice.exists(ck1): + os.remove(ck1) # pragma: no cover + ifname = "Test CK type 1 segment created by cspice_ckw01" + handle = spice.ckopn(ck1, ifname, 10) + spice.ckw01( + handle, + 1.0, + 10.0, + -77701, + "J2000", + True, + "Test type 1 CK segment", + 2 - 1, + [1.1, 4.1], + [[1.0, 1.0, 1.0, 1.0], [2.0, 2.0, 2.0, 2.0]], + [[0.0, 0.0, 1.0], [0.0, 0.0, 2.0]], + ) spice.ckcls(handle) spice.kclear() - assert spice.exists(CK1) - if spice.exists(CK1): - os.remove(CK1) # pragma: no cover - assert not spice.exists(CK1) + assert spice.exists(ck1) + if spice.exists(ck1): + os.remove(ck1) # pragma: no cover + assert not spice.exists(ck1) def test_ckcov(): @@ -400,12 +416,17 @@ def test_ckcov(): spice.furnsh(CassiniKernels.cassSclk) ckid = spice.ckobj(CassiniKernels.cassCk)[0] cover = spice.ckcov(CassiniKernels.cassCk, ckid, False, "INTERVAL", 0.0, "SCLK") - expected_intervals = [[267832537952.000000, 267839247264.000000], - [267839256480.000000, 267867970464.000000], - [267868006304.000000, 267876773792.000000]] - assert [[cover[i*2],cover[i*2+1]] for i in range(spice.wncard(cover))] == expected_intervals + expected_intervals = [ + [267832537952.000000, 267839247264.000000], + [267839256480.000000, 267867970464.000000], + [267868006304.000000, 267876773792.000000], + ] + assert [ + [cover[i * 2], cover[i * 2 + 1]] for i in range(spice.wncard(cover)) + ] == expected_intervals spice.kclear() + def test_ckfrot(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) @@ -415,16 +436,21 @@ def test_ckfrot(): spice.furnsh(CassiniKernels.cassFk) spice.furnsh(CassiniKernels.cassPck) ckid = spice.ckobj(CassiniKernels.cassCk)[0] - # aribtrary time covered by test ck kernel + # aribtrary time covered by test ck kernel et = spice.str2et("2013-FEB-26 00:01:08.828") rotation, ref = spice.ckfrot(ckid, et) - expected = np.array([[-0.64399206, 0.48057295, 0.5952511 ], - [-0.34110294, -0.87682328, 0.33886533], - [ 0.68477954, 0.01518468, 0.72859208]]) + expected = np.array( + [ + [-0.64399206, 0.48057295, 0.5952511], + [-0.34110294, -0.87682328, 0.33886533], + [0.68477954, 0.01518468, 0.72859208], + ] + ) npt.assert_array_almost_equal(rotation, expected) - assert ref == 1 + assert ref == 1 spice.kclear() + def test_ckgp(): spice.kclear() spice.reset() @@ -437,9 +463,11 @@ def test_ckgp(): ckid = spice.ckobj(CassiniKernels.cassCk)[0] cover = spice.ckcov(CassiniKernels.cassCk, ckid, False, "INTERVAL", 0.0, "SCLK") cmat, clkout = spice.ckgp(ckid, cover[0], 256, "J2000") - expected_cmat = [[ 0.5064665782997639365 , -0.75794210739897316387, 0.41111478554891744963], - [-0.42372128242505308071, 0.19647683351734512858, 0.88422685364733510927], - [-0.7509672961490383436 , -0.6220294331642198804, -0.22164725216433822652]] + expected_cmat = [ + [0.5064665782997639365, -0.75794210739897316387, 0.41111478554891744963], + [-0.42372128242505308071, 0.19647683351734512858, 0.88422685364733510927], + [-0.7509672961490383436, -0.6220294331642198804, -0.22164725216433822652], + ] npt.assert_array_almost_equal(cmat, expected_cmat) assert clkout == 267832537952.0 spice.reset() @@ -457,10 +485,16 @@ def test_ckgpav(): ckid = spice.ckobj(CassiniKernels.cassCk)[0] cover = spice.ckcov(CassiniKernels.cassCk, ckid, False, "INTERVAL", 0.0, "SCLK") cmat, avout, clkout = spice.ckgpav(ckid, cover[0], 256, "J2000") - expected_cmat = [[0.5064665782997639365 , -0.75794210739897316387, 0.41111478554891744963], - [-0.42372128242505308071, 0.19647683351734512858, 0.88422685364733510927], - [-0.7509672961490383436 , -0.6220294331642198804, -0.22164725216433822652]] - expected_avout = [-0.00231258422150853885, -0.00190333614370416515, -0.00069657429072504716] + expected_cmat = [ + [0.5064665782997639365, -0.75794210739897316387, 0.41111478554891744963], + [-0.42372128242505308071, 0.19647683351734512858, 0.88422685364733510927], + [-0.7509672961490383436, -0.6220294331642198804, -0.22164725216433822652], + ] + expected_avout = [ + -0.00231258422150853885, + -0.00190333614370416515, + -0.00069657429072504716, + ] npt.assert_array_almost_equal(cmat, expected_cmat) npt.assert_array_almost_equal(avout, expected_avout) assert clkout == 267832537952.0 @@ -470,25 +504,35 @@ def test_ckgpav(): def test_cklpf(): spice.kclear() spice.reset() - CKLPF = os.path.join(cwd, "cklpfkernel.bc") - if spice.exists(CKLPF): - os.remove(CKLPF) # pragma: no cover - IFNAME = "Test CK type 1 segment created by cspice_cklpf" - handle = spice.ckopn(CKLPF, IFNAME, 10) - spice.ckw01(handle, 1.0, 10.0, -77701, "J2000", True, "Test type 1 CK segment", - 2 - 1, [1.1, 4.1], [[1.0, 1.0, 1.0, 1.0], [2.0, 2.0, 2.0, 2.0]], - [[0.0, 0.0, 1.0], [0.0, 0.0, 2.0]]) + cklpf = os.path.join(cwd, "cklpfkernel.bc") + if spice.exists(cklpf): + os.remove(cklpf) # pragma: no cover + ifname = "Test CK type 1 segment created by cspice_cklpf" + handle = spice.ckopn(cklpf, ifname, 10) + spice.ckw01( + handle, + 1.0, + 10.0, + -77701, + "J2000", + True, + "Test type 1 CK segment", + 2 - 1, + [1.1, 4.1], + [[1.0, 1.0, 1.0, 1.0], [2.0, 2.0, 2.0, 2.0]], + [[0.0, 0.0, 1.0], [0.0, 0.0, 2.0]], + ) spice.ckcls(handle) spice.kclear() - handle = spice.cklpf(CKLPF) + handle = spice.cklpf(cklpf) spice.ckupf(handle) spice.ckcls(handle) spice.kclear() spice.reset() - assert spice.exists(CKLPF) - if spice.exists(CKLPF): - os.remove(CKLPF) # pragma: no cover - assert not spice.exists(CKLPF) + assert spice.exists(cklpf) + if spice.exists(cklpf): + os.remove(cklpf) # pragma: no cover + assert not spice.exists(cklpf) def test_ckobj(): @@ -503,21 +547,31 @@ def test_ckobj(): def test_ckopn(): # Spice crashes if ckcls detects nothing written to ck1 spice.kclear() - CK1 = os.path.join(cwd, "ckopenkernel.bc") - if spice.exists(CK1): - os.remove(CK1) # pragma: no cover - IFNAME = "Test CK type 1 segment created by cspice_ckw01" - handle = spice.ckopn(CK1, IFNAME, 10) - spice.ckw01(handle, 1.0, 10.0, -77701, "J2000", True, "Test type 1 CK segment", - 2 - 1, [1.1, 4.1], [[1.0, 1.0, 1.0, 1.0], [2.0, 2.0, 2.0, 2.0]], - [[0.0, 0.0, 1.0], [0.0, 0.0, 2.0]]) + ck1 = os.path.join(cwd, "ckopenkernel.bc") + if spice.exists(ck1): + os.remove(ck1) # pragma: no cover + ifname = "Test CK type 1 segment created by cspice_ckw01" + handle = spice.ckopn(ck1, ifname, 10) + spice.ckw01( + handle, + 1.0, + 10.0, + -77701, + "J2000", + True, + "Test type 1 CK segment", + 2 - 1, + [1.1, 4.1], + [[1.0, 1.0, 1.0, 1.0], [2.0, 2.0, 2.0, 2.0]], + [[0.0, 0.0, 1.0], [0.0, 0.0, 2.0]], + ) spice.ckcls(handle) spice.kclear() - assert spice.exists(CK1) - if spice.exists(CK1): - os.remove(CK1) # pragma: no cover - assert not spice.exists(CK1) + assert spice.exists(ck1) + if spice.exists(ck1): + os.remove(ck1) # pragma: no cover + assert not spice.exists(ck1) def test_ckupf(): @@ -532,21 +586,21 @@ def test_ckupf(): def test_ckw01(): spice.kclear() - CK1 = os.path.join(cwd, "type1.bc") - if spice.exists(CK1): - os.remove(CK1) # pragma: no cover + ck1 = os.path.join(cwd, "type1.bc") + if spice.exists(ck1): + os.remove(ck1) # pragma: no cover INST = -77701 MAXREC = 201 SECPERTICK = 0.001 SEGID = "Test type 1 CK segment" - IFNAME = "Test CK type 1 segment created by cspice_ckw01" + ifname = "Test CK type 1 segment created by cspice_ckw01" NCOMCH = 0 REF = "J2000" SPACING_TICKS = 10.0 SPACING_SECS = SPACING_TICKS * SECPERTICK RATE = 0.01 - handle = spice.ckopn(CK1, IFNAME, NCOMCH) - init_size = os.path.getsize(CK1) + handle = spice.ckopn(ck1, ifname, NCOMCH) + init_size = os.path.getsize(ck1) quats = np.zeros((MAXREC, 4)) av = np.zeros((MAXREC, 3)) work_mat = spice.ident() @@ -564,32 +618,44 @@ def test_ckw01(): avflag = True begtime = sclkdp[0] endtime = sclkdp[-1] - spice.ckw01(handle, begtime, endtime, INST, REF, avflag, SEGID, MAXREC - 1, sclkdp, quats, av) + spice.ckw01( + handle, + begtime, + endtime, + INST, + REF, + avflag, + SEGID, + MAXREC - 1, + sclkdp, + quats, + av, + ) spice.ckcls(handle) - end_size = os.path.getsize(CK1) + end_size = os.path.getsize(ck1) assert end_size != init_size spice.kclear() - if spice.exists(CK1): - os.remove(CK1) # pragma: no cover + if spice.exists(ck1): + os.remove(ck1) # pragma: no cover def test_ckw02(): spice.kclear() - CK2 = os.path.join(cwd, "type2.bc") - if spice.exists(CK2): - os.remove(CK2) # pragma: no cover + ck2 = os.path.join(cwd, "type2.bc") + if spice.exists(ck2): + os.remove(ck2) # pragma: no cover INST = -77702 MAXREC = 201 SECPERTICK = 0.001 SEGID = "Test type 2 CK segment" - IFNAME = "Test CK type 2 segment created by cspice_ckw02" + ifname = "Test CK type 2 segment created by cspice_ckw02" NCOMCH = 0 REF = "J2000" SPACING_TICKS = 10.0 SPACING_SECS = SPACING_TICKS * SECPERTICK RATE = 0.01 - handle = spice.ckopn(CK2, IFNAME, NCOMCH) - init_size = os.path.getsize(CK2) + handle = spice.ckopn(ck2, ifname, NCOMCH) + init_size = os.path.getsize(ck2) quats = np.zeros((MAXREC, 4)) av = np.zeros((MAXREC, 3)) work_mat = spice.ident() @@ -609,29 +675,42 @@ def test_ckw02(): av[i] = [0.0, 0.0, RATE] begtime = sclkdp[0] endtime = sclkdp[-1] - spice.ckw02(handle, begtime, endtime, INST, REF, SEGID, MAXREC - 1, starts, stops, quats, av, rates) + spice.ckw02( + handle, + begtime, + endtime, + INST, + REF, + SEGID, + MAXREC - 1, + starts, + stops, + quats, + av, + rates, + ) spice.ckcls(handle) - end_size = os.path.getsize(CK2) + end_size = os.path.getsize(ck2) assert end_size != init_size spice.kclear() - if spice.exists(CK2): - os.remove(CK2) # pragma: no cover + if spice.exists(ck2): + os.remove(ck2) # pragma: no cover def test_ckw03(): spice.kclear() - CK3 = os.path.join(cwd, "type3.bc") - if spice.exists(CK3): - os.remove(CK3) # pragma: no cover + ck3 = os.path.join(cwd, "type3.bc") + if spice.exists(ck3): + os.remove(ck3) # pragma: no cover MAXREC = 201 SECPERTICK = 0.001 SEGID = "Test type 3 CK segment" - IFNAME = "Test CK type 3 segment created by cspice_ckw03" + ifname = "Test CK type 3 segment created by cspice_ckw03" SPACING_TICKS = 10.0 SPACING_SECS = SPACING_TICKS * SECPERTICK RATE = 0.01 - handle = spice.ckopn(CK3, IFNAME, 0) - init_size = os.path.getsize(CK3) + handle = spice.ckopn(ck3, ifname, 0) + init_size = os.path.getsize(ck3) quats = np.zeros((MAXREC, 4)) av = np.zeros((MAXREC, 3)) work_mat = spice.ident() @@ -650,62 +729,185 @@ def test_ckw03(): starts = [sclkdp[2 * i] for i in range(99)] begtime = sclkdp[0] endtime = sclkdp[-1] - spice.ckw03(handle, begtime, endtime, -77703, "J2000", True, SEGID, MAXREC - 1, sclkdp, quats, av, 99, starts) + spice.ckw03( + handle, + begtime, + endtime, + -77703, + "J2000", + True, + SEGID, + MAXREC - 1, + sclkdp, + quats, + av, + 99, + starts, + ) spice.ckcls(handle) - end_size = os.path.getsize(CK3) + end_size = os.path.getsize(ck3) assert end_size != init_size spice.kclear() - if spice.exists(CK3): - os.remove(CK3) # pragma: no cover + if spice.exists(ck3): + os.remove(ck3) # pragma: no cover def test_ckw05(): spice.kclear() - CK5 = os.path.join(cwd, "type5.bc") - if spice.exists(CK5): - os.remove(CK5) # pragma: no cover + ck5 = os.path.join(cwd, "type5.bc") + if spice.exists(ck5): + os.remove(ck5) # pragma: no cover # constants avflag = True epochs = np.arange(0.0, 2.0) inst = [-41000, -41001, -41002, -41003] segid = "CK type 05 test segment" # make type 1 data - type0data = [[ 9.999e-1, -1.530e-4, -8.047e-5, -4.691e-4, 0.0, 0.0, 0.0, 0.0], - [9.999e-1, -4.592e-4, -2.414e-4, -1.407e-3, -7.921e-10, -1.616e-7, -8.499e-8, -4.954e-7]] - type1data = [[ 9.999e-1, -1.530e-4, -8.047e-5, -4.691e-4], - [9.999e-1, -4.592e-4, -2.414e-4, -1.407e-3]] - type2data = [[0.959, -0.00015309, -8.0476e-5, -0.00046913, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], - [0.959, -0.00045928, -0.00024143, -0.0014073, -7.921e-10, -1.616e-7, -8.499e-8, -4.954e-7, 3.234e-7, 1.7e-7, 9.91e-7, 3.234e-7, 1.7e-9, 9.91e-9]] - type3data = [[0.959, -0.00015309, -8.0476e-05, -0.00046913, 0.0, 0.0, 0.0], - [0.959, -0.00045928, -0.00024143, -0.0014073, 3.234e-7, 1.7e-7, 9.91e-7]] + type0data = [ + [9.999e-1, -1.530e-4, -8.047e-5, -4.691e-4, 0.0, 0.0, 0.0, 0.0], + [ + 9.999e-1, + -4.592e-4, + -2.414e-4, + -1.407e-3, + -7.921e-10, + -1.616e-7, + -8.499e-8, + -4.954e-7, + ], + ] + type1data = [ + [9.999e-1, -1.530e-4, -8.047e-5, -4.691e-4], + [9.999e-1, -4.592e-4, -2.414e-4, -1.407e-3], + ] + type2data = [ + [ + 0.959, + -0.00015309, + -8.0476e-5, + -0.00046913, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + ], + [ + 0.959, + -0.00045928, + -0.00024143, + -0.0014073, + -7.921e-10, + -1.616e-7, + -8.499e-8, + -4.954e-7, + 3.234e-7, + 1.7e-7, + 9.91e-7, + 3.234e-7, + 1.7e-9, + 9.91e-9, + ], + ] + type3data = [ + [0.959, -0.00015309, -8.0476e-05, -0.00046913, 0.0, 0.0, 0.0], + [0.959, -0.00045928, -0.00024143, -0.0014073, 3.234e-7, 1.7e-7, 9.91e-7], + ] # begin testing ckw05 - handle = spice.ckopn(CK5, " ", 0) - init_size = os.path.getsize(CK5) + handle = spice.ckopn(ck5, " ", 0) + init_size = os.path.getsize(ck5) # test subtype 0 - spice.ckw05(handle, 0, 15, epochs[0], epochs[-1], inst[0], "J2000", avflag, segid, epochs, type0data, 1000.0, 1, epochs) + spice.ckw05( + handle, + 0, + 15, + epochs[0], + epochs[-1], + inst[0], + "J2000", + avflag, + segid, + epochs, + type0data, + 1000.0, + 1, + epochs, + ) # test subtype 1 - spice.ckw05(handle, 1, 15, epochs[0], epochs[-1], inst[1], "J2000", avflag, segid, epochs, type1data, 1000.0, 1, epochs) + spice.ckw05( + handle, + 1, + 15, + epochs[0], + epochs[-1], + inst[1], + "J2000", + avflag, + segid, + epochs, + type1data, + 1000.0, + 1, + epochs, + ) # test subtype 2 - spice.ckw05(handle, 2, 15, epochs[0], epochs[-1], inst[2], "J2000", avflag, segid, epochs, type2data, 1000.0, 1, epochs) + spice.ckw05( + handle, + 2, + 15, + epochs[0], + epochs[-1], + inst[2], + "J2000", + avflag, + segid, + epochs, + type2data, + 1000.0, + 1, + epochs, + ) # test subtype 3 - spice.ckw05(handle, 3, 15, epochs[0], epochs[-1], inst[3], "J2000", avflag, segid, epochs, type3data, 1000.0, 1, epochs) + spice.ckw05( + handle, + 3, + 15, + epochs[0], + epochs[-1], + inst[3], + "J2000", + avflag, + segid, + epochs, + type3data, + 1000.0, + 1, + epochs, + ) spice.ckcls(handle) # test size - end_size = os.path.getsize(CK5) + end_size = os.path.getsize(ck5) assert end_size != init_size # try reading using ck kernel - spice.furnsh(CK5) - cmat, av, clk = spice.ckgpav(-41000, epochs[0]+0.5, 1.0, "J2000") + spice.furnsh(ck5) + cmat, av, clk = spice.ckgpav(-41000, epochs[0] + 0.5, 1.0, "J2000") assert clk == pytest.approx(0.5) spice.kclear() - if spice.exists(CK5): - os.remove(CK5) # pragma: no cover + if spice.exists(ck5): + os.remove(ck5) # pragma: no cover spice.kclear() + def test_stress_ckw05(): for i in range(1000): test_ckw05() + def test_cleard(): with pytest.raises(NotImplementedError): spice.cleard() @@ -717,86 +919,95 @@ def test_clight(): def test_clpool(): spice.kclear() - spice.pdpool('TEST_VAR', [-666.0]) - value = spice.gdpool('TEST_VAR', 0, 1) + spice.pdpool("TEST_VAR", [-666.0]) + value = spice.gdpool("TEST_VAR", 0, 1) assert len(value) == 1 assert value[0] == -666.0 spice.clpool() with pytest.raises(spice.stypes.SpiceyError): - spice.gdpool('TEST_VAR', 0, 1) + spice.gdpool("TEST_VAR", 0, 1) spice.kclear() def test_cmprss(): - strings = ['ABC...DE.F...', '...........', '.. ..AB....CD'] - assert spice.cmprss('.', 2, strings[0]) == 'ABC..DE.F..' - assert spice.cmprss('.', 3, strings[1]) == '...' - assert spice.cmprss('.', 1, strings[2]) == '. .AB.CD' - assert spice.cmprss('.', 3, strings[1]) == '...' - assert spice.cmprss('.', 1, strings[2]) == '. .AB.CD' - assert spice.cmprss(' ', 0, ' Embe dde d -sp a c es ') == 'Embedded-spaces' + strings = ["ABC...DE.F...", "...........", ".. ..AB....CD"] + assert spice.cmprss(".", 2, strings[0]) == "ABC..DE.F.." + assert spice.cmprss(".", 3, strings[1]) == "..." + assert spice.cmprss(".", 1, strings[2]) == ". .AB.CD" + assert spice.cmprss(".", 3, strings[1]) == "..." + assert spice.cmprss(".", 1, strings[2]) == ". .AB.CD" + assert spice.cmprss(" ", 0, " Embe dde d -sp a c es ") == "Embedded-spaces" def test_cnmfrm(): - ioFrcode, ioFrname = spice.cnmfrm('IO') + ioFrcode, ioFrname = spice.cnmfrm("IO") assert ioFrcode == 10023 - assert ioFrname == 'IAU_IO' + assert ioFrname == "IAU_IO" def test_conics(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('Dec 25, 2007') - state, ltime = spice.spkezr('Moon', et, 'J2000', 'NONE', 'EARTH') - dim, mu = spice.bodvrd('EARTH', 'GM', 1) + et = spice.str2et("Dec 25, 2007") + state, ltime = spice.spkezr("Moon", et, "J2000", "NONE", "EARTH") + dim, mu = spice.bodvrd("EARTH", "GM", 1) elts = spice.oscelt(state, et, mu[0]) later = et + 7.0 * spice.spd() later_state = spice.conics(elts, later) - state, ltime = spice.spkezr('Moon', later, 'J2000', 'NONE', 'EARTH') + state, ltime = spice.spkezr("Moon", later, "J2000", "NONE", "EARTH") spice.kclear() pert = np.array(later_state) - np.array(state) - expectedPert = [-7.48885583081946242601e+03, 3.97608014470621128567e+02, - 1.95744667259379639290e+02, -3.61527427787390887026e-02, - -1.27926899069508159812e-03, -2.01458906615054056388e-03] - npt.assert_array_almost_equal(pert, expectedPert, decimal=5) + expected_pert = [ + -7.48885583081946242601e03, + 3.97608014470621128567e02, + 1.95744667259379639290e02, + -3.61527427787390887026e-02, + -1.27926899069508159812e-03, + -2.01458906615054056388e-03, + ] + npt.assert_array_almost_equal(pert, expected_pert, decimal=5) def test_convrt(): - assert spice.convrt(300.0, 'statute_miles', 'km') == 482.80320 - npt.assert_almost_equal(spice.convrt(1.0, 'parsecs', 'lightyears'), 3.2615638, decimal=6) - - npt.assert_almost_equal(spice.convrt([1.0, 2.0], 'AU', 'km'), [ 149597870.7, 299195741.4], decimal=0) + assert spice.convrt(300.0, "statute_miles", "km") == 482.80320 + npt.assert_almost_equal( + spice.convrt(1.0, "parsecs", "lightyears"), 3.2615638, decimal=6 + ) + + npt.assert_almost_equal( + spice.convrt([1.0, 2.0], "AU", "km"), [149597870.7, 299195741.4], decimal=0 + ) def test_copy(): # SPICEINT_CELL; dtype=2 - outCell = spice.bltfrm(-1) - assert outCell.size >= 126 - cellCopy = spice.copy(outCell) - assert cellCopy.size >= 126 - assert cellCopy is not outCell - assert cellCopy.dtype is 2 + out_cell = spice.bltfrm(-1) + assert out_cell.size >= 126 + cell_copy = spice.copy(out_cell) + assert cell_copy.size >= 126 + assert cell_copy is not out_cell + assert cell_copy.dtype is 2 # SPICECHAR_CELL; dtype=0 - cellSrc = spice.cell_char(10,10) - tmpRtn = [spice.appndc('{}'.format(i), cellSrc) for i in range(5)] - cellCopy = spice.copy(cellSrc) - assert cellCopy.dtype is 0 - assert cellCopy.size == cellSrc.size - assert cellCopy.card == cellSrc.card - assert cellCopy[:] == cellSrc[:] - assert cellCopy.length >= cellSrc.length + cell_src = spice.cell_char(10, 10) + tmpRtn = [spice.appndc("{}".format(i), cell_src) for i in range(5)] + cell_copy = spice.copy(cell_src) + assert cell_copy.dtype is 0 + assert cell_copy.size == cell_src.size + assert cell_copy.card == cell_src.card + assert cell_copy[:] == cell_src[:] + assert cell_copy.length >= cell_src.length # SPICEDOUBLE_CELL; dtype=1 - cellSrc = spice.cell_double(10) - tmpRtn = [spice.appndd(float(i), cellSrc) for i in range(8)] - cellCopy = spice.copy(cellSrc) - assert cellCopy.dtype is 1 - assert cellCopy.size == cellSrc.size - assert cellCopy.card == cellSrc.card - assert cellCopy[:] == cellSrc[:] + cell_src = spice.cell_double(10) + tmpRtn = [spice.appndd(float(i), cell_src) for i in range(8)] + cell_copy = spice.copy(cell_src) + assert cell_copy.dtype is 1 + assert cell_copy.size == cell_src.size + assert cell_copy.card == cell_src.card + assert cell_copy[:] == cell_src[:] # SPICEBOOLEAN_CELL; dtype=4 - cellSrc = spice.cell_bool(9) + cell_src = spice.cell_bool(9) with pytest.raises(NotImplementedError): - spice.copy(cellSrc) + spice.copy(cell_src) def test_cpos(): @@ -850,11 +1061,17 @@ def test_cvpool(): def test_cyllat(): - assert spice.cyllat(1.0, 180.0*spice.rpd(), -1.0) == (np.sqrt(2), np.pi, -np.pi/4) + assert spice.cyllat(1.0, 180.0 * spice.rpd(), -1.0) == ( + np.sqrt(2), + np.pi, + -np.pi / 4, + ) def test_cylrec(): - npt.assert_array_almost_equal(spice.cylrec(0.0, np.radians(33.0), 0.0), [0.0, 0.0, 0.0]) + npt.assert_array_almost_equal( + spice.cylrec(0.0, np.radians(33.0), 0.0), [0.0, 0.0, 0.0] + ) def test_cylsph(): @@ -868,12 +1085,12 @@ def test_dafac(): spice.kclear() dafpath = os.path.join(cwd, "ex_dafac.bc") if spice.exists(dafpath): - os.remove(dafpath) # pragma: no cover + os.remove(dafpath) # pragma: no cover # Open CK to get new DAF because DAFONW (Create DAF) is not available to CSPICE/spiceypy handle = spice.ckopn(dafpath, "TEST_ex_dafac", 140) assert handle is not None # Write some comments - cmnts = ['a', 'bc', 'def', 'ghij'] + cmnts = ["a", "bc", "def", "ghij"] spice.dafac(handle, cmnts) # Use DAFCLS because CKCLS requires segments to be written before closing spice.dafcls(handle) @@ -900,13 +1117,13 @@ def test_dafac(): # ... to get fewer than the total number of comments nOut, cmntsOut, done = spice.dafec(handle, 3, 99) assert nOut == 3 - assert not done + assert not done spice.dafcls(handle) assert not spice.failed() spice.kclear() spice.reset() if spice.exists(dafpath): - os.remove(dafpath) # pragma: no cover + os.remove(dafpath) # pragma: no cover def test_dafbbs(): @@ -954,12 +1171,12 @@ def test_dafdc(): spice.kclear() dafpath = os.path.join(cwd, "ex_dafdc.bc") if spice.exists(dafpath): - os.remove(dafpath) # pragma: no cover + os.remove(dafpath) # pragma: no cover # Open CK to get new DAF because DAFONW (Create DAF) is not available to CSPICE/spiceypy handle = spice.ckopn(dafpath, "TEST_ex_dafdc", 140) assert handle is not None # Write some comments - cmnts = ['a', 'bc', 'def', 'ghij'] + cmnts = ["a", "bc", "def", "ghij"] spice.dafac(handle, cmnts) # Use DAFCLS because CKCLS requires segments to be written before closing spice.dafcls(handle) @@ -994,7 +1211,7 @@ def test_dafdc(): spice.kclear() spice.reset() if spice.exists(dafpath): - os.remove(dafpath) # pragma: no cover + os.remove(dafpath) # pragma: no cover def test_dafec(): @@ -1002,12 +1219,21 @@ def test_dafec(): handle = spice.dafopr(CoreKernels.spk) n, buffer, done = spice.dafec(handle, 13) assert n == 13 - assert buffer == ['; de405s.bsp LOG FILE', ';', '; Created 1997-12-19/18:07:31.00.', ';', - '; BEGIN NIOSPK COMMANDS', '', 'LEAPSECONDS_FILE = /kernels/gen/lsk/naif0006.tls', - 'SPK_FILE = de405s.bsp', ' SOURCE_NIO_FILE = /usr2/nio/gen/de405.nio', - ' BODIES = 1 2 3 4 5 6 7 8 9 10 301 399 199 299 499', - ' BEGIN_TIME = CAL-ET 1997 JAN 01 00:01:02.183', - ' END_TIME = CAL-ET 2010 JAN 02 00:01:03.183', ''] + assert buffer == [ + "; de405s.bsp LOG FILE", + ";", + "; Created 1997-12-19/18:07:31.00.", + ";", + "; BEGIN NIOSPK COMMANDS", + "", + "LEAPSECONDS_FILE = /kernels/gen/lsk/naif0006.tls", + "SPK_FILE = de405s.bsp", + " SOURCE_NIO_FILE = /usr2/nio/gen/de405.nio", + " BODIES = 1 2 3 4 5 6 7 8 9 10 301 399 199 299 499", + " BEGIN_TIME = CAL-ET 1997 JAN 01 00:01:02.183", + " END_TIME = CAL-ET 2010 JAN 02 00:01:03.183", + "", + ] assert done is False spice.dafcls(handle) spice.kclear() @@ -1061,9 +1287,11 @@ def test_dafgn(): found = spice.daffna() assert found out = spice.dafgs(n=2) - npt.assert_array_almost_equal(out, [-9.46511378160646408796e+07, 3.15662463183953464031e+08]) + npt.assert_array_almost_equal( + out, [-9.46511378160646408796e07, 3.15662463183953464031e08] + ) outname = spice.dafgn(100) - assert outname == 'DE-405' + assert outname == "DE-405" spice.dafcls(handle) spice.kclear() @@ -1075,7 +1303,9 @@ def test_dafgs(): found = spice.daffna() assert found out = spice.dafgs(n=2) - npt.assert_array_almost_equal(out, [-9.46511378160646408796e+07, 3.15662463183953464031e+08]) + npt.assert_array_almost_equal( + out, [-9.46511378160646408796e07, 3.15662463183953464031e08] + ) spice.dafcls(handle) spice.kclear() @@ -1098,7 +1328,7 @@ def test_dafgsr(): nd, ni, ifname, fward, bward, free = spice.dafrfr(handle) assert nd == 2 and ni == 6 # Calculate Single Summary size - ss = nd + ((ni+1) >> 1) + ss = nd + ((ni + 1) >> 1) # Loop over Summary records while fward > 0: iRecno = fward @@ -1113,20 +1343,22 @@ def test_dafgsr(): firstWord = 4 # Set DAF record before daf421.bsp next summary record's first record (641) lastIEndWord = 1024 - for iSS in range(1, nSS+1): + for iSS in range(1, nSS + 1): # Get packed summary - drec = spice.dafgsr(handle, iRecno, firstWord, firstWord+ss-1) + drec = spice.dafgsr(handle, iRecno, firstWord, firstWord + ss - 1) # Unpack summary dc, ic = spice.dafus(drec, nd, ni) iBody, iCenter, iFrame, iSPKtype, iStartWord, iEndWord = ic # SPK de405s.bsp ephemerides run from [1997 JAN 01 00:01:02.183 (TDB)] to [2010 JAN 02 00:01:03.183 (TDB)] - npt.assert_array_almost_equal(dc, [-9.46511378160646408796e+07, 3.15662463183953464031e+08]) + npt.assert_array_almost_equal( + dc, [-9.46511378160646408796e07, 3.15662463183953464031e08] + ) # Solar System body barycenters (IDs 1-10) centers are the Solar System Barycenter (ID=0) # All other bodies' centers (e.g. 301; Moon) are their systems barycenter (e.g. 3 Earth-Moon Barycenter) assert (iBody // 100) == iCenter # All de405s.bsp ephemerides are in the J2000 frame (ID 1), use Type 2 SPK records, # and start after the last record for the previous ephemeris - assert iFrame == 1 and iSPKtype == 2 and (lastIEndWord+1) == iStartWord + assert iFrame == 1 and iSPKtype == 2 and (lastIEndWord + 1) == iStartWord # Set up for next pa through loop firstWord += ss lastIEndWord = iEndWord @@ -1162,12 +1394,22 @@ def test_dafps_dafrs(): spice.kclear() dafpath = os.path.join(cwd, "ckopenkernel_dafps.bc") if spice.exists(dafpath): - os.remove(dafpath) # pragma: no cover - IFNAME = "Test CK type 1 segment created by cspice_ckw01" - handle = spice.ckopn(dafpath, IFNAME, 10) - spice.ckw01(handle, 1.0, 10.0, -77701, "J2000", True, "Test type 1 CK segment", - 2 - 1, [1.1, 4.1], [[1.0, 1.0, 1.0, 1.0], [2.0, 2.0, 2.0, 2.0]], - [[0.0, 0.0, 1.0], [0.0, 0.0, 2.0]]) + os.remove(dafpath) # pragma: no cover + ifname = "Test CK type 1 segment created by cspice_ckw01" + handle = spice.ckopn(dafpath, ifname, 10) + spice.ckw01( + handle, + 1.0, + 10.0, + -77701, + "J2000", + True, + "Test type 1 CK segment", + 2 - 1, + [1.1, 4.1], + [[1.0, 1.0, 1.0, 1.0], [2.0, 2.0, 2.0, 2.0]], + [[0.0, 0.0, 1.0], [0.0, 0.0, 2.0]], + ) spice.ckcls(handle) spice.kclear() @@ -1203,7 +1445,7 @@ def test_dafps_dafrs(): spice.dafcls(handle) spice.kclear() if spice.exists(dafpath): - os.remove(dafpath) # pragma: no cover + os.remove(dafpath) # pragma: no cover def test_dafrda(): @@ -1218,7 +1460,7 @@ def test_dafrda(): nd, ni, ifname, fward, bward, free = spice.dafrfr(handle) assert nd == 2 and ni == 6 # Calculate Single Summary size - ss = nd + ((ni+1) >> 1) + ss = nd + ((ni + 1) >> 1) iRecno = fward # Get first three words at summary record (DAF record iRecno) # * drec(1) NEXT forward pointer to next summary record @@ -1234,21 +1476,28 @@ def test_dafrda(): # Loop over single summaries for iSS in range(int(nSS)): # Get packed summary - drec = spice.dafgsr(handle, iRecno, firstWord, firstWord+ss-1) + drec = spice.dafgsr(handle, iRecno, firstWord, firstWord + ss - 1) # Unpack summary dc, ic = spice.dafus(drec, nd, ni) iBody, iCenter, iFrame, iSPKtype, iStartWord, iEndWord = ic # SPK de405s.bsp ephemerides run from [1997 JAN 01 00:01:02.183 (TDB)] to [2010 JAN 02 00:01:03.183 (TDB)] - npt.assert_array_almost_equal(dc, [-9.46511378160646408796e+07, 3.15662463183953464031e+08]) + npt.assert_array_almost_equal( + dc, [-9.46511378160646408796e07, 3.15662463183953464031e08] + ) # Solar System body barycenters (IDs 1-10) centers are the Solar System Barycenter (ID=0) # All other bodies' centers (e.g. 301; Moon) are their systems barycenter (e.g. 3 Earth-Moon Barycenter) assert (iBody // 100) == iCenter # All de405s.bsp ephemeris segments are in the J2000 frame (ID 1), # are Type 2 SPK segments, and start immediately after the last # word (lastIEndWord) for the previous segment - assert iFrame == 1 and iSPKtype == 2 and (lastIEndWord+1) == iStartWord + assert iFrame == 1 and iSPKtype == 2 and (lastIEndWord + 1) == iStartWord # Get the four-word directory at the end of the segment - segmentInit, segmentIntlen, segmentRsize, segmentN = segmentLast4 = spice.dafrda(handle, ic[5]-3, ic[5]) + ( + segmentInit, + segmentIntlen, + segmentRsize, + segmentN, + ) = segmentLast4 = spice.dafrda(handle, ic[5] - 3, ic[5]) # Check segment word count (1+END-BEGIN) against directory word content # Type 2 SPK segment word count: # - A count of [segmentN] Chebyshev polynomial records @ RSIZE words per Cheby. poly. record @@ -1287,7 +1536,9 @@ def test_dafus(): out = spice.dafgs(n=124) dc, ic = spice.dafus(out, 2, 6) spice.dafcls(handle) - npt.assert_array_almost_equal(dc, [-9.46511378160646408796e+07, 3.15662463183953464031e+08]) + npt.assert_array_almost_equal( + dc, [-9.46511378160646408796e07, 3.15662463183953464031e08] + ) npt.assert_array_almost_equal(ic, [1, 0, 1, 2, 1025, 27164]) spice.kclear() @@ -1296,7 +1547,7 @@ def test_dasac_dasopr_dasec_dasdc(): spice.kclear() daspath = os.path.join(cwd, "ex_dasac.das") if spice.exists(daspath): - os.remove(daspath) # pragma: no cover + os.remove(daspath) # pragma: no cover handle = spice.dasonw(daspath, "TEST", "ex_dasac", 140) assert handle is not None # write some comments @@ -1321,12 +1572,12 @@ def test_dasac_dasopr_dasec_dasdc(): assert handle is not None idword, ifname, nresvr, nresvc, ncomr, ncomc = spice.dasrfr(handle) assert idword is not None - assert idword == 'DAS/TEST' - assert ifname == 'ex_dasac' + assert idword == "DAS/TEST" + assert ifname == "ex_dasac" assert nresvr == 0 assert nresvc == 0 - assert ncomr == 140 - assert ncomc == 18 + assert ncomr == 140 + assert ncomc == 18 # close the das file spice.dascls(handle) ############################################### @@ -1347,7 +1598,7 @@ def test_dasac_dasopr_dasec_dasdc(): spice.dascls(handle) # done, so clean up if spice.exists(daspath): - os.remove(daspath) # pragma: no cover + os.remove(daspath) # pragma: no cover spice.kclear() @@ -1355,7 +1606,7 @@ def test_dasopw_dascls_dasopr(): spice.kclear() daspath = os.path.join(cwd, "ex_das.das") if spice.exists(daspath): - os.remove(daspath) # pragma: no cover + os.remove(daspath) # pragma: no cover handle = spice.dasonw(daspath, "TEST", daspath, 0) assert handle is not None spice.dascls(handle) @@ -1366,27 +1617,25 @@ def test_dasopw_dascls_dasopr(): spice.dascls(handle) assert handle is not None if spice.exists(daspath): - os.remove(daspath) # pragma: no cover + os.remove(daspath) # pragma: no cover spice.kclear() def test_dcyldr(): output = spice.dcyldr(1.0, 0.0, 0.0) - expected = [[1.0, 0.0, 0.0], - [0.0, 1.0, 0.0], - [0.0, 0.0, 1.0]] + expected = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] npt.assert_array_almost_equal(output, expected) def test_deltet(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - UTC_1997 = 'Jan 1 1997' - UTC_2004 = 'Jan 1 2004' + UTC_1997 = "Jan 1 1997" + UTC_2004 = "Jan 1 2004" et_1997 = spice.str2et(UTC_1997) et_2004 = spice.str2et(UTC_2004) - delt_1997 = spice.deltet(et_1997, 'ET') - delt_2004 = spice.deltet(et_2004, 'ET') + delt_1997 = spice.deltet(et_1997, "ET") + delt_2004 = spice.deltet(et_2004, "ET") npt.assert_almost_equal(delt_1997, 62.1839353, decimal=6) npt.assert_almost_equal(delt_2004, 64.1839116, decimal=6) spice.kclear() @@ -1401,7 +1650,7 @@ def test_det(): def test_dgeodr(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - size, radii = spice.bodvrd('EARTH', 'RADII', 3) + size, radii = spice.bodvrd("EARTH", "RADII", 3) flat = (radii[0] - radii[2]) / radii[0] lon = 118.0 * spice.rpd() lat = 32.0 * spice.rpd() @@ -1409,66 +1658,68 @@ def test_dgeodr(): spice.kclear() rec = spice.latrec(lon, lat, alt) output = spice.dgeodr(rec[0], rec[1], rec[2], radii[0], flat) - expected = [[-0.25730624850202866, 0.41177607401581356, 0.0], - [-0.019818463887750683, -0.012383950685377182, 0.0011247386599188864], - [0.040768073853231314, 0.02547471988726025, 0.9988438330394612]] + expected = [ + [-0.25730624850202866, 0.41177607401581356, 0.0], + [-0.019818463887750683, -0.012383950685377182, 0.0011247386599188864], + [0.040768073853231314, 0.02547471988726025, 0.9988438330394612], + ] npt.assert_array_almost_equal(output, expected) def test_diags2(): mat = [[1.0, 4.0], [4.0, -5.0]] diag, rot = spice.diags2(mat) - expectedDiag = [[3.0, 0.0], [0.0, -7.0]] - expectedRot = [[0.89442719, -0.44721360], [0.44721360, 0.89442719]] - npt.assert_array_almost_equal(diag, expectedDiag) - npt.assert_array_almost_equal(rot, expectedRot) + expected_diag = [[3.0, 0.0], [0.0, -7.0]] + expected_rot = [[0.89442719, -0.44721360], [0.44721360, 0.89442719]] + npt.assert_array_almost_equal(diag, expected_diag) + npt.assert_array_almost_equal(rot, expected_rot) def test_diff(): # SPICEINT_CELL - testCellOne = spice.cell_int(8) - testCellTwo = spice.cell_int(8) - spice.insrti(1, testCellOne) - spice.insrti(2, testCellOne) - spice.insrti(3, testCellOne) - spice.insrti(2, testCellTwo) - spice.insrti(3, testCellTwo) - spice.insrti(4, testCellTwo) - outCell = spice.diff(testCellOne, testCellTwo) - assert [x for x in outCell] == [1] - outCell = spice.diff(testCellTwo, testCellOne) - assert [x for x in outCell] == [4] + test_cell_one = spice.cell_int(8) + test_cell_two = spice.cell_int(8) + spice.insrti(1, test_cell_one) + spice.insrti(2, test_cell_one) + spice.insrti(3, test_cell_one) + spice.insrti(2, test_cell_two) + spice.insrti(3, test_cell_two) + spice.insrti(4, test_cell_two) + out_cell = spice.diff(test_cell_one, test_cell_two) + assert [x for x in out_cell] == [1] + out_cell = spice.diff(test_cell_two, test_cell_one) + assert [x for x in out_cell] == [4] # SPICECHAR_CELL - testCellOne = spice.cell_char(8, 8) - testCellTwo = spice.cell_char(8, 8) - spice.insrtc('1', testCellOne) - spice.insrtc('2', testCellOne) - spice.insrtc('3', testCellOne) - spice.insrtc('2', testCellTwo) - spice.insrtc('3', testCellTwo) - spice.insrtc('4', testCellTwo) - outCell = spice.diff(testCellOne, testCellTwo) - assert [x for x in outCell] == ['1'] - outCell = spice.diff(testCellTwo, testCellOne) - assert [x for x in outCell] == ['4'] + test_cell_one = spice.cell_char(8, 8) + test_cell_two = spice.cell_char(8, 8) + spice.insrtc("1", test_cell_one) + spice.insrtc("2", test_cell_one) + spice.insrtc("3", test_cell_one) + spice.insrtc("2", test_cell_two) + spice.insrtc("3", test_cell_two) + spice.insrtc("4", test_cell_two) + out_cell = spice.diff(test_cell_one, test_cell_two) + assert [x for x in out_cell] == ["1"] + out_cell = spice.diff(test_cell_two, test_cell_one) + assert [x for x in out_cell] == ["4"] # SPICEDOUBLE_CELL - testCellOne = spice.cell_double(8) - testCellTwo = spice.cell_double(8) - spice.insrtd(1.0, testCellOne) - spice.insrtd(2.0, testCellOne) - spice.insrtd(3.0, testCellOne) - spice.insrtd(2.0, testCellTwo) - spice.insrtd(3.0, testCellTwo) - spice.insrtd(4.0, testCellTwo) - outCell = spice.diff(testCellOne, testCellTwo) - assert [x for x in outCell] == [1.0] - outCell = spice.diff(testCellTwo, testCellOne) - assert [x for x in outCell] == [4.0] + test_cell_one = spice.cell_double(8) + test_cell_two = spice.cell_double(8) + spice.insrtd(1.0, test_cell_one) + spice.insrtd(2.0, test_cell_one) + spice.insrtd(3.0, test_cell_one) + spice.insrtd(2.0, test_cell_two) + spice.insrtd(3.0, test_cell_two) + spice.insrtd(4.0, test_cell_two) + out_cell = spice.diff(test_cell_one, test_cell_two) + assert [x for x in out_cell] == [1.0] + out_cell = spice.diff(test_cell_two, test_cell_one) + assert [x for x in out_cell] == [4.0] # SPICEBOOLEAN_CELL; dtype=4 - testCellOne = spice.cell_bool(9) - testCellTwo = spice.cell_bool(9) + test_cell_one = spice.cell_bool(9) + test_cell_two = spice.cell_bool(9) with pytest.raises(NotImplementedError): - spice.diff(testCellOne, testCellTwo) + spice.diff(test_cell_one, test_cell_two) def test_dlabfs(): @@ -1497,9 +1748,7 @@ def test_dlabbs(): def test_dlatdr(): output = spice.dlatdr(1.0, 0.0, 0.0) - expected = [[1.0, 0.0, 0.0], - [0.0, 1.0, 0.0], - [0.0, 0.0, 1.0]] + expected = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] npt.assert_array_almost_equal(output, expected) @@ -1522,9 +1771,11 @@ def test_dpgrdr(): rp = radii[2] f = (re - rp) / re output = spice.dpgrdr("Mars", 90.0 * spice.rpd(), 45 * spice.rpd(), 300, re, f) - expected = [[0.25464790894703276, -0.5092958178940655, -0.0], - [-0.002629849831988239, -0.0013149249159941194, 1.5182979166821334e-05], - [0.004618598844358383, 0.0023092994221791917, 0.9999866677515724]] + expected = [ + [0.25464790894703276, -0.5092958178940655, -0.0], + [-0.002629849831988239, -0.0013149249159941194, 1.5182979166821334e-05], + [0.004618598844358383, 0.0023092994221791917, 0.9999866677515724], + ] npt.assert_array_almost_equal(output, expected) spice.kclear() @@ -1543,33 +1794,31 @@ def test_dpr(): def test_drdcyl(): output = spice.drdcyl(1.0, np.deg2rad(180.0), 1.0) - expected = [[-1.0, 0.0, 0.0], - [0.0, -1.0, 0.0], - [0.0, 0.0, 1.0]] + expected = [[-1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [0.0, 0.0, 1.0]] npt.assert_array_almost_equal(output, expected) def test_drdgeo(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - size, radii = spice.bodvrd('EARTH', 'RADII', 3) + size, radii = spice.bodvrd("EARTH", "RADII", 3) flat = (radii[0] - radii[2]) / radii[0] lon = 118.0 * spice.rpd() lat = 32.0 * spice.rpd() alt = 0.0 spice.kclear() output = spice.drdgeo(lon, lat, alt, radii[0], flat) - expected = [[-4780.329375996193, 1580.5982261675397, -0.3981344650201568], - [-2541.7462156656084, -2972.6729150327574, 0.7487820251299121], - [0.0, 5387.9427815962445, 0.5299192642332049]] + expected = [ + [-4780.329375996193, 1580.5982261675397, -0.3981344650201568], + [-2541.7462156656084, -2972.6729150327574, 0.7487820251299121], + [0.0, 5387.9427815962445, 0.5299192642332049], + ] npt.assert_array_almost_equal(output, expected) def test_drdlat(): output = spice.drdlat(1.0, 90.0 * spice.rpd(), 0.0) - expected = [[0.0, -1.0, -0.0], - [1.0, 0.0, -0.0], - [0.0, 0.0, 1.0]] + expected = [[0.0, -1.0, -0.0], [1.0, 0.0, -0.0], [0.0, 0.0, 1.0]] npt.assert_array_almost_equal(output, expected) @@ -1581,18 +1830,18 @@ def test_drdpgr(): rp = radii[2] f = (re - rp) / re output = spice.drdpgr("Mars", 90.0 * spice.rpd(), 45 * spice.rpd(), 300, re, f) - expected = [[-2620.6789148181783, 0.0, 0.0], - [0.0, 2606.460468253308, -0.7071067811865476], - [-0.0, 2606.460468253308, 0.7071067811865475]] + expected = [ + [-2620.6789148181783, 0.0, 0.0], + [0.0, 2606.460468253308, -0.7071067811865476], + [-0.0, 2606.460468253308, 0.7071067811865475], + ] npt.assert_array_almost_equal(output, expected) spice.kclear() def test_drdsph(): output = spice.drdsph(1.0, np.pi / 2, np.pi) - expected = [[-1.0, 0.0, 0.0], - [0.0, 0.0, -1.0], - [0.0, -1.0, 0.0]] + expected = [[-1.0, 0.0, 0.0], [0.0, 0.0, -1.0], [0.0, -1.0, 0.0]] npt.assert_array_almost_equal(output, expected) @@ -1620,12 +1869,12 @@ def test_dskopn_dskcls(): spice.kclear() dskpath = os.path.join(cwd, "TEST.dsk") if spice.exists(dskpath): - os.remove(dskpath) # pragma: no cover - handle = spice.dskopn(dskpath, 'TEST.DSK/NAIF/NJB/20-OCT-2006/14:37:00', 0) + os.remove(dskpath) # pragma: no cover + handle = spice.dskopn(dskpath, "TEST.DSK/NAIF/NJB/20-OCT-2006/14:37:00", 0) assert handle is not None spice.dskcls(handle) if spice.exists(dskpath): - os.remove(dskpath) # pragma: no cover + os.remove(dskpath) # pragma: no cover spice.kclear() @@ -1636,7 +1885,19 @@ def test_dskb02(): # get the dladsc from the file dladsc = spice.dlabfs(handle) # test dskb02 - nv, nump, nvxtot, vtxbds, voxsiz, voxori, vgrext, cgscal, vtxnpl, voxnpt, voxnpl = spice.dskb02(handle, dladsc) + ( + nv, + nump, + nvxtot, + vtxbds, + voxsiz, + voxori, + vgrext, + cgscal, + vtxnpl, + voxnpt, + voxnpl, + ) = spice.dskb02(handle, dladsc) # test results assert nv == 422 assert nump == 840 @@ -1650,6 +1911,7 @@ def test_dskb02(): spice.dascls(handle) spice.kclear() + def test_dskd02(): spice.kclear() # open the dsk file @@ -1659,11 +1921,18 @@ def test_dskd02(): # Fetch the vertex values = spice.dskd02(handle, dladsc, 19, 0, 3) assert len(values) > 0 - npt.assert_almost_equal(values, [5.12656957900699912362e-16, -0.00000000000000000000e+00, - -8.37260000000000026432e+00]) + npt.assert_almost_equal( + values, + [ + 5.12656957900699912362e-16, + -0.00000000000000000000e00, + -8.37260000000000026432e00, + ], + ) spice.dascls(handle) spice.kclear() + def test_dskgd(): spice.kclear() # open the dsk file @@ -1676,7 +1945,7 @@ def test_dskgd(): assert dskdsc.surfce == 401 assert dskdsc.center == 401 assert dskdsc.dclass == 1 - assert dskdsc.dtype == 2 + assert dskdsc.dtype == 2 assert dskdsc.frmcde == 10021 assert dskdsc.corsys == 1 npt.assert_almost_equal(dskdsc.corpar, np.zeros(10)) @@ -1686,12 +1955,13 @@ def test_dskgd(): assert dskdsc.co2max == pytest.approx(1.570796) assert dskdsc.co3min == pytest.approx(8.181895873588292) assert dskdsc.co3max == pytest.approx(13.89340000000111) - assert dskdsc.start == pytest.approx(-1577879958.816059) - assert dskdsc.stop == pytest.approx(1577880066.183913) + assert dskdsc.start == pytest.approx(-1577879958.816059) + assert dskdsc.stop == pytest.approx(1577880066.183913) # cleanup spice.dascls(handle) spice.kclear() + def test_dski02(): spice.kclear() # open the dsk file @@ -1705,6 +1975,7 @@ def test_dski02(): spice.dascls(handle) spice.kclear() + def test_dskn02(): spice.kclear() # open the dsk file @@ -1713,11 +1984,14 @@ def test_dskn02(): dladsc = spice.dlabfs(handle) # get the normal vector for first plate normal = spice.dskn02(handle, dladsc, 1) - npt.assert_almost_equal(normal, [0.20813166897151150203, 0.07187012861854354118, - -0.97545676120650637309]) + npt.assert_almost_equal( + normal, + [0.20813166897151150203, 0.07187012861854354118, -0.97545676120650637309], + ) spice.dascls(handle) spice.kclear() + def test_dskp02(): spice.kclear() # open the dsk file @@ -1731,6 +2005,7 @@ def test_dskp02(): spice.dascls(handle) spice.kclear() + def test_dskv02(): spice.kclear() # open the dsk file @@ -1739,11 +2014,18 @@ def test_dskv02(): dladsc = spice.dlabfs(handle) # read the vertices vrtces = spice.dskv02(handle, dladsc, 1, 1) - npt.assert_almost_equal(vrtces[0], [5.12656957900699912362e-16, -0.00000000000000000000e+00, - -8.37260000000000026432e+00]) + npt.assert_almost_equal( + vrtces[0], + [ + 5.12656957900699912362e-16, + -0.00000000000000000000e00, + -8.37260000000000026432e00, + ], + ) spice.dascls(handle) spice.kclear() + def test_dskw02_dskrb2_dskmi2(): spice.kclear() dskpath = os.path.join(cwd, "TESTdskw02.dsk") @@ -1761,17 +2043,23 @@ def test_dskw02_dskrb2_dskmi2(): dclass = 2 frame = "IAU_PHOBOS" first = -50 * spice.jyear() - last = 50 * spice.jyear() + last = 50 * spice.jyear() # stuff from spicedsk.h - SPICE_DSK02_MAXVRT = 16000002 // 128 # divide to lower memory usage + SPICE_DSK02_MAXVRT = 16000002 // 128 # divide to lower memory usage SPICE_DSK02_MAXPLT = 2 * (SPICE_DSK02_MAXVRT - 2) SPICE_DSK02_MAXVXP = SPICE_DSK02_MAXPLT // 2 - SPICE_DSK02_MAXCEL = 60000000 // 128 # divide to lower memory usage + SPICE_DSK02_MAXCEL = 60000000 // 128 # divide to lower memory usage SPICE_DSK02_MXNVLS = SPICE_DSK02_MAXCEL + (SPICE_DSK02_MAXVXP // 2) - SPICE_DSK02_MAXCGR = 100000 // 128 # divide to lower memory usage + SPICE_DSK02_MAXCGR = 100000 // 128 # divide to lower memory usage SPICE_DSK02_IXIFIX = SPICE_DSK02_MAXCGR + 7 SPICE_DSK02_MAXNPV = 3 * (SPICE_DSK02_MAXPLT // 2) + 1 - SPICE_DSK02_SPAISZ = SPICE_DSK02_IXIFIX + SPICE_DSK02_MAXVXP + SPICE_DSK02_MXNVLS + SPICE_DSK02_MAXVRT + SPICE_DSK02_MAXNPV + SPICE_DSK02_SPAISZ = ( + SPICE_DSK02_IXIFIX + + SPICE_DSK02_MAXVXP + + SPICE_DSK02_MXNVLS + + SPICE_DSK02_MAXVRT + + SPICE_DSK02_MAXNPV + ) worksz = SPICE_DSK02_MAXCEL voxpsz = SPICE_DSK02_MAXVXP voxlsz = SPICE_DSK02_MXNVLS @@ -1784,9 +2072,11 @@ def test_dskw02_dskrb2_dskmi2(): spice.dskcls(handle) spice.kclear() # open new dsk file - handle = spice.dskopn(dskpath, 'TESTdskw02.dsk/AA/29-SEP-2017', 0) + handle = spice.dskopn(dskpath, "TESTdskw02.dsk/AA/29-SEP-2017", 0) # create spatial index - spaixd, spaixi = spice.dskmi2(vrtces, plates, finscl, corscl, worksz, voxpsz, voxlsz, False, spaisz) + spaixd, spaixi = spice.dskmi2( + vrtces, plates, finscl, corscl, worksz, voxpsz, voxlsz, False, spaisz + ) # do stuff corsys = 1 mncor1 = -spice.pi() @@ -1797,9 +2087,27 @@ def test_dskw02_dskrb2_dskmi2(): corpar = np.zeros(10) mncor3, mxcor3 = spice.dskrb2(vrtces, plates, corsys, corpar) # Write the segment to the file - spice.dskw02(handle, center, surfid, dclass, frame, corsys, corpar, - mncor1, mxcor1, mncor2, mxcor2, mncor3, mxcor3, first, - last, vrtces, plates, spaixd, spaixi) + spice.dskw02( + handle, + center, + surfid, + dclass, + frame, + corsys, + corpar, + mncor1, + mxcor1, + mncor2, + mxcor2, + mncor3, + mxcor3, + first, + last, + vrtces, + plates, + spaixd, + spaixi, + ) # Close the dsk file spice.dskcls(handle, optmiz=True) # cleanup @@ -1829,6 +2137,7 @@ def test_dskx02(): spice.dascls(handle) spice.kclear() + def test_dskxsi(): spice.kclear() # load kernels @@ -1846,7 +2155,9 @@ def test_dskxsi(): raydir = spice.vminus(vertex) srflst = [dskdsc.surfce] # call dskxsi - xpt, handle, dladsc2, dskdsc2, dc, ic = spice.dskxsi(False, target, srflst, 0.0, fixref, vertex, raydir) + xpt, handle, dladsc2, dskdsc2, dc, ic = spice.dskxsi( + False, target, srflst, 0.0, fixref, vertex, raydir + ) # check output assert handle is not None assert ic[0] == 420 @@ -1854,6 +2165,7 @@ def test_dskxsi(): npt.assert_almost_equal(xpt, [12.36679999999999957083, 0.0, 0.0]) spice.kclear() + def test_dskxv(): spice.kclear() # load kernels @@ -1871,7 +2183,9 @@ def test_dskxv(): raydir = spice.vminus(vertex) srflst = [dskdsc.surfce] # call dskxsi - xpt, foundarray = spice.dskxv(False, target, srflst, 0.0, fixref, [vertex], [raydir]) + xpt, foundarray = spice.dskxv( + False, target, srflst, 0.0, fixref, [vertex], [raydir] + ) # check output assert len(xpt) == 1 assert len(foundarray) == 1 @@ -1879,6 +2193,7 @@ def test_dskxv(): npt.assert_almost_equal(xpt[0], [12.36679999999999957083, 0.0, 0.0]) spice.kclear() + def test_dskxv_2(): spice.kclear() # load kernels @@ -1909,14 +2224,14 @@ def test_dskxv_2(): while lon < 180.0: while nlstep <= 180: if lon == 180.0: - lat = 90.0 - nlstep*latstp + lat = 90.0 - nlstep * latstp else: if nlstep == 0: lat = 90.0 - polmrg elif nlstep == 180: lat = -90.0 + polmrg else: - lat = 90.0 - nlstep*latstp + lat = 90.0 - nlstep * latstp vertex = spice.latrec(r, np.radians(lon), np.radians(lat)) raydir = spice.vminus(vertex) verticies.append(vertex) @@ -1929,13 +2244,16 @@ def test_dskxv_2(): srflst = [dskdsc.surfce] # call dskxsi - xpt, foundarray = spice.dskxv(False, target, srflst, 0.0, fixref, verticies, raydirs) + xpt, foundarray = spice.dskxv( + False, target, srflst, 0.0, fixref, verticies, raydirs + ) # check output assert len(xpt) == 32580 assert len(foundarray) == 32580 assert foundarray.all() spice.kclear() + def test_dskz02(): spice.kclear() # open the dsk file @@ -1949,47 +2267,57 @@ def test_dskz02(): spice.dascls(handle) spice.kclear() + def test_dsphdr(): output = spice.dsphdr(-1.0, 0.0, 0.0) - expected = [[-1.0, 0.0, 0.0], - [0.0, 0.0, -1.0], - [0.0, -1.0, 0.0]] + expected = [[-1.0, 0.0, 0.0], [0.0, 0.0, -1.0], [0.0, -1.0, 0.0]] npt.assert_array_almost_equal(output, expected) def test_dtpool(): spice.kclear() - lmpoolNames = ['DELTET/DELTA_T_A', 'DELTET/K', 'DELTET/EB', 'DELTET/M', 'DELTET/DELTA_AT'] - lmpoolLens = [1, 1, 1, 2, 46] - textbuf = ['DELTET/DELTA_T_A = 32.184', 'DELTET/K = 1.657D-3', 'DELTET/EB = 1.671D-2', - 'DELTET/M = ( 6.239996 1.99096871D-7 )', 'DELTET/DELTA_AT = ( 10, @1972-JAN-1', - ' 11, @1972-JUL-1', - ' 12, @1973-JAN-1', - ' 13, @1974-JAN-1', - ' 14, @1975-JAN-1', - ' 15, @1976-JAN-1', - ' 16, @1977-JAN-1', - ' 17, @1978-JAN-1', - ' 18, @1979-JAN-1', - ' 19, @1980-JAN-1', - ' 20, @1981-JUL-1', - ' 21, @1982-JUL-1', - ' 22, @1983-JUL-1', - ' 23, @1985-JUL-1', - ' 24, @1988-JAN-1', - ' 25, @1990-JAN-1', - ' 26, @1991-JAN-1', - ' 27, @1992-JUL-1', - ' 28, @1993-JUL-1', - ' 29, @1994-JUL-1', - ' 30, @1996-JAN-1', - ' 31, @1997-JUL-1', - ' 32, @1999-JAN-1 )'] + lmpool_names = [ + "DELTET/DELTA_T_A", + "DELTET/K", + "DELTET/EB", + "DELTET/M", + "DELTET/DELTA_AT", + ] + lmpool_lens = [1, 1, 1, 2, 46] + textbuf = [ + "DELTET/DELTA_T_A = 32.184", + "DELTET/K = 1.657D-3", + "DELTET/EB = 1.671D-2", + "DELTET/M = ( 6.239996 1.99096871D-7 )", + "DELTET/DELTA_AT = ( 10, @1972-JAN-1", + " 11, @1972-JUL-1", + " 12, @1973-JAN-1", + " 13, @1974-JAN-1", + " 14, @1975-JAN-1", + " 15, @1976-JAN-1", + " 16, @1977-JAN-1", + " 17, @1978-JAN-1", + " 18, @1979-JAN-1", + " 19, @1980-JAN-1", + " 20, @1981-JUL-1", + " 21, @1982-JUL-1", + " 22, @1983-JUL-1", + " 23, @1985-JUL-1", + " 24, @1988-JAN-1", + " 25, @1990-JAN-1", + " 26, @1991-JAN-1", + " 27, @1992-JUL-1", + " 28, @1993-JUL-1", + " 29, @1994-JUL-1", + " 30, @1996-JAN-1", + " 31, @1997-JUL-1", + " 32, @1999-JAN-1 )", + ] spice.lmpool(textbuf) - for var, expectLen in zip(lmpoolNames, lmpoolLens): + for var, expectLen in zip(lmpool_names, lmpool_lens): n, vartype = spice.dtpool(var) assert expectLen == n - assert vartype == 'N' + assert vartype == "N" spice.kclear() @@ -2002,8 +2330,14 @@ def test_ducrss(): z_j2000 = np.dot(np.array(trans), np.array(z_earth)) state, ltime = spice.spkezr("Sun", et, "J2000", "LT+S", "Earth") z_new = spice.ducrss(state, z_j2000) - z_expected = [-0.9798625180326394, -0.1996715076226282, 0.0008572038510904833, - 4.453114222872359e-08, -2.1853106962531453e-07, -3.6140021238340607e-11] + z_expected = [ + -0.9798625180326394, + -0.1996715076226282, + 0.0008572038510904833, + 4.453114222872359e-08, + -2.1853106962531453e-07, + -3.6140021238340607e-11, + ] npt.assert_array_almost_equal(z_new, z_expected) spice.kclear() @@ -2018,14 +2352,22 @@ def test_dvcrss(): state, ltime = spice.spkezr("Sun", et, "J2000", "LT+S", "Earth") z = spice.dvcrss(state, z_j2000) spice.kclear() - expected = [-1.32672690582546606660e+08, -2.70353812480484284461e+07, - 1.16064793997540167766e+05, 5.12510726479525757782e+00, - -2.97732415336074147660e+01, -4.10216496370272454969e-03] + expected = [ + -1.32672690582546606660e08, + -2.70353812480484284461e07, + 1.16064793997540167766e05, + 5.12510726479525757782e00, + -2.97732415336074147660e01, + -4.10216496370272454969e-03, + ] npt.assert_almost_equal(z, expected) def test_dvdot(): - assert spice.dvdot([1.0, 0.0, 1.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]) == 3.0 + assert ( + spice.dvdot([1.0, 0.0, 1.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]) + == 3.0 + ) def test_dvhat(): @@ -2035,8 +2377,14 @@ def test_dvhat(): state, ltime = spice.spkezr("Sun", et, "J2000", "LT+S", "Earth") x_new = spice.dvhat(state) spice.kclear() - expected = [0.1834466376334262, -0.9019196633282948, -0.39100927360200305, - 2.0244976750658316e-07, 3.4660106111045445e-08, 1.5033141925267006e-08] + expected = [ + 0.1834466376334262, + -0.9019196633282948, + -0.39100927360200305, + 2.0244976750658316e-07, + 3.4660106111045445e-08, + 1.5033141925267006e-08, + ] npt.assert_array_almost_equal(expected, x_new) @@ -2064,9 +2412,9 @@ def test_dvpool(): def test_dvsep(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('JAN 1 2009') - state_e, eltime = spice.spkezr('EARTH', et, 'J2000', 'NONE', 'SUN') - state_m, mltime = spice.spkezr('MOON', et, 'J2000', 'NONE', 'SUN') + et = spice.str2et("JAN 1 2009") + state_e, eltime = spice.spkezr("EARTH", et, "J2000", "NONE", "SUN") + state_m, mltime = spice.spkezr("MOON", et, "J2000", "NONE", "SUN") dsept = spice.dvsep(state_e, state_m) npt.assert_approx_equal(dsept, 3.8121194e-09) spice.kclear() @@ -2075,12 +2423,12 @@ def test_dvsep(): def test_edlimb(): viewpt = [2.0, 0.0, 0.0] limb = spice.edlimb(np.sqrt(2), 2.0 * np.sqrt(2), np.sqrt(2), viewpt) - expectedSMinor = [0.0, 0.0, -1.0] - expectedSMajor = [0.0, 2.0, 0.0] - expectedCenter = [1.0, 0.0, 0.0] - npt.assert_array_almost_equal(limb.center, expectedCenter) - npt.assert_array_almost_equal(limb.semi_major, expectedSMajor) - npt.assert_array_almost_equal(limb.semi_minor, expectedSMinor) + expected_s_minor = [0.0, 0.0, -1.0] + expected_s_major = [0.0, 2.0, 0.0] + expected_center = [1.0, 0.0, 0.0] + npt.assert_array_almost_equal(limb.center, expected_center) + npt.assert_array_almost_equal(limb.semi_major, expected_s_major) + npt.assert_array_almost_equal(limb.semi_minor, expected_s_minor) def test_edterm(): @@ -2088,44 +2436,82 @@ def test_edterm(): spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2007 FEB 3 00:00:00.000") # umbral - trgepc, obspos, trmpts = spice.edterm("UMBRAL", "SUN", "MOON", et, "IAU_MOON", "LT+S", "EARTH", 3) + trgepc, obspos, trmpts = spice.edterm( + "UMBRAL", "SUN", "MOON", et, "IAU_MOON", "LT+S", "EARTH", 3 + ) expected_trgepc = 223732863.86351674795 - expected_obspos = [394721.1024056578753516078, 27265.11780063395417528227, -19069.08478859506431035697] - expected_trmpts0 = [-1.53978381936825627463e+02, -1.73056331949840728157e+03, 1.22893325627419600088e-01] - expected_trmpts1 = [87.37506200891714058798, 864.40670594653545322217, 1504.56817899807947469526] - expected_trmpts2 = [42.21324376177891224415, 868.21134635239388899208, -1504.3223923468244720425] + expected_obspos = [ + 394721.1024056578753516078, + 27265.11780063395417528227, + -19069.08478859506431035697, + ] + expected_trmpts0 = [ + -1.53978381936825627463e02, + -1.73056331949840728157e03, + 1.22893325627419600088e-01, + ] + expected_trmpts1 = [ + 87.37506200891714058798, + 864.40670594653545322217, + 1504.56817899807947469526, + ] + expected_trmpts2 = [ + 42.21324376177891224415, + 868.21134635239388899208, + -1504.3223923468244720425, + ] npt.assert_almost_equal(trgepc, expected_trgepc) npt.assert_array_almost_equal(obspos, expected_obspos) npt.assert_array_almost_equal(trmpts[0], expected_trmpts0) npt.assert_array_almost_equal(trmpts[1], expected_trmpts1) npt.assert_array_almost_equal(trmpts[2], expected_trmpts2) - iluet0, srfvec0, phase0, solar0, emissn0 = spice.ilumin("Ellipsoid", "MOON", et, "IAU_MOON", - "LT+S", "EARTH", trmpts[0]) + iluet0, srfvec0, phase0, solar0, emissn0 = spice.ilumin( + "Ellipsoid", "MOON", et, "IAU_MOON", "LT+S", "EARTH", trmpts[0] + ) npt.assert_almost_equal(spice.dpr() * solar0, 90.269765819) - iluet1, srfvec1, phase1, solar1, emissn1 = spice.ilumin("Ellipsoid", "MOON", et, "IAU_MOON", - "LT+S", "EARTH", trmpts[1]) + iluet1, srfvec1, phase1, solar1, emissn1 = spice.ilumin( + "Ellipsoid", "MOON", et, "IAU_MOON", "LT+S", "EARTH", trmpts[1] + ) npt.assert_almost_equal(spice.dpr() * solar1, 90.269765706) - iluet2, srfvec2, phase2, solar2, emissn2 = spice.ilumin("Ellipsoid", "MOON", et, "IAU_MOON", - "LT+S", "EARTH", trmpts[2]) + iluet2, srfvec2, phase2, solar2, emissn2 = spice.ilumin( + "Ellipsoid", "MOON", et, "IAU_MOON", "LT+S", "EARTH", trmpts[2] + ) npt.assert_almost_equal(spice.dpr() * solar2, 90.269765730) - #penumbral - trgepc, obspos, trmpts = spice.edterm("PENUMBRAL", "SUN", "MOON", et, "IAU_MOON", "LT+S", "EARTH", 3) - expected_trmpts0 = [1.54019056755619715204e+02, 1.73055969989532059117e+03, -1.23508409498995316844e-01] - expected_trmpts1 = [-87.33436047798454637814, -864.41003834758112134296, -1504.56862757530461749411] - expected_trmpts2 = [-42.17254722919552278881, -868.21467833235510624945, 1504.32161075630597224517] + # penumbral + trgepc, obspos, trmpts = spice.edterm( + "PENUMBRAL", "SUN", "MOON", et, "IAU_MOON", "LT+S", "EARTH", 3 + ) + expected_trmpts0 = [ + 1.54019056755619715204e02, + 1.73055969989532059117e03, + -1.23508409498995316844e-01, + ] + expected_trmpts1 = [ + -87.33436047798454637814, + -864.41003834758112134296, + -1504.56862757530461749411, + ] + expected_trmpts2 = [ + -42.17254722919552278881, + -868.21467833235510624945, + 1504.32161075630597224517, + ] npt.assert_almost_equal(trgepc, expected_trgepc) npt.assert_array_almost_equal(obspos, expected_obspos) npt.assert_array_almost_equal(trmpts[0], expected_trmpts0) npt.assert_array_almost_equal(trmpts[1], expected_trmpts1) npt.assert_array_almost_equal(trmpts[2], expected_trmpts2) - iluet0, srfvec0, phase0, solar0, emissn0 = spice.ilumin("Ellipsoid", "MOON", et, "IAU_MOON", - "LT+S", "EARTH", trmpts[0]) + iluet0, srfvec0, phase0, solar0, emissn0 = spice.ilumin( + "Ellipsoid", "MOON", et, "IAU_MOON", "LT+S", "EARTH", trmpts[0] + ) npt.assert_almost_equal(spice.dpr() * solar0, 89.730234406) - iluet1, srfvec1, phase1, solar1, emissn1 = spice.ilumin("Ellipsoid", "MOON", et, "IAU_MOON", - "LT+S", "EARTH", trmpts[1]) + iluet1, srfvec1, phase1, solar1, emissn1 = spice.ilumin( + "Ellipsoid", "MOON", et, "IAU_MOON", "LT+S", "EARTH", trmpts[1] + ) npt.assert_almost_equal(spice.dpr() * solar1, 89.730234298) - iluet2, srfvec2, phase2, solar2, emissn2 = spice.ilumin("Ellipsoid", "MOON", et, "IAU_MOON", - "LT+S", "EARTH", trmpts[2]) + iluet2, srfvec2, phase2, solar2, emissn2 = spice.ilumin( + "Ellipsoid", "MOON", et, "IAU_MOON", "LT+S", "EARTH", trmpts[2] + ) npt.assert_almost_equal(spice.dpr() * solar2, 89.730234322) spice.kclear() @@ -2134,15 +2520,20 @@ def test_ekacec(): spice.kclear() ekpath = os.path.join(cwd, "example_ekacec.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno = spice.ekbseg(handle, "test_table_ekacec", ["c1"], ["DATATYPE = CHARACTER*(*), NULLS_OK = TRUE"]) + segno = spice.ekbseg( + handle, + "test_table_ekacec", + ["c1"], + ["DATATYPE = CHARACTER*(*), NULLS_OK = TRUE"], + ) recno = spice.ekappr(handle, segno) spice.ekacec(handle, segno, recno, "c1", 2, ["1.0", "2.0"], False) spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2150,15 +2541,20 @@ def test_ekaced(): spice.kclear() ekpath = os.path.join(cwd, "example_ekaced.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno = spice.ekbseg(handle, "test_table_ekaced", ["c1"], ["DATATYPE = DOUBLE PRECISION, NULLS_OK = TRUE"]) + segno = spice.ekbseg( + handle, + "test_table_ekaced", + ["c1"], + ["DATATYPE = DOUBLE PRECISION, NULLS_OK = TRUE"], + ) recno = spice.ekappr(handle, segno) spice.ekaced(handle, segno, recno, "c1", 2, [1.0, 2.0], False) spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2167,15 +2563,17 @@ def test_ekmany(): ekpath = os.path.join(cwd, "example_ekmany.ek") tablename = "test_table_ekmany" if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover # Create new EK and new segment with table handle = spice.ekopn(ekpath, ekpath, 0) - decls = ["DATATYPE = CHARACTER*(10), NULLS_OK = FALSE, SIZE = VARIABLE", - "DATATYPE = DOUBLE PRECISION, NULLS_OK = FALSE, SIZE = VARIABLE", - "DATATYPE = INTEGER, NULLS_OK = FALSE, SIZE = VARIABLE"] - segno = spice.ekbseg(handle, tablename, ['c1', 'd1', 'i1'], decls) + decls = [ + "DATATYPE = CHARACTER*(10), NULLS_OK = FALSE, SIZE = VARIABLE", + "DATATYPE = DOUBLE PRECISION, NULLS_OK = FALSE, SIZE = VARIABLE", + "DATATYPE = INTEGER, NULLS_OK = FALSE, SIZE = VARIABLE", + ] + segno = spice.ekbseg(handle, tablename, ["c1", "d1", "i1"], decls) # Insert records: 1, 2, and 3 entries at rows 0, 1, 2, respectively - c_data = [['100'], ['101', '101'], ['102', '102', '102']] + c_data = [["100"], ["101", "101"], ["102", "102", "102"]] d_data = [[100.0], [101.0, 101.0], [102.0, 102.0, 102.0]] i_data = [[100], [101, 101], [102, 102, 102]] for r in range(0, 3): @@ -2196,13 +2594,15 @@ def test_ekmany(): assert handle is not None # Test query using ekpsel query = "SELECT c1, d1, i1 from {}".format(tablename) - n, xbegs, xends, xtypes, xclass, tabs, cols, err, errmsg = spice.ekpsel(query, 99, 99, 99) + n, xbegs, xends, xtypes, xclass, tabs, cols, err, errmsg = spice.ekpsel( + query, 99, 99, 99 + ) assert n == 3 assert spice.stypes.SpiceEKDataType.SPICE_CHR == xtypes[0] - assert spice.stypes.SpiceEKDataType.SPICE_DP == xtypes[1] + assert spice.stypes.SpiceEKDataType.SPICE_DP == xtypes[1] assert spice.stypes.SpiceEKDataType.SPICE_INT == xtypes[2] - assert ([spice.stypes.SpiceEKExprClass.SPICE_EK_EXP_COL]*3) == list(xclass) - assert (["TEST_TABLE_EKMANY"]*3) == tabs + assert ([spice.stypes.SpiceEKExprClass.SPICE_EK_EXP_COL] * 3) == list(xclass) + assert (["TEST_TABLE_EKMANY"] * 3) == tabs assert "C1 D1 I1".split() == cols assert not err assert "" == errmsg @@ -2210,16 +2610,16 @@ def test_ekmany(): nmrows, error, errmsg = spice.ekfind(query, 99) assert nmrows == 3 assert not error - assert '' == errmsg + assert "" == errmsg # test fail case for eknelt with pytest.raises(spice.stypes.SpiceyError): - spice.eknelt(0, nmrows+1) + spice.eknelt(0, nmrows + 1) # Validate the content of each field, including exceptions when # Loop over rows, test .ekgc/.ekgd/.ekgi for r in range(nmrows): # get number of elements in this row n_elm = spice.eknelt(0, r) - assert n_elm == r + 1 + assert n_elm == r + 1 for e in range(0, n_elm): # get row int data i_datum, i_null = spice.ekgi(2, r, e) @@ -2255,7 +2655,7 @@ def test_ekmany(): spice.ekrcei(handle, segno, 3, "i1") with pytest.raises(spice.stypes.SpiceyError): spice.ekrced(handle, segno, 3, "d1") - #with pytest.raises(spice.stypes.SpiceyError): TODO: FIX + # with pytest.raises(spice.stypes.SpiceyError): TODO: FIX # spice.ekrcec(handle, segno, 4, "c1", 4) # this causes a SIGSEGV # # Part 3 @@ -2264,7 +2664,7 @@ def test_ekmany(): spice.ekuef(handle) handle = spice.ekopw(ekpath) # Loop over rows, update values using .ekucec/.ekuced/.ekucei - c_data = [['200'], ['201', '201'], ['202', '202', '202']] + c_data = [["200"], ["201", "201"], ["202", "202", "202"]] d_data = [[200.0], [201.0, 201.0], [202.0, 202.0, 202.0]] i_data = [[200], [201, 201], [202, 202, 202]] for r in range(0, 3): @@ -2273,7 +2673,7 @@ def test_ekmany(): spice.ekucei(handle, segno, r, "i1", len(i_data[r]), i_data[r], False) # Test invalid updates with pytest.raises(spice.stypes.SpiceyError): - spice.ekucec(handle, segno, 3, "c1", 1, ['300'], False) + spice.ekucec(handle, segno, 3, "c1", 1, ["300"], False) with pytest.raises(spice.stypes.SpiceyError): spice.ekuced(handle, segno, 3, "d1", 1, [300.0], False) with pytest.raises(spice.stypes.SpiceyError): @@ -2299,23 +2699,33 @@ def test_ekmany(): spice.ekcls(handle) assert not spice.failed() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover def test_ekaclc(): spice.kclear() ekpath = os.path.join(cwd, "example_ekaclc.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekaclc", 1, 2, 200, ["c1"], 200, - ["DATATYPE = CHARACTER*(*), INDEXED = TRUE"]) - spice.ekaclc(handle, segno, "c1", 10, ["1.0", "2.0"], [4, 4], [False, False], rcptrs, [0, 0]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekaclc", + 1, + 2, + 200, + ["c1"], + 200, + ["DATATYPE = CHARACTER*(*), INDEXED = TRUE"], + ) + spice.ekaclc( + handle, segno, "c1", 10, ["1.0", "2.0"], [4, 4], [False, False], rcptrs, [0, 0] + ) spice.ekffld(handle, segno, rcptrs) spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2323,16 +2733,26 @@ def test_ekacld(): spice.kclear() ekpath = os.path.join(cwd, "example_ekacld.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekacld", 1, 2, 200, ["c1"], 200, - ["DATATYPE = DOUBLE PRECISION, NULLS_OK = FALSE"]) - spice.ekacld(handle, segno, "c1", [1.0, 2.0], [1, 1], [False, False], rcptrs, [0, 0]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekacld", + 1, + 2, + 200, + ["c1"], + 200, + ["DATATYPE = DOUBLE PRECISION, NULLS_OK = FALSE"], + ) + spice.ekacld( + handle, segno, "c1", [1.0, 2.0], [1, 1], [False, False], rcptrs, [0, 0] + ) spice.ekffld(handle, segno, rcptrs) spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2340,16 +2760,24 @@ def test_ekacli(): spice.kclear() ekpath = os.path.join(cwd, "example_ekacli.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekacli", 1, 2, 200, ["c1"], 200, - ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekacli", + 1, + 2, + 200, + ["c1"], + 200, + ["DATATYPE = INTEGER, NULLS_OK = TRUE"], + ) spice.ekacli(handle, segno, "c1", [1, 2], [1, 1], [False, False], rcptrs, [0, 0]) spice.ekffld(handle, segno, rcptrs) spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2362,15 +2790,17 @@ def test_ekappr(): spice.kclear() ekpath = os.path.join(cwd, "example_ekappr.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno = spice.ekbseg(handle, "test_table_ekappr", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno = spice.ekbseg( + handle, "test_table_ekappr", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"] + ) recno = spice.ekappr(handle, segno) spice.ekacei(handle, segno, recno, "c1", 2, [1, 2], False) spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2378,19 +2808,19 @@ def test_ekbseg(): ekpath = os.path.join(cwd, "example_ekbseg.ek") spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, "Test EK", 100) - cnames = ['INT_COL_1'] + cnames = ["INT_COL_1"] cdecls = ["DATATYPE=INTEGER, INDEXED=TRUE, NULLS_OK=TRUE"] segno = spice.ekbseg(handle, "SCALAR_DATA", cnames, cdecls) recno = spice.ekappr(handle, segno) assert recno != -1 ordids = [x for x in range(5)] - spice.ekacei(handle, segno, recno, 'INT_COL_1', 5, ordids, False) + spice.ekacei(handle, segno, recno, "INT_COL_1", 5, ordids, False) spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2403,9 +2833,11 @@ def test_ekccnt(): spice.kclear() ekpath = os.path.join(cwd, "example_ekccnt.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno = spice.ekbseg(handle, "TEST_TABLE_EKCCNT", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno = spice.ekbseg( + handle, "TEST_TABLE_EKCCNT", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"] + ) recno = spice.ekappr(handle, segno) spice.ekacei(handle, segno, recno, "c1", 2, [1, 2], False) spice.ekcls(handle) @@ -2416,7 +2848,7 @@ def test_ekccnt(): assert spice.ekccnt("TEST_TABLE_EKCCNT") == 1 spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2424,9 +2856,11 @@ def test_ekcii(): spice.kclear() ekpath = os.path.join(cwd, "example_ekcii.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno = spice.ekbseg(handle, "TEST_TABLE_EKCII", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno = spice.ekbseg( + handle, "TEST_TABLE_EKCII", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"] + ) recno = spice.ekappr(handle, segno) spice.ekacei(handle, segno, recno, "c1", 2, [1, 2], False) spice.ekcls(handle) @@ -2443,9 +2877,11 @@ def test_ekcii(): assert attdsc.size == 1 assert attdsc.strlen == 1 assert not attdsc.indexd - assert attdsc.nullok # this used to be false, although clearly it should be true given the call to ekbseg + assert ( + attdsc.nullok + ) # this used to be false, although clearly it should be true given the call to ekbseg if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2453,12 +2889,12 @@ def test_ekcls(): spice.kclear() # same as ekopn test ekpath = os.path.join(cwd, "example_ekcls.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 80) spice.ekcls(handle) assert spice.exists(ekpath) if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover spice.kclear() @@ -2466,17 +2902,25 @@ def test_ekdelr(): spice.kclear() ekpath = os.path.join(cwd, "example_ekdelr.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekdelr", 1, 10, 200, ["c1"], 200, - ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekdelr", + 1, + 10, + 200, + ["c1"], + 200, + ["DATATYPE = INTEGER, NULLS_OK = TRUE"], + ) spice.ekacli(handle, segno, "c1", [1, 2], [1], [False, False], rcptrs, [1]) spice.ekffld(handle, segno, rcptrs) spice.ekdelr(handle, segno, 2) spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2490,16 +2934,24 @@ def test_ekffld(): spice.kclear() ekpath = os.path.join(cwd, "example_ekffld.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekffld", 1, 10, 200, ["c1"], 200, - ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekffld", + 1, + 10, + 200, + ["c1"], + 200, + ["DATATYPE = INTEGER, NULLS_OK = TRUE"], + ) spice.ekacli(handle, segno, "c1", [1, 2], [1], [False, False], rcptrs, [1]) spice.ekffld(handle, segno, rcptrs) spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2512,21 +2964,33 @@ def test_ekfind(): spice.kclear() ekpath = os.path.join(cwd, "example_ekfind.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekfind", 1, 2, 200, ["cc1"], 200, - ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekfind", + 1, + 2, + 200, + ["cc1"], + 200, + ["DATATYPE = INTEGER, NULLS_OK = TRUE"], + ) spice.ekacli(handle, segno, "cc1", [1, 2], [1, 1], [False, False], rcptrs, [0, 0]) spice.ekffld(handle, segno, rcptrs) spice.ekcls(handle) spice.kclear() spice.furnsh(ekpath) - nmrows, error, errmsg = spice.ekfind("SELECT CC1 FROM TEST_TABLE_EKFIND WHERE CC1 > 0", 100) - assert nmrows != 0 # should be 2 but I am not concerned about correctness in this case + nmrows, error, errmsg = spice.ekfind( + "SELECT CC1 FROM TEST_TABLE_EKFIND WHERE CC1 > 0", 100 + ) + assert ( + nmrows != 0 + ) # should be 2 but I am not concerned about correctness in this case assert not error spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2539,11 +3003,21 @@ def test_ekgc(): spice.kclear() ekpath = os.path.join(cwd, "example_ekgc.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekgc", 1, 2, 200, ["c1"], 200, - ["DATATYPE = CHARACTER*(*), INDEXED = TRUE"]) - spice.ekaclc(handle, segno, "c1", 10, ["1.0", "2.0"], [4, 4], [False, False], rcptrs, [0, 0]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekgc", + 1, + 2, + 200, + ["c1"], + 200, + ["DATATYPE = CHARACTER*(*), INDEXED = TRUE"], + ) + spice.ekaclc( + handle, segno, "c1", 10, ["1.0", "2.0"], [4, 4], [False, False], rcptrs, [0, 0] + ) spice.ekffld(handle, segno, rcptrs) spice.ekcls(handle) spice.kclear() @@ -2558,7 +3032,7 @@ def test_ekgc(): # assert c == "2.0" this fails, c is an empty string despite found being true. spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2566,11 +3040,21 @@ def test_ekgd(): spice.kclear() ekpath = os.path.join(cwd, "example_ekgd.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekgd", 1, 2, 200, ["c1"], 200, - ["DATATYPE = DOUBLE PRECISION, NULLS_OK = TRUE"]) - spice.ekacld(handle, segno, "c1", [1.0, 2.0], [1, 1], [False, False], rcptrs, [0, 0]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekgd", + 1, + 2, + 200, + ["c1"], + 200, + ["DATATYPE = DOUBLE PRECISION, NULLS_OK = TRUE"], + ) + spice.ekacld( + handle, segno, "c1", [1.0, 2.0], [1, 1], [False, False], rcptrs, [0, 0] + ) spice.ekffld(handle, segno, rcptrs) spice.ekcls(handle) spice.kclear() @@ -2585,7 +3069,7 @@ def test_ekgd(): assert d == 2.0 spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2593,10 +3077,18 @@ def test_ekgi(): spice.kclear() ekpath = os.path.join(cwd, "example_ekgi.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekgi", 1, 2, 200, ["c1"], 200, - ["DATATYPE = INTEGER, NULLS_OK = FALSE"]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekgi", + 1, + 2, + 200, + ["c1"], + 200, + ["DATATYPE = INTEGER, NULLS_OK = FALSE"], + ) spice.ekacli(handle, segno, "c1", [1, 2], [1, 1], [False, False], rcptrs, [0, 0]) spice.ekffld(handle, segno, rcptrs) spice.ekcls(handle) @@ -2612,7 +3104,7 @@ def test_ekgi(): assert i == 2 spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2621,16 +3113,24 @@ def test_ekifld(): spice.kclear() ekpath = os.path.join(cwd, "example_ekifld.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekifld", 1, 2, 200, ["c1"], 200, - ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekifld", + 1, + 2, + 200, + ["c1"], + 200, + ["DATATYPE = INTEGER, NULLS_OK = TRUE"], + ) spice.ekacli(handle, segno, "c1", [1, 2], [1, 1], [False, False], rcptrs, [0, 0]) spice.ekffld(handle, segno, rcptrs) spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2638,9 +3138,11 @@ def test_eklef(): spice.kclear() ekpath = os.path.join(cwd, "example_eklef.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno = spice.ekbseg(handle, "test_table_eklef", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno = spice.ekbseg( + handle, "test_table_eklef", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"] + ) recno = spice.ekappr(handle, segno) spice.ekacei(handle, segno, recno, "c1", 2, [1, 2], False) spice.ekcls(handle) @@ -2649,16 +3151,18 @@ def test_eklef(): assert handle is not None spice.ekuef(handle) if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover def test_eknseg(): spice.kclear() ekpath = os.path.join(cwd, "example_eknseg.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno = spice.ekbseg(handle, "TEST_TABLE_EKNSEG", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno = spice.ekbseg( + handle, "TEST_TABLE_EKNSEG", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"] + ) recno = spice.ekappr(handle, segno) spice.ekacei(handle, segno, recno, "c1", 2, [1, 2], False) spice.ekcls(handle) @@ -2668,7 +3172,7 @@ def test_eknseg(): spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2680,20 +3184,20 @@ def test_ekopn(): spice.kclear() ekpath = os.path.join(cwd, "example_ek.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 80) spice.ekcls(handle) spice.kclear() assert spice.exists(ekpath) if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover def test_ekopr(): spice.kclear() ekpath = os.path.join(cwd, "example_ekopr.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 80) spice.ekcls(handle) assert spice.exists(ekpath) @@ -2702,7 +3206,7 @@ def test_ekopr(): spice.ekcls(testhandle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover def test_ekops(): @@ -2717,7 +3221,7 @@ def test_ekopw(): spice.kclear() ekpath = os.path.join(cwd, "example_ekopw.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 80) spice.ekcls(handle) assert spice.exists(ekpath) @@ -2725,7 +3229,7 @@ def test_ekopw(): assert testhandle is not None spice.ekcls(testhandle) if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover spice.kclear() @@ -2733,10 +3237,18 @@ def test_ekssum(): spice.kclear() ekpath = os.path.join(cwd, "example_ekssum.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno, rcptrs = spice.ekifld(handle, "test_table_ekssum", 1, 2, 200, ["c1"], 200, - ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno, rcptrs = spice.ekifld( + handle, + "test_table_ekssum", + 1, + 2, + 200, + ["c1"], + 200, + ["DATATYPE = INTEGER, NULLS_OK = TRUE"], + ) spice.ekacli(handle, segno, "c1", [1, 2], [1, 1], [False, False], rcptrs, [0, 0]) spice.ekffld(handle, segno, rcptrs) segsum = spice.ekssum(handle, segno) @@ -2751,7 +3263,7 @@ def test_ekssum(): spice.ekcls(handle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2759,9 +3271,11 @@ def test_ektnam(): spice.kclear() ekpath = os.path.join(cwd, "example_ektnam.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 0) - segno = spice.ekbseg(handle, "TEST_TABLE_EKTNAM", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"]) + segno = spice.ekbseg( + handle, "TEST_TABLE_EKTNAM", ["c1"], ["DATATYPE = INTEGER, NULLS_OK = TRUE"] + ) recno = spice.ekappr(handle, segno) spice.ekacei(handle, segno, recno, "c1", 2, [1, 2], False) spice.ekcls(handle) @@ -2772,7 +3286,7 @@ def test_ektnam(): assert spice.ekccnt("TEST_TABLE_EKTNAM") == 1 spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover assert not spice.exists(ekpath) @@ -2792,7 +3306,7 @@ def test_ekuef(): spice.kclear() ekpath = os.path.join(cwd, "example_ekuef.ek") if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover handle = spice.ekopn(ekpath, ekpath, 80) spice.ekcls(handle) spice.kclear() @@ -2803,7 +3317,7 @@ def test_ekuef(): spice.ekcls(testhandle) spice.kclear() if spice.exists(ekpath): - os.remove(ekpath) # pragma: no cover + os.remove(ekpath) # pragma: no cover def test_el2cgv(): @@ -2813,48 +3327,48 @@ def test_el2cgv(): smajor, sminor = spice.saelgv(vec1, vec2) ellipse = spice.cgv2el(center, smajor, sminor) outCenter, outSmajor, outSminor = spice.el2cgv(ellipse) - expectedCenter = [1.0, 1.0, 1.0] - expectedSmajor = [np.sqrt(2.0), 0.0, np.sqrt(2.0)] - expectedSminor = [0.0, np.sqrt(2.0), 0.0] - npt.assert_array_almost_equal(outCenter, expectedCenter) - npt.assert_array_almost_equal(outSmajor, expectedSmajor) - npt.assert_array_almost_equal(outSminor, expectedSminor) + expected_center = [1.0, 1.0, 1.0] + expected_s_major = [np.sqrt(2.0), 0.0, np.sqrt(2.0)] + expected_s_minor = [0.0, np.sqrt(2.0), 0.0] + npt.assert_array_almost_equal(outCenter, expected_center) + npt.assert_array_almost_equal(outSmajor, expected_s_major) + npt.assert_array_almost_equal(outSminor, expected_s_minor) def test_elemc(): - testCellOne = spice.cell_char(10, 10) - spice.insrtc("one", testCellOne) - spice.insrtc("two", testCellOne) - spice.insrtc("three", testCellOne) - assert spice.elemc("one", testCellOne) - assert spice.elemc("two", testCellOne) - assert spice.elemc("three", testCellOne) - assert not spice.elemc("not", testCellOne) - assert not spice.elemc("there", testCellOne) + test_cell_one = spice.cell_char(10, 10) + spice.insrtc("one", test_cell_one) + spice.insrtc("two", test_cell_one) + spice.insrtc("three", test_cell_one) + assert spice.elemc("one", test_cell_one) + assert spice.elemc("two", test_cell_one) + assert spice.elemc("three", test_cell_one) + assert not spice.elemc("not", test_cell_one) + assert not spice.elemc("there", test_cell_one) def test_elemd(): - testCellOne = spice.cell_double(8) - spice.insrtd(1.0, testCellOne) - spice.insrtd(2.0, testCellOne) - spice.insrtd(3.0, testCellOne) - assert spice.elemd(1.0, testCellOne) - assert spice.elemd(2.0, testCellOne) - assert spice.elemd(3.0, testCellOne) - assert not spice.elemd(4.0, testCellOne) - assert not spice.elemd(-1.0, testCellOne) + test_cell_one = spice.cell_double(8) + spice.insrtd(1.0, test_cell_one) + spice.insrtd(2.0, test_cell_one) + spice.insrtd(3.0, test_cell_one) + assert spice.elemd(1.0, test_cell_one) + assert spice.elemd(2.0, test_cell_one) + assert spice.elemd(3.0, test_cell_one) + assert not spice.elemd(4.0, test_cell_one) + assert not spice.elemd(-1.0, test_cell_one) def test_elemi(): - testCellOne = spice.cell_int(8) - spice.insrti(1, testCellOne) - spice.insrti(2, testCellOne) - spice.insrti(3, testCellOne) - assert spice.elemi(1, testCellOne) - assert spice.elemi(2, testCellOne) - assert spice.elemi(3, testCellOne) - assert not spice.elemi(4, testCellOne) - assert not spice.elemi(-1, testCellOne) + test_cell_one = spice.cell_int(8) + spice.insrti(1, test_cell_one) + spice.insrti(2, test_cell_one) + spice.insrti(3, test_cell_one) + assert spice.elemi(1, test_cell_one) + assert spice.elemi(2, test_cell_one) + assert spice.elemi(3, test_cell_one) + assert not spice.elemi(4, test_cell_one) + assert not spice.elemi(-1, test_cell_one) def test_eqncpv(): @@ -2863,16 +3377,31 @@ def test_eqncpv(): ecc = 0.1 a = p / (1.0 - ecc) n = np.sqrt(gm / a) / a - argp = 30. * spice.rpd() - node = 15. * spice.rpd() - inc = 10. * spice.rpd() - m0 = 45. * spice.rpd() + argp = 30.0 * spice.rpd() + node = 15.0 * spice.rpd() + inc = 10.0 * spice.rpd() + m0 = 45.0 * spice.rpd() t0 = -100000000.0 - eqel = [a, ecc * np.sin(argp + node), ecc * np.cos(argp + node), m0 + argp + node, - np.tan(inc / 2.0) * np.sin(node), np.tan(inc / 2.0) * np.cos(node), 0.0, n, 0.0] + eqel = [ + a, + ecc * np.sin(argp + node), + ecc * np.cos(argp + node), + m0 + argp + node, + np.tan(inc / 2.0) * np.sin(node), + np.tan(inc / 2.0) * np.cos(node), + 0.0, + n, + 0.0, + ] state = spice.eqncpv(t0 - 9750.0, t0, eqel, spice.halfpi() * -1, spice.halfpi()) - expected = [-10732.167433285387, 3902.505790600528, 1154.4516152766892, - -2.540766899262123, -5.15226920298345, -0.7615758062877463] + expected = [ + -10732.167433285387, + 3902.505790600528, + 1154.4516152766892, + -2.540766899262123, + -5.15226920298345, + -0.7615758062877463, + ] npt.assert_array_almost_equal(expected, state, decimal=5) @@ -2935,12 +3464,14 @@ def test_et2lst(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2004 may 17 16:30:00") - hr, mn, sc, time, ampm = spice.et2lst(et, 399, 281.49521300000004 * spice.rpd(), "planetocentric", 51, 51) + hr, mn, sc, time, ampm = spice.et2lst( + et, 399, 281.49521300000004 * spice.rpd(), "planetocentric", 51, 51 + ) assert hr == 11 assert mn == 19 assert sc == 22 assert time == "11:19:22" - assert ampm == '11:19:22 A.M.' + assert ampm == "11:19:22 A.M." spice.kclear() @@ -2960,16 +3491,16 @@ def test_et2utc_vectorized(): output = spice.et2utc(3 * [et], "J", 6) assert output == 3 * ["JD 2445438.006415"] spice.kclear() - + def test_etcal(): et = np.arange(0, 20) cal = spice.etcal(et[0]) - assert cal == '2000 JAN 01 12:00:00.000' + assert cal == "2000 JAN 01 12:00:00.000" calArr = spice.etcal(et) assert calArr[0] == cal - assert calArr[1] == '2000 JAN 01 12:00:01.000' - assert calArr[-1] == '2000 JAN 01 12:00:19.000' + assert calArr[1] == "2000 JAN 01 12:00:01.000" + assert calArr[-1] == "2000 JAN 01 12:00:19.000" def test_eul2m(): @@ -2981,9 +3512,15 @@ def test_eul2xf(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("Jan 1, 2009") - expected = spice.sxform('IAU_EARTH', 'J2000', et) - eul = [1.571803284049681, 0.0008750002978301174, 2.9555269829740034, - 3.5458495690569166e-12, 3.080552365717176e-12, -7.292115373266558e-05] + expected = spice.sxform("IAU_EARTH", "J2000", et) + eul = [ + 1.571803284049681, + 0.0008750002978301174, + 2.9555269829740034, + 3.5458495690569166e-12, + 3.080552365717176e-12, + -7.292115373266558e-05, + ] out = spice.eul2xf(eul, 3, 1, 3) npt.assert_array_almost_equal(out, expected) spice.kclear() @@ -2992,42 +3529,94 @@ def test_eul2xf(): def test_ev2lin(): spice.kclear() # lightsail 2 - tle = ['1 44420U 19036AC 19311.70264562 .00005403 00000-0 12176-2 0 9991', - '2 44420 24.0060 72.9267 0016343 241.6999 118.1833 14.53580129 17852'] + tle = [ + "1 44420U 19036AC 19311.70264562 .00005403 00000-0 12176-2 0 9991", + "2 44420 24.0060 72.9267 0016343 241.6999 118.1833 14.53580129 17852", + ] spice.furnsh(CoreKernels.testMetaKernel) epoch, elems = spice.getelm(2019, 75, tle) # adding 3 seconds manually as something is wrong with provided tle epoch or the lsk kernel was not used when generating the expected output - expected_elems = np.array([1.63715519939676e-10, 0, 0.0012176, 0.418983740233759, 1.27281102761415, 0.0016343, 4.21845905674104, 2.06268770587221, 0.0634243979815348, 626417577.764171]) + expected_elems = np.array( + [ + 1.63715519939676e-10, + 0, + 0.0012176, + 0.418983740233759, + 1.27281102761415, + 0.0016343, + 4.21845905674104, + 2.06268770587221, + 0.0634243979815348, + 626417577.764171, + ] + ) expected_epoch = 626417577.764171 npt.assert_array_almost_equal(expected_elems, elems) npt.assert_almost_equal(epoch, expected_epoch) # test ev2lin - geophs = [1.082616e-3, -2.53881e-6, -1.65597e-6, 7.43669161e-2, 120.0, 78.0, 6378.135, 1.0] + geophs = [ + 1.082616e-3, + -2.53881e-6, + -1.65597e-6, + 7.43669161e-2, + 120.0, + 78.0, + 6378.135, + 1.0, + ] # test at t0 state_0 = spice.ev2lin(epoch, geophs, elems) - expected_state_0 = np.array([2083.32107340449, 6782.80001655649, -0.0505350227151017, -6.54335340061531, 2.01771874263164, 3.0515091420169]) + expected_state_0 = np.array( + [ + 2083.32107340449, + 6782.80001655649, + -0.0505350227151017, + -6.54335340061531, + 2.01771874263164, + 3.0515091420169, + ] + ) npt.assert_array_almost_equal(expected_state_0, state_0) # test at t3600 - state_3600 = spice.ev2lin(epoch+3600, geophs, elems) - expected_state_3600 = np.array([2175.83882413485, -6497.55066037852, -1786.06093660828, 6.52417720498168, 2.84696745594303, -2.39736415840424]) + state_3600 = spice.ev2lin(epoch + 3600, geophs, elems) + expected_state_3600 = np.array( + [ + 2175.83882413485, + -6497.55066037852, + -1786.06093660828, + 6.52417720498168, + 2.84696745594303, + -2.39736415840424, + ] + ) npt.assert_array_almost_equal(expected_state_3600, state_3600) spice.kclear() # test at t86400 - state_86400 = spice.ev2lin(epoch+86400, geophs, elems) - expected_state_86400 = np.array([-193.463324028138, -6986.20486685614, -1154.18287208625, 6.96216415803069, 0.276466105258879, -2.79931910593688]) + state_86400 = spice.ev2lin(epoch + 86400, geophs, elems) + expected_state_86400 = np.array( + [ + -193.463324028138, + -6986.20486685614, + -1154.18287208625, + 6.96216415803069, + 0.276466105258879, + -2.79931910593688, + ] + ) npt.assert_array_almost_equal(expected_state_86400, state_86400) spice.kclear() + def test_exists(): assert spice.exists(CoreKernels.testMetaKernel) def test_expool(): spice.kclear() - textbuf = ['DELTET/K = 1.657D-3', 'DELTET/EB = 1.671D-2'] + textbuf = ["DELTET/K = 1.657D-3", "DELTET/EB = 1.671D-2"] spice.lmpool(textbuf) - assert spice.expool('DELTET/K') - assert spice.expool('DELTET/EB') + assert spice.expool("DELTET/K") + assert spice.expool("DELTET/EB") spice.kclear() @@ -3057,7 +3646,9 @@ def test_fovray(): camid = spice.bodn2c("CASSINI_ISS_NAC") shape, frame, bsight, n, bounds = spice.getfov(camid, 4) et = spice.str2et("2013 FEB 25 11:50:00 UTC") - visible = spice.fovray("CASSINI_ISS_NAC", [0.0, 0.0, 1.0], frame, "S", "CASSINI", et) + visible = spice.fovray( + "CASSINI_ISS_NAC", [0.0, 0.0, 1.0], frame, "S", "CASSINI", et + ) assert visible is True spice.kclear() @@ -3076,7 +3667,15 @@ def test_fovtrg(): spice.furnsh(CassiniKernels.cassCk) # core of test et = spice.str2et("2013 FEB 25 11:50:00 UTC") - visible = spice.fovtrg("CASSINI_ISS_NAC", "Enceladus", "Ellipsoid", "IAU_ENCELADUS", "LT+S", "CASSINI", et) + visible = spice.fovtrg( + "CASSINI_ISS_NAC", + "Enceladus", + "Ellipsoid", + "IAU_ENCELADUS", + "LT+S", + "CASSINI", + et, + ) assert visible is True spice.kclear() @@ -3103,10 +3702,11 @@ def test_frmnam(): def test_ftncls(): import datetime + spice.reset() spice.kclear() # Create temporary filename - FTNCLS=os.path.join(cwd, 'ex_ftncls.txt') + FTNCLS = os.path.join(cwd, "ex_ftncls.txt") # Ensure file does not exist if spice.exists(FTNCLS): os.remove(FTNCLS) # pragma no cover @@ -3145,10 +3745,11 @@ def test_furnsh_vectorized(): def test_gcpool(): # same as pcpool test import string + spice.kclear() data = [j + str(i) for i, j in enumerate(list(string.ascii_lowercase))] - spice.pcpool('pcpool_test', data) - cvals = spice.gcpool('pcpool_test', 0, 30) + spice.pcpool("pcpool_test", data) + cvals = spice.gcpool("pcpool_test", 0, 30) assert data == cvals spice.kclear() @@ -3157,8 +3758,8 @@ def test_gdpool(): # same as pdpool test spice.kclear() data = np.arange(0.0, 10.0) - spice.pdpool('pdpool_array', data) - dvals = spice.gdpool('pdpool_array', 0, 30) + spice.pdpool("pdpool_array", data) + dvals = spice.gdpool("pdpool_array", 0, 30) npt.assert_array_almost_equal(data, dvals) spice.kclear() @@ -3166,7 +3767,7 @@ def test_gdpool(): def test_georec(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - size, radii = spice.bodvrd('EARTH', 'RADII', 3) + size, radii = spice.bodvrd("EARTH", "RADII", 3) flat = (radii[0] - radii[2]) / radii[0] lon = 118.0 * spice.rpd() lat = 32.0 * spice.rpd() @@ -3179,13 +3780,24 @@ def test_georec(): def test_getelm(): spice.kclear() - tle = ['1 18123U 87 53 A 87324.61041692 -.00000023 00000-0 -75103-5 0 00675', - '2 18123 98.8296 152.0074 0014950 168.7820 191.3688 14.12912554 21686'] + tle = [ + "1 18123U 87 53 A 87324.61041692 -.00000023 00000-0 -75103-5 0 00675", + "2 18123 98.8296 152.0074 0014950 168.7820 191.3688 14.12912554 21686", + ] spice.furnsh(CoreKernels.testMetaKernel) epoch, elems = spice.getelm(1950, 75, tle) - expected_elems = [-6.969196665949579e-13, 0.0, -7.510300000000001e-06, - 1.724901918428988, 2.653029617396028, 0.001495, - 2.9458016181010693, 3.3400156455905243, 0.06164994027515544, -382310404.79526937] + expected_elems = [ + -6.969196665949579e-13, + 0.0, + -7.510300000000001e-06, + 1.724901918428988, + 2.653029617396028, + 0.001495, + 2.9458016181010693, + 3.3400156455905243, + 0.06164994027515544, + -382310404.79526937, + ] expected_epoch = -382310404.79526937 npt.assert_array_almost_equal(expected_elems, elems) npt.assert_almost_equal(epoch, expected_epoch) @@ -3200,11 +3812,11 @@ def test_getfat(): def test_getfov(): spice.kclear() - kernel = os.path.join(cwd, 'getfov_test.ti') + kernel = os.path.join(cwd, "getfov_test.ti") if spice.exists(kernel): - os.remove(kernel) # pragma: no cover - with open(kernel, 'w') as kernelFile: - kernelFile.write('\\begindata\n') + os.remove(kernel) # pragma: no cover + with open(kernel, "w") as kernelFile: + kernelFile.write("\\begindata\n") kernelFile.write("INS-999004_FOV_SHAPE = 'POLYGON'\n") kernelFile.write("INS-999004_FOV_FRAME = 'SC999_INST004'\n") kernelFile.write("INS-999004_BORESIGHT = ( 0.0, 1.0, 0.0 )\n") @@ -3223,7 +3835,7 @@ def test_getfov(): npt.assert_array_almost_equal(expected, bounds) spice.kclear() if spice.exists(kernel): - os.remove(kernel) # pragma: no cover + os.remove(kernel) # pragma: no cover def test_getmsg(): @@ -3245,26 +3857,38 @@ def test_gfclrh(): def test_gfdist(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et0 = spice.str2et('2007 JAN 01 00:00:00 TDB') - et1 = spice.str2et('2007 APR 01 00:00:00 TDB') + et0 = spice.str2et("2007 JAN 01 00:00:00 TDB") + et1 = spice.str2et("2007 APR 01 00:00:00 TDB") cnfine = spice.cell_double(2) spice.wninsd(et0, et1, cnfine) result = spice.cell_double(1000) - spice.gfdist("moon", "none", "earth", ">", 400000, 0.0, spice.spd(), 1000, cnfine, result) + spice.gfdist( + "moon", "none", "earth", ">", 400000, 0.0, spice.spd(), 1000, cnfine, result + ) count = spice.wncard(result) assert count == 4 - tempResults = [] + temp_results = [] for i in range(0, count): left, right = spice.wnfetd(result, i) - timstrLeft = spice.timout(left, 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND', 41) - timstrRight = spice.timout(right, 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND', 41) - tempResults.append(timstrLeft) - tempResults.append(timstrRight) - expected = ['2007-JAN-08 00:11:07.661897 (TDB)', '2007-JAN-13 06:37:47.937762 (TDB)', - '2007-FEB-04 07:02:35.320555 (TDB)', '2007-FEB-10 09:31:01.829206 (TDB)', - '2007-MAR-03 00:20:25.228066 (TDB)', '2007-MAR-10 14:04:38.482902 (TDB)', - '2007-MAR-29 22:53:58.186230 (TDB)', '2007-APR-01 00:00:00.000000 (TDB)'] - assert tempResults == expected + timstr_left = spice.timout( + left, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41 + ) + timstr_right = spice.timout( + right, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41 + ) + temp_results.append(timstr_left) + temp_results.append(timstr_right) + expected = [ + "2007-JAN-08 00:11:07.661897 (TDB)", + "2007-JAN-13 06:37:47.937762 (TDB)", + "2007-FEB-04 07:02:35.320555 (TDB)", + "2007-FEB-10 09:31:01.829206 (TDB)", + "2007-MAR-03 00:20:25.228066 (TDB)", + "2007-MAR-10 14:04:38.482902 (TDB)", + "2007-MAR-29 22:53:58.186230 (TDB)", + "2007-APR-01 00:00:00.000000 (TDB)", + ] + assert temp_results == expected spice.kclear() @@ -3273,12 +3897,12 @@ def test_gfevnt(): spice.furnsh(CoreKernels.testMetaKernel) # et_start = spice.str2et("2001 jan 01 00:00:00.000") - et_end = spice.str2et("2001 dec 31 00:00:00.000") - cnfine = spice.cell_double(2) + et_end = spice.str2et("2001 dec 31 00:00:00.000") + cnfine = spice.cell_double(2) spice.wninsd(et_start, et_end, cnfine) - result = spice.cell_double(1000) - qpnams = ["TARGET", "OBSERVER", "ABCORR"] - qcpars = ["MOON ", "EARTH ", "LT+S "] + result = spice.cell_double(1000) + qpnams = ["TARGET", "OBSERVER", "ABCORR"] + qcpars = ["MOON ", "EARTH ", "LT+S "] # Set the step size to 1/1000 day and convert to seconds spice.gfsstp(0.001 * spice.spd()) # setup callbacks @@ -3292,18 +3916,39 @@ def test_gfevnt(): qipars = np.zeros(10, dtype=np.int32) qlpars = np.zeros(10, dtype=np.int32) # call gfevnt - spice.gfevnt(udstep, udrefn, 'DISTANCE', 3, 81, qpnams, qcpars, - qdpars, qipars, qlpars, 'LOCMAX', 0, 1.e-6, 0, - True, udrepi, udrepu, udrepf, 10000, - True, udbail, cnfine, result) + spice.gfevnt( + udstep, + udrefn, + "DISTANCE", + 3, + 81, + qpnams, + qcpars, + qdpars, + qipars, + qlpars, + "LOCMAX", + 0, + 1.0e-6, + 0, + True, + udrepi, + udrepu, + udrepf, + 10000, + True, + udbail, + cnfine, + result, + ) # Verify the expected results assert len(result) == 26 sTimout = "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND" - assert spice.timout(result[0], sTimout) == '2001-JAN-24 19:22:01.418715 (TDB)' - assert spice.timout(result[1], sTimout) == '2001-JAN-24 19:22:01.418715 (TDB)' - assert spice.timout(result[2], sTimout) == '2001-FEB-20 21:52:07.900872 (TDB)' - assert spice.timout(result[3], sTimout) == '2001-FEB-20 21:52:07.900872 (TDB)' + assert spice.timout(result[0], sTimout) == "2001-JAN-24 19:22:01.418715 (TDB)" + assert spice.timout(result[1], sTimout) == "2001-JAN-24 19:22:01.418715 (TDB)" + assert spice.timout(result[2], sTimout) == "2001-FEB-20 21:52:07.900872 (TDB)" + assert spice.timout(result[3], sTimout) == "2001-FEB-20 21:52:07.900872 (TDB)" # Cleanup if spice.gfbail(): spice.gfclrh() @@ -3324,10 +3969,10 @@ def test_gffove(): # Cassini ISS NAC observed Enceladus on 2013-FEB-25 from ~11:00 to ~12:00 # Split confinement window, from continuous CK coverage, into two pieces et_start = spice.str2et("2013-FEB-25 10:00:00.000") - et_end = spice.str2et("2013-FEB-25 11:45:00.000") - cnfine = spice.cell_double(2) + et_end = spice.str2et("2013-FEB-25 11:45:00.000") + cnfine = spice.cell_double(2) spice.wninsd(et_start, et_end, cnfine) - result = spice.cell_double(1000) + result = spice.cell_double(1000) # call gffove udstep = spiceypy.utils.callbacks.SpiceUDSTEP(spice.gfstep) udrefn = spiceypy.utils.callbacks.SpiceUDREFN(spice.gfrefn) @@ -3336,15 +3981,31 @@ def test_gffove(): udrepf = spiceypy.utils.callbacks.SpiceUDREPF(spice.gfrepf) udbail = spiceypy.utils.callbacks.SpiceUDBAIL(spice.gfbail) spice.gfsstp(1.0) - spice.gffove('CASSINI_ISS_NAC', 'ELLIPSOID', [0.0, 0.0, 0.0], 'ENCELADUS', 'IAU_ENCELADUS', - 'LT+S', 'CASSINI', 1.e-6, udstep, udrefn, True, - udrepi, udrepu, udrepf, True, udbail, - cnfine, result) + spice.gffove( + "CASSINI_ISS_NAC", + "ELLIPSOID", + [0.0, 0.0, 0.0], + "ENCELADUS", + "IAU_ENCELADUS", + "LT+S", + "CASSINI", + 1.0e-6, + udstep, + udrefn, + True, + udrepi, + udrepu, + udrepf, + True, + udbail, + cnfine, + result, + ) # Verify the expected results assert len(result) == 2 sTimout = "YYYY-MON-DD HR:MN:SC UTC ::RND" - assert spice.timout(result[0], sTimout) == '2013-FEB-25 10:42:33 UTC' - assert spice.timout(result[1], sTimout) == '2013-FEB-25 11:45:00 UTC' + assert spice.timout(result[0], sTimout) == "2013-FEB-25 10:42:33 UTC" + assert spice.timout(result[1], sTimout) == "2013-FEB-25 11:45:00 UTC" # Cleanup if spice.gfbail(): spice.gfclrh() @@ -3355,35 +4016,65 @@ def test_gffove(): def test_gfilum(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - spice.furnsh(ExtraKernels.marsSpk) # to get Phobos ephemeris + spice.furnsh(ExtraKernels.marsSpk) # to get Phobos ephemeris # Hard-code the future position of MER-1 # pos, lt = spice.spkpos("MER-1", spice.str2et("2006 OCT 02 00:00:00 UTC"), "iau_mars", "CN+S", "Mars") - pos = [3376.17890941875839416753, -325.55203839445334779157, -121.47422900638389364758] + pos = [ + 3376.17890941875839416753, + -325.55203839445334779157, + -121.47422900638389364758, + ] # Two-month Viking orbiter window for Phobos; # - marsSPK runs from [1971 OCT 01] to [1972 OCT 01] startET = spice.str2et("1971 OCT 02 00:00:00 UTC") - endET = spice.str2et("1971 NOV 30 12:00:00 UTC") + endET = spice.str2et("1971 NOV 30 12:00:00 UTC") # Create confining and result windows for incidence angle GF check - cnfine = spice.cell_double(2000) + cnfine = spice.cell_double(2000) spice.wninsd(startET, endET, cnfine) - wnsolr = spice.cell_double(2000) + wnsolr = spice.cell_double(2000) # Find windows where solar incidence angle at MER-1 position is < 60deg - spice.gfilum("Ellipsoid", "INCIDENCE", "Mars", "Sun", - "iau_mars", "CN+S", "PHOBOS", pos, - "<", 60.0 * spice.rpd(), 0.0, 21600.0, - 1000, cnfine, wnsolr) + spice.gfilum( + "Ellipsoid", + "INCIDENCE", + "Mars", + "Sun", + "iau_mars", + "CN+S", + "PHOBOS", + pos, + "<", + 60.0 * spice.rpd(), + 0.0, + 21600.0, + 1000, + cnfine, + wnsolr, + ) # Create result window for emission angle GF check result = spice.cell_double(2000) # Find windows, within solar incidence angle windows found above (wnsolar), # where emission angle from MER-1 position to Phobos is < 20deg - spice.gfilum("Ellipsoid", "EMISSION", "Mars", "Sun", - "iau_mars", "CN+S", "PHOBOS", pos, - "<", 20.0 * spice.rpd(), 0.0, 900.0, - 1000, wnsolr, result) + spice.gfilum( + "Ellipsoid", + "EMISSION", + "Mars", + "Sun", + "iau_mars", + "CN+S", + "PHOBOS", + pos, + "<", + 20.0 * spice.rpd(), + 0.0, + 900.0, + 1000, + wnsolr, + result, + ) # Ensure there were some results assert spice.wncard(result) > 0 - startEpoch = spice.timout(result[0], "YYYY MON DD HR:MN:SC.###### UTC") - endEpoch = spice.timout(result[-1], "YYYY MON DD HR:MN:SC.###### UTC") + startEpoch = spice.timout(result[0], "YYYY MON DD HR:MN:SC.###### UTC") + endEpoch = spice.timout(result[-1], "YYYY MON DD HR:MN:SC.###### UTC") # Check times of results assert startEpoch.startswith("1971 OCT 02") assert endEpoch.startswith("1971 NOV 29") @@ -3402,8 +4093,8 @@ def test_gfocce(): if spice.gfbail(): spice.gfclrh() spice.furnsh(CoreKernels.testMetaKernel) - et0 = spice.str2et('2001 DEC 01 00:00:00 TDB') - et1 = spice.str2et('2002 JAN 01 00:00:00 TDB') + et0 = spice.str2et("2001 DEC 01 00:00:00 TDB") + et1 = spice.str2et("2002 JAN 01 00:00:00 TDB") cnfine = spice.cell_double(2) spice.wninsd(et0, et1, cnfine) result = spice.cell_double(1000) @@ -3415,10 +4106,28 @@ def test_gfocce(): udrepf = spiceypy.utils.callbacks.SpiceUDREPF(spice.gfrepf) udbail = spiceypy.utils.callbacks.SpiceUDBAIL(spice.gfbail) # call gfocce - spice.gfocce("Any", "moon", "ellipsoid", "iau_moon", "sun", - "ellipsoid", "iau_sun", "lt", "earth", 1.e-6, - udstep, udrefn, True, udrepi, udrepu, udrepf, - True, udbail, cnfine, result) + spice.gfocce( + "Any", + "moon", + "ellipsoid", + "iau_moon", + "sun", + "ellipsoid", + "iau_sun", + "lt", + "earth", + 1.0e-6, + udstep, + udrefn, + True, + udrepi, + udrepu, + udrepf, + True, + udbail, + cnfine, + result, + ) if spice.gfbail(): spice.gfclrh() count = spice.wncard(result) @@ -3429,76 +4138,149 @@ def test_gfocce(): def test_gfoclt(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et0 = spice.str2et('2001 DEC 01 00:00:00 TDB') - et1 = spice.str2et('2002 JAN 01 00:00:00 TDB') + et0 = spice.str2et("2001 DEC 01 00:00:00 TDB") + et1 = spice.str2et("2002 JAN 01 00:00:00 TDB") cnfine = spice.cell_double(2) spice.wninsd(et0, et1, cnfine) result = spice.cell_double(1000) - spice.gfoclt("any", "moon", "ellipsoid", "iau_moon", "sun", - "ellipsoid", "iau_sun", "lt", "earth", 180.0, cnfine, result) + spice.gfoclt( + "any", + "moon", + "ellipsoid", + "iau_moon", + "sun", + "ellipsoid", + "iau_sun", + "lt", + "earth", + 180.0, + cnfine, + result, + ) count = spice.wncard(result) assert count == 1 start, end = spice.wnfetd(result, 0) - startTime = spice.timout(start, 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND', 41) - endTime = spice.timout(end, 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND', 41) - assert startTime == "2001-DEC-14 20:10:14.203347 (TDB)" - assert endTime == "2001-DEC-14 21:35:50.328804 (TDB)" + start_time = spice.timout( + start, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41 + ) + end_time = spice.timout(end, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41) + assert start_time == "2001-DEC-14 20:10:14.203347 (TDB)" + assert end_time == "2001-DEC-14 21:35:50.328804 (TDB)" spice.kclear() def test_gfpa(): relate = ["=", "<", ">", "LOCMIN", "ABSMIN", "LOCMAX", "ABSMAX"] - expected = {"=": ['2006-DEC-02 13:31:34.425', '2006-DEC-02 13:31:34.425', '2006-DEC-07 14:07:55.480', '2006-DEC-07 14:07:55.480', - '2007-JAN-01 00:00:00.007', '2007-JAN-01 00:00:00.007', '2007-JAN-06 08:16:25.522', '2007-JAN-06 08:16:25.522', - '2007-JAN-30 11:41:32.568', '2007-JAN-30 11:41:32.568'], - "<": ['2006-DEC-02 13:31:34.425', '2006-DEC-07 14:07:55.480', '2007-JAN-01 00:00:00.007', '2007-JAN-06 08:16:25.522', - '2007-JAN-30 11:41:32.568', '2007-JAN-31 00:00:00.000'], - ">": ['2006-DEC-01 00:00:00.000', '2006-DEC-02 13:31:34.425', '2006-DEC-07 14:07:55.480', '2007-JAN-01 00:00:00.007', - '2007-JAN-06 08:16:25.522', '2007-JAN-30 11:41:32.568'], - "LOCMIN": ['2006-DEC-05 00:16:50.327', '2006-DEC-05 00:16:50.327', '2007-JAN-03 14:18:31.987', '2007-JAN-03 14:18:31.987'], - "ABSMIN": ['2007-JAN-03 14:18:31.987', '2007-JAN-03 14:18:31.987'], - "LOCMAX": ['2006-DEC-20 14:09:10.402', '2006-DEC-20 14:09:10.402', '2007-JAN-19 04:27:54.610', '2007-JAN-19 04:27:54.610'], - "ABSMAX": ['2007-JAN-19 04:27:54.610', '2007-JAN-19 04:27:54.610']} - spice.kclear() - spice.furnsh(CoreKernels.testMetaKernel) - et0 = spice.str2et('2006 DEC 01') - et1 = spice.str2et('2007 JAN 31') + expected = { + "=": [ + "2006-DEC-02 13:31:34.425", + "2006-DEC-02 13:31:34.425", + "2006-DEC-07 14:07:55.480", + "2006-DEC-07 14:07:55.480", + "2007-JAN-01 00:00:00.007", + "2007-JAN-01 00:00:00.007", + "2007-JAN-06 08:16:25.522", + "2007-JAN-06 08:16:25.522", + "2007-JAN-30 11:41:32.568", + "2007-JAN-30 11:41:32.568", + ], + "<": [ + "2006-DEC-02 13:31:34.425", + "2006-DEC-07 14:07:55.480", + "2007-JAN-01 00:00:00.007", + "2007-JAN-06 08:16:25.522", + "2007-JAN-30 11:41:32.568", + "2007-JAN-31 00:00:00.000", + ], + ">": [ + "2006-DEC-01 00:00:00.000", + "2006-DEC-02 13:31:34.425", + "2006-DEC-07 14:07:55.480", + "2007-JAN-01 00:00:00.007", + "2007-JAN-06 08:16:25.522", + "2007-JAN-30 11:41:32.568", + ], + "LOCMIN": [ + "2006-DEC-05 00:16:50.327", + "2006-DEC-05 00:16:50.327", + "2007-JAN-03 14:18:31.987", + "2007-JAN-03 14:18:31.987", + ], + "ABSMIN": ["2007-JAN-03 14:18:31.987", "2007-JAN-03 14:18:31.987"], + "LOCMAX": [ + "2006-DEC-20 14:09:10.402", + "2006-DEC-20 14:09:10.402", + "2007-JAN-19 04:27:54.610", + "2007-JAN-19 04:27:54.610", + ], + "ABSMAX": ["2007-JAN-19 04:27:54.610", "2007-JAN-19 04:27:54.610"], + } + spice.kclear() + spice.furnsh(CoreKernels.testMetaKernel) + et0 = spice.str2et("2006 DEC 01") + et1 = spice.str2et("2007 JAN 31") cnfine = spice.cell_double(2) spice.wninsd(et0, et1, cnfine) result = spice.cell_double(2000) for relation in relate: - spice.gfpa("Moon", "Sun", "LT+S", "Earth", relation, 0.57598845, - 0.0, spice.spd(), 5000, cnfine, result) + spice.gfpa( + "Moon", + "Sun", + "LT+S", + "Earth", + relation, + 0.57598845, + 0.0, + spice.spd(), + 5000, + cnfine, + result, + ) count = spice.wncard(result) if count > 0: - tempResults = [] + temp_results = [] for i in range(0, count): left, right = spice.wnfetd(result, i) - timstrLeft = spice.timout(left, 'YYYY-MON-DD HR:MN:SC.###', 41) - timstrRight = spice.timout(right, 'YYYY-MON-DD HR:MN:SC.###', 41) - tempResults.append(timstrLeft) - tempResults.append(timstrRight) - assert tempResults == expected.get(relation) + timstr_left = spice.timout(left, "YYYY-MON-DD HR:MN:SC.###", 41) + timstr_right = spice.timout(right, "YYYY-MON-DD HR:MN:SC.###", 41) + temp_results.append(timstr_left) + temp_results.append(timstr_right) + assert temp_results == expected.get(relation) spice.kclear() def test_gfposc(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et0 = spice.str2et('2007 JAN 01') - et1 = spice.str2et('2008 JAN 01') + et0 = spice.str2et("2007 JAN 01") + et1 = spice.str2et("2008 JAN 01") cnfine = spice.cell_double(2) spice.wninsd(et0, et1, cnfine) result = spice.cell_double(1000) - spice.gfposc("sun", "iau_earth", "none", "earth", "latitudinal", "latitude", - "absmax", 0.0, 0.0, 90.0 * spice.spd(), 1000, cnfine, result) + spice.gfposc( + "sun", + "iau_earth", + "none", + "earth", + "latitudinal", + "latitude", + "absmax", + 0.0, + 0.0, + 90.0 * spice.spd(), + 1000, + cnfine, + result, + ) count = spice.wncard(result) assert count == 1 start, end = spice.wnfetd(result, 0) - startTime = spice.timout(start, 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND', 41) - endTime = spice.timout(end, 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND', 41) - assert startTime == endTime - assert startTime == "2007-JUN-21 17:54:13.201561 (TDB)" + start_time = spice.timout( + start, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41 + ) + end_time = spice.timout(end, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41) + assert start_time == end_time + assert start_time == "2007-JUN-21 17:54:13.201561 (TDB)" spice.kclear() @@ -3510,23 +4292,24 @@ def test_gfrefn(): scale = 10.0 * i + j t1 = 5.0 * scale t2 = 7.0 * scale - t = spice.gfrefn(t1, t2, s1[i], s2[j]) - assert t == pytest.approx(scale*6.0) + t = spice.gfrefn(t1, t2, s1[i], s2[j]) + assert t == pytest.approx(scale * 6.0) for i in range(0, 2): for j in range(0, 2): scale = 10.0 * i + j t1 = 15.0 * scale t2 = 7.0 * scale - t = spice.gfrefn(t1, t2, s1[i], s2[j]) - assert t == pytest.approx(scale*11.0) + t = spice.gfrefn(t1, t2, s1[i], s2[j]) + assert t == pytest.approx(scale * 11.0) for i in range(0, 2): for j in range(0, 2): scale = 10.0 * i + j t1 = -scale t2 = -scale - t = spice.gfrefn(t1, t2, s1[i], s2[j]) + t = spice.gfrefn(t1, t2, s1[i], s2[j]) assert t == pytest.approx(-scale) + def test_gfrepf(): # Minimal test; gfrepf does nothing PyTest can notice spice.gfrepf() @@ -3537,37 +4320,37 @@ def test_gfrepf(): def test_gfrepi(): window = spice.cell_double(4) - spice.wninsd(0., 100., window) - spice.gfrepi(window, 'x', 'y') + spice.wninsd(0.0, 100.0, window) + spice.gfrepi(window, "x", "y") # BEGMSS or ENDMSS empty, too long, or containing non-printing characters with pytest.raises(spice.stypes.SpiceyError): - spice.gfrepi(window, '', 'y') + spice.gfrepi(window, "", "y") with pytest.raises(spice.stypes.SpiceyError): - spice.gfrepi(window, 'x', '') + spice.gfrepi(window, "x", "") with pytest.raises(spice.stypes.SpiceyError): - spice.gfrepi(window, 'x'*1000, 'y') + spice.gfrepi(window, "x" * 1000, "y") with pytest.raises(spice.stypes.SpiceyError): - spice.gfrepi(window, 'x', 'y'*1000) + spice.gfrepi(window, "x", "y" * 1000) with pytest.raises(spice.stypes.SpiceyError): - spice.gfrepi(window, 'y\n', 'y') + spice.gfrepi(window, "y\n", "y") with pytest.raises(spice.stypes.SpiceyError): - spice.gfrepi(window, 'x', 'y\n') + spice.gfrepi(window, "x", "y\n") spice.gfrepf() def test_gfrepu(): window = spice.cell_double(4) - spice.wninsd(0., 100., window) - spice.gfrepi(window, 'x', 'y') - spice.gfrepu(0., 100., 50.) - spice.gfrepu(0., 100., 100.) + spice.wninsd(0.0, 100.0, window) + spice.gfrepi(window, "x", "y") + spice.gfrepu(0.0, 100.0, 50.0) + spice.gfrepu(0.0, 100.0, 100.0) with pytest.raises(spice.stypes.SpiceyError): - spice.gfrepu(100., 0., 100.) + spice.gfrepu(100.0, 0.0, 100.0) with pytest.raises(spice.stypes.SpiceyError): - spice.gfrepu(0., 100., -1.) + spice.gfrepu(0.0, 100.0, -1.0) with pytest.raises(spice.stypes.SpiceyError): - spice.gfrepu(0., 100., 1011.) - spice.gfrepu(0., 100., 100.) + spice.gfrepu(0.0, 100.0, 1011.0) + spice.gfrepu(0.0, 100.0, 100.0) spice.gfrepf() @@ -3583,108 +4366,179 @@ def test_gfrfov(): spice.furnsh(CassiniKernels.satSpk) # Changed ABCORR to NONE from S for this test, so we do not need SSB # begin test - inst = "CASSINI_ISS_WAC" + inst = "CASSINI_ISS_WAC" # Cassini ISS NAC observed Enceladus on 2013-FEB-25 from ~11:00 to ~12:00 # Split confinement window, from continuous CK coverage, into two pieces et_start1 = spice.str2et("2013-FEB-25 07:20:00.000") - et_end1 = spice.str2et("2013-FEB-25 11:45:00.000") #\ - et_start2 = spice.str2et("2013-FEB-25 11:55:00.000") #_>synthetic 10min gap - et_end2 = spice.str2et("2013-FEB-26 14:25:00.000") - cnfine = spice.cell_double(4) + et_end1 = spice.str2et("2013-FEB-25 11:45:00.000") # \ + et_start2 = spice.str2et("2013-FEB-25 11:55:00.000") # _>synthetic 10min gap + et_end2 = spice.str2et("2013-FEB-26 14:25:00.000") + cnfine = spice.cell_double(4) spice.wninsd(et_start1, et_end1, cnfine) spice.wninsd(et_start2, et_end2, cnfine) # The ray direction vector is from Cassini toward Enceladus during the gap - et_nom = spice.str2et("2013-FEB-25 11:50:00.000") #\ - raydir, lt = spice.spkpos("Enceladus", et_nom, "J2000", "NONE", "Cassini") - result = spice.cell_double(2000) + et_nom = spice.str2et("2013-FEB-25 11:50:00.000") # \ + raydir, lt = spice.spkpos("Enceladus", et_nom, "J2000", "NONE", "Cassini") + result = spice.cell_double(2000) spice.gfrfov(inst, raydir, "J2000", "NONE", "Cassini", 10.0, cnfine, result) # Verify the expected results assert len(result) == 4 sTimout = "YYYY-MON-DD HR:MN:SC UTC ::RND" - assert spice.timout(result[0], sTimout) == '2013-FEB-25 11:26:46 UTC' - assert spice.timout(result[1], sTimout) == '2013-FEB-25 11:45:00 UTC' - assert spice.timout(result[2], sTimout) == '2013-FEB-25 11:55:00 UTC' - assert spice.timout(result[3], sTimout) == '2013-FEB-25 12:05:33 UTC' + assert spice.timout(result[0], sTimout) == "2013-FEB-25 11:26:46 UTC" + assert spice.timout(result[1], sTimout) == "2013-FEB-25 11:45:00 UTC" + assert spice.timout(result[2], sTimout) == "2013-FEB-25 11:55:00 UTC" + assert spice.timout(result[3], sTimout) == "2013-FEB-25 12:05:33 UTC" # Cleanup spice.kclear() def test_gfrr(): relate = ["=", "<", ">", "LOCMIN", "ABSMIN", "LOCMAX", "ABSMAX"] - expected = {"=": ['2007-JAN-02 00:35:19.583', '2007-JAN-02 00:35:19.583', '2007-JAN-19 22:04:54.905', - '2007-JAN-19 22:04:54.905', '2007-FEB-01 23:30:13.439', '2007-FEB-01 23:30:13.439', - '2007-FEB-17 11:10:46.547', '2007-FEB-17 11:10:46.547', '2007-MAR-04 15:50:19.940', - '2007-MAR-04 15:50:19.940', '2007-MAR-18 09:59:05.966', '2007-MAR-18 09:59:05.966'], - "<": ['2007-JAN-02 00:35:19.583', '2007-JAN-19 22:04:54.905', '2007-FEB-01 23:30:13.439', - '2007-FEB-17 11:10:46.547', '2007-MAR-04 15:50:19.940', '2007-MAR-18 09:59:05.966'], - ">": ['2007-JAN-01 00:00:00.000', '2007-JAN-02 00:35:19.583', '2007-JAN-19 22:04:54.905', - '2007-FEB-01 23:30:13.439', '2007-FEB-17 11:10:46.547', '2007-MAR-04 15:50:19.940', - '2007-MAR-18 09:59:05.966', '2007-APR-01 00:00:00.000'], - "LOCMIN": ['2007-JAN-11 07:03:59.001', '2007-JAN-11 07:03:59.001', - '2007-FEB-10 06:26:15.451', '2007-FEB-10 06:26:15.451', - '2007-MAR-12 03:28:36.414', '2007-MAR-12 03:28:36.414'], - "ABSMIN": ['2007-JAN-11 07:03:59.001', '2007-JAN-11 07:03:59.001'], - "LOCMAX": ['2007-JAN-26 02:27:33.772', '2007-JAN-26 02:27:33.772', - '2007-FEB-24 09:35:07.822', '2007-FEB-24 09:35:07.822', - '2007-MAR-25 17:26:56.158', '2007-MAR-25 17:26:56.158'], - "ABSMAX": ['2007-MAR-25 17:26:56.158', '2007-MAR-25 17:26:56.158']} - spice.kclear() - spice.furnsh(CoreKernels.testMetaKernel) - et0 = spice.str2et('2007 JAN 01') - et1 = spice.str2et('2007 APR 01') + expected = { + "=": [ + "2007-JAN-02 00:35:19.583", + "2007-JAN-02 00:35:19.583", + "2007-JAN-19 22:04:54.905", + "2007-JAN-19 22:04:54.905", + "2007-FEB-01 23:30:13.439", + "2007-FEB-01 23:30:13.439", + "2007-FEB-17 11:10:46.547", + "2007-FEB-17 11:10:46.547", + "2007-MAR-04 15:50:19.940", + "2007-MAR-04 15:50:19.940", + "2007-MAR-18 09:59:05.966", + "2007-MAR-18 09:59:05.966", + ], + "<": [ + "2007-JAN-02 00:35:19.583", + "2007-JAN-19 22:04:54.905", + "2007-FEB-01 23:30:13.439", + "2007-FEB-17 11:10:46.547", + "2007-MAR-04 15:50:19.940", + "2007-MAR-18 09:59:05.966", + ], + ">": [ + "2007-JAN-01 00:00:00.000", + "2007-JAN-02 00:35:19.583", + "2007-JAN-19 22:04:54.905", + "2007-FEB-01 23:30:13.439", + "2007-FEB-17 11:10:46.547", + "2007-MAR-04 15:50:19.940", + "2007-MAR-18 09:59:05.966", + "2007-APR-01 00:00:00.000", + ], + "LOCMIN": [ + "2007-JAN-11 07:03:59.001", + "2007-JAN-11 07:03:59.001", + "2007-FEB-10 06:26:15.451", + "2007-FEB-10 06:26:15.451", + "2007-MAR-12 03:28:36.414", + "2007-MAR-12 03:28:36.414", + ], + "ABSMIN": ["2007-JAN-11 07:03:59.001", "2007-JAN-11 07:03:59.001"], + "LOCMAX": [ + "2007-JAN-26 02:27:33.772", + "2007-JAN-26 02:27:33.772", + "2007-FEB-24 09:35:07.822", + "2007-FEB-24 09:35:07.822", + "2007-MAR-25 17:26:56.158", + "2007-MAR-25 17:26:56.158", + ], + "ABSMAX": ["2007-MAR-25 17:26:56.158", "2007-MAR-25 17:26:56.158"], + } + spice.kclear() + spice.furnsh(CoreKernels.testMetaKernel) + et0 = spice.str2et("2007 JAN 01") + et1 = spice.str2et("2007 APR 01") cnfine = spice.cell_double(2) spice.wninsd(et0, et1, cnfine) for relation in relate: result = spice.cell_double(2000) - spice.gfrr("moon", "none", "sun", relation, 0.3365, 0.0, spice.spd(), 2000, cnfine, result) + spice.gfrr( + "moon", + "none", + "sun", + relation, + 0.3365, + 0.0, + spice.spd(), + 2000, + cnfine, + result, + ) count = spice.wncard(result) if count > 0: - tempResults = [] + temp_results = [] for i in range(0, count): left, right = spice.wnfetd(result, i) - timstrLeft = spice.timout(left, 'YYYY-MON-DD HR:MN:SC.###', 41) - timstrRight = spice.timout(right, 'YYYY-MON-DD HR:MN:SC.###', 41) - tempResults.append(timstrLeft) - tempResults.append(timstrRight) - assert tempResults == expected.get(relation) + timstr_left = spice.timout(left, "YYYY-MON-DD HR:MN:SC.###", 41) + timstr_right = spice.timout(right, "YYYY-MON-DD HR:MN:SC.###", 41) + temp_results.append(timstr_left) + temp_results.append(timstr_right) + assert temp_results == expected.get(relation) spice.kclear() def test_gfsep(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - expected = ['2007-JAN-03 14:20:24.628017 (TDB)', '2007-FEB-02 06:16:24.111794 (TDB)', - '2007-MAR-03 23:22:42.005064 (TDB)', '2007-APR-02 16:49:16.145506 (TDB)', - '2007-MAY-02 09:41:43.840096 (TDB)', '2007-JUN-01 01:03:44.537483 (TDB)', - '2007-JUN-30 14:15:26.586223 (TDB)', '2007-JUL-30 01:14:49.010797 (TDB)', - '2007-AUG-28 10:39:01.398087 (TDB)', '2007-SEP-26 19:25:51.519413 (TDB)', - '2007-OCT-26 04:30:56.635336 (TDB)', '2007-NOV-24 14:31:04.341632 (TDB)', - '2007-DEC-24 01:40:12.245932 (TDB)'] - et0 = spice.str2et('2007 JAN 01') - et1 = spice.str2et('2008 JAN 01') + expected = [ + "2007-JAN-03 14:20:24.628017 (TDB)", + "2007-FEB-02 06:16:24.111794 (TDB)", + "2007-MAR-03 23:22:42.005064 (TDB)", + "2007-APR-02 16:49:16.145506 (TDB)", + "2007-MAY-02 09:41:43.840096 (TDB)", + "2007-JUN-01 01:03:44.537483 (TDB)", + "2007-JUN-30 14:15:26.586223 (TDB)", + "2007-JUL-30 01:14:49.010797 (TDB)", + "2007-AUG-28 10:39:01.398087 (TDB)", + "2007-SEP-26 19:25:51.519413 (TDB)", + "2007-OCT-26 04:30:56.635336 (TDB)", + "2007-NOV-24 14:31:04.341632 (TDB)", + "2007-DEC-24 01:40:12.245932 (TDB)", + ] + et0 = spice.str2et("2007 JAN 01") + et1 = spice.str2et("2008 JAN 01") cnfine = spice.cell_double(2) spice.wninsd(et0, et1, cnfine) result = spice.cell_double(2000) - spice.gfsep("MOON", "SPHERE", "NULL", "SUN", "SPHERE", "NULL", "NONE", "EARTH", - "LOCMAX", 0.0, 0.0, 6.0 * spice.spd(), 1000, cnfine, result) + spice.gfsep( + "MOON", + "SPHERE", + "NULL", + "SUN", + "SPHERE", + "NULL", + "NONE", + "EARTH", + "LOCMAX", + 0.0, + 0.0, + 6.0 * spice.spd(), + 1000, + cnfine, + result, + ) count = spice.wncard(result) assert count == 13 - tempResults = [] + temp_results = [] for i in range(0, count): start, end = spice.wnfetd(result, i) assert start == end - tempResults.append(spice.timout(start, 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND', 41)) - assert tempResults == expected + temp_results.append( + spice.timout(start, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41) + ) + assert temp_results == expected spice.kclear() def test_gfsntc(): spice.kclear() - kernel = os.path.join(cwd, 'gfnstc_test.tf') + kernel = os.path.join(cwd, "gfnstc_test.tf") if spice.exists(kernel): - os.remove(kernel) # pragma: no cover # pragma: no cover - with open(kernel, 'w') as kernelFile: - kernelFile.write('\\begindata\n') + os.remove(kernel) # pragma: no cover # pragma: no cover + with open(kernel, "w") as kernelFile: + kernelFile.write("\\begindata\n") kernelFile.write("FRAME_SEM = 10100000\n") kernelFile.write("FRAME_10100000_NAME = 'SEM'\n") kernelFile.write("FRAME_10100000_CLASS = 5\n") @@ -3707,13 +4561,29 @@ def test_gfsntc(): kernelFile.close() spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(kernel) - et0 = spice.str2et('2007 JAN 01') - et1 = spice.str2et('2008 JAN 01') + et0 = spice.str2et("2007 JAN 01") + et1 = spice.str2et("2008 JAN 01") cnfine = spice.cell_double(2) spice.wninsd(et0, et1, cnfine) result = spice.cell_double(2000) - spice.gfsntc("EARTH", "IAU_EARTH", "Ellipsoid", "NONE", "SUN", "SEM", [1.0, 0.0, 0.0], "LATITUDINAL", - "LATITUDE", "=", 0.0, 0.0, 90.0 * spice.spd(), 1000, cnfine, result) + spice.gfsntc( + "EARTH", + "IAU_EARTH", + "Ellipsoid", + "NONE", + "SUN", + "SEM", + [1.0, 0.0, 0.0], + "LATITUDINAL", + "LATITUDE", + "=", + 0.0, + 0.0, + 90.0 * spice.spd(), + 1000, + cnfine, + result, + ) count = spice.wncard(result) assert count > 0 beg, end = spice.wnfetd(result, 0) @@ -3728,7 +4598,7 @@ def test_gfsntc(): assert endstr == "2007-SEP-23 09:46:39.606982 (TDB)" spice.kclear() if spice.exists(kernel): - os.remove(kernel) # pragma: no cover # pragma: no cover + os.remove(kernel) # pragma: no cover # pragma: no cover def test_gfsstp(): @@ -3749,20 +4619,36 @@ def test_gfstol(): def test_gfsubc(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et0 = spice.str2et('2007 JAN 01') - et1 = spice.str2et('2008 JAN 01') + et0 = spice.str2et("2007 JAN 01") + et1 = spice.str2et("2008 JAN 01") cnfine = spice.cell_double(2) spice.wninsd(et0, et1, cnfine) result = spice.cell_double(2000) - spice.gfsubc("earth", "iau_earth", "Near point: ellipsoid", "none", "sun", "geodetic", "latitude", ">", - 16.0 * spice.rpd(), 0.0, spice.spd() * 90.0, 1000, cnfine, result) + spice.gfsubc( + "earth", + "iau_earth", + "Near point: ellipsoid", + "none", + "sun", + "geodetic", + "latitude", + ">", + 16.0 * spice.rpd(), + 0.0, + spice.spd() * 90.0, + 1000, + cnfine, + result, + ) count = spice.wncard(result) assert count > 0 start, end = spice.wnfetd(result, 0) - startTime = spice.timout(start, 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND', 41) - endTime = spice.timout(end, 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND', 41) - assert startTime == "2007-MAY-04 17:08:56.724320 (TDB)" - assert endTime == "2007-AUG-09 01:51:29.307830 (TDB)" + start_time = spice.timout( + start, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41 + ) + end_time = spice.timout(end, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41) + assert start_time == "2007-MAY-04 17:08:56.724320 (TDB)" + assert end_time == "2007-AUG-09 01:51:29.307830 (TDB)" spice.kclear() @@ -3781,21 +4667,30 @@ def test_gftfov(): # Cassini ISS NAC observed Enceladus on 2013-FEB-25 from ~11:00 to ~12:00 # Split confinement window, from continuous CK coverage, into two pieces et_start1 = spice.str2et("2013-FEB-25 07:20:00.000") - et_end1 = spice.str2et("2013-FEB-25 11:45:00.000") #\ - et_start2 = spice.str2et("2013-FEB-25 11:55:00.000") #_>synthetic 10min gap - et_end2 = spice.str2et("2013-FEB-26 14:25:00.000") - cnfine = spice.cell_double(4) + et_end1 = spice.str2et("2013-FEB-25 11:45:00.000") # \ + et_start2 = spice.str2et("2013-FEB-25 11:55:00.000") # _>synthetic 10min gap + et_end2 = spice.str2et("2013-FEB-26 14:25:00.000") + cnfine = spice.cell_double(4) spice.wninsd(et_start1, et_end1, cnfine) spice.wninsd(et_start2, et_end2, cnfine) # Subtract off the position of the spacecraft relative to the solar system barycenter the result is the ray's direction vector. - result = spice.gftfov("CASSINI_ISS_NAC", "ENCELADUS", "ELLIPSOID", "IAU_ENCELADUS", "LT", "CASSINI", 10.0, cnfine) + result = spice.gftfov( + "CASSINI_ISS_NAC", + "ENCELADUS", + "ELLIPSOID", + "IAU_ENCELADUS", + "LT", + "CASSINI", + 10.0, + cnfine, + ) # Verify the expected results assert spice.card(result) == 4 sTimout = "YYYY-MON-DD HR:MN:SC UTC ::RND" - assert spice.timout(result[0], sTimout) == '2013-FEB-25 10:42:33 UTC' - assert spice.timout(result[1], sTimout) == '2013-FEB-25 11:45:00 UTC' - assert spice.timout(result[2], sTimout) == '2013-FEB-25 11:55:00 UTC' - assert spice.timout(result[3], sTimout) == '2013-FEB-25 12:04:30 UTC' + assert spice.timout(result[0], sTimout) == "2013-FEB-25 10:42:33 UTC" + assert spice.timout(result[1], sTimout) == "2013-FEB-25 11:45:00 UTC" + assert spice.timout(result[2], sTimout) == "2013-FEB-25 11:55:00 UTC" + assert spice.timout(result[3], sTimout) == "2013-FEB-25 12:04:30 UTC" # Cleanup spice.kclear() @@ -3806,9 +4701,9 @@ def test_gfudb(): spice.furnsh(CoreKernels.testMetaKernel) # begin test et_start = spice.str2et("Jan 1 2001") - et_end = spice.str2et("Jan 1 2002") - result = spice.cell_double(40000) - cnfine = spice.cell_double(2) + et_end = spice.str2et("Jan 1 2002") + result = spice.cell_double(40000) + cnfine = spice.cell_double(2) spice.wninsd(et_start, et_end, cnfine) step = 5.0 * spice.spd() @@ -3819,13 +4714,13 @@ def test_gfudb(): @spiceypy.utils.callbacks.SpiceUDFUNB def gfq(udfunc, et): # we are not using udfunc in this example - state, lt = spice.spkez(301, et, 'IAU_EARTH', 'NONE', 399) + state, lt = spice.spkez(301, et, "IAU_EARTH", "NONE", 399) return state[2] >= 0.0 and state[5] > 0.0 # call gfudb spice.gfudb(udf, gfq, step, cnfine, result) # count - assert len(result) > 20 # true value is 28 + assert len(result) > 20 # true value is 28 spice.kclear() @@ -3844,7 +4739,7 @@ def test_gfudb2(): # define gfq @spiceypy.utils.callbacks.SpiceUDFUNS def gfq(et): - pos, lt = spice.spkezp(301, et, 'IAU_EARTH', 'NONE', 399) + pos, lt = spice.spkezp(301, et, "IAU_EARTH", "NONE", 399) return pos[2] # define gfb @@ -3871,11 +4766,12 @@ def test_gfuds(): # set up some constants step = spice.spd() adjust = 0.0 - refval = 0.3365 + refval = 0.3365 + # declare the callbacks we will use in the test @spiceypy.utils.callbacks.SpiceUDFUNS def gfq(et): - state, lt = spice.spkez(301, et, 'J2000', 'NONE', 10) + state, lt = spice.spkez(301, et, "J2000", "NONE", 10) return spice.dvnorm(state) @spiceypy.utils.callbacks.SpiceUDFUNB @@ -3888,7 +4784,9 @@ def gfdecrx(udfuns, et): cnfine = spice.cell_double(2) spice.wninsd(et_start, et_end, cnfine) # call gfuds - result = spice.gfuds(gfq, gfdecrx, r, refval, adjust, step, 20000, cnfine, result) + result = spice.gfuds( + gfq, gfdecrx, r, refval, adjust, step, 20000, cnfine, result + ) assert len(result) > 0 # cleanup spice.kclear() @@ -3898,8 +4796,8 @@ def test_gipool(): # same as pipool test spice.kclear() data = np.arange(0, 10) - spice.pipool('pipool_array', data) - ivals = spice.gipool('pipool_array', 0, 50) + spice.pipool("pipool_array", data) + ivals = spice.gipool("pipool_array", 0, 50) npt.assert_array_almost_equal(data, ivals) spice.kclear() @@ -3910,9 +4808,17 @@ def test_gnpool(): var = "BODY599*" index = 0 room = 10 - expected = ["BODY599_POLE_DEC", "BODY599_LONG_AXIS", "BODY599_PM", "BODY599_RADII", - "BODY599_POLE_RA", "BODY599_GM", "BODY599_NUT_PREC_PM", "BODY599_NUT_PREC_DEC", - "BODY599_NUT_PREC_RA"] + expected = [ + "BODY599_POLE_DEC", + "BODY599_LONG_AXIS", + "BODY599_PM", + "BODY599_RADII", + "BODY599_POLE_RA", + "BODY599_GM", + "BODY599_NUT_PREC_PM", + "BODY599_NUT_PREC_DEC", + "BODY599_NUT_PREC_RA", + ] kervar = spice.gnpool(var, index, room) spice.kclear() assert set(expected) == set(kervar) @@ -3927,16 +4833,16 @@ def test_hrmint(): yvals = [6.0, 3.0, 5.0, 0.0, 2210.0, 5115.0, 78180.0, 109395.0] answer, deriv = spice.hrmint(xvals, yvals, 2) assert answer == pytest.approx(141.0) - assert deriv == pytest.approx(456.0) + assert deriv == pytest.approx(456.0) def test_hx2dp(): - assert spice.hx2dp('1^1') == 1.0 - assert spice.hx2dp('7F5EB^5') == 521707.0 - assert spice.hx2dp('+1B^+2') == 27.0 + assert spice.hx2dp("1^1") == 1.0 + assert spice.hx2dp("7F5EB^5") == 521707.0 + assert spice.hx2dp("+1B^+2") == 27.0 # Bad value badReturn = "ERROR: Illegal character 'Z' encountered." - assert spice.hx2dp('1Z^+2')[:len(badReturn)] == badReturn + assert spice.hx2dp("1Z^+2")[: len(badReturn)] == badReturn def test_ident(): @@ -3951,9 +4857,14 @@ def test_illum(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2007 FEB 3 00:00:00.000") - trgepc, obspos, trmpts = spice.edterm("UMBRAL", "SUN", "MOON", et, "IAU_MOON", "LT+S", "EARTH", 3) - expected_trmpts0 = [-1.53978381936825627463e+02, -1.73056331949840728157e+03, - 1.22893325627419600088e-01] + trgepc, obspos, trmpts = spice.edterm( + "UMBRAL", "SUN", "MOON", et, "IAU_MOON", "LT+S", "EARTH", 3 + ) + expected_trmpts0 = [ + -1.53978381936825627463e02, + -1.73056331949840728157e03, + 1.22893325627419600088e-01, + ] npt.assert_array_almost_equal(trmpts[0], expected_trmpts0) phase, solar, emissn = spice.illum("MOON", et, "LT+S", "EARTH", trmpts[0]) npt.assert_almost_equal(spice.dpr() * phase, 9.206597597007834) @@ -3967,28 +4878,42 @@ def test_ilumin(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2007 FEB 3 00:00:00.000") - trgepc, obspos, trmpts = spice.edterm("UMBRAL", "SUN", "MOON", et, "IAU_MOON", "LT+S", "EARTH", 3) + trgepc, obspos, trmpts = spice.edterm( + "UMBRAL", "SUN", "MOON", et, "IAU_MOON", "LT+S", "EARTH", 3 + ) expected_trgepc = 223732863.86351672 - expected_obspos = [394721.1024056578753516078, 27265.11780063395417528227, - -19069.08478859506431035697] - expected_trmpts0 = [-1.53978381936825627463e+02, -1.73056331949840728157e+03, - 1.22893325627419600088e-01] - expected_trmpts1 = [87.37506200891714058798, 864.40670594653545322217, - 1504.56817899807947469526] + expected_obspos = [ + 394721.1024056578753516078, + 27265.11780063395417528227, + -19069.08478859506431035697, + ] + expected_trmpts0 = [ + -1.53978381936825627463e02, + -1.73056331949840728157e03, + 1.22893325627419600088e-01, + ] + expected_trmpts1 = [ + 87.37506200891714058798, + 864.40670594653545322217, + 1504.56817899807947469526, + ] expected_trmpts2 = [42.213243378688254, 868.21134651980412, -1504.3223922609538] npt.assert_almost_equal(trgepc, expected_trgepc) npt.assert_array_almost_equal(obspos, expected_obspos) npt.assert_array_almost_equal(trmpts[0], expected_trmpts0) npt.assert_array_almost_equal(trmpts[1], expected_trmpts1) npt.assert_array_almost_equal(trmpts[2], expected_trmpts2) - iluet0, srfvec0, phase0, solar0, emissn0 = spice.ilumin("Ellipsoid", "MOON", et, "IAU_MOON", - "LT+S", "EARTH", trmpts[0]) + iluet0, srfvec0, phase0, solar0, emissn0 = spice.ilumin( + "Ellipsoid", "MOON", et, "IAU_MOON", "LT+S", "EARTH", trmpts[0] + ) npt.assert_almost_equal(spice.dpr() * solar0, 90.269765819) - iluet1, srfvec1, phase1, solar1, emissn1 = spice.ilumin("Ellipsoid", "MOON", et, "IAU_MOON", - "LT+S", "EARTH", trmpts[1]) + iluet1, srfvec1, phase1, solar1, emissn1 = spice.ilumin( + "Ellipsoid", "MOON", et, "IAU_MOON", "LT+S", "EARTH", trmpts[1] + ) npt.assert_almost_equal(spice.dpr() * solar1, 90.269765706) - iluet2, srfvec2, phase2, solar2, emissn2 = spice.ilumin("Ellipsoid", "MOON", et, "IAU_MOON", - "LT+S", "EARTH", trmpts[2]) + iluet2, srfvec2, phase2, solar2, emissn2 = spice.ilumin( + "Ellipsoid", "MOON", et, "IAU_MOON", "LT+S", "EARTH", trmpts[2] + ) npt.assert_almost_equal(spice.dpr() * solar2, 90.269765730) spice.kclear() @@ -4004,21 +4929,25 @@ def test_illumf(): spice.furnsh(CassiniKernels.satSpk) spice.furnsh(CassiniKernels.cassTourSpk) spice.furnsh(CassiniKernels.cassCk) - et = spice.str2et('2013 FEB 25 11:50:00 UTC') + et = spice.str2et("2013 FEB 25 11:50:00 UTC") # start of test camid = spice.bodn2c("CASSINI_ISS_NAC") shape, obsref, bsight, n, bounds = spice.getfov(camid, 4) # run sincpt on boresight vector - spoint, etemit, srfvec = spice.sincpt("Ellipsoid", 'Enceladus', et, "IAU_ENCELADUS", "CN+S", "CASSINI", obsref, bsight) - trgepc2, srfvec2, phase, incid, emissn, visibl, lit = spice.illumf("Ellipsoid", 'Enceladus', 'Sun', et, 'IAU_ENCELADUS', 'CN+S', 'CASSINI', spoint) + spoint, etemit, srfvec = spice.sincpt( + "Ellipsoid", "Enceladus", et, "IAU_ENCELADUS", "CN+S", "CASSINI", obsref, bsight + ) + trgepc2, srfvec2, phase, incid, emissn, visibl, lit = spice.illumf( + "Ellipsoid", "Enceladus", "Sun", et, "IAU_ENCELADUS", "CN+S", "CASSINI", spoint + ) phase = phase * spice.dpr() incid = incid * spice.dpr() emissn = emissn * spice.dpr() assert phase == pytest.approx(161.82854377660345) assert incid == pytest.approx(134.92108561449996) assert emissn == pytest.approx(63.23618556218115) - assert not lit # Incidence angle is greater than 90deg - assert visibl # Emission angle is less than 90deg + assert not lit # Incidence angle is greater than 90deg + assert visibl # Emission angle is less than 90deg spice.kclear() @@ -4033,9 +4962,13 @@ def test_illumg(): spice.furnsh(CassiniKernels.satSpk) spice.furnsh(CassiniKernels.cassTourSpk) spice.furnsh(CassiniKernels.cassCk) - et = spice.str2et('2013 FEB 25 11:50:00 UTC') - spoint, trgepc, srfvec = spice.subpnt("Near Point/Ellipsoid", 'Enceladus', et, 'IAU_ENCELADUS', 'CN+S', 'Earth') - trgepc2, srfvec2, phase, incid, emissn = spice.illumg("Ellipsoid", 'Enceladus', 'Sun', et, 'IAU_ENCELADUS', 'CN+S', 'CASSINI', spoint) + et = spice.str2et("2013 FEB 25 11:50:00 UTC") + spoint, trgepc, srfvec = spice.subpnt( + "Near Point/Ellipsoid", "Enceladus", et, "IAU_ENCELADUS", "CN+S", "Earth" + ) + trgepc2, srfvec2, phase, incid, emissn = spice.illumg( + "Ellipsoid", "Enceladus", "Sun", et, "IAU_ENCELADUS", "CN+S", "CASSINI", spoint + ) phase = phase * spice.dpr() incid = incid * spice.dpr() emissn = emissn * spice.dpr() @@ -4048,27 +4981,31 @@ def test_illumg(): def test_inedpl(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - TIME = 'Oct 31 2002, 12:55:00 PST' - FRAME = 'J2000' - CORR = 'LT+S' + TIME = "Oct 31 2002, 12:55:00 PST" + FRAME = "J2000" + CORR = "LT+S" et = spice.str2et(TIME) - state, ltime = spice.spkezr('EARTH', et, FRAME, CORR, 'SUN') + state, ltime = spice.spkezr("EARTH", et, FRAME, CORR, "SUN") pos = state[0:3] - dim, radii = spice.bodvrd('EARTH', 'RADII', 3) - pos = [pos[0] / radii[0] ** 2.0, - pos[1] / radii[1] ** 2.0, - pos[2] / radii[2] ** 2.0] + dim, radii = spice.bodvrd("EARTH", "RADII", 3) + pos = [pos[0] / radii[0] ** 2.0, pos[1] / radii[1] ** 2.0, pos[2] / radii[2] ** 2.0] plane = spice.nvc2pl(pos, 1.0) term = spice.inedpl(radii[0], radii[1], radii[2], plane) spice.kclear() - expectedCenter = [0.21512031, 0.15544527, 0.067391641] - expectedSMajor = [-3.73561164720596843836e+03, 5.16970328302375583007e+03, - 1.35988201424391742850e-11] - expectedSMinor = [-1276.33357469839393161237, -922.27470443423590040766, - 6159.97371233560443215538] - npt.assert_array_almost_equal(term.center, expectedCenter) - npt.assert_array_almost_equal(term.semi_major, expectedSMajor, decimal=5) - npt.assert_array_almost_equal(term.semi_minor, expectedSMinor, decimal=5) + expected_center = [0.21512031, 0.15544527, 0.067391641] + expected_s_major = [ + -3.73561164720596843836e03, + 5.16970328302375583007e03, + 1.35988201424391742850e-11, + ] + expected_s_minor = [ + -1276.33357469839393161237, + -922.27470443423590040766, + 6159.97371233560443215538, + ] + npt.assert_array_almost_equal(term.center, expected_center) + npt.assert_array_almost_equal(term.semi_major, expected_s_major, decimal=5) + npt.assert_array_almost_equal(term.semi_minor, expected_s_minor, decimal=5) npt.assert_almost_equal(spice.vnorm(term.semi_major), 6378.1365, decimal=2) npt.assert_almost_equal(spice.vnorm(term.semi_minor), 6358.0558, decimal=2) @@ -4076,7 +5013,7 @@ def test_inedpl(): def test_inelpl(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - dim, radii = spice.bodvrd('SATURN', 'RADII', 3) + dim, radii = spice.bodvrd("SATURN", "RADII", 3) vertex = [100.0 * radii[0], 0.0, radii[0] * 100.0] limb = spice.edlimb(radii[0], radii[1], radii[2], vertex) normal = [0.0, 0.0, 1.0] @@ -4108,82 +5045,82 @@ def test_inrypl(): def test_insrtc(): - testCell = spice.cell_char(10, 10) + test_cell = spice.cell_char(10, 10) cList = ["aaa", "bbb", "ccc", "bbb"] for c in cList: - spice.insrtc(c, testCell) - assert [x for x in testCell] == ["aaa", "bbb", "ccc"] + spice.insrtc(c, test_cell) + assert [x for x in test_cell] == ["aaa", "bbb", "ccc"] def test_insrtc_vectorized(): - testCell = spice.cell_char(10, 10) + test_cell = spice.cell_char(10, 10) cList = ["aaa", "bbb", "ccc", "bbb"] - spice.insrtc(cList, testCell) - assert [x for x in testCell] == ["aaa", "bbb", "ccc"] + spice.insrtc(cList, test_cell) + assert [x for x in test_cell] == ["aaa", "bbb", "ccc"] def test_insrtd(): - testCell = spice.cell_double(8) + test_cell = spice.cell_double(8) dlist = [0.5, 2.0, 30.0, 0.01, 30.0] for d in dlist: - spice.insrtd(d, testCell) - assert [x for x in testCell] == [0.01, 0.5, 2.0, 30.0] + spice.insrtd(d, test_cell) + assert [x for x in test_cell] == [0.01, 0.5, 2.0, 30.0] def test_insrtd_vectorized(): - testCell = spice.cell_double(8) + test_cell = spice.cell_double(8) dList = [0.5, 2.0, 30.0, 0.01, 30.0] - spice.insrtd(dList, testCell) - assert [x for x in testCell] == [0.01, 0.5, 2.0, 30.0] + spice.insrtd(dList, test_cell) + assert [x for x in test_cell] == [0.01, 0.5, 2.0, 30.0] def test_insrti(): - testCell = spice.cell_int(8) + test_cell = spice.cell_int(8) ilist = [1, 2, 30, 1, 30] for i in ilist: - spice.insrti(i, testCell) - assert [x for x in testCell] == [1, 2, 30] + spice.insrti(i, test_cell) + assert [x for x in test_cell] == [1, 2, 30] def test_insrti_vectorized(): - testCell = spice.cell_int(8) + test_cell = spice.cell_int(8) iList = [1, 2, 30, 1, 30] - spice.insrti(iList, testCell) - assert [x for x in testCell] == [1, 2, 30] + spice.insrti(iList, test_cell) + assert [x for x in test_cell] == [1, 2, 30] def test_inter(): - testCellOne = spice.cell_int(8) - testCellTwo = spice.cell_int(8) - spice.insrti(1, testCellOne) - spice.insrti(2, testCellOne) - spice.insrti(1, testCellTwo) - spice.insrti(3, testCellTwo) - outCell = spice.inter(testCellOne, testCellTwo) - assert [x for x in outCell] == [1] + test_cell_one = spice.cell_int(8) + test_cell_two = spice.cell_int(8) + spice.insrti(1, test_cell_one) + spice.insrti(2, test_cell_one) + spice.insrti(1, test_cell_two) + spice.insrti(3, test_cell_two) + out_cell = spice.inter(test_cell_one, test_cell_two) + assert [x for x in out_cell] == [1] # SPICECHAR_CELL - testCellOne = spice.cell_char(8, 8) - testCellTwo = spice.cell_char(8, 8) - spice.insrtc('1', testCellOne) - spice.insrtc('2', testCellOne) - spice.insrtc('1', testCellTwo) - spice.insrtc('3', testCellTwo) - outCell = spice.inter(testCellOne, testCellTwo) - assert [x for x in outCell] == ['1'] + test_cell_one = spice.cell_char(8, 8) + test_cell_two = spice.cell_char(8, 8) + spice.insrtc("1", test_cell_one) + spice.insrtc("2", test_cell_one) + spice.insrtc("1", test_cell_two) + spice.insrtc("3", test_cell_two) + out_cell = spice.inter(test_cell_one, test_cell_two) + assert [x for x in out_cell] == ["1"] # SPICEDOUBLE_CELL - testCellOne = spice.cell_double(8) - testCellTwo = spice.cell_double(8) - spice.insrtd(1.0, testCellOne) - spice.insrtd(2.0, testCellOne) - spice.insrtd(1.0, testCellTwo) - spice.insrtd(3.0, testCellTwo) - outCell = spice.inter(testCellOne, testCellTwo) - assert [x for x in outCell] == [1.0] + test_cell_one = spice.cell_double(8) + test_cell_two = spice.cell_double(8) + spice.insrtd(1.0, test_cell_one) + spice.insrtd(2.0, test_cell_one) + spice.insrtd(1.0, test_cell_two) + spice.insrtd(3.0, test_cell_two) + out_cell = spice.inter(test_cell_one, test_cell_two) + assert [x for x in out_cell] == [1.0] # SPICEBOOLEAN_CELL; dtype=4 - testCellOne = spice.cell_bool(9) - testCellTwo = spice.cell_bool(9) + test_cell_one = spice.cell_bool(9) + test_cell_two = spice.cell_bool(9) with pytest.raises(NotImplementedError): - spice.inter(testCellOne, testCellTwo) + spice.inter(test_cell_one, test_cell_two) def test_intmax(): @@ -4274,7 +5211,7 @@ def test_kdata(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) file, ftype, source, handle = spice.kdata(0, "META", 400, 10, 50) - assert ftype == 'META' + assert ftype == "META" spice.kclear() @@ -4282,7 +5219,7 @@ def test_kinfo(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) filetype, source, handle = spice.kinfo(CoreKernels.testMetaKernel, 80, 80) - assert filetype == 'META' + assert filetype == "META" spice.kclear() @@ -4310,12 +5247,37 @@ def test_kxtrct(): i = 0 while i < 500: i += 1 - assert (' TO 1 January 1987', '1 October 1984 12:00:00') == spice.kxtrct('FROM', 'from to beginning ending'.upper().split(), 4, 'FROM 1 October 1984 12:00:00 TO 1 January 1987') - assert ('FROM 1 October 1984 12:00:00', '1 January 1987') == spice.kxtrct('TO', 'from to beginning ending'.upper().split(), 4, 'FROM 1 October 1984 12:00:00 TO 1 January 1987') - assert (' PHONE: 354-4321', '4800 OAK GROVE DRIVE') == spice.kxtrct('ADDRESS:', 'address: phone: name:'.upper().split(), 3, 'ADDRESS: 4800 OAK GROVE DRIVE PHONE: 354-4321 ') - assert ('ADDRESS: 4800 OAK GROVE DRIVE', '354-4321') == spice.kxtrct('PHONE:', 'address: phone: name:'.upper().split(), 3, 'ADDRESS: 4800 OAK GROVE DRIVE PHONE: 354-4321 ') + assert (" TO 1 January 1987", "1 October 1984 12:00:00") == spice.kxtrct( + "FROM", + "from to beginning ending".upper().split(), + 4, + "FROM 1 October 1984 12:00:00 TO 1 January 1987", + ) + assert ("FROM 1 October 1984 12:00:00", "1 January 1987") == spice.kxtrct( + "TO", + "from to beginning ending".upper().split(), + 4, + "FROM 1 October 1984 12:00:00 TO 1 January 1987", + ) + assert (" PHONE: 354-4321", "4800 OAK GROVE DRIVE") == spice.kxtrct( + "ADDRESS:", + "address: phone: name:".upper().split(), + 3, + "ADDRESS: 4800 OAK GROVE DRIVE PHONE: 354-4321 ", + ) + assert ("ADDRESS: 4800 OAK GROVE DRIVE", "354-4321") == spice.kxtrct( + "PHONE:", + "address: phone: name:".upper().split(), + 3, + "ADDRESS: 4800 OAK GROVE DRIVE PHONE: 354-4321 ", + ) with pytest.raises(spice.stypes.SpiceyError): - spice.kxtrct('NAME:', 'address: phone: name:'.upper().split(), 3, 'ADDRESS: 4800 OAK GROVE DRIVE PHONE: 354-4321 ') + spice.kxtrct( + "NAME:", + "address: phone: name:".upper().split(), + 3, + "ADDRESS: 4800 OAK GROVE DRIVE PHONE: 354-4321 ", + ) def test_lastnb(): @@ -4330,8 +5292,12 @@ def test_latcyl(): expected2 = np.array([1.0, 90.0 * spice.rpd(), 0.0]) expected3 = np.array([1.0, 180.0 * spice.rpd(), 0.0]) npt.assert_array_almost_equal(expected1, spice.latcyl(1.0, 0.0, 0.0), decimal=7) - npt.assert_array_almost_equal(expected2, spice.latcyl(1.0, 90.0 * spice.rpd(), 0.0), decimal=7) - npt.assert_array_almost_equal(expected3, spice.latcyl(1.0, 180.0 * spice.rpd(), 0.0), decimal=7) + npt.assert_array_almost_equal( + expected2, spice.latcyl(1.0, 90.0 * spice.rpd(), 0.0), decimal=7 + ) + npt.assert_array_almost_equal( + expected3, spice.latcyl(1.0, 180.0 * spice.rpd(), 0.0), decimal=7 + ) def test_latrec(): @@ -4339,8 +5305,12 @@ def test_latrec(): expected2 = np.array([0.0, 1.0, 0.0]) expected3 = np.array([-1.0, 0.0, 0.0]) npt.assert_array_almost_equal(expected1, spice.latrec(1.0, 0.0, 0.0), decimal=7) - npt.assert_array_almost_equal(expected2, spice.latrec(1.0, 90.0 * spice.rpd(), 0.0), decimal=7) - npt.assert_array_almost_equal(expected3, spice.latrec(1.0, 180.0 * spice.rpd(), 0.0), decimal=7) + npt.assert_array_almost_equal( + expected2, spice.latrec(1.0, 90.0 * spice.rpd(), 0.0), decimal=7 + ) + npt.assert_array_almost_equal( + expected3, spice.latrec(1.0, 180.0 * spice.rpd(), 0.0), decimal=7 + ) def test_latsph(): @@ -4348,14 +5318,20 @@ def test_latsph(): expected2 = np.array([1.0, 90.0 * spice.rpd(), 90.0 * spice.rpd()]) expected3 = np.array([1.0, 90.0 * spice.rpd(), 180.0 * spice.rpd()]) npt.assert_array_almost_equal(expected1, spice.latsph(1.0, 0.0, 0.0), decimal=7) - npt.assert_array_almost_equal(expected2, spice.latsph(1.0, 90.0 * spice.rpd(), 0.0), decimal=7) - npt.assert_array_almost_equal(expected3, spice.latsph(1.0, 180.0 * spice.rpd(), 0.0), decimal=7) + npt.assert_array_almost_equal( + expected2, spice.latsph(1.0, 90.0 * spice.rpd(), 0.0), decimal=7 + ) + npt.assert_array_almost_equal( + expected3, spice.latsph(1.0, 180.0 * spice.rpd(), 0.0), decimal=7 + ) def test_latsrf(): spice.kclear() spice.furnsh(ExtraKernels.phobosDsk) - srfpts = spice.latsrf("DSK/UNPRIORITIZED", "phobos", 0.0, "iau_phobos", [[0.0, 45.0], [60.0, 45.0]]) + srfpts = spice.latsrf( + "DSK/UNPRIORITIZED", "phobos", 0.0, "iau_phobos", [[0.0, 45.0], [60.0, 45.0]] + ) radii = [spice.recrad(x)[0] for x in srfpts] assert radii[0] > 9.77 assert radii[1] > 9.51 @@ -4369,49 +5345,60 @@ def test_lcase(): def test_ldpool(): spice.kclear() - ldpoolNames = ['DELTET/DELTA_T_A', 'DELTET/K', 'DELTET/EB', 'DELTET/M', 'DELTET/DELTA_AT'] - ldpoolLens = [1, 1, 1, 2, 46] - textbuf = ['DELTET/DELTA_T_A = 32.184', 'DELTET/K = 1.657D-3', 'DELTET/EB = 1.671D-2', - 'DELTET/M = ( 6.239996 1.99096871D-7 )', 'DELTET/DELTA_AT = ( 10, @1972-JAN-1', - ' 11, @1972-JUL-1', - ' 12, @1973-JAN-1', - ' 13, @1974-JAN-1', - ' 14, @1975-JAN-1', - ' 15, @1976-JAN-1', - ' 16, @1977-JAN-1', - ' 17, @1978-JAN-1', - ' 18, @1979-JAN-1', - ' 19, @1980-JAN-1', - ' 20, @1981-JUL-1', - ' 21, @1982-JUL-1', - ' 22, @1983-JUL-1', - ' 23, @1985-JUL-1', - ' 24, @1988-JAN-1', - ' 25, @1990-JAN-1', - ' 26, @1991-JAN-1', - ' 27, @1992-JUL-1', - ' 28, @1993-JUL-1', - ' 29, @1994-JUL-1', - ' 30, @1996-JAN-1', - ' 31, @1997-JUL-1', - ' 32, @1999-JAN-1 )'] - kernel = os.path.join(cwd, 'ldpool_test.tls') + ldpool_names = [ + "DELTET/DELTA_T_A", + "DELTET/K", + "DELTET/EB", + "DELTET/M", + "DELTET/DELTA_AT", + ] + ldpool_lens = [1, 1, 1, 2, 46] + textbuf = [ + "DELTET/DELTA_T_A = 32.184", + "DELTET/K = 1.657D-3", + "DELTET/EB = 1.671D-2", + "DELTET/M = ( 6.239996 1.99096871D-7 )", + "DELTET/DELTA_AT = ( 10, @1972-JAN-1", + " 11, @1972-JUL-1", + " 12, @1973-JAN-1", + " 13, @1974-JAN-1", + " 14, @1975-JAN-1", + " 15, @1976-JAN-1", + " 16, @1977-JAN-1", + " 17, @1978-JAN-1", + " 18, @1979-JAN-1", + " 19, @1980-JAN-1", + " 20, @1981-JUL-1", + " 21, @1982-JUL-1", + " 22, @1983-JUL-1", + " 23, @1985-JUL-1", + " 24, @1988-JAN-1", + " 25, @1990-JAN-1", + " 26, @1991-JAN-1", + " 27, @1992-JUL-1", + " 28, @1993-JUL-1", + " 29, @1994-JUL-1", + " 30, @1996-JAN-1", + " 31, @1997-JUL-1", + " 32, @1999-JAN-1 )", + ] + kernel = os.path.join(cwd, "ldpool_test.tls") if spice.exists(kernel): - os.remove(kernel) # pragma: no cover - with open(kernel, 'w') as kernelFile: - kernelFile.write('\\begindata\n') + os.remove(kernel) # pragma: no cover + with open(kernel, "w") as kernelFile: + kernelFile.write("\\begindata\n") for line in textbuf: kernelFile.write(line + "\n") kernelFile.write("\\begintext\n") kernelFile.close() spice.ldpool(kernel) - for var, expectLen in zip(ldpoolNames, ldpoolLens): + for var, expectLen in zip(ldpool_names, ldpool_lens): n, vartype = spice.dtpool(var) assert expectLen == n - assert vartype == 'N' + assert vartype == "N" spice.kclear() if spice.exists(kernel): - os.remove(kernel) # pragma: no cover + os.remove(kernel) # pragma: no cover def test_lgrind(): @@ -4430,9 +5417,21 @@ def test_limbpt(): # set the time et = spice.str2et("1972 AUG 11 00:00:00") # call limpt - npts, points, epochs, tangts = spice.limbpt("TANGENT/DSK/UNPRIORITIZED", "Phobos", et, "IAU_PHOBOS", - "CN+S", "CENTER", "MARS", [0.0, 0.0, 1.0], - spice.twopi()/3.0, 3, 1.0e-4, 1.0e-7, 10000) + npts, points, epochs, tangts = spice.limbpt( + "TANGENT/DSK/UNPRIORITIZED", + "Phobos", + et, + "IAU_PHOBOS", + "CN+S", + "CENTER", + "MARS", + [0.0, 0.0, 1.0], + spice.twopi() / 3.0, + 3, + 1.0e-4, + 1.0e-7, + 10000, + ) assert points is not None assert len(points) == 3 spice.kclear() @@ -4440,73 +5439,97 @@ def test_limbpt(): def test_lmpool(): spice.kclear() - lmpoolNames = ['DELTET/DELTA_T_A', 'DELTET/K', 'DELTET/EB', 'DELTET/M', 'DELTET/DELTA_AT'] - lmpoolLens = [1, 1, 1, 2, 46] - textbuf = ['DELTET/DELTA_T_A = 32.184', 'DELTET/K = 1.657D-3', 'DELTET/EB = 1.671D-2', - 'DELTET/M = ( 6.239996 1.99096871D-7 )', 'DELTET/DELTA_AT = ( 10, @1972-JAN-1', - ' 11, @1972-JUL-1', - ' 12, @1973-JAN-1', - ' 13, @1974-JAN-1', - ' 14, @1975-JAN-1', - ' 15, @1976-JAN-1', - ' 16, @1977-JAN-1', - ' 17, @1978-JAN-1', - ' 18, @1979-JAN-1', - ' 19, @1980-JAN-1', - ' 20, @1981-JUL-1', - ' 21, @1982-JUL-1', - ' 22, @1983-JUL-1', - ' 23, @1985-JUL-1', - ' 24, @1988-JAN-1', - ' 25, @1990-JAN-1', - ' 26, @1991-JAN-1', - ' 27, @1992-JUL-1', - ' 28, @1993-JUL-1', - ' 29, @1994-JUL-1', - ' 30, @1996-JAN-1', - ' 31, @1997-JUL-1', - ' 32, @1999-JAN-1 )'] + lmpool_names = [ + "DELTET/DELTA_T_A", + "DELTET/K", + "DELTET/EB", + "DELTET/M", + "DELTET/DELTA_AT", + ] + lmpool_lens = [1, 1, 1, 2, 46] + textbuf = [ + "DELTET/DELTA_T_A = 32.184", + "DELTET/K = 1.657D-3", + "DELTET/EB = 1.671D-2", + "DELTET/M = ( 6.239996 1.99096871D-7 )", + "DELTET/DELTA_AT = ( 10, @1972-JAN-1", + " 11, @1972-JUL-1", + " 12, @1973-JAN-1", + " 13, @1974-JAN-1", + " 14, @1975-JAN-1", + " 15, @1976-JAN-1", + " 16, @1977-JAN-1", + " 17, @1978-JAN-1", + " 18, @1979-JAN-1", + " 19, @1980-JAN-1", + " 20, @1981-JUL-1", + " 21, @1982-JUL-1", + " 22, @1983-JUL-1", + " 23, @1985-JUL-1", + " 24, @1988-JAN-1", + " 25, @1990-JAN-1", + " 26, @1991-JAN-1", + " 27, @1992-JUL-1", + " 28, @1993-JUL-1", + " 29, @1994-JUL-1", + " 30, @1996-JAN-1", + " 31, @1997-JUL-1", + " 32, @1999-JAN-1 )", + ] spice.lmpool(textbuf) - for var, expectLen in zip(lmpoolNames, lmpoolLens): + for var, expectLen in zip(lmpool_names, lmpool_lens): n, vartype = spice.dtpool(var) assert expectLen == n - assert vartype == 'N' + assert vartype == "N" spice.kclear() def test_lmpool_numpy(): spice.kclear() - lmpoolNames = ['DELTET/DELTA_T_A', 'DELTET/K', 'DELTET/EB', 'DELTET/M', 'DELTET/DELTA_AT'] - lmpoolLens = [1, 1, 1, 2, 46] - textbuf = np.array(['DELTET/DELTA_T_A = 32.184', 'DELTET/K = 1.657D-3', 'DELTET/EB = 1.671D-2', - 'DELTET/M = ( 6.239996 1.99096871D-7 )', 'DELTET/DELTA_AT = ( 10, @1972-JAN-1', - ' 11, @1972-JUL-1', - ' 12, @1973-JAN-1', - ' 13, @1974-JAN-1', - ' 14, @1975-JAN-1', - ' 15, @1976-JAN-1', - ' 16, @1977-JAN-1', - ' 17, @1978-JAN-1', - ' 18, @1979-JAN-1', - ' 19, @1980-JAN-1', - ' 20, @1981-JUL-1', - ' 21, @1982-JUL-1', - ' 22, @1983-JUL-1', - ' 23, @1985-JUL-1', - ' 24, @1988-JAN-1', - ' 25, @1990-JAN-1', - ' 26, @1991-JAN-1', - ' 27, @1992-JUL-1', - ' 28, @1993-JUL-1', - ' 29, @1994-JUL-1', - ' 30, @1996-JAN-1', - ' 31, @1997-JUL-1', - ' 32, @1999-JAN-1 )']) + lmpool_names = [ + "DELTET/DELTA_T_A", + "DELTET/K", + "DELTET/EB", + "DELTET/M", + "DELTET/DELTA_AT", + ] + lmpool_lens = [1, 1, 1, 2, 46] + textbuf = np.array( + [ + "DELTET/DELTA_T_A = 32.184", + "DELTET/K = 1.657D-3", + "DELTET/EB = 1.671D-2", + "DELTET/M = ( 6.239996 1.99096871D-7 )", + "DELTET/DELTA_AT = ( 10, @1972-JAN-1", + " 11, @1972-JUL-1", + " 12, @1973-JAN-1", + " 13, @1974-JAN-1", + " 14, @1975-JAN-1", + " 15, @1976-JAN-1", + " 16, @1977-JAN-1", + " 17, @1978-JAN-1", + " 18, @1979-JAN-1", + " 19, @1980-JAN-1", + " 20, @1981-JUL-1", + " 21, @1982-JUL-1", + " 22, @1983-JUL-1", + " 23, @1985-JUL-1", + " 24, @1988-JAN-1", + " 25, @1990-JAN-1", + " 26, @1991-JAN-1", + " 27, @1992-JUL-1", + " 28, @1993-JUL-1", + " 29, @1994-JUL-1", + " 30, @1996-JAN-1", + " 31, @1997-JUL-1", + " 32, @1999-JAN-1 )", + ] + ) spice.lmpool(textbuf) - for var, expectLen in zip(lmpoolNames, lmpoolLens): + for var, expectLen in zip(lmpool_names, lmpool_lens): n, vartype = spice.dtpool(var) assert expectLen == n - assert vartype == 'N' + assert vartype == "N" spice.kclear() @@ -4517,9 +5540,9 @@ def test_lmpoolstress(): def test_lparse(): - stringtest = 'one two three four' - items = spice.lparse(stringtest, ' ', 25) - assert items == ['one', 'two', 'three', 'four'] + stringtest = "one two three four" + items = spice.lparse(stringtest, " ", 25) + assert items == ["one", "two", "three", "four"] def test_lparsm(): @@ -4527,25 +5550,25 @@ def test_lparsm(): # Test with nmax (20) not equal to lenout (23), to ensure that # their purposes have not been switched within spice.lparsm() items = spice.lparsm(stringtest, " ", 20, lenout=23) - assert items == ['A', 'number', 'of', 'words', 'separated', 'by', 'spaces'] + assert items == ["A", "number", "of", "words", "separated", "by", "spaces"] # Test without lenout - items = spice.lparsm(stringtest, " ", len(stringtest)+10) - assert items == ['A', 'number', 'of', 'words', 'separated', 'by', 'spaces'] + items = spice.lparsm(stringtest, " ", len(stringtest) + 10) + assert items == ["A", "number", "of", "words", "separated", "by", "spaces"] def test_lparss(): stringtest = " A number of words separated by spaces. " delims = " ,." outset = spice.lparss(stringtest, delims) - expected = ['', 'A', 'by', 'number', 'of', 'separated', 'spaces', 'words'] + expected = ["", "A", "by", "number", "of", "separated", "spaces", "words"] assert [x for x in outset] == expected def test_lspcn(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('21 march 2005') - lon = spice.dpr() * spice.lspcn('EARTH', et, 'NONE') + et = spice.str2et("21 march 2005") + lon = spice.dpr() * spice.lspcn("EARTH", et, "NONE") spice.kclear() npt.assert_almost_equal(lon, 0.48153755894179384) @@ -4611,17 +5634,17 @@ def test_ltime(): spice.furnsh(CoreKernels.testMetaKernel) OBS = 399 TARGET = 5 - TIME_STR = 'July 4, 2004' + TIME_STR = "July 4, 2004" et = spice.str2et(TIME_STR) arrive, ltime = spice.ltime(et, OBS, "->", TARGET) - arrive_utc = spice.et2utc(arrive, 'C', 3, 50) + arrive_utc = spice.et2utc(arrive, "C", 3, 50) npt.assert_almost_equal(ltime, 2918.71705, decimal=4) - assert arrive_utc == '2004 JUL 04 00:48:38.717' + assert arrive_utc == "2004 JUL 04 00:48:38.717" receive, rtime = spice.ltime(et, OBS, "<-", TARGET) - receive_utc = spice.et2utc(receive, 'C', 3, 50) + receive_utc = spice.et2utc(receive, "C", 3, 50) spice.kclear() npt.assert_almost_equal(rtime, 2918.75247, decimal=4) - assert receive_utc == '2004 JUL 03 23:11:21.248' + assert receive_utc == "2004 JUL 03 23:11:21.248" def test_lx4dec(): @@ -4649,20 +5672,22 @@ def test_lx4uns(): def test_lxqstr(): - assert spice.lxqstr('The "SPICE" system', "\"", 4) == (10, 7) + assert spice.lxqstr('The "SPICE" system', '"', 4) == (10, 7) assert spice.lxqstr('The "SPICE" system', '"', 4) == (10, 7) assert spice.lxqstr('The "SPICE" system', '"', 0) == (-1, 0) assert spice.lxqstr('The "SPICE" system', "'", 4) == (3, 0) assert spice.lxqstr('The """SPICE"""" system', '"', 4) == (14, 11) - assert spice.lxqstr('The &&&SPICE system', '&', 4) == (5, 2) + assert spice.lxqstr("The &&&SPICE system", "&", 4) == (5, 2) assert spice.lxqstr("' '", "'", 0) == (2, 3) assert spice.lxqstr("''", "'", 0) == (1, 2) def test_m2eul(): - ticam = [[0.49127379678135830, 0.50872620321864170, 0.70699908539882417], - [-0.50872620321864193, -0.49127379678135802, 0.70699908539882428], - [0.70699908539882406, -0.70699908539882439, 0.01745240643728360]] + ticam = [ + [0.49127379678135830, 0.50872620321864170, 0.70699908539882417], + [-0.50872620321864193, -0.49127379678135802, 0.70699908539882428], + [0.70699908539882406, -0.70699908539882439, 0.01745240643728360], + ] kappa, ang2, ang1 = spice.m2eul(ticam, 3, 1, 3) alpha = ang1 + 1.5 * spice.pi() delta = spice.halfpi() - ang2 @@ -4675,7 +5700,7 @@ def test_m2q(): r = spice.rotate(spice.halfpi(), 3) q = spice.m2q(r) expected = [np.sqrt(2) / 2.0, 0.0, 0.0, -np.sqrt(2) / 2.0] - np.testing.assert_array_almost_equal(expected, q, decimal = 6) + np.testing.assert_array_almost_equal(expected, q, decimal=6) def test_matchi(): @@ -4736,7 +5761,9 @@ def test_mtxmg(): m1 = np.array([[1.0, 2.0, 3.0, 0.0], [1.0, 1.0, 1.0, 1.0]]) m2 = np.array([[1.0, 2.0, 3.0], [0.0, 0.0, 0.0]]) mout = spice.mtxmg(m1, m2, 4, 2, 3) - expected = np.array([[1.0, 2.0, 3.0], [2.0, 4.0, 6.0], [3.0, 6.0, 9.0], [0.0, 0.0, 0.0]]) + expected = np.array( + [[1.0, 2.0, 3.0], [2.0, 4.0, 6.0], [3.0, 6.0, 9.0], [0.0, 0.0, 0.0]] + ) assert np.array_equal(mout, expected) @@ -4810,7 +5837,7 @@ def test_mxvg(): def test_namfrm(): - assert spice.namfrm('J2000') == 1 + assert spice.namfrm("J2000") == 1 def test_ncpos(): @@ -4858,10 +5885,10 @@ def test_nearpt(): a, b, c = 1.0, 2.0, 3.0 point = [3.5, 0.0, 0.0] pnear, alt = spice.nearpt(point, a, b, c) - expectedPnear = [1.0, 0.0, 0.0] - expectedAlt = 2.5 - npt.assert_almost_equal(alt, expectedAlt) - npt.assert_array_almost_equal(pnear, expectedPnear) + expected_pnear = [1.0, 0.0, 0.0] + expected_alt = 2.5 + npt.assert_almost_equal(alt, expected_alt) + npt.assert_array_almost_equal(pnear, expected_pnear) def test_npedln(): @@ -4869,10 +5896,10 @@ def test_npedln(): a, b, c = 7.0e5, 7.0e5, 6.0e5 linedr = [-4.472091234e-1, -8.944182469e-1, -4.472091234e-3] pnear, dist = spice.npedln(a, b, c, linept, linedr) - expectedPnear = [-1633.3111, -3266.6222, 599991.83] - expectedDist = 2389967.9 - npt.assert_almost_equal(dist, expectedDist, decimal=1) - npt.assert_array_almost_equal(expectedPnear, pnear, decimal=2) + expected_pnear = [-1633.3111, -3266.6222, 599991.83] + expected_dist = 2389967.9 + npt.assert_almost_equal(dist, expected_dist, decimal=1) + npt.assert_array_almost_equal(expected_pnear, pnear, decimal=2) def test_npelpt(): @@ -4880,12 +5907,12 @@ def test_npelpt(): smajor = [3.0, 0.0, 0.0] sminor = [0.0, 2.0, 0.0] point = [-4.0, 2.0, 1.0] - expectedPnear = [-2.0, 2.0, 3.0] - expectedDist = 2.8284271 + expected_pnear = [-2.0, 2.0, 3.0] + expected_dist = 2.8284271 ellipse = spice.cgv2el(center, smajor, sminor) pnear, dist = spice.npelpt(point, ellipse) - npt.assert_almost_equal(dist, expectedDist) - npt.assert_array_almost_equal(expectedPnear, pnear) + npt.assert_almost_equal(dist, expected_dist) + npt.assert_array_almost_equal(expected_pnear, pnear) def test_nplnpt(): @@ -4893,30 +5920,30 @@ def test_nplnpt(): linedr = [0.0, 1.0, 1.0] point = [-6.0, 9.0, 10.0] pnear, dist = spice.nplnpt(linept, linedr, point) - expectedPnear = [1.0, 9.0, 10.0] - expectedDist = 7.0 - assert dist == expectedDist - npt.assert_array_almost_equal(expectedPnear, pnear) + expected_pnear = [1.0, 9.0, 10.0] + expected_dist = 7.0 + assert dist == expected_dist + npt.assert_array_almost_equal(expected_pnear, pnear) def test_nvc2pl(): normal = [1.0, 1.0, 1.0] constant = 23.0 - expectedConstant = 13.279056 - expectedNormal = [0.57735027, 0.57735027, 0.57735027] + expected_constant = 13.279056 + expected_normal = [0.57735027, 0.57735027, 0.57735027] plane = spice.nvc2pl(normal, constant) - npt.assert_array_almost_equal(plane.normal, expectedNormal) - npt.assert_almost_equal(plane.constant, expectedConstant, decimal=6) + npt.assert_array_almost_equal(plane.normal, expected_normal) + npt.assert_almost_equal(plane.constant, expected_constant, decimal=6) def test_nvp2pl(): normal = [1.0, 1.0, 1.0] point = [1.0, 4.0, 9.0] - expectedConstant = 8.0829038 - expectedNormal = [0.57735027, 0.57735027, 0.57735027] + expected_constant = 8.0829038 + expected_normal = [0.57735027, 0.57735027, 0.57735027] plane = spice.nvp2pl(normal, point) - npt.assert_array_almost_equal(plane.normal, expectedNormal) - npt.assert_almost_equal(plane.constant, expectedConstant, decimal=6) + npt.assert_array_almost_equal(plane.normal, expected_normal) + npt.assert_almost_equal(plane.constant, expected_constant, decimal=6) def test_occult(): @@ -4925,23 +5952,53 @@ def test_occult(): spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(ExtraKernels.earthStnSpk) spice.furnsh(ExtraKernels.earthHighPerPck) - spice.furnsh(ExtraKernels.earthTopoTf ) + spice.furnsh(ExtraKernels.earthTopoTf) # start test # Mercury transited the Sun w.r.t. Earth-based observer ca. 2006-11-08 for about 5h # cf. https://science.nasa.gov/science-news/science-at-nasa/2006/20oct_transitofmercury # Mercury was occulted by the sun about six months later et_sun_transited_by_mercury = spice.str2et("2006-11-08T22:00") - occult_code_one = spice.occult("MERCURY", "point", " ", "SUN", "ellipsoid", "IAU_SUN", "CN", "DSS-13", et_sun_transited_by_mercury) + occult_code_one = spice.occult( + "MERCURY", + "point", + " ", + "SUN", + "ellipsoid", + "IAU_SUN", + "CN", + "DSS-13", + et_sun_transited_by_mercury, + ) # Mercury is in front of the Sun as seen by observer (DSS-13) - assert occult_code_one == 2 # SPICE_OCCULT_ANNLR2 + assert occult_code_one == 2 # SPICE_OCCULT_ANNLR2 et_sun_mercury_both_visible = spice.str2et("2006-11-09T02:00") - occult_code_two = spice.occult("MERCURY", "point", " ", "SUN", "ellipsoid", "IAU_SUN", "CN", "DSS-13", et_sun_mercury_both_visible) + occult_code_two = spice.occult( + "MERCURY", + "point", + " ", + "SUN", + "ellipsoid", + "IAU_SUN", + "CN", + "DSS-13", + et_sun_mercury_both_visible, + ) # Both Mercury and the Sun are visible to observer (DSS-13) - assert occult_code_two == 0 # SPICE_OCCULT_NOOCC + assert occult_code_two == 0 # SPICE_OCCULT_NOOCC et_sun_totally_occulted_mercury = spice.str2et("2007-05-03T05:00") - occult_code_three = spice.occult("MERCURY", "point", " ", "SUN", "ellipsoid", "IAU_SUN", "CN", "DSS-13", et_sun_totally_occulted_mercury) + occult_code_three = spice.occult( + "MERCURY", + "point", + " ", + "SUN", + "ellipsoid", + "IAU_SUN", + "CN", + "DSS-13", + et_sun_totally_occulted_mercury, + ) # The Sun is in front of Mercury as seen by observer (DSS-13) - assert occult_code_three == -3 # SPICE_OCCULT_TOTAL1 + assert occult_code_three == -3 # SPICE_OCCULT_TOTAL1 # cleanup spice.kclear() @@ -4978,45 +6035,51 @@ def test_ordi(): def test_orderc(): inarray = ["a", "abc", "ab"] - expectedOrder = [0, 2, 1] + expected_order = [0, 2, 1] order = spice.orderc(inarray) - npt.assert_array_almost_equal(expectedOrder, order) + npt.assert_array_almost_equal(expected_order, order) # Using ndim order = spice.orderc(inarray, ndim=len(inarray)) - npt.assert_array_almost_equal(expectedOrder, order) + npt.assert_array_almost_equal(expected_order, order) def test_orderd(): inarray = [0.0, 2.0, 1.0] - expectedOrder = [0, 2, 1] + expected_order = [0, 2, 1] order = spice.orderd(inarray) - npt.assert_array_almost_equal(expectedOrder, order) + npt.assert_array_almost_equal(expected_order, order) # Using ndim order = spice.orderd(inarray, ndim=len(inarray)) - npt.assert_array_almost_equal(expectedOrder, order) + npt.assert_array_almost_equal(expected_order, order) def test_orderi(): inarray = [0, 2, 1] - expectedOrder = [0, 2, 1] + expected_order = [0, 2, 1] order = spice.orderi(inarray) - npt.assert_array_almost_equal(expectedOrder, order) + npt.assert_array_almost_equal(expected_order, order) # Using ndim order = spice.orderi(inarray, ndim=len(inarray)) - npt.assert_array_almost_equal(expectedOrder, order) + npt.assert_array_almost_equal(expected_order, order) def test_oscelt(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('Dec 25, 2007') - state, ltime = spice.spkezr('Moon', et, 'J2000', 'LT+S', 'EARTH') - mass_earth = spice.bodvrd('EARTH', 'GM', 1) + et = spice.str2et("Dec 25, 2007") + state, ltime = spice.spkezr("Moon", et, "J2000", "LT+S", "EARTH") + mass_earth = spice.bodvrd("EARTH", "GM", 1) elts = spice.oscelt(state, et, mass_earth[0]) - expected = [3.65914105273643566761e+05, 4.23931145731340453494e+05, - 4.87177926278510253777e-01, 6.18584206992959551030e+00, - 1.88544634402406319218e+00, 1.86769787246217056236e+04, - 2.51812865183709204197e+08, 1.00000000000000000000e+00] + expected = [ + 3.65914105273643566761e05, + 4.23931145731340453494e05, + 4.87177926278510253777e-01, + 6.18584206992959551030e00, + 1.88544634402406319218e00, + 1.86769787246217056236e04, + 2.51812865183709204197e08, + 1.00000000000000000000e00, + ] npt.assert_array_almost_equal(elts, expected, decimal=4) spice.kclear() @@ -5029,16 +6092,23 @@ def test_oscltx_stress(): def test_oscltx(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('Dec 25, 2007') - state, ltime = spice.spkezr('Moon', et, 'J2000', 'LT+S', 'EARTH') - mass_earth = spice.bodvrd('EARTH', 'GM', 1) + et = spice.str2et("Dec 25, 2007") + state, ltime = spice.spkezr("Moon", et, "J2000", "LT+S", "EARTH") + mass_earth = spice.bodvrd("EARTH", "GM", 1) elts = spice.oscltx(state, et, mass_earth[0]) - expected = [3.65914105273643566761e+05, 4.23931145731340453494e+05, - 4.87177926278510253777e-01, 6.18584206992959551030e+00, - 1.88544634402406319218e+00, 1.86769787246217056236e+04, - 2.51812865183709204197e+08, 1.00000000000000000000e+00, - 4.40283687897870881778e-02, -8.63147169311087925081e-01, - 0.00000000000000000000e+00] + expected = [ + 3.65914105273643566761e05, + 4.23931145731340453494e05, + 4.87177926278510253777e-01, + 6.18584206992959551030e00, + 1.88544634402406319218e00, + 1.86769787246217056236e04, + 2.51812865183709204197e08, + 1.00000000000000000000e00, + 4.40283687897870881778e-02, + -8.63147169311087925081e-01, + 0.00000000000000000000e00, + ] npt.assert_array_almost_equal(elts, expected, decimal=4) spice.kclear() @@ -5046,14 +6116,16 @@ def test_oscltx(): def test_pckopn_pckw02_pckcls(): pck = os.path.join(cwd, "test_pck.pck") if spice.exists(pck): - os.remove(pck) # pragma: no cover + os.remove(pck) # pragma: no cover spice.kclear() handle = spice.pckopn(pck, "Test PCK file", 5000) - spice.pckw02(handle, 301, "j2000", 0.0, 3.0, "segid", 1.0, 3, 1, [1.0, 2.0, 3.0], 0.0) + spice.pckw02( + handle, 301, "j2000", 0.0, 3.0, "segid", 1.0, 3, 1, [1.0, 2.0, 3.0], 0.0 + ) spice.pckcls(handle) spice.kclear() if spice.exists(pck): - os.remove(pck) # pragma: no cover + os.remove(pck) # pragma: no cover def test_pckcov(): @@ -5095,10 +6167,11 @@ def test_pckuof(): def test_pcpool(): import string + spice.kclear() data = [j + str(i) for i, j in enumerate(list(string.ascii_lowercase))] - spice.pcpool('pcpool_test', data) - cvals = spice.gcpool('pcpool_test', 0, 30, 4) + spice.pcpool("pcpool_test", data) + cvals = spice.gcpool("pcpool_test", 0, 30, 4) assert data == cvals spice.kclear() @@ -5106,8 +6179,8 @@ def test_pcpool(): def test_pdpool(): spice.kclear() data = np.arange(0.0, 10.0) - spice.pdpool('pdpool_array', data) - dvals = spice.gdpool('pdpool_array', 0, 30) + spice.pdpool("pdpool_array", data) + dvals = spice.gdpool("pdpool_array", 0, 30) npt.assert_array_almost_equal(data, dvals) spice.kclear() @@ -5120,42 +6193,78 @@ def test_pgrrec(): rp = radii[2] f = (re - rp) / re rectan = spice.pgrrec("Mars", 90.0 * spice.rpd(), 45 * spice.rpd(), 300, re, f) - expected = [1.604650025e-13, -2.620678915e+3, 2.592408909e+3] + expected = [1.604650025e-13, -2.620678915e3, 2.592408909e3] npt.assert_array_almost_equal(rectan, expected) spice.kclear() def test_phaseq(): relate = ["=", "<", ">", "LOCMIN", "ABSMIN", "LOCMAX", "ABSMAX"] - expected = {"=": [0.575988450, 0.575988450, 0.575988450, 0.575988450, 0.575988450, - 0.575988450, 0.575988450, 0.575988450, 0.575988450, 0.575988450], - "<": [0.575988450, 0.575988450, 0.575988450, 0.575988450, 0.575988450, 0.468279091], - ">": [0.940714974, 0.575988450, 0.575988450, 0.575988450, 0.575988450, 0.575988450], - "LOCMIN": [0.086121423, 0.086121423, 0.079899769, 0.079899769], - "ABSMIN": [0.079899769, 0.079899769], - "LOCMAX": [3.055062862, 3.055062862, 3.074603891, 3.074603891], - "ABSMAX": [3.074603891, 3.074603891] + expected = { + "=": [ + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + ], + "<": [ + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + 0.468279091, + ], + ">": [ + 0.940714974, + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + 0.575988450, + ], + "LOCMIN": [0.086121423, 0.086121423, 0.079899769, 0.079899769], + "ABSMIN": [0.079899769, 0.079899769], + "LOCMAX": [3.055062862, 3.055062862, 3.074603891, 3.074603891], + "ABSMAX": [3.074603891, 3.074603891], } spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et0 = spice.str2et('2006 DEC 01') - et1 = spice.str2et('2007 JAN 31') + et0 = spice.str2et("2006 DEC 01") + et1 = spice.str2et("2007 JAN 31") cnfine = spice.cell_double(2) spice.wninsd(et0, et1, cnfine) result = spice.cell_double(10000) for relation in relate: - spice.gfpa("Moon", "Sun", "LT+S", "Earth", relation, 0.57598845, - 0.0, spice.spd(), 5000, cnfine, result) + spice.gfpa( + "Moon", + "Sun", + "LT+S", + "Earth", + relation, + 0.57598845, + 0.0, + spice.spd(), + 5000, + cnfine, + result, + ) count = spice.wncard(result) if count > 0: - tempResults = [] + temp_results = [] for i in range(0, count): start, stop = spice.wnfetd(result, i) startPhase = spice.phaseq(start, "moon", "sun", "earth", "lt+s") stopPhase = spice.phaseq(stop, "moon", "sun", "earth", "lt+s") - tempResults.append(startPhase) - tempResults.append(stopPhase) - npt.assert_array_almost_equal(tempResults, expected.get(relation)) + temp_results.append(startPhase) + temp_results.append(stopPhase) + npt.assert_array_almost_equal(temp_results, expected.get(relation)) spice.kclear() @@ -5166,8 +6275,8 @@ def test_pi(): def test_pipool(): spice.kclear() data = np.arange(0, 10) - spice.pipool('pipool_array', data) - ivals = spice.gipool('pipool_array', 0, 50) + spice.pipool("pipool_array", data) + ivals = spice.gipool("pipool_array", 0, 50) npt.assert_array_almost_equal(data, ivals) spice.kclear() @@ -5180,12 +6289,12 @@ def test_pjelpl(): plane = spice.nvc2pl(normal, 0.0) elin = spice.cgv2el(center, vec1, vec2) ellipse = spice.pjelpl(elin, plane) - expectedSmajor = [2.0, 0.0, 0.0] - expectedSminor = [0.0, 1.0, 0.0] - expectedCenter = [1.0, 1.0, 0.0] - npt.assert_array_almost_equal(expectedCenter, ellipse.center) - npt.assert_array_almost_equal(expectedSmajor, ellipse.semi_major) - npt.assert_array_almost_equal(expectedSminor, ellipse.semi_minor) + expected_s_major = [2.0, 0.0, 0.0] + expected_s_minor = [0.0, 1.0, 0.0] + expected_center = [1.0, 1.0, 0.0] + npt.assert_array_almost_equal(expected_center, ellipse.center) + npt.assert_array_almost_equal(expected_s_major, ellipse.semi_major) + npt.assert_array_almost_equal(expected_s_minor, ellipse.semi_minor) def test_pl2nvc(): @@ -5193,9 +6302,9 @@ def test_pl2nvc(): point = [9.0, -0.65, -12.0] plane = spice.nvp2pl(normal, point) normal, constant = spice.pl2nvc(plane) - expectedNormal = [-0.16169042, 0.80845208, -0.56591646] + expected_normal = [-0.16169042, 0.80845208, -0.56591646] npt.assert_almost_equal(constant, 4.8102899, decimal=6) - npt.assert_array_almost_equal(expectedNormal, normal, decimal=6) + npt.assert_array_almost_equal(expected_normal, normal, decimal=6) def test_pl2nvp(): @@ -5203,8 +6312,8 @@ def test_pl2nvp(): const = 3.141592654 plane = spice.nvc2pl(plane_norm, const) norm_vec, point = spice.pl2nvp(plane) - expectedPoint = [0.74966576, -0.51206678, 0.37551564] - npt.assert_array_almost_equal(expectedPoint, point) + expected_point = [0.74966576, -0.51206678, 0.37551564] + npt.assert_array_almost_equal(expected_point, point) def test_pl2psv(): @@ -5224,9 +6333,17 @@ def test_pltar(): def test_pltexp(): - iverts = [[np.sqrt(3.0) / 2.0, -0.5, 7.0], [0.0, 1.0, 7.0], [-np.sqrt(3.0) / 2.0, -0.5, 7.0]] + iverts = [ + [np.sqrt(3.0) / 2.0, -0.5, 7.0], + [0.0, 1.0, 7.0], + [-np.sqrt(3.0) / 2.0, -0.5, 7.0], + ] overts = spice.pltexp(iverts, 1.0) - expected = [[1.732050807569, -1.0, 7.0], [0.0, 2.0, 7.0], [-1.732050807569, -1.0, 7.0]] + expected = [ + [1.732050807569, -1.0, 7.0], + [0.0, 2.0, 7.0], + [-1.732050807569, -1.0, 7.0], + ] npt.assert_array_almost_equal(expected, overts) @@ -5236,25 +6353,25 @@ def test_pltnp(): v2 = [0.0, 1.0, 0.0] v3 = [0.0, 0.0, 1.0] near, distance = spice.pltnp(point, v1, v2, v3) - npt.assert_array_almost_equal([1.0/3.0, 1.0/3.0, 1.0/3.0], near) + npt.assert_array_almost_equal([1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0], near) assert distance == pytest.approx(2.8867513) def test_pltnrm(): - v1 = [np.sqrt(3.0)/2.0, -0.5, 0.0] + v1 = [np.sqrt(3.0) / 2.0, -0.5, 0.0] v2 = [0.0, 1.0, 0.0] - v3 = [-np.sqrt(3.0)/2.0, -0.5, 0.0] + v3 = [-np.sqrt(3.0) / 2.0, -0.5, 0.0] npt.assert_array_almost_equal([0.0, 0.0, 2.59807621135], spice.pltnrm(v1, v2, v3)) def test_pltvol(): vrtces = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] plates = [[1, 4, 3], [1, 2, 4], [1, 3, 2], [2, 3, 4]] - assert spice.pltvol(vrtces, plates) == pytest.approx(1.0/6.0) + assert spice.pltvol(vrtces, plates) == pytest.approx(1.0 / 6.0) def test_polyds(): - result = spice.polyds([1., 3., 0.5, 1., 0.5, -1., 1.], 6, 3, 1) + result = spice.polyds([1.0, 3.0, 0.5, 1.0, 0.5, -1.0, 1.0], 6, 3, 1) npt.assert_array_almost_equal([6.0, 10.0, 23.0, 78.0], result) @@ -5298,7 +6415,16 @@ def test_prop2b(): r = 1.0e8 speed = np.sqrt(mu / r) t = spice.pi() * (r / speed) - pvinit = np.array([0.0, r / np.sqrt(2.0), r / np.sqrt(2.0), 0.0, -speed / np.sqrt(2.0), speed / np.sqrt(2.0)]) + pvinit = np.array( + [ + 0.0, + r / np.sqrt(2.0), + r / np.sqrt(2.0), + 0.0, + -speed / np.sqrt(2.0), + speed / np.sqrt(2.0), + ] + ) state = np.array(spice.prop2b(mu, pvinit, t)) npt.assert_array_almost_equal(state, -1.0 * pvinit, decimal=6) @@ -5313,18 +6439,20 @@ def test_prsint(): def test_psv2pl(): spice.kclear() - epoch = 'Jan 1 2005' - frame = 'ECLIPJ2000' + epoch = "Jan 1 2005" + frame = "ECLIPJ2000" spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et(epoch) - state, ltime = spice.spkezr('EARTH', et, frame, 'NONE', 'Solar System Barycenter') + state, ltime = spice.spkezr("EARTH", et, frame, "NONE", "Solar System Barycenter") es_plane = spice.psv2pl(state[0:3], state[0:3], state[3:6]) es_norm, es_const = spice.pl2nvc(es_plane) - mstate, mltime = spice.spkezr('MOON', et, frame, 'NONE', 'EARTH BARYCENTER') + mstate, mltime = spice.spkezr("MOON", et, frame, "NONE", "EARTH BARYCENTER") em_plane = spice.psv2pl(mstate[0:3], mstate[0:3], mstate[3:6]) em_norm, em_const = spice.pl2nvc(em_plane) spice.kclear() - npt.assert_almost_equal(spice.vsep(es_norm, em_norm) * spice.dpr(), 5.0424941, decimal=6) + npt.assert_almost_equal( + spice.vsep(es_norm, em_norm) * spice.dpr(), 5.0424941, decimal=6 + ) def test_pxform(): @@ -5333,14 +6461,14 @@ def test_pxform(): lon = 118.25 * spice.rpd() lat = 34.05 * spice.rpd() alt = 0.0 - utc = 'January 1, 2005' + utc = "January 1, 2005" et = spice.str2et(utc) - len, abc = spice.bodvrd('EARTH', 'RADII', 3) + len, abc = spice.bodvrd("EARTH", "RADII", 3) equatr = abc[0] polar = abc[2] f = (equatr - polar) / equatr epos = spice.georec(lon, lat, alt, equatr, f) - rotate = np.array(spice.pxform('IAU_EARTH', 'J2000', et)) + rotate = np.array(spice.pxform("IAU_EARTH", "J2000", et)) spice.kclear() jstate = np.dot(epos, rotate) expected = np.array([5042.1309421, 1603.52962986, 3549.82398086]) @@ -5364,14 +6492,23 @@ def test_pxfrm2(): camid = spice.bodn2c("CASSINI_ISS_NAC") shape, obsref, bsight, n, bounds = spice.getfov(camid, 4) # run sincpt on boresight vector - spoint, etemit, srfvec = spice.sincpt("Ellipsoid", 'Enceladus', etrec, "IAU_ENCELADUS", "CN+S", "CASSINI", obsref, bsight) + spoint, etemit, srfvec = spice.sincpt( + "Ellipsoid", + "Enceladus", + etrec, + "IAU_ENCELADUS", + "CN+S", + "CASSINI", + obsref, + bsight, + ) rotate = spice.pxfrm2(obsref, "IAU_ENCELADUS", etrec, etemit) # get radii num_vals, radii = spice.bodvrd("Enceladus", "RADII", 3) # find position of center with respect to MGS pcassmr = spice.vsub(spoint, srfvec) # rotate into IAU_MARS - bndvec = spice.mxv(rotate, spice.vlcom(0.9999,bsight,0.0001,bounds[1])) + bndvec = spice.mxv(rotate, spice.vlcom(0.9999, bsight, 0.0001, bounds[1])) # get surface point spoint = spice.surfpt(pcassmr, bndvec, radii[0], radii[1], radii[2]) radius, lon, lat = spice.reclat(spoint) @@ -5379,17 +6516,21 @@ def test_pxfrm2(): lat *= spice.dpr() # test output npt.assert_almost_equal(radius, 250.14507342586242, decimal=5) - npt.assert_almost_equal(lon, 125.42089677611104, decimal=5) - npt.assert_almost_equal(lat, -6.3718522103931585, decimal=5) + npt.assert_almost_equal(lon, 125.42089677611104, decimal=5) + npt.assert_almost_equal(lat, -6.3718522103931585, decimal=5) # end of test spice.kclear() def test_q2m(): mout = spice.q2m(np.array([0.5, 0.4, 0.3, 0.1])) - expected = np.array([[0.607843137254902, 0.27450980392156854, 0.7450980392156862], - [0.6666666666666666, 0.33333333333333326, -0.6666666666666666], - [-0.43137254901960775, 0.9019607843137255, 0.019607843137254832]]) + expected = np.array( + [ + [0.607843137254902, 0.27450980392156854, 0.7450980392156862], + [0.6666666666666666, 0.33333333333333326, -0.6666666666666666], + [-0.43137254901960775, 0.9019607843137255, 0.019607843137254832], + ] + ) assert np.array_equal(expected, mout) @@ -5398,7 +6539,7 @@ def test_qcktrc(): spice.chkin("test") spice.chkin("qcktrc") trace = spice.qcktrc(40) - assert trace == 'test --> qcktrc' + assert trace == "test --> qcktrc" spice.chkout("qcktrc") spice.chkout("test") spice.reset() @@ -5434,15 +6575,17 @@ def test_qxq(): def test_radrec(): npt.assert_array_almost_equal([1.0, 0.0, 0.0], spice.radrec(1.0, 0.0, 0.0)) - npt.assert_array_almost_equal([0.0, 1.0, 0.0], spice.radrec(1.0, 90.0 * spice.rpd(), 0.0)) - npt.assert_array_almost_equal([0.0, 0.0, 1.0], spice.radrec(1.0, 0.0, 90.0 * spice.rpd())) + npt.assert_array_almost_equal( + [0.0, 1.0, 0.0], spice.radrec(1.0, 90.0 * spice.rpd(), 0.0) + ) + npt.assert_array_almost_equal( + [0.0, 0.0, 1.0], spice.radrec(1.0, 0.0, 90.0 * spice.rpd()) + ) def test_rav2xf(): e = [1.0, 0.0, 0.0] - rz = [[0.0, 1.0, 0.0], - [-1.0, 0.0, 0.0], - [0.0, 0.0, 1.0]] + rz = [[0.0, 1.0, 0.0], [-1.0, 0.0, 0.0], [0.0, 0.0, 1.0]] assert spice.rav2xf(rz, e) is not None @@ -5451,20 +6594,21 @@ def test_raxisa(): angle = 0.1 * spice.twopi() rotate_matrix = spice.axisar(axis, angle) axout, angout = spice.raxisa(rotate_matrix) - expectedAngout = [0.26726124, 0.53452248, 0.80178373] + expected_angout = [0.26726124, 0.53452248, 0.80178373] npt.assert_approx_equal(angout, 0.62831853, significant=7) - npt.assert_array_almost_equal(axout, expectedAngout) + npt.assert_array_almost_equal(axout, expected_angout) def test_rdtext(): import datetime + # Create ISO UTC datetime string using current time utcnow = datetime.datetime.utcnow().isoformat() spice.reset() spice.kclear() # Create temporary filenames - RDTEXT=os.path.join(cwd, 'ex_rdtext.txt') - xRDTEXT=os.path.join(cwd, 'xex_rdtext.txt') + RDTEXT = os.path.join(cwd, "ex_rdtext.txt") + xRDTEXT = os.path.join(cwd, "xex_rdtext.txt") # Ensure files do not exist if spice.exists(RDTEXT): os.remove(RDTEXT) # pragma no cover @@ -5474,11 +6618,11 @@ def test_rdtext(): unit = spice.txtopn(RDTEXT) xunit = spice.txtopn(xRDTEXT) # Build base lines - writln_lines = ['{} writln_ to x.txt {}'.format(c, utcnow) for c in '12'] - xwritln_lines = ['x{}'.format(writln_line) for writln_line in writln_lines] + writln_lines = ["{} writln_ to x.txt {}".format(c, utcnow) for c in "12"] + xwritln_lines = ["x{}".format(writln_line) for writln_line in writln_lines] # Write lines to the files using FORTRAN SPICE WRITLN for writln_line in writln_lines: - xwritln_line = 'x{}'.format(writln_line,) + xwritln_line = "x{}".format(writln_line,) spice.writln(writln_line, unit) spice.writln(xwritln_line, xunit) # Close the FORTRAN logical units using ftncls @@ -5493,24 +6637,30 @@ def test_rdtext(): with pytest.raises(spice.stypes.SpiceyError): xclosed_unit = spice.fn2lun(xRDTEXT) spice.reset() + # Wrapper function to call spice.rdtext and assert expected result def rdtext_helper(filename, expected_line, expected_done): read_line, done = spice.rdtext(filename, 99) assert (read_line == expected_line) and (done is expected_done) + # rdtext_helper(RDTEXT, writln_lines[0], False) # Read first line from RDTEXT rdtext_helper(RDTEXT, writln_lines[1], False) # Read second line from RDTEXT - rdtext_helper(RDTEXT, '', True) # Read another time from RDTEXT to confirm done will be set to True at end of file - rdtext_helper(RDTEXT, writln_lines[0], False) # Read another time from RDTEXT to confirm file will be re-opened + rdtext_helper( + RDTEXT, "", True + ) # Read another time from RDTEXT to confirm done will be set to True at end of file + rdtext_helper( + RDTEXT, writln_lines[0], False + ) # Read another time from RDTEXT to confirm file will be re-opened spice.cltext(RDTEXT) # Close text file. # Read two files in interleaved (1, 2, 2, 1) sequence to verify that can be done - rdtext_helper( RDTEXT, writln_lines[0], False) # Read first line from RDTEXT + rdtext_helper(RDTEXT, writln_lines[0], False) # Read first line from RDTEXT rdtext_helper(xRDTEXT, xwritln_lines[0], False) # Read first line from xRDTEXT rdtext_helper(xRDTEXT, xwritln_lines[1], False) # Read second line from xRDTEXT - rdtext_helper( RDTEXT, writln_lines[1], False) # Read second line from RDTEXT + rdtext_helper(RDTEXT, writln_lines[1], False) # Read second line from RDTEXT # Check end-of-file cases - rdtext_helper( RDTEXT, '', True) - rdtext_helper(xRDTEXT, '', True) + rdtext_helper(RDTEXT, "", True) + rdtext_helper(xRDTEXT, "", True) # Cleanup spice.reset() spice.kclear() @@ -5576,7 +6726,7 @@ def test_recrad(): def test_recsph(): v1 = np.array([-1.0, 0.0, 0.0]) - assert spice.recsph(v1) == (1.0, np.pi/2, np.pi) + assert spice.recsph(v1) == (1.0, np.pi / 2, np.pi) def test_removc(): @@ -5584,8 +6734,8 @@ def test_removc(): items = ["one", "two", "three", "four"] for i in items: spice.insrtc(i, cell) - removeItems = ["three", "four"] - for r in removeItems: + remove_items = ["three", "four"] + for r in remove_items: spice.removc(r, cell) expected = ["one", "two"] assert expected == [x for x in cell] @@ -5596,8 +6746,8 @@ def test_removd(): items = [0.0, 1.0, 1.0, 2.0, 3.0, 5.0, 8.0, 13.0, 21.0] for i in items: spice.insrtd(i, cell) - removeItems = [0.0, 2.0, 4.0, 6.0, 8.0, 12.0] - for r in removeItems: + remove_items = [0.0, 2.0, 4.0, 6.0, 8.0, 12.0] + for r in remove_items: spice.removd(r, cell) expected = [1.0, 3.0, 5.0, 13.0, 21.0] for x, y in zip(cell, expected): @@ -5609,8 +6759,8 @@ def test_removi(): items = [0, 1, 1, 2, 3, 5, 8, 13, 21] for i in items: spice.insrti(i, cell) - removeItems = [0, 2, 4, 6, 8, 12] - for r in removeItems: + remove_items = [0, 2, 4, 6, 8, 12] + for r in remove_items: spice.removi(r, cell) expected = [1, 3, 5, 13, 21] for x, y in zip(cell, expected): @@ -5625,6 +6775,7 @@ def test_reordc(): with pytest.raises(AssertionError): assert outarray == ["zero", "one", "two", "three"] + def test_reordd(): array = [1.0, 3.0, 2.0] iorder = [0, 2, 1] @@ -5654,22 +6805,22 @@ def test_repmc(): def test_repmct(): stringtestone = "The value is #" - outstringone = spice.repmct(stringtestone, '#', 5, 'U') - outstringtwo = spice.repmct(stringtestone, '#', 5, 'l') + outstringone = spice.repmct(stringtestone, "#", 5, "U") + outstringtwo = spice.repmct(stringtestone, "#", 5, "l") assert outstringone == "The value is FIVE" assert outstringtwo == "The value is five" def test_repmd(): stringtestone = "The value is #" - outstringone = spice.repmd(stringtestone, '#', 5.0e11, 1) + outstringone = spice.repmd(stringtestone, "#", 5.0e11, 1) assert outstringone == "The value is 5.E+11" def test_repmf(): stringtestone = "The value is #" - outstringone = spice.repmf(stringtestone, '#', 5.0e3, 5, 'f') - outstringtwo = spice.repmf(stringtestone, '#', -5.2e-9, 3, 'e') + outstringone = spice.repmf(stringtestone, "#", 5.0e3, 5, "f") + outstringtwo = spice.repmf(stringtestone, "#", -5.2e-9, 3, "e") assert outstringone == "The value is 5000.0" assert outstringtwo == "The value is -5.20E-09" @@ -5682,8 +6833,8 @@ def test_repmi(): def test_repmot(): stringtestone = "The value is #" - outstringone = spice.repmot(stringtestone, '#', 5, 'U') - outstringtwo = spice.repmot(stringtestone, '#', 5, 'l') + outstringone = spice.repmot(stringtestone, "#", 5, "U") + outstringtwo = spice.repmot(stringtestone, "#", 5, "l") assert outstringone == "The value is FIFTH" assert outstringtwo == "The value is fifth" @@ -5701,28 +6852,28 @@ def test_return_c(): def test_rotate(): mout = spice.rotate(spice.pi() / 4, 3) - mExpected = [[np.sqrt(2) / 2.0, np.sqrt(2) / 2.0, 0.0], - [-np.sqrt(2) / 2.0, np.sqrt(2) / 2.0, 0.0], - [0.0, 0.0, 1.0]] + mExpected = [ + [np.sqrt(2) / 2.0, np.sqrt(2) / 2.0, 0.0], + [-np.sqrt(2) / 2.0, np.sqrt(2) / 2.0, 0.0], + [0.0, 0.0, 1.0], + ] npt.assert_array_almost_equal(mout, mExpected) def test_rotmat(): ident = spice.ident() - expectedR = [[0.0, 0.0, -1.0], - [0.0, 1.0, 0.0], - [1.0, 0.0, 0.0]] - rOut = spice.rotmat(ident, spice.halfpi(), 2) - npt.assert_array_almost_equal(rOut, expectedR) + expected_r = [[0.0, 0.0, -1.0], [0.0, 1.0, 0.0], [1.0, 0.0, 0.0]] + r_out = spice.rotmat(ident, spice.halfpi(), 2) + npt.assert_array_almost_equal(r_out, expected_r) def test_rotvec(): vin = [np.sqrt(2), 0.0, 0.0] angle = spice.pi() / 4 iaxis = 3 - vExpected = [1.0, -1.0, 0.0] + v_expected = [1.0, -1.0, 0.0] vout = spice.rotvec(vin, angle, iaxis) - npt.assert_array_almost_equal(vout, vExpected) + npt.assert_array_almost_equal(vout, v_expected) def test_rpd(): @@ -5732,20 +6883,20 @@ def test_rpd(): def test_rquad(): # solve x^2 + 2x + 3 = 0 root1, root2 = spice.rquad(1.0, 2.0, 3.0) - expectedRootOne = [-1.0, np.sqrt(2.0)] - expectedRootTwo = [-1.0, -np.sqrt(2.0)] - npt.assert_array_almost_equal(root1, expectedRootOne) - npt.assert_array_almost_equal(root2, expectedRootTwo) + expected_root_one = [-1.0, np.sqrt(2.0)] + expected_root_two = [-1.0, -np.sqrt(2.0)] + npt.assert_array_almost_equal(root1, expected_root_one) + npt.assert_array_almost_equal(root2, expected_root_two) def test_saelgv(): vec1 = [1.0, 1.0, 1.0] vec2 = [1.0, -1.0, 1.0] - expectedSmajor = [np.sqrt(2.0), 0.0, np.sqrt(2.0)] - expectedSminor = [0.0, np.sqrt(2.0), 0.0] + expected_s_major = [np.sqrt(2.0), 0.0, np.sqrt(2.0)] + expected_s_minor = [0.0, np.sqrt(2.0), 0.0] smajor, sminor = spice.saelgv(vec1, vec2) - npt.assert_array_almost_equal(smajor, expectedSmajor) - npt.assert_array_almost_equal(sminor, expectedSminor) + npt.assert_array_almost_equal(smajor, expected_s_major) + npt.assert_array_almost_equal(sminor, expected_s_minor) def test_scard(): @@ -5763,9 +6914,9 @@ def test_scdecd(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(ExtraKernels.voyagerSclk) - timein = spice.scencd(-32, '2/20538:39:768') + timein = spice.scencd(-32, "2/20538:39:768") sclkch = spice.scdecd(-32, timein) - assert sclkch == '2/20538:39:768' + assert sclkch == "2/20538:39:768" spice.kclear() @@ -5773,7 +6924,7 @@ def test_sce2c(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(ExtraKernels.voyagerSclk) - et = spice.str2et('1979 JUL 05 21:50:21.23379') + et = spice.str2et("1979 JUL 05 21:50:21.23379") sclkdp = spice.sce2c(-32, et) npt.assert_almost_equal(sclkdp, 985327949.9999709, decimal=6) spice.kclear() @@ -5783,7 +6934,7 @@ def test_sce2s(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(ExtraKernels.voyagerSclk) - et = spice.str2et('1979 JUL 05 21:50:21.23379') + et = spice.str2et("1979 JUL 05 21:50:21.23379") sclkch = spice.sce2s(-32, et) assert sclkch == "2/20538:39:768" spice.kclear() @@ -5793,7 +6944,7 @@ def test_sce2t(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(ExtraKernels.voyagerSclk) - et = spice.str2et('1979 JUL 05 21:50:21.23379') + et = spice.str2et("1979 JUL 05 21:50:21.23379") sclkdp = spice.sce2t(-32, et) npt.assert_almost_equal(sclkdp, 985327950.000000) spice.kclear() @@ -5814,12 +6965,12 @@ def test_scencd_vectorized(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(ExtraKernels.voyagerSclk) - sclkch = '2/20538:39:768' + sclkch = "2/20538:39:768" sclkdp = spice.scencd(-32, 3 * [sclkch]) - npt.assert_almost_equal(sclkdp, 3*[985327950.0], decimal=6) + npt.assert_almost_equal(sclkdp, 3 * [985327950.0], decimal=6) spice.kclear() - - + + def test_scfmt(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) @@ -5846,9 +6997,9 @@ def test_scs2e(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(ExtraKernels.voyagerSclk) - et = spice.scs2e(-32, '2/20538:39:768') + et = spice.scs2e(-32, "2/20538:39:768") npt.assert_almost_equal(et, -646668528.58222842) - utc = spice.et2utc(et, 'C', 3, 50) + utc = spice.et2utc(et, "C", 3, 50) assert utc == "1979 JUL 05 21:50:21.234" spice.kclear() @@ -5858,7 +7009,7 @@ def test_sct2e(): spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(ExtraKernels.voyagerSclk) et = spice.sct2e(-32, 985327965.0) - utc = spice.et2utc(et, 'C', 3, 50) + utc = spice.et2utc(et, "C", 3, 50) assert utc == "1979 JUL 05 21:50:22.134" spice.kclear() @@ -5873,13 +7024,13 @@ def test_sct2e_vectorized(): expected = -646668527.6822292 npt.assert_almost_equal(3 * [expected], to_test, decimal=6) spice.kclear() - - + + def test_sctiks(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(ExtraKernels.voyagerSclk) - ticks = spice.sctiks(-32, '20656:14:768') + ticks = spice.sctiks(-32, "20656:14:768") assert ticks == 991499967.00000000 spice.kclear() @@ -5899,30 +7050,30 @@ def test_sdiff(): # SPICECHAR_CELL a = spice.cell_char(8, 8) b = spice.cell_char(8, 8) - spice.insrtc('1', a) - spice.insrtc('2', a) - spice.insrtc('5', a) - spice.insrtc('3', b) - spice.insrtc('4', b) - spice.insrtc('5', b) + spice.insrtc("1", a) + spice.insrtc("2", a) + spice.insrtc("5", a) + spice.insrtc("3", b) + spice.insrtc("4", b) + spice.insrtc("5", b) c = spice.sdiff(a, b) - assert [x for x in c] == ['1', '2', '3', '4'] + assert [x for x in c] == ["1", "2", "3", "4"] # SPICEDOUBLE_CELL a = spice.cell_double(8) b = spice.cell_double(8) - spice.insrtd(1., a) - spice.insrtd(2., a) - spice.insrtd(5., a) - spice.insrtd(3., b) - spice.insrtd(4., b) - spice.insrtd(5., b) + spice.insrtd(1.0, a) + spice.insrtd(2.0, a) + spice.insrtd(5.0, a) + spice.insrtd(3.0, b) + spice.insrtd(4.0, b) + spice.insrtd(5.0, b) c = spice.sdiff(a, b) - assert [x for x in c] == [1., 2., 3., 4.] + assert [x for x in c] == [1.0, 2.0, 3.0, 4.0] # SPICEBOOLEAN_CELL - testCellOne = spice.cell_bool(9) - testCellTwo = spice.cell_bool(9) + test_cell_one = spice.cell_bool(9) + test_cell_two = spice.cell_bool(9) with pytest.raises(NotImplementedError): - spice.sdiff(testCellOne, testCellTwo) + spice.sdiff(test_cell_one, test_cell_two) def test_set_c(): @@ -5997,20 +7148,28 @@ def test_sincpt(): camid = spice.bodn2c("CASSINI_ISS_NAC") shape, frame, bsight, n, bounds = spice.getfov(camid, 4) # run sincpt on boresight vector - spoint, trgepc, obspos = spice.sincpt("Ellipsoid", 'Enceladus', et, "IAU_ENCELADUS", "CN+S", "CASSINI", frame, bsight) + spoint, trgepc, obspos = spice.sincpt( + "Ellipsoid", "Enceladus", et, "IAU_ENCELADUS", "CN+S", "CASSINI", frame, bsight + ) npt.assert_almost_equal(trgepc, 415065064.9055491) - expected_spoint = [-143.56046004007180272311, 202.90045955888857065474, - -27.99454300594213052022] - expected_obspos = [-329794.62202281970530748367, -557628.89673861570190638304, - 217721.3870436516881454736] + expected_spoint = [ + -143.56046004007180272311, + 202.90045955888857065474, + -27.99454300594213052022, + ] + expected_obspos = [ + -329794.62202281970530748367, + -557628.89673861570190638304, + 217721.3870436516881454736, + ] npt.assert_array_almost_equal(spoint, expected_spoint, 5) npt.assert_array_almost_equal(obspos, expected_obspos, 5) spice.kclear() def test_size(): - testCellOne = spice.cell_int(8) - assert spice.size(testCellOne) == 8 + test_cell_one = spice.cell_int(8) + assert spice.size(test_cell_one) == 8 def test_spd(): @@ -6035,40 +7194,100 @@ def test_sphrec(): expected3 = np.array([0.0, 0.0, -1.0]) npt.assert_array_almost_equal(spice.sphrec(0.0, 0.0, 0.0), expected1) npt.assert_array_almost_equal(spice.sphrec(1.0, 90.0 * spice.rpd(), 0.0), expected2) - npt.assert_array_almost_equal(spice.sphrec(1.0, 180.0 * spice.rpd(), 0.0), expected3) + npt.assert_array_almost_equal( + spice.sphrec(1.0, 180.0 * spice.rpd(), 0.0), expected3 + ) def test_spk14a(): discrete_epochs = [100.0, 200.0, 300.0, 400.0] - cheby_coeffs14 = [150.0, 50.0, 1.0101, 1.0102, 1.0103, - 1.0201, 1.0202, 1.0203, - 1.0301, 1.0302, 1.0303, - 1.0401, 1.0402, 1.0403, - 1.0501, 1.0502, 1.0503, - 1.0601, 1.0602, 1.0603, 250.0, 50.0, - 2.0101, 2.0102, 2.0103, - 2.0201, 2.0202, 2.0203, - 2.0301, 2.0302, 2.0303, - 2.0401, 2.0402, 2.0403, - 2.0501, 2.0502, 2.0503, - 2.0601, 2.0602, 2.0603, 350.0, 50.0, - 3.0101, 3.0102, 3.0103, - 3.0201, 3.0202, 3.0203, - 3.0301, 3.0302, 3.0303, - 3.0401, 3.0402, 3.0403, - 3.0501, 3.0502, 3.0503, - 3.0601, 3.0602, 3.0603, 450.0, 50.0, - 4.0101, 4.0102, 4.0103, - 4.0201, 4.0202, 4.0203, - 4.0301, 4.0302, 4.0303, - 4.0401, 4.0402, 4.0403, - 4.0501, 4.0502, 4.0503, - 4.0601, 4.0602, 4.0603] + cheby_coeffs14 = [ + 150.0, + 50.0, + 1.0101, + 1.0102, + 1.0103, + 1.0201, + 1.0202, + 1.0203, + 1.0301, + 1.0302, + 1.0303, + 1.0401, + 1.0402, + 1.0403, + 1.0501, + 1.0502, + 1.0503, + 1.0601, + 1.0602, + 1.0603, + 250.0, + 50.0, + 2.0101, + 2.0102, + 2.0103, + 2.0201, + 2.0202, + 2.0203, + 2.0301, + 2.0302, + 2.0303, + 2.0401, + 2.0402, + 2.0403, + 2.0501, + 2.0502, + 2.0503, + 2.0601, + 2.0602, + 2.0603, + 350.0, + 50.0, + 3.0101, + 3.0102, + 3.0103, + 3.0201, + 3.0202, + 3.0203, + 3.0301, + 3.0302, + 3.0303, + 3.0401, + 3.0402, + 3.0403, + 3.0501, + 3.0502, + 3.0503, + 3.0601, + 3.0602, + 3.0603, + 450.0, + 50.0, + 4.0101, + 4.0102, + 4.0103, + 4.0201, + 4.0202, + 4.0203, + 4.0301, + 4.0302, + 4.0303, + 4.0401, + 4.0402, + 4.0403, + 4.0501, + 4.0502, + 4.0503, + 4.0601, + 4.0602, + 4.0603, + ] spk14 = os.path.join(cwd, "test14.bsp") if spice.exists(spk14): - os.remove(spk14) # pragma: no cover + os.remove(spk14) # pragma: no cover spice.kclear() - handle = spice.spkopn(spk14, 'Type 14 SPK internal file name.', 1024) + handle = spice.spkopn(spk14, "Type 14 SPK internal file name.", 1024) init_size = os.path.getsize(spk14) spice.spk14b(handle, "SAMPLE_SPK_TYPE_14_SEGMENT", 399, 0, "J2000", 100.0, 400.0, 2) spice.spk14a(handle, 4, cheby_coeffs14, discrete_epochs) @@ -6078,7 +7297,7 @@ def test_spk14a(): spice.kclear() assert end_size != init_size if spice.exists(spk14): - os.remove(spk14) # pragma: no cover + os.remove(spk14) # pragma: no cover def test_spk14bstress(): @@ -6089,35 +7308,93 @@ def test_spk14bstress(): def test_spk14b(): # Same as test_spk14a discrete_epochs = [100.0, 200.0, 300.0, 400.0] - cheby_coeffs14 = [150.0, 50.0, 1.0101, 1.0102, 1.0103, - 1.0201, 1.0202, 1.0203, - 1.0301, 1.0302, 1.0303, - 1.0401, 1.0402, 1.0403, - 1.0501, 1.0502, 1.0503, - 1.0601, 1.0602, 1.0603, 250.0, 50.0, - 2.0101, 2.0102, 2.0103, - 2.0201, 2.0202, 2.0203, - 2.0301, 2.0302, 2.0303, - 2.0401, 2.0402, 2.0403, - 2.0501, 2.0502, 2.0503, - 2.0601, 2.0602, 2.0603, 350.0, 50.0, - 3.0101, 3.0102, 3.0103, - 3.0201, 3.0202, 3.0203, - 3.0301, 3.0302, 3.0303, - 3.0401, 3.0402, 3.0403, - 3.0501, 3.0502, 3.0503, - 3.0601, 3.0602, 3.0603, 450.0, 50.0, - 4.0101, 4.0102, 4.0103, - 4.0201, 4.0202, 4.0203, - 4.0301, 4.0302, 4.0303, - 4.0401, 4.0402, 4.0403, - 4.0501, 4.0502, 4.0503, - 4.0601, 4.0602, 4.0603] + cheby_coeffs14 = [ + 150.0, + 50.0, + 1.0101, + 1.0102, + 1.0103, + 1.0201, + 1.0202, + 1.0203, + 1.0301, + 1.0302, + 1.0303, + 1.0401, + 1.0402, + 1.0403, + 1.0501, + 1.0502, + 1.0503, + 1.0601, + 1.0602, + 1.0603, + 250.0, + 50.0, + 2.0101, + 2.0102, + 2.0103, + 2.0201, + 2.0202, + 2.0203, + 2.0301, + 2.0302, + 2.0303, + 2.0401, + 2.0402, + 2.0403, + 2.0501, + 2.0502, + 2.0503, + 2.0601, + 2.0602, + 2.0603, + 350.0, + 50.0, + 3.0101, + 3.0102, + 3.0103, + 3.0201, + 3.0202, + 3.0203, + 3.0301, + 3.0302, + 3.0303, + 3.0401, + 3.0402, + 3.0403, + 3.0501, + 3.0502, + 3.0503, + 3.0601, + 3.0602, + 3.0603, + 450.0, + 50.0, + 4.0101, + 4.0102, + 4.0103, + 4.0201, + 4.0202, + 4.0203, + 4.0301, + 4.0302, + 4.0303, + 4.0401, + 4.0402, + 4.0403, + 4.0501, + 4.0502, + 4.0503, + 4.0601, + 4.0602, + 4.0603, + ] spk14 = os.path.join(cwd, "test14.bsp") if spice.exists(spk14): - os.remove(spk14) # pragma: no cover + os.remove(spk14) # pragma: no cover spice.kclear() - handle = spice.spkopn(spk14, 'Type 14 SPK internal file name.', 1024) + handle = spice.spkopn(spk14, "Type 14 SPK internal file name.", 1024) init_size = os.path.getsize(spk14) spice.spk14b(handle, "SAMPLE_SPK_TYPE_14_SEGMENT", 399, 0, "J2000", 100.0, 400.0, 2) spice.spk14a(handle, 4, cheby_coeffs14, discrete_epochs) @@ -6127,41 +7404,99 @@ def test_spk14b(): spice.kclear() assert end_size != init_size if spice.exists(spk14): - os.remove(spk14) # pragma: no cover + os.remove(spk14) # pragma: no cover def test_spk14e(): # Same as test_spk14a discrete_epochs = [100.0, 200.0, 300.0, 400.0] - cheby_coeffs14 = [150.0, 50.0, 1.0101, 1.0102, 1.0103, - 1.0201, 1.0202, 1.0203, - 1.0301, 1.0302, 1.0303, - 1.0401, 1.0402, 1.0403, - 1.0501, 1.0502, 1.0503, - 1.0601, 1.0602, 1.0603, 250.0, 50.0, - 2.0101, 2.0102, 2.0103, - 2.0201, 2.0202, 2.0203, - 2.0301, 2.0302, 2.0303, - 2.0401, 2.0402, 2.0403, - 2.0501, 2.0502, 2.0503, - 2.0601, 2.0602, 2.0603, 350.0, 50.0, - 3.0101, 3.0102, 3.0103, - 3.0201, 3.0202, 3.0203, - 3.0301, 3.0302, 3.0303, - 3.0401, 3.0402, 3.0403, - 3.0501, 3.0502, 3.0503, - 3.0601, 3.0602, 3.0603, 450.0, 50.0, - 4.0101, 4.0102, 4.0103, - 4.0201, 4.0202, 4.0203, - 4.0301, 4.0302, 4.0303, - 4.0401, 4.0402, 4.0403, - 4.0501, 4.0502, 4.0503, - 4.0601, 4.0602, 4.0603] + cheby_coeffs14 = [ + 150.0, + 50.0, + 1.0101, + 1.0102, + 1.0103, + 1.0201, + 1.0202, + 1.0203, + 1.0301, + 1.0302, + 1.0303, + 1.0401, + 1.0402, + 1.0403, + 1.0501, + 1.0502, + 1.0503, + 1.0601, + 1.0602, + 1.0603, + 250.0, + 50.0, + 2.0101, + 2.0102, + 2.0103, + 2.0201, + 2.0202, + 2.0203, + 2.0301, + 2.0302, + 2.0303, + 2.0401, + 2.0402, + 2.0403, + 2.0501, + 2.0502, + 2.0503, + 2.0601, + 2.0602, + 2.0603, + 350.0, + 50.0, + 3.0101, + 3.0102, + 3.0103, + 3.0201, + 3.0202, + 3.0203, + 3.0301, + 3.0302, + 3.0303, + 3.0401, + 3.0402, + 3.0403, + 3.0501, + 3.0502, + 3.0503, + 3.0601, + 3.0602, + 3.0603, + 450.0, + 50.0, + 4.0101, + 4.0102, + 4.0103, + 4.0201, + 4.0202, + 4.0203, + 4.0301, + 4.0302, + 4.0303, + 4.0401, + 4.0402, + 4.0403, + 4.0501, + 4.0502, + 4.0503, + 4.0601, + 4.0602, + 4.0603, + ] spk14 = os.path.join(cwd, "test14.bsp") if spice.exists(spk14): - os.remove(spk14) # pragma: no cover + os.remove(spk14) # pragma: no cover spice.kclear() - handle = spice.spkopn(spk14, 'Type 14 SPK internal file name.', 1024) + handle = spice.spkopn(spk14, "Type 14 SPK internal file name.", 1024) init_size = os.path.getsize(spk14) spice.spk14b(handle, "SAMPLE_SPK_TYPE_14_SEGMENT", 399, 0, "J2000", 100.0, 400.0, 2) spice.spk14a(handle, 4, cheby_coeffs14, discrete_epochs) @@ -6171,7 +7506,7 @@ def test_spk14e(): spice.kclear() assert end_size != init_size if spice.exists(spk14): - os.remove(spk14) # pragma: no cover + os.remove(spk14) # pragma: no cover def test_spkacs(): @@ -6179,9 +7514,14 @@ def test_spkacs(): spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2000 JAN 1 12:00:00 TDB") state, lt, dlt = spice.spkacs(301, et, "J2000", "lt+s", 399) - expected_state = [-2.91584616594972088933e+05, -2.66693402359092258848e+05, - -7.60956475582799030235e+04, 6.43439144942984264652e-01, - -6.66065882529007446955e-01, -3.01310065348405708985e-01] + expected_state = [ + -2.91584616594972088933e05, + -2.66693402359092258848e05, + -7.60956475582799030235e04, + 6.43439144942984264652e-01, + -6.66065882529007446955e-01, + -3.01310065348405708985e-01, + ] expected_lt = 1.3423106103603615 expected_dlt = 1.073169085424106e-07 npt.assert_almost_equal(expected_lt, lt) @@ -6194,28 +7534,36 @@ def test_spkapo(): spice.kclear() MARS = 499 MOON = 301 - EPOCH = 'Jan 1 2004 5:00 PM' - REF = 'J2000' - ABCORR = 'LT+S' + EPOCH = "Jan 1 2004 5:00 PM" + REF = "J2000" + ABCORR = "LT+S" spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et(EPOCH) state = spice.spkssb(MOON, et, REF) pos_vec, ltime = spice.spkapo(MARS, et, REF, state, ABCORR) - expectedPos = [1.64534472413454592228e+08, 2.51219951337271928787e+07, - 1.11454124484200235456e+07] - npt.assert_array_almost_equal(pos_vec, expectedPos, decimal=5) + expected_pos = [ + 1.64534472413454592228e08, + 2.51219951337271928787e07, + 1.11454124484200235456e07, + ] + npt.assert_array_almost_equal(pos_vec, expected_pos, decimal=5) spice.kclear() def test_spkapp(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('Jan 1 2004 5:00 PM') - state = spice.spkssb(301, et, 'J2000') - state_vec, ltime = spice.spkapp(499, et, 'J2000', state, 'LT+S') - expected_vec = [1.64534472413454592228e+08, 2.51219951337271928787e+07, - 1.11454124484200235456e+07, 1.23119770045260814584e+01, - 1.98884005139675998919e+01, 9.40678685353050170193e+00] + et = spice.str2et("Jan 1 2004 5:00 PM") + state = spice.spkssb(301, et, "J2000") + state_vec, ltime = spice.spkapp(499, et, "J2000", state, "LT+S") + expected_vec = [ + 1.64534472413454592228e08, + 2.51219951337271928787e07, + 1.11454124484200235456e07, + 1.23119770045260814584e01, + 1.98884005139675998919e01, + 9.40678685353050170193e00, + ] npt.assert_array_almost_equal(state_vec, expected_vec, decimal=6) spice.kclear() @@ -6224,70 +7572,120 @@ def test_spkaps(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2000 JAN 1 12:00:00 TDB") - stobs = spice.spkssb(399, et, 'J2000') - state0 = np.array(spice.spkssb(399, et - 1, 'J2000')) - state2 = np.array(spice.spkssb(399, et + 1, 'J2000')) + stobs = spice.spkssb(399, et, "J2000") + state0 = np.array(spice.spkssb(399, et - 1, "J2000")) + state2 = np.array(spice.spkssb(399, et + 1, "J2000")) # qderiv proc acc = spice.vlcomg(3, 0.5 / 1.0, state0 + 3, -0.5 / 1.0, state2 + 3) acc = [acc[0], acc[1], acc[2], 0.0, 0.0, 0.0] state, lt, dlt = spice.spkaps(301, et, "j2000", "lt+s", stobs, acc) spice.kclear() - expectedLt = 1.3423106103603615 - expectedDlt = 1.073169085424106e-07 - expectedState = [-2.91584616594972088933e+05, -2.66693402359092258848e+05, - -7.60956475582799030235e+04, 1.59912685775666059129e+01, - -1.64471169612870582455e+01, -3.80333369259831766129e+00] - npt.assert_almost_equal(expectedLt, lt) - npt.assert_almost_equal(expectedDlt, dlt) - npt.assert_array_almost_equal(state, expectedState, decimal=5) + expected_lt = 1.3423106103603615 + expected_dlt = 1.073169085424106e-07 + expected_state = [ + -2.91584616594972088933e05, + -2.66693402359092258848e05, + -7.60956475582799030235e04, + 1.59912685775666059129e01, + -1.64471169612870582455e01, + -3.80333369259831766129e00, + ] + npt.assert_almost_equal(expected_lt, lt) + npt.assert_almost_equal(expected_dlt, dlt) + npt.assert_array_almost_equal(state, expected_state, decimal=5) def test_spkcls(): # Same as test_spkw02 - SPK2 = os.path.join(cwd, "test2.bsp") - if spice.exists(SPK2): - os.remove(SPK2) # pragma: no cover + spk2 = os.path.join(cwd, "test2.bsp") + if spice.exists(spk2): + os.remove(spk2) # pragma: no cover spice.kclear() - handle = spice.spkopn(SPK2, 'Type 2 SPK internal file name.', 4) - init_size = os.path.getsize(SPK2) + handle = spice.spkopn(spk2, "Type 2 SPK internal file name.", 4) + init_size = os.path.getsize(spk2) discrete_epochs = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0] - cheby_coeffs02 = [1.0101, 1.0102, 1.0103, 1.0201, 1.0202, 1.0203, 1.0301, 1.0302, - 1.0303, 2.0101, 2.0102, 2.0103, 2.0201, 2.0202, 2.0203, 2.0301, - 2.0302, 2.0303, 3.0101, 3.0102, 3.0103, 3.0201, 3.0202, 3.0203, - 3.0301, 3.0302, 3.0303, 4.0101, 4.0102, 4.0103, 4.0201, 4.0202, - 4.0203, 4.0301, 4.0302, 4.0303] - segid = 'SPK type 2 test segment' + cheby_coeffs02 = [ + 1.0101, + 1.0102, + 1.0103, + 1.0201, + 1.0202, + 1.0203, + 1.0301, + 1.0302, + 1.0303, + 2.0101, + 2.0102, + 2.0103, + 2.0201, + 2.0202, + 2.0203, + 2.0301, + 2.0302, + 2.0303, + 3.0101, + 3.0102, + 3.0103, + 3.0201, + 3.0202, + 3.0203, + 3.0301, + 3.0302, + 3.0303, + 4.0101, + 4.0102, + 4.0103, + 4.0201, + 4.0202, + 4.0203, + 4.0301, + 4.0302, + 4.0303, + ] + segid = "SPK type 2 test segment" intlen = discrete_epochs[1] - discrete_epochs[0] - spice.spkw02(handle, 3, 10, "J2000", discrete_epochs[0], - discrete_epochs[4], segid, intlen, 4, 2, cheby_coeffs02, discrete_epochs[0]) + spice.spkw02( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[4], + segid, + intlen, + 4, + 2, + cheby_coeffs02, + discrete_epochs[0], + ) spice.spkcls(handle) - end_size = os.path.getsize(SPK2) + end_size = os.path.getsize(spk2) spice.kclear() assert end_size != init_size - if spice.exists(SPK2): - os.remove(SPK2) # pragma: no cover + if spice.exists(spk2): + os.remove(spk2) # pragma: no cover def test_spkcov(): spice.kclear() - + ids = spice.spkobj(CoreKernels.spk) - tempObj = ids[0] - - #Checks for defaults - cover=spice.spkcov(CoreKernels.spk, tempObj) + temp_obj = ids[0] + + # Checks for defaults + cover = spice.spkcov(CoreKernels.spk, temp_obj) result = [x for x in cover] expected = [-94651137.81606464, 315662463.18395346] npt.assert_array_almost_equal(result, expected) - - #Checks for old way, where if cover is pre-set, it should remain set + + # Checks for old way, where if cover is pre-set, it should remain set cover = spice.cell_double(2000) spice.scard(0, cover) - spice.spkcov(CoreKernels.spk, tempObj, cover) + spice.spkcov(CoreKernels.spk, temp_obj, cover) result = [x for x in cover] expected = [-94651137.81606464, 315662463.18395346] npt.assert_array_almost_equal(result, expected) - + spice.kclear() @@ -6295,16 +7693,23 @@ def test_spkcpo(): spice.kclear() spice.furnsh(ExtraKernels.earthStnSpk) spice.furnsh(ExtraKernels.earthHighPerPck) - spice.furnsh(ExtraKernels.earthTopoTf ) + spice.furnsh(ExtraKernels.earthTopoTf) spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2003 Oct 13 06:00:00") obspos = [-2353.6213656676991, -4641.3414911499403, 3677.0523293197439] - state, lt = spice.spkcpo("SUN", et, "DSS-14_TOPO", "OBSERVER", "CN+S", obspos, "EARTH", "ITRF93") + state, lt = spice.spkcpo( + "SUN", et, "DSS-14_TOPO", "OBSERVER", "CN+S", obspos, "EARTH", "ITRF93" + ) spice.kclear() expected_lt = 497.93167787805714 - expected_state = [6.25122733012810498476e+07, 5.89674929926417097449e+07, - -1.22059095879866167903e+08, 2.47597313358008614159e+03, - -9.87026711803482794494e+03, -3.49990805659246507275e+03] + expected_state = [ + 6.25122733012810498476e07, + 5.89674929926417097449e07, + -1.22059095879866167903e08, + 2.47597313358008614159e03, + -9.87026711803482794494e03, + -3.49990805659246507275e03, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(state, expected_state, decimal=6) @@ -6313,16 +7718,23 @@ def test_spkcpt(): spice.kclear() spice.furnsh(ExtraKernels.earthStnSpk) spice.furnsh(ExtraKernels.earthHighPerPck) - spice.furnsh(ExtraKernels.earthTopoTf ) + spice.furnsh(ExtraKernels.earthTopoTf) spice.furnsh(CoreKernels.testMetaKernel) obstime = spice.str2et("2003 Oct 13 06:00:00") trgpos = [-2353.6213656676991, -4641.3414911499403, 3677.0523293197439] - state, lt = spice.spkcpt(trgpos, "EARTH", "ITRF93", obstime, "ITRF93", "TARGET", "CN+S", "SUN") + state, lt = spice.spkcpt( + trgpos, "EARTH", "ITRF93", obstime, "ITRF93", "TARGET", "CN+S", "SUN" + ) spice.kclear() expected_lt = 497.9321928250503 - expected_state = [-3.41263006568005401641e+06, -1.47916331564148992300e+08, - 1.98124035009580813348e+07, -1.07582448117249587085e+04, - 2.50028331500427839273e+02, 1.11355285621842696742e+01] + expected_state = [ + -3.41263006568005401641e06, + -1.47916331564148992300e08, + 1.98124035009580813348e07, + -1.07582448117249587085e04, + 2.50028331500427839273e02, + 1.11355285621842696742e01, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(state, expected_state, decimal=6) @@ -6331,17 +7743,38 @@ def test_spkcvo(): spice.kclear() spice.furnsh(ExtraKernels.earthStnSpk) spice.furnsh(ExtraKernels.earthHighPerPck) - spice.furnsh(ExtraKernels.earthTopoTf ) + spice.furnsh(ExtraKernels.earthTopoTf) spice.furnsh(CoreKernels.testMetaKernel) obstime = spice.str2et("2003 Oct 13 06:00:00") - obstate = [-2353.6213656676991, -4641.3414911499403, 3677.0523293197439, -0.00000000000057086, 0.00000000000020549, - -0.00000000000012171] - state, lt = spice.spkcvo("SUN", obstime, "DSS-14_TOPO", "OBSERVER", "CN+S", obstate, 0.0, "EARTH", "ITRF93") + obstate = [ + -2353.6213656676991, + -4641.3414911499403, + 3677.0523293197439, + -0.00000000000057086, + 0.00000000000020549, + -0.00000000000012171, + ] + state, lt = spice.spkcvo( + "SUN", + obstime, + "DSS-14_TOPO", + "OBSERVER", + "CN+S", + obstate, + 0.0, + "EARTH", + "ITRF93", + ) spice.kclear() expected_lt = 497.93167787798325 - expected_state = [6.25122733012975975871e+07, 5.89674929925705492496e+07, - -1.22059095879864960909e+08, 2.47597313358015026097e+03, - -9.87026711803497346409e+03, -3.49990805659256830040e+03] + expected_state = [ + 6.25122733012975975871e07, + 5.89674929925705492496e07, + -1.22059095879864960909e08, + 2.47597313358015026097e03, + -9.87026711803497346409e03, + -3.49990805659256830040e03, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(state, expected_state, decimal=6) @@ -6350,17 +7783,30 @@ def test_spkcvt(): spice.kclear() spice.furnsh(ExtraKernels.earthStnSpk) spice.furnsh(ExtraKernels.earthHighPerPck) - spice.furnsh(ExtraKernels.earthTopoTf ) + spice.furnsh(ExtraKernels.earthTopoTf) spice.furnsh(CoreKernels.testMetaKernel) obstime = spice.str2et("2003 Oct 13 06:00:00") - trgstate = [-2353.6213656676991, -4641.3414911499403, 3677.0523293197439, -0.00000000000057086, 0.00000000000020549, - -0.00000000000012171] - state, lt = spice.spkcvt(trgstate, 0.0, "EARTH", "ITRF93", obstime, "ITRF93", "TARGET", "CN+S", "SUN") + trgstate = [ + -2353.6213656676991, + -4641.3414911499403, + 3677.0523293197439, + -0.00000000000057086, + 0.00000000000020549, + -0.00000000000012171, + ] + state, lt = spice.spkcvt( + trgstate, 0.0, "EARTH", "ITRF93", obstime, "ITRF93", "TARGET", "CN+S", "SUN" + ) spice.kclear() expected_lt = 497.932192824968 - expected_state = [-3.41263006574816117063e+06, -1.47916331564124494791e+08, - 1.98124035009435638785e+07, -1.07582448117247804475e+04, - 2.50028331500423831812e+02, 1.11355285621839659171e+01] + expected_state = [ + -3.41263006574816117063e06, + -1.47916331564124494791e08, + 1.98124035009435638785e07, + -1.07582448117247804475e04, + 2.50028331500423831812e02, + 1.11355285621839659171e01, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(state, expected_state, decimal=6) @@ -6368,12 +7814,17 @@ def test_spkcvt(): def test_spkez(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('July 4, 2003 11:00 AM PST') - state, lt = spice.spkez(499, et, 'J2000', 'LT+S', 399) + et = spice.str2et("July 4, 2003 11:00 AM PST") + state, lt = spice.spkez(499, et, "J2000", "LT+S", 399) expected_lt = 269.6898813661505 - expected_state = [7.38222353105354905128e+07, -2.71279189984722770751e+07, - -1.87413063014898747206e+07, -6.80851334001380692484e+00, - 7.51399612408221173609e+00, 3.00129849265935222391e+00] + expected_state = [ + 7.38222353105354905128e07, + -2.71279189984722770751e07, + -1.87413063014898747206e07, + -6.80851334001380692484e00, + 7.51399612408221173609e00, + 3.00129849265935222391e00, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(state, expected_state) spice.kclear() @@ -6382,11 +7833,14 @@ def test_spkez(): def test_spkezp(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('July 4, 2003 11:00 AM PST') - pos, lt = spice.spkezp(499, et, 'J2000', 'LT+S', 399) + et = spice.str2et("July 4, 2003 11:00 AM PST") + pos, lt = spice.spkezp(499, et, "J2000", "LT+S", 399) expected_lt = 269.6898813661505 - expected_pos = [73822235.31053550541400909424, -27127918.99847228080034255981, - -18741306.30148987472057342529] + expected_pos = [ + 73822235.31053550541400909424, + -27127918.99847228080034255981, + -18741306.30148987472057342529, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(pos, expected_pos) spice.kclear() @@ -6395,39 +7849,58 @@ def test_spkezp(): def test_spkezr(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('July 4, 2003 11:00 AM PST') + et = spice.str2et("July 4, 2003 11:00 AM PST") state, lt = spice.spkezr("Mars", et, "J2000", "LT+S", "Earth") expected_lt = 269.6898813661505 - expected_state = [7.38222353105354905128e+07, -2.71279189984722770751e+07, - -1.87413063014898747206e+07, -6.80851334001380692484e+00, - 7.51399612408221173609e+00, 3.00129849265935222391e+00] + expected_state = [ + 7.38222353105354905128e07, + -2.71279189984722770751e07, + -1.87413063014898747206e07, + -6.80851334001380692484e00, + 7.51399612408221173609e00, + 3.00129849265935222391e00, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(state, expected_state) spice.kclear() + def test_spkezr_vectorized(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = np.full((100,), spice.str2et('July 4, 2003 11:00 AM PST')) + et = np.full((100,), spice.str2et("July 4, 2003 11:00 AM PST")) state, lt = spice.spkezr("Mars", et, "J2000", "LT+S", "Earth") expected_lt = np.full((100,), 269.6898816177049) - expected_state = np.full((100, 6), [73822235.33116072, -27127919.178592984, - -18741306.284863796, - -6.808513317178952, 7.513996167680786, - 3.001298515816776]) + expected_state = np.full( + (100, 6), + [ + 73822235.33116072, + -27127919.178592984, + -18741306.284863796, + -6.808513317178952, + 7.513996167680786, + 3.001298515816776, + ], + ) npt.assert_allclose(lt, expected_lt) npt.assert_allclose(state, expected_state) spice.kclear() + def test_spkgeo(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('July 4, 2003 11:00 AM PST') - state, lt = spice.spkgeo(499, et, 'J2000', 399) + et = spice.str2et("July 4, 2003 11:00 AM PST") + state, lt = spice.spkgeo(499, et, "J2000", 399) expected_lt = 269.70264751151603 - expected_state = [7.38262164145559966564e+07, -2.71280305524311661720e+07, - -1.87419738849752545357e+07, -6.80950358877040429206e+00, - 7.51381423681132254444e+00, 3.00129002640705921934e+00] + expected_state = [ + 7.38262164145559966564e07, + -2.71280305524311661720e07, + -1.87419738849752545357e07, + -6.80950358877040429206e00, + 7.51381423681132254444e00, + 3.00129002640705921934e00, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(state, expected_state) spice.kclear() @@ -6436,11 +7909,14 @@ def test_spkgeo(): def test_spkgps(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('July 4, 2003 11:00 AM PST') - pos, lt = spice.spkgps(499, et, 'J2000', 399) + et = spice.str2et("July 4, 2003 11:00 AM PST") + pos, lt = spice.spkgps(499, et, "J2000", 399) expected_lt = 269.70264751151603 - expected_pos = [73826216.41455599665641784668, -27128030.55243116617202758789, - -18741973.88497525453567504883] + expected_pos = [ + 73826216.41455599665641784668, + -27128030.55243116617202758789, + -18741973.88497525453567504883, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(pos, expected_pos) spice.kclear() @@ -6461,13 +7937,18 @@ def test_spkltc(): stobs = spice.spkssb(399, et, "j2000") state, lt, dlt = spice.spkltc(301, et, "j2000", "lt", stobs) expectedOneWayLt = 1.342310610325 - expectedLt = 1.07316909e-07 - expectedState = [-2.91569268313527107239e+05, -2.66709183005481958389e+05, - -7.60991494675353169441e+04, 6.43530600728670520994e-01, - -6.66081825882520739412e-01, -3.01322833716675120286e-01] + expected_lt = 1.07316909e-07 + expected_state = [ + -2.91569268313527107239e05, + -2.66709183005481958389e05, + -7.60991494675353169441e04, + 6.43530600728670520994e-01, + -6.66081825882520739412e-01, + -3.01322833716675120286e-01, + ] npt.assert_almost_equal(lt, expectedOneWayLt) - npt.assert_almost_equal(dlt, expectedLt) - npt.assert_array_almost_equal(state, expectedState, decimal=5) + npt.assert_almost_equal(dlt, expected_lt) + npt.assert_array_almost_equal(state, expected_state, decimal=5) spice.kclear() @@ -6476,9 +7957,9 @@ def test_spkobj(): spice.kclear() cover = spice.cell_double(2000) ids = spice.spkobj(CoreKernels.spk) - tempObj = ids[0] + temp_obj = ids[0] spice.scard(0, cover) - spice.spkcov(CoreKernels.spk, tempObj, cover) + spice.spkcov(CoreKernels.spk, temp_obj, cover) result = [x for x in cover] expected = [-94651137.81606464, 315662463.18395346] npt.assert_array_almost_equal(result, expected) @@ -6488,7 +7969,7 @@ def test_spkobj(): def test_spkopa(): SPKOPA = os.path.join(cwd, "testspkopa.bsp") if spice.exists(SPKOPA): - os.remove(SPKOPA) # pragma: no cover + os.remove(SPKOPA) # pragma: no cover spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2002 APR 27 00:00:00.000 TDB") @@ -6496,7 +7977,7 @@ def test_spkopa(): handle, descr, ident = spice.spksfs(5, et, 41) body, center, frame, otype, first, last, begin, end = spice.spkuds(descr) # create empty spk kernel - handle_test = spice.spkopn(SPKOPA, 'Test Kernel for spkopa unit test.', 4) + handle_test = spice.spkopn(SPKOPA, "Test Kernel for spkopa unit test.", 4) # created empty spk kernel, write to it spice.spksub(handle, descr, ident, first, last, handle_test) # close kernel @@ -6510,34 +7991,79 @@ def test_spkopa(): spice.spkcls(handle_spkopa) # clean up if spice.exists(SPKOPA): - os.remove(SPKOPA) # pragma: no cover + os.remove(SPKOPA) # pragma: no cover spice.kclear() def test_spkopn(): # Same as test_spkw02 - SPK2 = os.path.join(cwd, "test2.bsp") - if spice.exists(SPK2): - os.remove(SPK2) # pragma: no cover + spk2 = os.path.join(cwd, "test2.bsp") + if spice.exists(spk2): + os.remove(spk2) # pragma: no cover spice.kclear() - handle = spice.spkopn(SPK2, 'Type 2 SPK internal file name.', 4) - init_size = os.path.getsize(SPK2) + handle = spice.spkopn(spk2, "Type 2 SPK internal file name.", 4) + init_size = os.path.getsize(spk2) discrete_epochs = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0] - cheby_coeffs02 = [1.0101, 1.0102, 1.0103, 1.0201, 1.0202, 1.0203, 1.0301, 1.0302, - 1.0303, 2.0101, 2.0102, 2.0103, 2.0201, 2.0202, 2.0203, 2.0301, - 2.0302, 2.0303, 3.0101, 3.0102, 3.0103, 3.0201, 3.0202, 3.0203, - 3.0301, 3.0302, 3.0303, 4.0101, 4.0102, 4.0103, 4.0201, 4.0202, - 4.0203, 4.0301, 4.0302, 4.0303] - segid = 'SPK type 2 test segment' + cheby_coeffs02 = [ + 1.0101, + 1.0102, + 1.0103, + 1.0201, + 1.0202, + 1.0203, + 1.0301, + 1.0302, + 1.0303, + 2.0101, + 2.0102, + 2.0103, + 2.0201, + 2.0202, + 2.0203, + 2.0301, + 2.0302, + 2.0303, + 3.0101, + 3.0102, + 3.0103, + 3.0201, + 3.0202, + 3.0203, + 3.0301, + 3.0302, + 3.0303, + 4.0101, + 4.0102, + 4.0103, + 4.0201, + 4.0202, + 4.0203, + 4.0301, + 4.0302, + 4.0303, + ] + segid = "SPK type 2 test segment" intlen = discrete_epochs[1] - discrete_epochs[0] - spice.spkw02(handle, 3, 10, "J2000", discrete_epochs[0], - discrete_epochs[4], segid, intlen, 4, 2, cheby_coeffs02, discrete_epochs[0]) + spice.spkw02( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[4], + segid, + intlen, + 4, + 2, + cheby_coeffs02, + discrete_epochs[0], + ) spice.spkcls(handle) - end_size = os.path.getsize(SPK2) + end_size = os.path.getsize(spk2) spice.kclear() assert end_size != init_size - if spice.exists(SPK2): - os.remove(SPK2) # pragma: no cover + if spice.exists(spk2): + os.remove(spk2) # pragma: no cover def test_spkpds(): @@ -6545,7 +8071,7 @@ def test_spkpds(): spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2002 APR 27 00:00:00.000 TDB") handle, descr, ident = spice.spksfs(5, et, 41) - body, center, frame, otype, first, last, begin, end = spice.spkuds(descr) + body, center, frame, otype, first, last, begin, end = spice.spkuds(descr) outframe = spice.frmnam(frame) spkpds_output = spice.spkpds(body, center, outframe, otype, first, last) npt.assert_almost_equal(spkpds_output, descr) @@ -6555,11 +8081,14 @@ def test_spkpds(): def test_spkpos(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('July 4, 2003 11:00 AM PST') + et = spice.str2et("July 4, 2003 11:00 AM PST") pos, lt = spice.spkpos("Mars", et, "J2000", "LT+S", "Earth") expected_lt = 269.6898813661505 - expected_pos = [73822235.31053550541400909424, -27127918.99847228080034255981, - -18741306.30148987472057342529] + expected_pos = [ + 73822235.31053550541400909424, + -27127918.99847228080034255981, + -18741306.30148987472057342529, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(pos, expected_pos) spice.kclear() @@ -6568,12 +8097,21 @@ def test_spkpos(): def test_spkpos_vectorized(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et(['July 4, 2003 11:00 AM PST', 'July 11, 2003 11:00 AM PST']) + et = spice.str2et(["July 4, 2003 11:00 AM PST", "July 11, 2003 11:00 AM PST"]) pos, lt = spice.spkpos("Mars", et, "J2000", "LT+S", "Earth") - expected_lt = [269.68988136615047324085, 251.44204326148698669385] - expected_pos = [[73822235.31053550541400909424, -27127918.99847228080034255981, - -18741306.30148987472057342529], [69682765.52989411354064941406, - -23090281.18098583817481994629, -17127756.93968883529305458069]] + expected_lt = [269.68988136615047324085, 251.44204326148698669385] + expected_pos = [ + [ + 73822235.31053550541400909424, + -27127918.99847228080034255981, + -18741306.30148987472057342529, + ], + [ + 69682765.52989411354064941406, + -23090281.18098583817481994629, + -17127756.93968883529305458069, + ], + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(pos, expected_pos) spice.kclear() @@ -6585,9 +8123,14 @@ def test_spkpvn(): et = spice.str2et("2002 APR 27 00:00:00.000 TDB") handle, descr, ident = spice.spksfs(5, et, 41) refid, state, center = spice.spkpvn(handle, descr, et) - expected_state = [-2.70063336478468656540e+08, 6.69404818553274393082e+08, - 2.93505043081457614899e+08, -1.24191493217698472051e+01, - -3.70147572019018955558e+00, -1.28422514561611489370e+00] + expected_state = [ + -2.70063336478468656540e08, + 6.69404818553274393082e08, + 2.93505043081457614899e08, + -1.24191493217698472051e01, + -3.70147572019018955558e00, + -1.28422514561611489370e00, + ] npt.assert_array_almost_equal(state, expected_state) spice.kclear() @@ -6606,21 +8149,21 @@ def test_spkssb(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) targ1 = 499 - epoch = 'July 4, 2003 11:00 AM PST' - frame = 'J2000' + epoch = "July 4, 2003 11:00 AM PST" + frame = "J2000" targ2 = 399 et = spice.str2et(epoch) state1 = spice.spkssb(targ1, et, frame) state2 = spice.spkssb(targ2, et, frame) dist = spice.vdist(state1[0:3], state2[0:3]) - npt.assert_approx_equal(dist, 80854820., significant=7) + npt.assert_approx_equal(dist, 80854820.0, significant=7) spice.kclear() def test_spksub(): SPKSUB = os.path.join(cwd, "testspksub.bsp") if spice.exists(SPKSUB): - os.remove(SPKSUB) # pragma: no cover + os.remove(SPKSUB) # pragma: no cover spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2002 APR 27 00:00:00.000 TDB") @@ -6628,13 +8171,13 @@ def test_spksub(): handle, descr, ident = spice.spksfs(5, et, 41) body, center, frame, otype, first, last, begin, end = spice.spkuds(descr) # create empty spk kernel - handle_test = spice.spkopn(SPKSUB, 'Test Kernel for spksub unit test.', 4) + handle_test = spice.spkopn(SPKSUB, "Test Kernel for spksub unit test.", 4) # created empty spk kernel, write to it spice.spksub(handle, descr, ident, first, last, handle_test) # close kernel spice.spkcls(handle_test) if spice.exists(SPKSUB): - os.remove(SPKSUB) # pragma: no cover + os.remove(SPKSUB) # pragma: no cover spice.kclear() @@ -6643,7 +8186,7 @@ def test_spkuds(): spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("2002 APR 27 00:00:00.000 TDB") handle, descr, ident = spice.spksfs(5, et, 41) - body, center, frame, otype, first, last, begin, end = spice.spkuds(descr) + body, center, frame, otype, first, last, begin, end = spice.spkuds(descr) assert body == 5 assert begin == 54073 assert end == 57950 @@ -6660,65 +8203,188 @@ def test_spkuef(): def test_spkw02(): - SPK2 = os.path.join(cwd, "test2.bsp") - if spice.exists(SPK2): - os.remove(SPK2) # pragma: no cover + spk2 = os.path.join(cwd, "test2.bsp") + if spice.exists(spk2): + os.remove(spk2) # pragma: no cover spice.kclear() - handle = spice.spkopn(SPK2, 'Type 2 SPK internal file name.', 4) - init_size = os.path.getsize(SPK2) + handle = spice.spkopn(spk2, "Type 2 SPK internal file name.", 4) + init_size = os.path.getsize(spk2) discrete_epochs = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0] - cheby_coeffs02 = [1.0101, 1.0102, 1.0103, 1.0201, 1.0202, 1.0203, 1.0301, 1.0302, - 1.0303, 2.0101, 2.0102, 2.0103, 2.0201, 2.0202, 2.0203, 2.0301, - 2.0302, 2.0303, 3.0101, 3.0102, 3.0103, 3.0201, 3.0202, 3.0203, - 3.0301, 3.0302, 3.0303, 4.0101, 4.0102, 4.0103, 4.0201, 4.0202, - 4.0203, 4.0301, 4.0302, 4.0303] - segid = 'SPK type 2 test segment' + cheby_coeffs02 = [ + 1.0101, + 1.0102, + 1.0103, + 1.0201, + 1.0202, + 1.0203, + 1.0301, + 1.0302, + 1.0303, + 2.0101, + 2.0102, + 2.0103, + 2.0201, + 2.0202, + 2.0203, + 2.0301, + 2.0302, + 2.0303, + 3.0101, + 3.0102, + 3.0103, + 3.0201, + 3.0202, + 3.0203, + 3.0301, + 3.0302, + 3.0303, + 4.0101, + 4.0102, + 4.0103, + 4.0201, + 4.0202, + 4.0203, + 4.0301, + 4.0302, + 4.0303, + ] + segid = "SPK type 2 test segment" intlen = discrete_epochs[1] - discrete_epochs[0] - spice.spkw02(handle, 3, 10, "J2000", discrete_epochs[0], - discrete_epochs[4], segid, intlen, 4, 2, cheby_coeffs02, discrete_epochs[0]) + spice.spkw02( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[4], + segid, + intlen, + 4, + 2, + cheby_coeffs02, + discrete_epochs[0], + ) spice.spkcls(handle) - end_size = os.path.getsize(SPK2) + end_size = os.path.getsize(spk2) spice.kclear() assert end_size != init_size - if spice.exists(SPK2): - os.remove(SPK2) # pragma: no cover + if spice.exists(spk2): + os.remove(spk2) # pragma: no cover def test_spkw03(): - SPK3 = os.path.join(cwd, "test3.bsp") - if spice.exists(SPK3): - os.remove(SPK3) # pragma: no cover + spk3 = os.path.join(cwd, "test3.bsp") + if spice.exists(spk3): + os.remove(spk3) # pragma: no cover spice.kclear() - handle = spice.spkopn(SPK3, 'Type 3 SPK internal file name.', 4) - init_size = os.path.getsize(SPK3) + handle = spice.spkopn(spk3, "Type 3 SPK internal file name.", 4) + init_size = os.path.getsize(spk3) discrete_epochs = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0] - cheby_coeffs03 = [1.0101, 1.0102, 1.0103, 1.0201, 1.0202, 1.0203, 1.0301, 1.0302, 1.0303, - 1.0401, 1.0402, 1.0403, 1.0501, 1.0502, 1.0503, 1.0601, 1.0602, 1.0603, - 2.0101, 2.0102, 2.0103, 2.0201, 2.0202, 2.0203, 2.0301, 2.0302, 2.0303, - 2.0401, 2.0402, 2.0403, 2.0501, 2.0502, 2.0503, 2.0601, 2.0602, 2.0603, - 3.0101, 3.0102, 3.0103, 3.0201, 3.0202, 3.0203, 3.0301, 3.0302, 3.0303, - 3.0401, 3.0402, 3.0403, 3.0501, 3.0502, 3.0503, 3.0601, 3.0602, 3.0603, - 4.0101, 4.0102, 4.0103, 4.0201, 4.0202, 4.0203, 4.0301, 4.0302, 4.0303, - 4.0401, 4.0402, 4.0403, 4.0501, 4.0502, 4.0503, 4.0601, 4.0602, 4.0603] - segid = 'SPK type 3 test segment' + cheby_coeffs03 = [ + 1.0101, + 1.0102, + 1.0103, + 1.0201, + 1.0202, + 1.0203, + 1.0301, + 1.0302, + 1.0303, + 1.0401, + 1.0402, + 1.0403, + 1.0501, + 1.0502, + 1.0503, + 1.0601, + 1.0602, + 1.0603, + 2.0101, + 2.0102, + 2.0103, + 2.0201, + 2.0202, + 2.0203, + 2.0301, + 2.0302, + 2.0303, + 2.0401, + 2.0402, + 2.0403, + 2.0501, + 2.0502, + 2.0503, + 2.0601, + 2.0602, + 2.0603, + 3.0101, + 3.0102, + 3.0103, + 3.0201, + 3.0202, + 3.0203, + 3.0301, + 3.0302, + 3.0303, + 3.0401, + 3.0402, + 3.0403, + 3.0501, + 3.0502, + 3.0503, + 3.0601, + 3.0602, + 3.0603, + 4.0101, + 4.0102, + 4.0103, + 4.0201, + 4.0202, + 4.0203, + 4.0301, + 4.0302, + 4.0303, + 4.0401, + 4.0402, + 4.0403, + 4.0501, + 4.0502, + 4.0503, + 4.0601, + 4.0602, + 4.0603, + ] + segid = "SPK type 3 test segment" intlen = discrete_epochs[1] - discrete_epochs[0] - spice.spkw03(handle, 3, 10, "J2000", discrete_epochs[0], - discrete_epochs[4], segid, intlen, 4, 2, cheby_coeffs03, discrete_epochs[0]) + spice.spkw03( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[4], + segid, + intlen, + 4, + 2, + cheby_coeffs03, + discrete_epochs[0], + ) spice.spkcls(handle) - end_size = os.path.getsize(SPK3) + end_size = os.path.getsize(spk3) spice.kclear() assert end_size != init_size - if spice.exists(SPK3): - os.remove(SPK3) # pragma: no cover + if spice.exists(spk3): + os.remove(spk3) # pragma: no cover def test_spkw05(): - SPK5 = os.path.join(cwd, "test5.bsp") - if spice.exists(SPK5): - os.remove(SPK5) # pragma: no cover + spk5 = os.path.join(cwd, "test5.bsp") + if spice.exists(spk5): + os.remove(spk5) # pragma: no cover spice.kclear() - handle = spice.spkopn(SPK5, 'Type 5 SPK internal file name.', 4) - init_size = os.path.getsize(SPK5) + handle = spice.spkopn(spk5, "Type 5 SPK internal file name.", 4) + init_size = os.path.getsize(spk5) discrete_epochs = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0] discrete_states = [ [101.0, 201.0, 301.0, 401.0, 501.0, 601.0], @@ -6729,26 +8395,37 @@ def test_spkw05(): [106.0, 206.0, 306.0, 406.0, 506.0, 606.0], [107.0, 207.0, 307.0, 407.0, 507.0, 607.0], [108.0, 208.0, 308.0, 408.0, 508.0, 608.0], - [109.0, 209.0, 309.0, 409.0, 509.0, 609.0] + [109.0, 209.0, 309.0, 409.0, 509.0, 609.0], ] - segid = 'SPK type 5 test segment' - spice.spkw05(handle, 3, 10, "J2000", discrete_epochs[0], discrete_epochs[-1], segid, - 132712440023.310, 9, discrete_states, discrete_epochs) + segid = "SPK type 5 test segment" + spice.spkw05( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[-1], + segid, + 132712440023.310, + 9, + discrete_states, + discrete_epochs, + ) spice.spkcls(handle) - end_size = os.path.getsize(SPK5) + end_size = os.path.getsize(spk5) spice.kclear() assert end_size != init_size - if spice.exists(SPK5): - os.remove(SPK5) # pragma: no cover + if spice.exists(spk5): + os.remove(spk5) # pragma: no cover def test_spkw08(): - SPK8 = os.path.join(cwd, "test8.bsp") - if spice.exists(SPK8): - os.remove(SPK8) # pragma: no cover + spk8 = os.path.join(cwd, "test8.bsp") + if spice.exists(spk8): + os.remove(spk8) # pragma: no cover spice.kclear() - handle = spice.spkopn(SPK8, 'Type 8 SPK internal file name.', 4) - init_size = os.path.getsize(SPK8) + handle = spice.spkopn(spk8, "Type 8 SPK internal file name.", 4) + init_size = os.path.getsize(spk8) discrete_epochs = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0] discrete_states = [ [101.0, 201.0, 301.0, 401.0, 501.0, 601.0], @@ -6759,27 +8436,39 @@ def test_spkw08(): [106.0, 206.0, 306.0, 406.0, 506.0, 606.0], [107.0, 207.0, 307.0, 407.0, 507.0, 607.0], [108.0, 208.0, 308.0, 408.0, 508.0, 608.0], - [109.0, 209.0, 309.0, 409.0, 509.0, 609.0] + [109.0, 209.0, 309.0, 409.0, 509.0, 609.0], ] - segid = 'SPK type 8 test segment' + segid = "SPK type 8 test segment" step = discrete_epochs[1] - discrete_epochs[0] - spice.spkw08(handle, 3, 10, "J2000", discrete_epochs[0], discrete_epochs[-1], segid, - 3, 9, discrete_states, discrete_epochs[0], step) + spice.spkw08( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[-1], + segid, + 3, + 9, + discrete_states, + discrete_epochs[0], + step, + ) spice.spkcls(handle) - end_size = os.path.getsize(SPK8) + end_size = os.path.getsize(spk8) spice.kclear() assert end_size != init_size - if spice.exists(SPK8): - os.remove(SPK8) # pragma: no cover + if spice.exists(spk8): + os.remove(spk8) # pragma: no cover def test_spkw09(): - SPK9 = os.path.join(cwd, "test9.bsp") - if spice.exists(SPK9): - os.remove(SPK9) # pragma: no cover + spk9 = os.path.join(cwd, "test9.bsp") + if spice.exists(spk9): + os.remove(spk9) # pragma: no cover spice.kclear() - handle = spice.spkopn(SPK9, 'Type 9 SPK internal file name.', 4) - init_size = os.path.getsize(SPK9) + handle = spice.spkopn(spk9, "Type 9 SPK internal file name.", 4) + init_size = os.path.getsize(spk9) discrete_epochs = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0] discrete_states = [ [101.0, 201.0, 301.0, 401.0, 501.0, 601.0], @@ -6790,40 +8479,53 @@ def test_spkw09(): [106.0, 206.0, 306.0, 406.0, 506.0, 606.0], [107.0, 207.0, 307.0, 407.0, 507.0, 607.0], [108.0, 208.0, 308.0, 408.0, 508.0, 608.0], - [109.0, 209.0, 309.0, 409.0, 509.0, 609.0] + [109.0, 209.0, 309.0, 409.0, 509.0, 609.0], ] - segid = 'SPK type 9 test segment' - spice.spkw09(handle, 3, 10, "J2000", discrete_epochs[0], discrete_epochs[-1], segid, - 3, 9, discrete_states, discrete_epochs) + segid = "SPK type 9 test segment" + spice.spkw09( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[-1], + segid, + 3, + 9, + discrete_states, + discrete_epochs, + ) spice.spkcls(handle) - end_size = os.path.getsize(SPK9) + end_size = os.path.getsize(spk9) spice.kclear() assert end_size != init_size - if spice.exists(SPK9): - os.remove(SPK9) # pragma: no cover + if spice.exists(spk9): + os.remove(spk9) # pragma: no cover def test_spkw10(): - SPK10 = os.path.join(cwd, "test10.bsp") - spice.kclear() - tle = ['1 18123U 87 53 A 87324.61041692 -.00000023 00000-0 -75103-5 0 00675', - '2 18123 98.8296 152.0074 0014950 168.7820 191.3688 14.12912554 21686', - '1 18123U 87 53 A 87326.73487726 .00000045 00000-0 28709-4 0 00684', - '2 18123 98.8335 154.1103 0015643 163.5445 196.6235 14.12912902 21988', - '1 18123U 87 53 A 87331.40868801 .00000104 00000-0 60183-4 0 00690', - '2 18123 98.8311 158.7160 0015481 149.9848 210.2220 14.12914624 22644', - '1 18123U 87 53 A 87334.24129978 .00000086 00000-0 51111-4 0 00702', - '2 18123 98.8296 161.5054 0015372 142.4159 217.8089 14.12914879 23045', - '1 18123U 87 53 A 87336.93227900 -.00000107 00000-0 -52860-4 0 00713', - '2 18123 98.8317 164.1627 0014570 135.9191 224.2321 14.12910572 23425', - '1 18123U 87 53 A 87337.28635487 .00000173 00000-0 10226-3 0 00726', - '2 18123 98.8284 164.5113 0015289 133.5979 226.6438 14.12916140 23475', - '1 18123U 87 53 A 87339.05673569 .00000079 00000-0 47069-4 0 00738', - '2 18123 98.8288 166.2585 0015281 127.9985 232.2567 14.12916010 24908', - '1 18123U 87 53 A 87345.43010859 .00000022 00000-0 16481-4 0 00758', - '2 18123 98.8241 172.5226 0015362 109.1515 251.1323 14.12915487 24626', - '1 18123U 87 53 A 87349.04167543 .00000042 00000-0 27370-4 0 00764', - '2 18123 98.8301 176.1010 0015565 100.0881 260.2047 14.12916361 25138'] + spk10 = os.path.join(cwd, "test10.bsp") + spice.kclear() + tle = [ + "1 18123U 87 53 A 87324.61041692 -.00000023 00000-0 -75103-5 0 00675", + "2 18123 98.8296 152.0074 0014950 168.7820 191.3688 14.12912554 21686", + "1 18123U 87 53 A 87326.73487726 .00000045 00000-0 28709-4 0 00684", + "2 18123 98.8335 154.1103 0015643 163.5445 196.6235 14.12912902 21988", + "1 18123U 87 53 A 87331.40868801 .00000104 00000-0 60183-4 0 00690", + "2 18123 98.8311 158.7160 0015481 149.9848 210.2220 14.12914624 22644", + "1 18123U 87 53 A 87334.24129978 .00000086 00000-0 51111-4 0 00702", + "2 18123 98.8296 161.5054 0015372 142.4159 217.8089 14.12914879 23045", + "1 18123U 87 53 A 87336.93227900 -.00000107 00000-0 -52860-4 0 00713", + "2 18123 98.8317 164.1627 0014570 135.9191 224.2321 14.12910572 23425", + "1 18123U 87 53 A 87337.28635487 .00000173 00000-0 10226-3 0 00726", + "2 18123 98.8284 164.5113 0015289 133.5979 226.6438 14.12916140 23475", + "1 18123U 87 53 A 87339.05673569 .00000079 00000-0 47069-4 0 00738", + "2 18123 98.8288 166.2585 0015281 127.9985 232.2567 14.12916010 24908", + "1 18123U 87 53 A 87345.43010859 .00000022 00000-0 16481-4 0 00758", + "2 18123 98.8241 172.5226 0015362 109.1515 251.1323 14.12915487 24626", + "1 18123U 87 53 A 87349.04167543 .00000042 00000-0 27370-4 0 00764", + "2 18123 98.8301 176.1010 0015565 100.0881 260.2047 14.12916361 25138", + ] epoch_x = [] elems_x = [] spice.furnsh(CoreKernels.testMetaKernel) @@ -6834,27 +8536,48 @@ def test_spkw10(): elems_x.extend(elems) first = epoch_x[0] - 0.5 * spice.spd() last = epoch_x[-1] + 0.5 * spice.spd() - consts = [1.082616e-3, -2.538813e-6, -1.65597e-6, 7.43669161e-2, 120.0, 78.0, 6378.135, 1.0] - if spice.exists(SPK10): - os.remove(SPK10) # pragma: no cover - handle = spice.spkopn(SPK10, 'Type 10 SPK internal file name.', 100) - init_size = os.path.getsize(SPK10) - spice.spkw10(handle, -118123, 399, "J2000", first, last, "DMSP F8", consts, 9, elems_x, epoch_x) + consts = [ + 1.082616e-3, + -2.538813e-6, + -1.65597e-6, + 7.43669161e-2, + 120.0, + 78.0, + 6378.135, + 1.0, + ] + if spice.exists(spk10): + os.remove(spk10) # pragma: no cover + handle = spice.spkopn(spk10, "Type 10 SPK internal file name.", 100) + init_size = os.path.getsize(spk10) + spice.spkw10( + handle, + -118123, + 399, + "J2000", + first, + last, + "DMSP F8", + consts, + 9, + elems_x, + epoch_x, + ) spice.spkcls(handle) - end_size = os.path.getsize(SPK10) + end_size = os.path.getsize(spk10) assert end_size != init_size spice.kclear() - if spice.exists(SPK10): - os.remove(SPK10) # pragma: no cover + if spice.exists(spk10): + os.remove(spk10) # pragma: no cover def test_spkw12(): - SPK12 = os.path.join(cwd, "test12.bsp") - if spice.exists(SPK12): - os.remove(SPK12) # pragma: no cover + spk12 = os.path.join(cwd, "test12.bsp") + if spice.exists(spk12): + os.remove(spk12) # pragma: no cover spice.kclear() - handle = spice.spkopn(SPK12, 'Type 12 SPK internal file name.', 4) - init_size = os.path.getsize(SPK12) + handle = spice.spkopn(spk12, "Type 12 SPK internal file name.", 4) + init_size = os.path.getsize(spk12) discrete_epochs = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0] discrete_states = [ [101.0, 201.0, 301.0, 401.0, 501.0, 601.0], @@ -6865,27 +8588,39 @@ def test_spkw12(): [106.0, 206.0, 306.0, 406.0, 506.0, 606.0], [107.0, 207.0, 307.0, 407.0, 507.0, 607.0], [108.0, 208.0, 308.0, 408.0, 508.0, 608.0], - [109.0, 209.0, 309.0, 409.0, 509.0, 609.0] + [109.0, 209.0, 309.0, 409.0, 509.0, 609.0], ] - segid = 'SPK type 12 test segment' + segid = "SPK type 12 test segment" step = discrete_epochs[1] - discrete_epochs[0] - spice.spkw12(handle, 3, 10, "J2000", discrete_epochs[0], discrete_epochs[-1], segid, - 3, 9, discrete_states, discrete_epochs[0], step) + spice.spkw12( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[-1], + segid, + 3, + 9, + discrete_states, + discrete_epochs[0], + step, + ) spice.spkcls(handle) - end_size = os.path.getsize(SPK12) + end_size = os.path.getsize(spk12) spice.kclear() assert end_size != init_size - if spice.exists(SPK12): - os.remove(SPK12) # pragma: no cover + if spice.exists(spk12): + os.remove(spk12) # pragma: no cover def test_spkw13(): - SPK13 = os.path.join(cwd, "test13.bsp") - if spice.exists(SPK13): - os.remove(SPK13) # pragma: no cover + spk13 = os.path.join(cwd, "test13.bsp") + if spice.exists(spk13): + os.remove(spk13) # pragma: no cover spice.kclear() - handle = spice.spkopn(SPK13, 'Type 13 SPK internal file name.', 4) - init_size = os.path.getsize(SPK13) + handle = spice.spkopn(spk13, "Type 13 SPK internal file name.", 4) + init_size = os.path.getsize(spk13) discrete_epochs = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0] discrete_states = [ [101.0, 201.0, 301.0, 401.0, 501.0, 601.0], @@ -6896,41 +8631,52 @@ def test_spkw13(): [106.0, 206.0, 306.0, 406.0, 506.0, 606.0], [107.0, 207.0, 307.0, 407.0, 507.0, 607.0], [108.0, 208.0, 308.0, 408.0, 508.0, 608.0], - [109.0, 209.0, 309.0, 409.0, 509.0, 609.0] + [109.0, 209.0, 309.0, 409.0, 509.0, 609.0], ] - segid = 'SPK type 13 test segment' - spice.spkw13(handle, 3, 10, "J2000", discrete_epochs[0], discrete_epochs[-1], segid, - 3, 9, discrete_states, discrete_epochs) + segid = "SPK type 13 test segment" + spice.spkw13( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[-1], + segid, + 3, + 9, + discrete_states, + discrete_epochs, + ) spice.spkcls(handle) - end_size = os.path.getsize(SPK13) + end_size = os.path.getsize(spk13) spice.kclear() assert end_size != init_size - if spice.exists(SPK13): - os.remove(SPK13) # pragma: no cover + if spice.exists(spk13): + os.remove(spk13) # pragma: no cover def test_spkw15(): discrete_epochs = [100.0, 900.0] spice.kclear() # - SPK15 = os.path.join(cwd, "test15.bsp") - if spice.exists(SPK15): - os.remove(SPK15) # pragma: no cover + spk15 = os.path.join(cwd, "test15.bsp") + if spice.exists(spk15): + os.remove(spk15) # pragma: no cover # create the test kernel - handle = spice.spkopn(SPK15, 'Type 13 SPK internal file name.', 4) - init_size = os.path.getsize(SPK15) + handle = spice.spkopn(spk15, "Type 13 SPK internal file name.", 4) + init_size = os.path.getsize(spk15) # load kernels spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('Dec 25, 2007') - state, ltime = spice.spkezr('Moon', et, 'J2000', 'NONE', 'EARTH') - dim, mu = spice.bodvrd('EARTH', 'GM', 1) + et = spice.str2et("Dec 25, 2007") + state, ltime = spice.spkezr("Moon", et, "J2000", "NONE", "EARTH") + dim, mu = spice.bodvrd("EARTH", "GM", 1) elts = spice.oscelt(state, et, mu[0]) # From these collect the eccentricity and semi-latus ecc = elts[1] - p = elts[0] * (1.0 + ecc) + p = elts[0] * (1.0 + ecc) # Next get the trajectory pole vector and the periapsis vector. state = state[0:3] - tp = spice.ucrss(state, state+4) + tp = spice.ucrss(state, state + 4) pa = spice.vhat(state) # Enable both J2 corrections. j2flg = 0.0 @@ -6940,14 +8686,32 @@ def test_spkw15(): j2 = 1.0 radius = 6000.0 # now call spkw15 - spice.spkw15(handle, 3, 10, 'J2000', discrete_epochs[0], discrete_epochs[-1], "Test SPKW15", et, tp, pa, p, ecc, j2flg, pv, gm, j2, radius) + spice.spkw15( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[-1], + "Test SPKW15", + et, + tp, + pa, + p, + ecc, + j2flg, + pv, + gm, + j2, + radius, + ) # close the kernel spice.spkcls(handle) - end_size = os.path.getsize(SPK15) + end_size = os.path.getsize(spk15) # cleanup assert end_size != init_size - if spice.exists(SPK15): - os.remove(SPK15) # pragma: no cover + if spice.exists(spk15): + os.remove(spk15) # pragma: no cover # spice.kclear() @@ -6956,38 +8720,59 @@ def test_spkw17(): discrete_epochs = [100.0, 900.0] spice.kclear() # - SPK17 = os.path.join(cwd, "test17.bsp") - if spice.exists(SPK17): - os.remove(SPK17) # pragma: no cover + spk17 = os.path.join(cwd, "test17.bsp") + if spice.exists(spk17): + os.remove(spk17) # pragma: no cover # create the test kernel - handle = spice.spkopn(SPK17, 'Type 17 SPK internal file name.', 4) - init_size = os.path.getsize(SPK17) + handle = spice.spkopn(spk17, "Type 17 SPK internal file name.", 4) + init_size = os.path.getsize(spk17) # load kernels spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('Dec 25, 2007') + et = spice.str2et("Dec 25, 2007") # make the eqel vector and the rapol and decpol floats p = 10000.0 gm = 398600.436 ecc = 0.1 a = p / (1.0 - ecc) n = np.sqrt(gm / a) / a - argp = 30. * spice.rpd() - node = 15. * spice.rpd() - inc = 10. * spice.rpd() - m0 = 45. * spice.rpd() - eqel = [a, ecc * np.sin(argp + node), ecc * np.cos(argp + node), m0 + argp + node, - np.tan(inc / 2.0) * np.sin(node), np.tan(inc / 2.0) * np.cos(node), 0.0, n, 0.0] - rapol = spice.halfpi() * -1 + argp = 30.0 * spice.rpd() + node = 15.0 * spice.rpd() + inc = 10.0 * spice.rpd() + m0 = 45.0 * spice.rpd() + eqel = [ + a, + ecc * np.sin(argp + node), + ecc * np.cos(argp + node), + m0 + argp + node, + np.tan(inc / 2.0) * np.sin(node), + np.tan(inc / 2.0) * np.cos(node), + 0.0, + n, + 0.0, + ] + rapol = spice.halfpi() * -1 decpol = spice.halfpi() # now call spkw17 - spice.spkw17(handle, 3, 10, 'J2000', discrete_epochs[0], discrete_epochs[-1], "Test SPKW17", et, eqel, rapol, decpol) + spice.spkw17( + handle, + 3, + 10, + "J2000", + discrete_epochs[0], + discrete_epochs[-1], + "Test SPKW17", + et, + eqel, + rapol, + decpol, + ) # close the kernel spice.spkcls(handle) - end_size = os.path.getsize(SPK17) + end_size = os.path.getsize(spk17) # cleanup assert end_size != init_size - if spice.exists(SPK17): - os.remove(SPK17) # pragma: no cover + if spice.exists(spk17): + os.remove(spk17) # pragma: no cover # spice.kclear() @@ -6995,86 +8780,114 @@ def test_spkw17(): def test_spkw18(): spice.kclear() # - SPK18 = os.path.join(cwd, "test18.bsp") - if spice.exists(SPK18): - os.remove(SPK18) # pragma: no cover + spk18 = os.path.join(cwd, "test18.bsp") + if spice.exists(spk18): + os.remove(spk18) # pragma: no cover # make a new kernel - handle = spice.spkopn(SPK18, 'Type 18 SPK internal file name.', 4) - init_size = os.path.getsize(SPK18) + handle = spice.spkopn(spk18, "Type 18 SPK internal file name.", 4) + init_size = os.path.getsize(spk18) # test data body = 3 center = 10 - ref = "J2000" + ref = "J2000" epochs = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0] states = [ - [101., 201., 301., 401., 501., 601., 1., 1., 1., 1., 1., 1.], - [102., 202., 302., 402., 502., 602., 1., 1., 1., 1., 1., 1.], - [103., 203., 303., 403., 503., 603., 1., 1., 1., 1., 1., 1.], - [104., 204., 304., 404., 504., 604., 1., 1., 1., 1., 1., 1.], - [105., 205., 305., 405., 505., 605., 1., 1., 1., 1., 1., 1.], - [106., 206., 306., 406., 506., 606., 1., 1., 1., 1., 1., 1.], - [107., 207., 307., 407., 507., 607., 1., 1., 1., 1., 1., 1.], - [108., 208., 308., 408., 508., 608., 1., 1., 1., 1., 1., 1.], - [109., 209., 309., 409., 509., 609., 1., 1., 1., 1., 1., 1.], + [101.0, 201.0, 301.0, 401.0, 501.0, 601.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], + [102.0, 202.0, 302.0, 402.0, 502.0, 602.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], + [103.0, 203.0, 303.0, 403.0, 503.0, 603.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], + [104.0, 204.0, 304.0, 404.0, 504.0, 604.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], + [105.0, 205.0, 305.0, 405.0, 505.0, 605.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], + [106.0, 206.0, 306.0, 406.0, 506.0, 606.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], + [107.0, 207.0, 307.0, 407.0, 507.0, 607.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], + [108.0, 208.0, 308.0, 408.0, 508.0, 608.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], + [109.0, 209.0, 309.0, 409.0, 509.0, 609.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], ] # test spkw18 with S18TP0 - spice.spkw18(handle, spice.stypes.SpiceSPK18Subtype.S18TP0, body, center, ref, epochs[0], epochs[-1], "SPK type 18 test segment", 3, states, epochs) + spice.spkw18( + handle, + spice.stypes.SpiceSPK18Subtype.S18TP0, + body, + center, + ref, + epochs[0], + epochs[-1], + "SPK type 18 test segment", + 3, + states, + epochs, + ) # close the kernel spice.spkcls(handle) - end_size = os.path.getsize(SPK18) + end_size = os.path.getsize(spk18) assert end_size != init_size # test reading data - handle = spice.spklef(SPK18) + handle = spice.spklef(spk18) state, lt = spice.spkgeo(body, epochs[0], ref, center) - npt.assert_array_equal(state, [101., 201., 301., 1., 1., 1., ]) + npt.assert_array_equal(state, [101.0, 201.0, 301.0, 1.0, 1.0, 1.0]) state, lt = spice.spkgeo(body, epochs[1], ref, center) - npt.assert_array_equal(state, [102., 202., 302., 1., 1., 1., ]) + npt.assert_array_equal(state, [102.0, 202.0, 302.0, 1.0, 1.0, 1.0]) spice.spkcls(handle) spice.kclear() # cleanup - if spice.exists(SPK18): - os.remove(SPK18) # pragma: no cover + if spice.exists(spk18): + os.remove(spk18) # pragma: no cover def test_spkw20(): spice.kclear() # - SPK20 = os.path.join(cwd, "test20.bsp") - if spice.exists(SPK20): - os.remove(SPK20) # pragma: no cover + spk20 = os.path.join(cwd, "test20.bsp") + if spice.exists(spk20): + os.remove(spk20) # pragma: no cover # create the test kernel - handle = spice.spkopn(SPK20, 'Type 20 SPK internal file name.', 4) - init_size = os.path.getsize(SPK20) + handle = spice.spkopn(spk20, "Type 20 SPK internal file name.", 4) + init_size = os.path.getsize(spk20) # now call spkw20, giving fake data from f_spk20.c from tspice intlen = 5.0 n = 100 polydg = 1 - cdata = np.arange(1.0, 198000.0) # + cdata = np.arange(1.0, 198000.0) # dscale = 1.0 tscale = 1.0 initjd = 2451545.0 initfr = 0.25 - first = (initjd - spice.j2000() + initfr) * spice.spd() - last = ((initjd - spice.j2000()) + initfr + n*intlen) * spice.spd() - spice.spkw20(handle, 301, 3, "J2000", first, last, "Test SPKW20", intlen, n, polydg, cdata, dscale, tscale, initjd, initfr) + first = (initjd - spice.j2000() + initfr) * spice.spd() + last = ((initjd - spice.j2000()) + initfr + n * intlen) * spice.spd() + spice.spkw20( + handle, + 301, + 3, + "J2000", + first, + last, + "Test SPKW20", + intlen, + n, + polydg, + cdata, + dscale, + tscale, + initjd, + initfr, + ) # close the kernel spice.spkcls(handle) - end_size = os.path.getsize(SPK20) + end_size = os.path.getsize(spk20) # cleanup assert end_size != init_size - if spice.exists(SPK20): - os.remove(SPK20) # pragma: no cover + if spice.exists(spk20): + os.remove(spk20) # pragma: no cover # spice.kclear() def test_srfc2s(): spice.kclear() - kernel = os.path.join(cwd, 'srfc2s_ex1.tm') + kernel = os.path.join(cwd, "srfc2s_ex1.tm") if spice.exists(kernel): - os.remove(kernel) # pragma: no cover - with open(kernel, 'w') as kernelFile: - kernelFile.write('\\begindata\n') + os.remove(kernel) # pragma: no cover + with open(kernel, "w") as kernelFile: + kernelFile.write("\\begindata\n") kernelFile.write("NAIF_SURFACE_NAME += ( 'MGS MOLA 64 pixel/deg',\n") kernelFile.write(" 'MGS MOLA 128 pixel/deg',\n") kernelFile.write(" 'PHOBOS GASKELL Q512' )\n") @@ -7083,9 +8896,9 @@ def test_srfc2s(): kernelFile.write("\\begintext\n") kernelFile.close() spice.furnsh(kernel) - assert spice.srfc2s(1, 499) == "MGS MOLA 64 pixel/deg" + assert spice.srfc2s(1, 499) == "MGS MOLA 64 pixel/deg" assert spice.srfc2s(1, 401) == "PHOBOS GASKELL Q512" - assert spice.srfc2s(2, 499) == "MGS MOLA 128 pixel/deg" + assert spice.srfc2s(2, 499) == "MGS MOLA 128 pixel/deg" with pytest.raises(spice.stypes.SpiceyError): spice.srfc2s(1, -1) spice.reset() @@ -7096,11 +8909,11 @@ def test_srfc2s(): def test_srfcss(): spice.kclear() - kernel = os.path.join(cwd, 'srfcss_ex1.tm') + kernel = os.path.join(cwd, "srfcss_ex1.tm") if spice.exists(kernel): - os.remove(kernel) # pragma: no cover - with open(kernel, 'w') as kernelFile: - kernelFile.write('\\begindata\n') + os.remove(kernel) # pragma: no cover + with open(kernel, "w") as kernelFile: + kernelFile.write("\\begindata\n") kernelFile.write("NAIF_SURFACE_NAME += ( 'MGS MOLA 64 pixel/deg',\n") kernelFile.write(" 'MGS MOLA 128 pixel/deg',\n") kernelFile.write(" 'PHOBOS GASKELL Q512' )\n") @@ -7109,9 +8922,9 @@ def test_srfcss(): kernelFile.write("\\begintext\n") kernelFile.close() spice.furnsh(kernel) - assert spice.srfcss(1, "MARS") == "MGS MOLA 64 pixel/deg" + assert spice.srfcss(1, "MARS") == "MGS MOLA 64 pixel/deg" assert spice.srfcss(1, "PHOBOS") == "PHOBOS GASKELL Q512" - assert spice.srfcss(2, "499") == "MGS MOLA 128 pixel/deg" + assert spice.srfcss(2, "499") == "MGS MOLA 128 pixel/deg" with pytest.raises(spice.stypes.SpiceyError): spice.srfcss(1, "ZZZ") spice.reset() @@ -7124,10 +8937,10 @@ def test_srfnrm(): spice.kclear() spice.furnsh(CoreKernels.pck) spice.furnsh(ExtraKernels.phobosDsk) - srfpts = spice.latsrf("DSK/UNPRIORITIZED", "phobos", 0.0, "iau_phobos", - [[0.0, 45.0], [60.0, 45.0]]) - normals = spice.srfnrm("DSK/UNPRIORITIZED", "phobos", 0.0, "iau_phobos", - srfpts) + srfpts = spice.latsrf( + "DSK/UNPRIORITIZED", "phobos", 0.0, "iau_phobos", [[0.0, 45.0], [60.0, 45.0]] + ) + normals = spice.srfnrm("DSK/UNPRIORITIZED", "phobos", 0.0, "iau_phobos", srfpts) srf_rad = np.array([spice.recrad(x) for x in srfpts]) nrm_rad = np.array([spice.recrad(x) for x in normals]) assert np.any(np.not_equal(srf_rad, nrm_rad)) @@ -7145,11 +8958,11 @@ def test_srfrec(): def test_srfs2c(): spice.kclear() - kernel = os.path.join(cwd, 'srfs2c_ex1.tm') + kernel = os.path.join(cwd, "srfs2c_ex1.tm") if spice.exists(kernel): - os.remove(kernel) # pragma: no cover - with open(kernel, 'w') as kernelFile: - kernelFile.write('\\begindata\n') + os.remove(kernel) # pragma: no cover + with open(kernel, "w") as kernelFile: + kernelFile.write("\\begindata\n") kernelFile.write("NAIF_SURFACE_NAME += ( 'MGS MOLA 64 pixel/deg',\n") kernelFile.write(" 'MGS MOLA 128 pixel/deg',\n") kernelFile.write(" 'PHOBOS GASKELL Q512' )\n") @@ -7159,9 +8972,9 @@ def test_srfs2c(): kernelFile.close() spice.furnsh(kernel) assert spice.srfs2c("MGS MOLA 64 pixel/deg", "MARS") == 1 - assert spice.srfs2c("PHOBOS GASKELL Q512", "PHOBOS") == 1 + assert spice.srfs2c("PHOBOS GASKELL Q512", "PHOBOS") == 1 assert spice.srfs2c("MGS MOLA 128 pixel/deg", "MARS") == 2 - assert spice.srfs2c("MGS MOLA 64 pixel/deg", "499") == 1 + assert spice.srfs2c("MGS MOLA 64 pixel/deg", "499") == 1 assert spice.srfs2c("1", "PHOBOS") == 1 assert spice.srfs2c("2", "499") == 2 with pytest.raises(spice.stypes.SpiceyError): @@ -7174,11 +8987,11 @@ def test_srfs2c(): def test_srfscc(): spice.kclear() - kernel = os.path.join(cwd, 'srfscc_ex1.tm') + kernel = os.path.join(cwd, "srfscc_ex1.tm") if spice.exists(kernel): - os.remove(kernel) # pragma: no cover - with open(kernel, 'w') as kernelFile: - kernelFile.write('\\begindata\n') + os.remove(kernel) # pragma: no cover + with open(kernel, "w") as kernelFile: + kernelFile.write("\\begindata\n") kernelFile.write("NAIF_SURFACE_NAME += ( 'MGS MOLA 64 pixel/deg',\n") kernelFile.write(" 'MGS MOLA 128 pixel/deg',\n") kernelFile.write(" 'PHOBOS GASKELL Q512' )\n") @@ -7188,7 +9001,7 @@ def test_srfscc(): kernelFile.close() spice.furnsh(kernel) assert spice.srfscc("MGS MOLA 64 pixel/deg", 499) == 1 - assert spice.srfscc("PHOBOS GASKELL Q512", 401) == 1 + assert spice.srfscc("PHOBOS GASKELL Q512", 401) == 1 assert spice.srfscc("MGS MOLA 128 pixel/deg", 499) == 2 assert spice.srfscc("1", 401) == 1 assert spice.srfscc("2", 499) == 2 @@ -7217,22 +9030,32 @@ def test_srfxpt(): camid = spice.bodn2c("CASSINI_ISS_NAC") shape, frame, bsight, n, bounds = spice.getfov(camid, 4) # run srfxpt on boresight vector - spoint, dist, trgepc, obspos = spice.srfxpt("Ellipsoid", 'Enceladus', et, "LT+S", "CASSINI", frame, bsight) + spoint, dist, trgepc, obspos = spice.srfxpt( + "Ellipsoid", "Enceladus", et, "LT+S", "CASSINI", frame, bsight + ) npt.assert_almost_equal(dist, 683459.6415073496) npt.assert_almost_equal(trgepc, 415065064.9055491) - expected_spoint = [-143.56046006834264971985, 202.9004595420923067195, - -27.99454299292458969717] - expected_obspos = [329627.25001832831185311079, 557847.97086489037610590458, - -217744.02422016291529871523] + expected_spoint = [ + -143.56046006834264971985, + 202.9004595420923067195, + -27.99454299292458969717, + ] + expected_obspos = [ + 329627.25001832831185311079, + 557847.97086489037610590458, + -217744.02422016291529871523, + ] npt.assert_array_almost_equal(spoint, expected_spoint) npt.assert_array_almost_equal(obspos, expected_obspos) # Iterable ET argument: et-10, et, et+10 ets = [et - 10.0, et, et + 10.0] - spoints, dists, trgepcs, obsposs = spice.srfxpt("Ellipsoid", 'Enceladus', ets, "LT+S", "CASSINI", frame, bsight) - assert 0. == spice.vnorm(spice.vsub(spoints[1], spoint)) - assert 0. == (dists[1] - dist) - assert 0. == (trgepcs[1] - trgepc) - assert 0. == spice.vnorm(spice.vsub(obsposs[1], obspos)) + spoints, dists, trgepcs, obsposs = spice.srfxpt( + "Ellipsoid", "Enceladus", ets, "LT+S", "CASSINI", frame, bsight + ) + assert 0.0 == spice.vnorm(spice.vsub(spoints[1], spoint)) + assert 0.0 == (dists[1] - dist) + assert 0.0 == (trgepcs[1] - trgepc) + assert 0.0 == spice.vnorm(spice.vsub(obsposs[1], obspos)) # Cleanup spice.kclear() @@ -7247,30 +9070,39 @@ def test_ssize(): def test_stelab(): IDOBS = 399 IDTARG = 301 - UTC = 'July 4 2004' - FRAME = 'J2000' + UTC = "July 4 2004" + FRAME = "J2000" spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et(UTC) sobs = spice.spkssb(IDOBS, et, FRAME) - starg, ltime = spice.spkapp(IDTARG, et, FRAME, sobs, 'LT') - expected_starg = [2.01738718005936592817e+05, -2.60893145259797573090e+05, - -1.47722589585214853287e+05, 9.24727104822839152121e-01, - 5.32379608845730878386e-01, 2.17669748758417824774e-01] + starg, ltime = spice.spkapp(IDTARG, et, FRAME, sobs, "LT") + expected_starg = [ + 2.01738718005936592817e05, + -2.60893145259797573090e05, + -1.47722589585214853287e05, + 9.24727104822839152121e-01, + 5.32379608845730878386e-01, + 2.17669748758417824774e-01, + ] npt.assert_array_almost_equal(starg, expected_starg) cortarg = spice.stelab(starg[0:3], starg[3:6]) - expected_cortarg = [201739.80378842627396807075, -260892.46619604207808151841, -147722.30606629714020527899] + expected_cortarg = [ + 201739.80378842627396807075, + -260892.46619604207808151841, + -147722.30606629714020527899, + ] npt.assert_array_almost_equal(expected_cortarg, cortarg) spice.kclear() def test_stpool(): spice.kclear() - kernel = os.path.join(cwd, 'stpool_t.ker') + kernel = os.path.join(cwd, "stpool_t.ker") if spice.exists(kernel): - os.remove(kernel) # pragma: no cover - with open(kernel, 'w') as kernelFile: - kernelFile.write('\\begindata\n') + os.remove(kernel) # pragma: no cover + with open(kernel, "w") as kernelFile: + kernelFile.write("\\begindata\n") kernelFile.write("SPK_FILES = ( 'this_is_the_full_path_specification_*',\n") kernelFile.write(" 'of_a_file_with_a_long_name',\n") kernelFile.write(" 'this_is_the_full_path_specification_*',\n") @@ -7285,29 +9117,32 @@ def test_stpool(): assert string == "this_is_the_full_path_specification_of_a_second_file_name" spice.kclear() if spice.exists(kernel): - os.remove(kernel) # pragma: no cover + os.remove(kernel) # pragma: no cover def test_str2et(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - date = 'Thu Mar 20 12:53:29 PST 1997' + date = "Thu Mar 20 12:53:29 PST 1997" et = spice.str2et(date) npt.assert_almost_equal(et, -87836728.81438904) spice.kclear() - + + def test_datetime2et(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - date = datetime(1997,3,20,12,53,29) + date = datetime(1997, 3, 20, 12, 53, 29) et = spice.datetime2et(date) npt.assert_almost_equal(et, -87865528.8143913) - - expecteds=[-87865528.8143913,-792086354.8170365,-790847954.8166842] - dates = [datetime(1997,3,20,12,53,29), - datetime(1974,11,25,20,0,0), - datetime(1974,12,10,4,0,0)] - + + expecteds = [-87865528.8143913, -792086354.8170365, -790847954.8166842] + dates = [ + datetime(1997, 3, 20, 12, 53, 29), + datetime(1974, 11, 25, 20, 0, 0), + datetime(1974, 12, 10, 4, 0, 0), + ] + results = spice.datetime2et(dates) for expected, result in zip(expecteds, results): npt.assert_almost_equal(result, expected) @@ -7317,23 +9152,47 @@ def test_datetime2et(): def test_subpnt(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('2008 aug 11 00:00:00') + et = spice.str2et("2008 aug 11 00:00:00") num_vals, radii = spice.bodvrd("MARS", "RADII", 3) re = radii[0] rp = radii[2] f = (re - rp) / re - methods = ['Intercept: ellipsoid', 'Near point: ellipsoid'] - expecteds = [[349199089.604657, 349199089.64135259, 0.0, 199.30230503198658, 199.30230503198658, - 26.262401237213588, 25.99493675077423, 160.69769496801342, 160.69769496801342, - 25.994934171245205, 25.994934171245202], - [349199089.6046486, 349199089.60464859, 0.0, 199.30230503240247, 199.30230503240247, - 25.99493675092049, 25.99493675092049, 160.69769496759753, 160.69769496759753, - 25.729407227461937, 25.994934171391463]] + methods = ["Intercept: ellipsoid", "Near point: ellipsoid"] + expecteds = [ + [ + 349199089.604657, + 349199089.64135259, + 0.0, + 199.30230503198658, + 199.30230503198658, + 26.262401237213588, + 25.99493675077423, + 160.69769496801342, + 160.69769496801342, + 25.994934171245205, + 25.994934171245202, + ], + [ + 349199089.6046486, + 349199089.60464859, + 0.0, + 199.30230503240247, + 199.30230503240247, + 25.99493675092049, + 25.99493675092049, + 160.69769496759753, + 160.69769496759753, + 25.729407227461937, + 25.994934171391463, + ], + ] for expected, method in zip(expecteds, methods): - spoint, trgepc, srfvec = spice.subpnt(method, 'Mars', et, 'IAU_MARS', 'LT+S', 'Earth') + spoint, trgepc, srfvec = spice.subpnt( + method, "Mars", et, "IAU_MARS", "LT+S", "Earth" + ) odist = np.linalg.norm(srfvec) npt.assert_almost_equal(odist, expected[1], decimal=5) - spglon, spglat, spgalt = spice.recpgr('mars', spoint, re, f) + spglon, spglat, spgalt = spice.recpgr("mars", spoint, re, f) npt.assert_almost_equal(spgalt, expected[2], decimal=5) npt.assert_almost_equal(spglon * spice.dpr(), expected[3], decimal=5) npt.assert_almost_equal(spglat * spice.dpr(), expected[5], decimal=5) @@ -7341,7 +9200,7 @@ def test_subpnt(): npt.assert_almost_equal(spclon * spice.dpr(), expected[7], decimal=5) npt.assert_almost_equal(spclat * spice.dpr(), expected[9], decimal=5) obspos = np.subtract(spoint, srfvec) - opglon, opglat, opgalt = spice.recpgr('mars', obspos, re, f) + opglon, opglat, opgalt = spice.recpgr("mars", obspos, re, f) npt.assert_almost_equal(opgalt, expected[0], decimal=5) npt.assert_almost_equal(opglon * spice.dpr(), expected[4], decimal=5) npt.assert_almost_equal(opglat * spice.dpr(), expected[6], decimal=5) @@ -7362,9 +9221,11 @@ def test_subpt(): npt.assert_almost_equal(dist, 16.705476097706171) npt.assert_almost_equal(sep, 0.15016657506598063) # Iterable ET argument to spice.subpt() - points, alts = spice.subpt("near point", "earth", [et-20., et, et+20.], "lt+s", "moon") - assert 0. == spice.vnorm(spice.vsub(points[1], point1)) - assert 0. == (alts[1] - alt1) + points, alts = spice.subpt( + "near point", "earth", [et - 20.0, et, et + 20.0], "lt+s", "moon" + ) + assert 0.0 == spice.vnorm(spice.vsub(points[1], point1)) + assert 0.0 == (alts[1] - alt1) # Cleanup spice.kclear() @@ -7372,29 +9233,49 @@ def test_subpt(): def test_subslr(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('2008 aug 11 00:00:00') + et = spice.str2et("2008 aug 11 00:00:00") num_vals, radii = spice.bodvrd("MARS", "RADII", 3) re = radii[0] rp = radii[2] f = (re - rp) / re - methods = ['Intercept: ellipsoid', 'Near point: ellipsoid'] - expecteds = [[0.0, 175.8106755102322, 23.668550281477703, -175.81067551023222, - 23.420819936106213, 175.810721536362, 23.42082337182491, - -175.810721536362, 23.42081994605096], - [0.0, 175.8106754100492, 23.420823361866685, -175.81067551023222, - 23.175085577910583, 175.81072152220804, 23.420823371828, - -175.81072152220804, 23.420819946054046]] + methods = ["Intercept: ellipsoid", "Near point: ellipsoid"] + expecteds = [ + [ + 0.0, + 175.8106755102322, + 23.668550281477703, + -175.81067551023222, + 23.420819936106213, + 175.810721536362, + 23.42082337182491, + -175.810721536362, + 23.42081994605096, + ], + [ + 0.0, + 175.8106754100492, + 23.420823361866685, + -175.81067551023222, + 23.175085577910583, + 175.81072152220804, + 23.420823371828, + -175.81072152220804, + 23.420819946054046, + ], + ] for expected, method in zip(expecteds, methods): - spoint, trgepc, srfvec = spice.subslr(method, 'Mars', et, 'IAU_MARS', 'LT+S', 'Earth') - spglon, spglat, spgalt = spice.recpgr('mars', spoint, re, f) + spoint, trgepc, srfvec = spice.subslr( + method, "Mars", et, "IAU_MARS", "LT+S", "Earth" + ) + spglon, spglat, spgalt = spice.recpgr("mars", spoint, re, f) npt.assert_almost_equal(spgalt, expected[0], decimal=5) npt.assert_almost_equal(spglon * spice.dpr(), expected[1], decimal=5) npt.assert_almost_equal(spglat * spice.dpr(), expected[2], decimal=5) spcrad, spclon, spclat = spice.reclat(spoint) npt.assert_almost_equal(spclon * spice.dpr(), expected[3], decimal=5) npt.assert_almost_equal(spclat * spice.dpr(), expected[4], decimal=5) - sunpos, sunlt = spice.spkpos('sun', trgepc, 'iau_mars', 'lt+s', 'mars') - supgln, supglt, supgal = spice.recpgr('mars', sunpos, re, f) + sunpos, sunlt = spice.spkpos("sun", trgepc, "iau_mars", "lt+s", "mars") + supgln, supglt, supgal = spice.recpgr("mars", sunpos, re, f) npt.assert_almost_equal(supgln * spice.dpr(), expected[5], decimal=5) npt.assert_almost_equal(supglt * spice.dpr(), expected[6], decimal=5) supcrd, supcln, supclt = spice.reclat(sunpos) @@ -7406,10 +9287,14 @@ def test_subslr(): def test_subsol(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - point = spice.subsol('near point', 'earth', 0.0, 'lt+s', 'mars') - npt.assert_array_almost_equal(point, [5850.44947427, 509.68837118, -2480.24722673], decimal=4) - intercept = spice.subsol('intercept', 'earth', 0.0, 'lt+s', 'mars') - npt.assert_array_almost_equal(intercept, [5844.4362338, 509.16450054, -2494.39569089], decimal=4) + point = spice.subsol("near point", "earth", 0.0, "lt+s", "mars") + npt.assert_array_almost_equal( + point, [5850.44947427, 509.68837118, -2480.24722673], decimal=4 + ) + intercept = spice.subsol("intercept", "earth", 0.0, "lt+s", "mars") + npt.assert_array_almost_equal( + intercept, [5844.4362338, 509.16450054, -2494.39569089], decimal=4 + ) spice.kclear() @@ -7465,31 +9350,40 @@ def test_sxform(): lon = 118.25 * spice.rpd() lat = 34.05 * spice.rpd() alt = 0.0 - utc = 'January 1, 1990' + utc = "January 1, 1990" et = spice.str2et(utc) - len, abc = spice.bodvrd('EARTH', 'RADII', 3) + len, abc = spice.bodvrd("EARTH", "RADII", 3) equatr = abc[0] polar = abc[2] f = (equatr - polar) / equatr estate = spice.georec(lon, lat, alt, equatr, f) estate = np.append(estate, [0.0, 0.0, 0.0]) - xform = np.array(spice.sxform('IAU_EARTH', 'J2000', et)) + xform = np.array(spice.sxform("IAU_EARTH", "J2000", et)) spice.kclear() jstate = np.dot(xform, estate) - expected = np.array([-4131.45969, -3308.36805, 3547.02462, 0.241249619, -0.301019201, 0.000234215666]) + expected = np.array( + [ + -4131.45969, + -3308.36805, + 3547.02462, + 0.241249619, + -0.301019201, + 0.000234215666, + ] + ) npt.assert_array_almost_equal(jstate, expected, decimal=4) def test_sxform_vectorized(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - utc1 = 'January 1, 1990' - utc2 = 'January 1, 2010' + utc1 = "January 1, 1990" + utc2 = "January 1, 2010" et1 = spice.str2et(utc1) et2 = spice.str2et(utc2) step = (et2 - et1) / 240.0 et = np.arange(240) * step + et1 - xform = spice.sxform('IAU_EARTH', 'J2000', et) + xform = spice.sxform("IAU_EARTH", "J2000", et) assert len(xform) == 240 spice.kclear() @@ -7515,9 +9409,22 @@ def test_termpt(): # set the time et = spice.str2et("1972 AUG 11 00:00:00") # call limpt - npts, points, epochs, tangts = spice.termpt("UMBRAL/TANGENT/DSK/UNPRIORITIZED", "SUN", "Phobos", et, "IAU_PHOBOS", - "CN+S", "CENTER", "MARS", [0.0, 0.0, 1.0], - spice.twopi()/3.0, 3, 1.0e-4, 1.0e-7, 10000) + npts, points, epochs, tangts = spice.termpt( + "UMBRAL/TANGENT/DSK/UNPRIORITIZED", + "SUN", + "Phobos", + et, + "IAU_PHOBOS", + "CN+S", + "CENTER", + "MARS", + [0.0, 0.0, 1.0], + spice.twopi() / 3.0, + 3, + 1.0e-4, + 1.0e-7, + 10000, + ) assert points is not None assert len(points) == 3 spice.kclear() @@ -7528,24 +9435,24 @@ def test_timdef(): LSK = os.path.join(cwd, CoreKernels.currentLSK) spice.furnsh(LSK) # Calendar - default is Gregorian - value = spice.timdef('GET', 'CALENDAR', 10) - assert value == 'GREGORIAN' or 'JULIAN' or 'MIXED' + value = spice.timdef("GET", "CALENDAR", 10) + assert value == "GREGORIAN" or "JULIAN" or "MIXED" # System - ensure it changes the str2et results - assert 'UTC' == spice.timdef('GET', 'SYSTEM', 10) + assert "UTC" == spice.timdef("GET", "SYSTEM", 10) # Approximately 64.184 - saveET = spice.str2et('2000-01-01T12:00:00') + saveET = spice.str2et("2000-01-01T12:00:00") # Change to TDB system - assert 'TDB' == spice.timdef('SET', 'SYSTEM', 10, 'TDB') - assert 0.0 == spice.str2et('2000-01-01T12:00:00') + assert "TDB" == spice.timdef("SET", "SYSTEM", 10, "TDB") + assert 0.0 == spice.str2et("2000-01-01T12:00:00") # Change back to UTC system - assert 'UTC' == spice.timdef('SET', 'SYSTEM', 10, 'UTC') - assert saveET == spice.str2et('2000-01-01T12:00:00') + assert "UTC" == spice.timdef("SET", "SYSTEM", 10, "UTC") + assert saveET == spice.str2et("2000-01-01T12:00:00") # Cleanup spice.kclear() def test_timout(): - sample = 'Thu Oct 1 11:11:11 PDT 1111' + sample = "Thu Oct 1 11:11:11 PDT 1111" spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) pic, ok, err = spice.tpictr(sample) @@ -7557,7 +9464,7 @@ def test_timout(): def test_timout_vectorized(): - sample = 'Thu Oct 1 11:11:11 PDT 1111' + sample = "Thu Oct 1 11:11:11 PDT 1111" lenout = len(sample) + 2 spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) @@ -7565,9 +9472,13 @@ def test_timout_vectorized(): assert ok et = np.array(np.arange(5) * 10000) + 188745364.0 out = list(spice.timout(et, pic, lenout)) - expected = ["Sat Dec 24 18:14:59 PDT 2005", "Sat Dec 24 21:01:39 PDT 2005", - "Sat Dec 24 23:48:19 PDT 2005", "Sun Dec 25 02:34:59 PDT 2005", - "Sun Dec 25 05:21:39 PDT 2005"] + expected = [ + "Sat Dec 24 18:14:59 PDT 2005", + "Sat Dec 24 21:01:39 PDT 2005", + "Sat Dec 24 23:48:19 PDT 2005", + "Sun Dec 25 02:34:59 PDT 2005", + "Sun Dec 25 05:21:39 PDT 2005", + ] for e in expected: assert e in out spice.kclear() @@ -7576,8 +9487,8 @@ def test_timout_vectorized(): def test_tipbod(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('Jan 1 2005') - tipm = spice.tipbod('J2000', 699, et) + et = spice.str2et("Jan 1 2005") + tipm = spice.tipbod("J2000", 699, et) assert tipm is not None spice.kclear() @@ -7585,8 +9496,8 @@ def test_tipbod(): def test_tisbod(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('Jan 1 2005') - tsipm = spice.tisbod('J2000', 699, et) + et = spice.str2et("Jan 1 2005") + tsipm = spice.tisbod("J2000", 699, et) assert tsipm is not None spice.kclear() @@ -7596,11 +9507,15 @@ def test_tkfram(): spice.furnsh(CoreKernels.testMetaKernel) spice.furnsh(CassiniKernels.cassFk) rotation, nextFrame = spice.tkfram(-82001) - expected = np.array([[6.12323400e-17, 0.00000000e+00, -1.00000000e+00], - [0.00000000e+00, 1.00000000e+00, -0.00000000e+00], - [1.00000000e+00, 0.00000000e+00, 6.12323400e-17]]) + expected = np.array( + [ + [6.12323400e-17, 0.00000000e00, -1.00000000e00], + [0.00000000e00, 1.00000000e00, -0.00000000e00], + [1.00000000e00, 0.00000000e00, 6.12323400e-17], + ] + ) npt.assert_array_almost_equal(rotation, expected) - assert nextFrame == -82000 + assert nextFrame == -82000 spice.kclear() @@ -7610,12 +9525,12 @@ def test_tkvrsn(): def test_tparse(): - actualOne, errorOne = spice.tparse("1996-12-18T12:28:28") - assert actualOne == -95815892.0 - actualTwo, errorTwo = spice.tparse("1 DEC 1997 12:28:29.192") - assert actualTwo == -65748690.808 - actualThree, errorThree = spice.tparse("1997-162::12:18:28.827") - assert actualThree == -80696491.173 + actual_one, error_one = spice.tparse("1996-12-18T12:28:28") + assert actual_one == -95815892.0 + actual_two, error_two = spice.tparse("1 DEC 1997 12:28:29.192") + assert actual_two == -65748690.808 + actual_three, error_three = spice.tparse("1997-162::12:18:28.827") + assert actual_three == -80696491.173 def test_tpictr(): @@ -7664,17 +9579,17 @@ def teardown_test_trcoff(): spice.reset() spice.kclear() # Initialize stack trace with two values, and test - spice.chkin('A') - spice.chkin('B') + spice.chkin("A") + spice.chkin("B") assert 2 == spice.trcdep() - assert 'B' == spice.trcnam(1) - assert 'A' == spice.trcnam(0) + assert "B" == spice.trcnam(1) + assert "A" == spice.trcnam(0) # Turn off tracing and test spice.trcoff() assert 0 == spice.trcdep() - assert '' == spice.qcktrc(2) + assert "" == spice.qcktrc(2) # Ensure subsequent checkins are also ignored - spice.chkin('C') + spice.chkin("C") assert 0 == spice.trcdep() # Cleanup spice.reset() @@ -7683,32 +9598,35 @@ def teardown_test_trcoff(): def test_tsetyr(): spice.reset() + # Expand 2-digit year to full year, typically 4-digit - tmp_getyr4 = lambda iy2: int(spice.etcal(spice.tparse('3/3/{:02}'.format(iy2), 22)[0]).split()[0]) + def tmp_getyr4(iy2): + return int(spice.etcal(spice.tparse("3/3/{:02}".format(iy2), 22)[0]).split()[0]) + # Find current lower bound on the 100 year interval of expansion, # so it can be restored on exit tsetyr_lowerbound = tmp_getyr4(0) for iy2_test in range(100): - tmp_lowerbound = tmp_getyr4(iy2_test) - if tmp_lowerbound < tsetyr_lowerbound: - tsetyr_lowerbound = tmp_lowerbound - break + tmp_lowerbound = tmp_getyr4(iy2_test) + if tmp_lowerbound < tsetyr_lowerbound: + tsetyr_lowerbound = tmp_lowerbound + break # Run first case with a year not ending in 00 tsetyr_y2 = tsetyr_lowerbound % 100 tsetyr_y4 = tsetyr_lowerbound + 200 + ((tsetyr_y2 == 0) and 50 or 0) spice.tsetyr(tsetyr_y4) assert tmp_getyr4(tsetyr_y4 % 100) == tsetyr_y4 - assert tmp_getyr4((tsetyr_y4-1) % 100) == (tsetyr_y4+99) + assert tmp_getyr4((tsetyr_y4 - 1) % 100) == (tsetyr_y4 + 99) # Run second case with a year ending in 00 - tsetyr_y4 -= (tsetyr_y4 % 100) + tsetyr_y4 -= tsetyr_y4 % 100 spice.tsetyr(tsetyr_y4) assert tmp_getyr4(tsetyr_y4 % 100) == tsetyr_y4 - assert tmp_getyr4((tsetyr_y4-1) % 100) == (tsetyr_y4+99) + assert tmp_getyr4((tsetyr_y4 - 1) % 100) == (tsetyr_y4 + 99) # Cleanup: reset lowerbound to what it was when this routine started tsetyr_y4 = tsetyr_lowerbound spice.tsetyr(tsetyr_y4) assert tmp_getyr4(tsetyr_y4 % 100) == tsetyr_y4 - assert tmp_getyr4((tsetyr_y4-1) % 100) == (tsetyr_y4+99) + assert tmp_getyr4((tsetyr_y4 - 1) % 100) == (tsetyr_y4 + 99) assert not spice.failed() spice.reset() @@ -7780,50 +9698,50 @@ def test_udf(): def test_union(): # SPICEINT_CELL - testCellOne = spice.cell_int(8) - testCellTwo = spice.cell_int(8) - spice.insrti(1, testCellOne) - spice.insrti(2, testCellOne) - spice.insrti(3, testCellOne) - spice.insrti(2, testCellTwo) - spice.insrti(3, testCellTwo) - spice.insrti(4, testCellTwo) - outCell = spice.union(testCellOne, testCellTwo) - assert [x for x in outCell] == [1, 2, 3, 4] + test_cell_one = spice.cell_int(8) + test_cell_two = spice.cell_int(8) + spice.insrti(1, test_cell_one) + spice.insrti(2, test_cell_one) + spice.insrti(3, test_cell_one) + spice.insrti(2, test_cell_two) + spice.insrti(3, test_cell_two) + spice.insrti(4, test_cell_two) + out_cell = spice.union(test_cell_one, test_cell_two) + assert [x for x in out_cell] == [1, 2, 3, 4] # SPICECHAR_CELL - testCellOne = spice.cell_char(8, 8) - testCellTwo = spice.cell_char(8, 8) - spice.insrtc('1', testCellOne) - spice.insrtc('2', testCellOne) - spice.insrtc('3', testCellOne) - spice.insrtc('2', testCellTwo) - spice.insrtc('3', testCellTwo) - spice.insrtc('4', testCellTwo) - outCell = spice.union(testCellOne, testCellTwo) - assert [x for x in outCell] == ['1', '2', '3', '4'] + test_cell_one = spice.cell_char(8, 8) + test_cell_two = spice.cell_char(8, 8) + spice.insrtc("1", test_cell_one) + spice.insrtc("2", test_cell_one) + spice.insrtc("3", test_cell_one) + spice.insrtc("2", test_cell_two) + spice.insrtc("3", test_cell_two) + spice.insrtc("4", test_cell_two) + out_cell = spice.union(test_cell_one, test_cell_two) + assert [x for x in out_cell] == ["1", "2", "3", "4"] # SPICEDOUBLE_CELL - testCellOne = spice.cell_double(8) - testCellTwo = spice.cell_double(8) - spice.insrtd(1., testCellOne) - spice.insrtd(2., testCellOne) - spice.insrtd(3., testCellOne) - spice.insrtd(2., testCellTwo) - spice.insrtd(3., testCellTwo) - spice.insrtd(4., testCellTwo) - outCell = spice.union(testCellOne, testCellTwo) - assert [x for x in outCell] == [1., 2., 3., 4.] + test_cell_one = spice.cell_double(8) + test_cell_two = spice.cell_double(8) + spice.insrtd(1.0, test_cell_one) + spice.insrtd(2.0, test_cell_one) + spice.insrtd(3.0, test_cell_one) + spice.insrtd(2.0, test_cell_two) + spice.insrtd(3.0, test_cell_two) + spice.insrtd(4.0, test_cell_two) + out_cell = spice.union(test_cell_one, test_cell_two) + assert [x for x in out_cell] == [1.0, 2.0, 3.0, 4.0] # SPICEBOOLEAN_CELL - testCellOne = spice.cell_bool(9) - testCellTwo = spice.cell_bool(9) + test_cell_one = spice.cell_bool(9) + test_cell_two = spice.cell_bool(9) with pytest.raises(NotImplementedError): - spice.union(testCellOne, testCellTwo) + spice.union(test_cell_one, test_cell_two) def test_unitim(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('Dec 19 2003') - converted_et = spice.unitim(et, 'ET', 'JED') + et = spice.str2et("Dec 19 2003") + converted_et = spice.unitim(et, "ET", "JED") npt.assert_almost_equal(converted_et, 2452992.5007428653) spice.kclear() @@ -7834,21 +9752,22 @@ def test_unload(): # 4 kernels + the meta kernel = 5 assert spice.ktotal("ALL") == 5 # Make list of FURNSHed non-meta-kernels - kernelList = [] + kernel_list = [] for iKernel in range(spice.ktotal("ALL")): filnam, filtyp, srcnam, handle = spice.kdata(iKernel, "ALL", 999, 999, 999) - if filtyp != "META": kernelList.append(filnam) - assert len(kernelList) > 0 + if filtyp != "META": + kernel_list.append(filnam) + assert len(kernel_list) > 0 # Unload all kernels spice.unload(CoreKernels.testMetaKernel) assert spice.ktotal("ALL") == 0 spice.kclear() # Test passing the [list of kernels] as an argument to spice.unload - spice.furnsh(kernelList) - assert spice.ktotal("ALL") == len(kernelList) - spice.unload(kernelList[1:]) + spice.furnsh(kernel_list) + assert spice.ktotal("ALL") == len(kernel_list) + spice.unload(kernel_list[1:]) assert spice.ktotal("ALL") == 1 - spice.unload(kernelList[:1]) + spice.unload(kernel_list[:1]) assert spice.ktotal("ALL") == 0 @@ -7861,26 +9780,26 @@ def test_unload_emptystring(): def test_unorm(): v1 = np.array([5.0, 12.0, 0.0]) - expectedVout = np.array([5.0 / 13.0, 12.0 / 13.0, 0.0]) - expectedVmag = 13.0 + expected_vout = np.array([5.0 / 13.0, 12.0 / 13.0, 0.0]) + expected_vmag = 13.0 vout, vmag = spice.unorm(v1) - assert vmag == expectedVmag - assert np.array_equal(expectedVout, vout) + assert vmag == expected_vmag + assert np.array_equal(expected_vout, vout) def test_unormg(): v1 = np.array([5.0, 12.0]) - expectedVout = np.array([5.0/13.0, 12.0/13.0]) - expectedVmag = 13.0 + expected_vout = np.array([5.0 / 13.0, 12.0 / 13.0]) + expected_vmag = 13.0 vout, vmag = spice.unormg(v1, 2) - assert vmag == expectedVmag - assert np.array_equal(expectedVout, vout) + assert vmag == expected_vmag + assert np.array_equal(expected_vout, vout) def test_utc2et(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - utcstr = 'December 1, 2004 15:04:11' + utcstr = "December 1, 2004 15:04:11" output = spice.utc2et(utcstr) assert output == 155185515.1831043 # icy utc2et example gives 1.5518552e+08 as output @@ -7953,7 +9872,7 @@ def test_vequg(): def test_vhat(): v1 = np.array([5.0, 12.0, 0.0]) - expected = np.array([5/13.0, 12/13.0, 0.0]) + expected = np.array([5 / 13.0, 12 / 13.0, 0.0]) vout = spice.vhat(v1) assert np.array_equal(vout, expected) @@ -8003,8 +9922,8 @@ def test_vminus(): def test_vnorm(): - v1 = np.array([1.e0, 2.e0, 2.e0]) - assert spice.vnorm(v1) == 3.e0 + v1 = np.array([1.0e0, 2.0e0, 2.0e0]) + assert spice.vnorm(v1) == 3.0e0 def test_vnormg(): @@ -8090,7 +10009,7 @@ def test_vsclg(): def test_vsep(): v1 = np.array([1.0, 0.0, 0.0]) v2 = np.array([0.0, 1.0, 0.0]) - assert spice.vsep(v1, v2) == np.pi/2 + assert spice.vsep(v1, v2) == np.pi / 2 def test_vsepg(): @@ -8223,7 +10142,7 @@ def test_wnextd(): for d in darray: spice.wninsd(d[0], d[1], window) assert spice.wncard(window) == 4 - window = spice.wnextd('L', window) + window = spice.wnextd("L", window) assert spice.wncard(window) == 4 assert spice.wnfetd(window, 0) == (1.0, 1.0) assert spice.wnfetd(window, 1) == (7.0, 7.0) @@ -8316,7 +10235,7 @@ def test_wnreld(): for d in darray2: spice.wninsd(d[0], d[1], window2) assert spice.wncard(window2) == 3 - ops = ['=', '<>', '<=', '<', '>=', '>'] + ops = ["=", "<>", "<=", "<", ">=", ">"] expected = [False, True, False, False, True, True] for op, exp in zip(ops, expected): assert spice.wnreld(window1, op, window2) == exp @@ -8324,7 +10243,14 @@ def test_wnreld(): def test_wnsumd(): window = spice.cell_double(12) - darray = [[1.0, 3.0], [7.0, 11.0], [18.0, 18.0], [23.0, 27.0], [30.0, 69.0], [72.0, 80.0]] + darray = [ + [1.0, 3.0], + [7.0, 11.0], + [18.0, 18.0], + [23.0, 27.0], + [30.0, 69.0], + [72.0, 80.0], + ] for d in darray: spice.wninsd(d[0], d[1], window) meas, avg, stddev, shortest, longest = spice.wnsumd(window) @@ -8356,9 +10282,18 @@ def test_wnunid(): def test_wnvald(): window = spice.cell_double(30) - array = [[0.0, 0.0], [10.0, 12.0], [2.0, 7.0], - [13.0, 15.0], [1.0, 5.0], [23.0, 29.0], - [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]] + array = [ + [0.0, 0.0], + [10.0, 12.0], + [2.0, 7.0], + [13.0, 15.0], + [1.0, 5.0], + [23.0, 29.0], + [0.0, 0.0], + [0.0, 0.0], + [0.0, 0.0], + [0.0, 0.0], + ] for a in array: spice.wninsd(a[0], a[1], window) result = spice.wnvald(30, 20, window) @@ -8374,20 +10309,24 @@ def test_xf2eul(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) et = spice.str2et("Jan 1, 2009") - m = spice.sxform('IAU_EARTH', 'J2000', et) + m = spice.sxform("IAU_EARTH", "J2000", et) eulang, unique = spice.xf2eul(m, 3, 1, 3) assert unique - expected = [1.571803284049681, 0.0008750002978301174, 2.9555269829740034, - 3.5458495690569166e-12, 3.080552365717176e-12, -7.292115373266558e-05] + expected = [ + 1.571803284049681, + 0.0008750002978301174, + 2.9555269829740034, + 3.5458495690569166e-12, + 3.080552365717176e-12, + -7.292115373266558e-05, + ] npt.assert_array_almost_equal(expected, eulang) spice.kclear() def test_xf2rav(): e = [1.0, 0.0, 0.0] - rz = [[0.0, 1.0, 0.0], - [-1.0, 0.0, 0.0], - [0.0, 0.0, 1.0]] + rz = [[0.0, 1.0, 0.0], [-1.0, 0.0, 0.0], [0.0, 0.0, 1.0]] xform = spice.rav2xf(rz, e) rz2, e2 = spice.xf2rav(xform) npt.assert_array_almost_equal(e, e2) @@ -8397,61 +10336,93 @@ def test_xf2rav(): def test_xfmsta(): spice.kclear() spice.furnsh(CoreKernels.testMetaKernel) - et = spice.str2et('July 4, 2003 11:00 AM PST') + et = spice.str2et("July 4, 2003 11:00 AM PST") state, lt = spice.spkezr("Mars", et, "J2000", "LT+S", "Earth") expected_lt = 269.6898813661505 - expected_state = [7.38222353105354905128e+07, -2.71279189984722770751e+07, - -1.87413063014898747206e+07, -6.80851334001380692484e+00, - 7.51399612408221173609e+00, 3.00129849265935222391e+00] + expected_state = [ + 7.38222353105354905128e07, + -2.71279189984722770751e07, + -1.87413063014898747206e07, + -6.80851334001380692484e00, + 7.51399612408221173609e00, + 3.00129849265935222391e00, + ] npt.assert_almost_equal(lt, expected_lt) npt.assert_array_almost_equal(state, expected_state) state_lat = spice.xfmsta(state, "rectangular", "latitudinal", " ") - expected_lat_state = [8.08509924324866235256e+07, -3.52158255331780634112e-01, - -2.33928262716770696272e-01, -9.43348972618204761886e+00, - 5.98157681117165682860e-08, 1.03575559016377728336e-08] + expected_lat_state = [ + 8.08509924324866235256e07, + -3.52158255331780634112e-01, + -2.33928262716770696272e-01, + -9.43348972618204761886e00, + 5.98157681117165682860e-08, + 1.03575559016377728336e-08, + ] npt.assert_array_almost_equal(state_lat, expected_lat_state) spice.kclear() def test_xpose6(): - m1 = [[1.0, 2.0, 3.0, 4.0, 5.0, 6.0], [0.0, 7.0, 8.0, 9.0, 10.0, 11.0], [0.0, 0.0, 12.0, 13.0, 14.0, 15.0], - [0.0, 0.0, 0.0, 16.0, 17.0, 18.0], [0.0, 0.0, 0.0, 0.0, 19.0, 20.0], [0.0, 0.0, 0.0, 0.0, 0.0, 21.0]] + m1 = [ + [1.0, 2.0, 3.0, 4.0, 5.0, 6.0], + [0.0, 7.0, 8.0, 9.0, 10.0, 11.0], + [0.0, 0.0, 12.0, 13.0, 14.0, 15.0], + [0.0, 0.0, 0.0, 16.0, 17.0, 18.0], + [0.0, 0.0, 0.0, 0.0, 19.0, 20.0], + [0.0, 0.0, 0.0, 0.0, 0.0, 21.0], + ] mout_expected = np.array(m1).transpose().tolist() npt.assert_array_almost_equal(spice.xpose6(m1), mout_expected) def test_xpose(): m1 = [[1.0, 2.0, 3.0], [0.0, 4.0, 5.0], [0.0, 6.0, 0.0]] - npt.assert_array_almost_equal(spice.xpose(m1), [[1.0, 0.0, 0.0], [2.0, 4.0, 6.0], [3.0, 5.0, 0.0]]) - npt.assert_array_almost_equal(spice.xpose(np.array(m1)), [[1.0, 0.0, 0.0], [2.0, 4.0, 6.0], [3.0, 5.0, 0.0]]) + npt.assert_array_almost_equal( + spice.xpose(m1), [[1.0, 0.0, 0.0], [2.0, 4.0, 6.0], [3.0, 5.0, 0.0]] + ) + npt.assert_array_almost_equal( + spice.xpose(np.array(m1)), [[1.0, 0.0, 0.0], [2.0, 4.0, 6.0], [3.0, 5.0, 0.0]] + ) def test_xposeg(): m1 = [[1.0, 2.0, 3.0], [0.0, 4.0, 5.0], [0.0, 6.0, 0.0]] - npt.assert_array_almost_equal(spice.xposeg(m1, 3, 3), [[1.0, 0.0, 0.0], [2.0, 4.0, 6.0], [3.0, 5.0, 0.0]]) - npt.assert_array_almost_equal(spice.xposeg(np.array(m1), 3, 3), [[1.0, 0.0, 0.0], [2.0, 4.0, 6.0], [3.0, 5.0, 0.0]]) + npt.assert_array_almost_equal( + spice.xposeg(m1, 3, 3), [[1.0, 0.0, 0.0], [2.0, 4.0, 6.0], [3.0, 5.0, 0.0]] + ) + npt.assert_array_almost_equal( + spice.xposeg(np.array(m1), 3, 3), + [[1.0, 0.0, 0.0], [2.0, 4.0, 6.0], [3.0, 5.0, 0.0]], + ) + def test_zzdynrot(): spice.kclear() spice.furnsh(ExtraKernels.mroFk) rotation, frame = spice.zzdynrot(-74900, 499, 221051477.42023) - expected = np.array([[ 0.6733481, 0.73932559, 0.0 ], - [-0.5895359, 0.53692566, 0.60345527], - [ 0.44614992, -0.40633546, 0.79739685]]) + expected = np.array( + [ + [0.6733481, 0.73932559, 0.0], + [-0.5895359, 0.53692566, 0.60345527], + [0.44614992, -0.40633546, 0.79739685], + ] + ) npt.assert_array_almost_equal(rotation, expected) - assert frame == 1 + assert frame == 1 spice.kclear() + def teardown_tests(): # Tests that must be done last are put here and # scheduled in teardown_module() teardown_test_trcoff() + def teardown_module(module): teardown_tests() # if you are developing spiceypy, and don't want to delete kernels each time you run the tests, set # set the following environment variable "spiceypy_do_not_remove_kernels" to anything - if not os.environ.get('spiceypy_do_not_remove_kernels'): - cleanup_Cassini_Kernels() - cleanup_Extra_Kernels() - cleanup_Core_Kernels() + if not os.environ.get("spiceypy_do_not_remove_kernels"): + cleanup_cassini_kernels() + cleanup_extra_kernels() + cleanup_core_kernels() diff --git a/spiceypy/utils/callbacks.py b/spiceypy/utils/callbacks.py index 21be179d..ba4447db 100644 --- a/spiceypy/utils/callbacks.py +++ b/spiceypy/utils/callbacks.py @@ -35,6 +35,7 @@ UDREPF = CFUNCTYPE(None) UDBAIL = CFUNCTYPE(c_int) + def SpiceUDFUNS(f): """ Decorator for wrapping python functions in spice udfuns callback type @@ -51,6 +52,7 @@ def wrapping_udfuns(x, value): return UDFUNS(wrapping_udfuns) + def SpiceUDFUNB(f): """ Decorator for wrapping python functions in spice udfunb callback type @@ -62,11 +64,12 @@ def SpiceUDFUNB(f): @functools.wraps(f) def wrapping_udfunb(udf, et, xbool): - result = f(udf, et) # the function takes a udffunc as a argument + result = f(udf, et) # the function takes a udffunc as a argument xbool[0] = c_int(result) return UDFUNB(wrapping_udfunb) + def SpiceUDSTEP(f): """ Decorator for wrapping python functions in spice udstep callback type @@ -83,6 +86,7 @@ def wrapping_udstep(x, value): return UDSTEP(wrapping_udstep) + def SpiceUDREFN(f): """ Decorator for wrapping python functions in spice udrefn callback type @@ -91,6 +95,7 @@ def SpiceUDREFN(f): :return: wrapped udrefn function :rtype: builtins.function """ + @functools.wraps(f) def wrapping_udrefn(t1, t2, s1, s2, t): result = f(t1, t2, s1, s2) @@ -98,6 +103,7 @@ def wrapping_udrefn(t1, t2, s1, s2, t): return UDREFN(wrapping_udrefn) + def SpiceUDREPI(f): """ Decorator for wrapping python functions in spice udfrepi callback type @@ -106,12 +112,14 @@ def SpiceUDREPI(f): :return: wrapped udrepi function :rtype: builtins.function """ + @functools.wraps(f) def wrapping_udrepi(cnfine, srcpre, srcsurf): f(cnfine, srcpre, srcsurf) return UDREPI(wrapping_udrepi) + def SpiceUDREPU(f): """ Decorator for wrapping python functions in spice udrepu callback type @@ -120,12 +128,14 @@ def SpiceUDREPU(f): :return: wrapped udrepu function :rtype: builtins.function """ + @functools.wraps(f) def wrapping_udrepu(beg, end, et): f(beg, end, et) return UDREPU(wrapping_udrepu) + def SpiceUDREPF(f): """ Decorator for wrapping python functions in spice udrepf callback type @@ -134,9 +144,11 @@ def SpiceUDREPF(f): :return: wrapped udrepf function :rtype: builtins.function """ + @functools.wraps(f) def wrapping_udrepf(): f() + return UDREPF(wrapping_udrepf) @@ -148,10 +160,12 @@ def SpiceUDBAIL(f): :return: wrapped udbail function :rtype: builtins.function """ + @functools.wraps(f) def wrapping_udbail(): result = f() return int(result) + return UDBAIL(wrapping_udbail) @@ -168,4 +182,4 @@ def CallUDFUNS(f, x): """ value = c_double() f(x, byref(value)) - return value.value \ No newline at end of file + return value.value diff --git a/spiceypy/utils/libspicehelper.py b/spiceypy/utils/libspicehelper.py index 0def8c73..628bd75e 100644 --- a/spiceypy/utils/libspicehelper.py +++ b/spiceypy/utils/libspicehelper.py @@ -36,14 +36,14 @@ s_cell_p = POINTER(stypes.SpiceCell) s_elip_p = POINTER(stypes.Ellipse) s_plan_p = POINTER(stypes.Plane) -s_dla_p = POINTER(stypes.SpiceDLADescr) -s_eks_p = POINTER(stypes.SpiceEKSegSum) -s_eka_p = POINTER(stypes.SpiceEKAttDsc) -s_dsk_p = POINTER(stypes.SpiceDSKDescr) +s_dla_p = POINTER(stypes.SpiceDLADescr) +s_eks_p = POINTER(stypes.SpiceEKSegSum) +s_eka_p = POINTER(stypes.SpiceEKAttDsc) +s_dsk_p = POINTER(stypes.SpiceDSKDescr) c_double_p = POINTER(c_double) -c_int_p = POINTER(c_int) +c_int_p = POINTER(c_int) -__author__ = 'AndrewAnnex' +__author__ = "AndrewAnnex" # ###################################################################################################################### # A @@ -90,29 +90,111 @@ libspice.card_c.restype = c_int libspice.ccifrm_c.argtypes = [c_int, c_int, c_int, c_int_p, c_char_p, c_int_p, c_int_p] libspice.cgv2el_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3), s_elip_p] -libspice.chbder_c.argtypes = [c_double_p, c_int, (c_double*2), c_double, c_int, c_double_p, c_double_p] +libspice.chbder_c.argtypes = [ + c_double_p, + c_int, + (c_double * 2), + c_double, + c_int, + c_double_p, + c_double_p, +] libspice.chkin_c.argtypes = [c_char_p] libspice.chkout_c.argtypes = [c_char_p] libspice.cidfrm_c.argtypes = [c_int, c_int, c_int_p, c_char_p, c_int_p] libspice.ckcls_c.argtypes = [c_int] -libspice.ckcov_c.argtypes = [c_char_p, c_int, c_int, c_char_p, c_double, c_char_p, s_cell_p] +libspice.ckcov_c.argtypes = [ + c_char_p, + c_int, + c_int, + c_char_p, + c_double, + c_char_p, + s_cell_p, +] libspice.ckobj_c.argtypes = [c_char_p, s_cell_p] libspice.ckfrot_.argtypes = [c_int_p, c_double_p, (c_double * 3) * 3, c_int_p, c_int_p] -libspice.ckgp_c.argtypes = [c_int, c_double, c_double, c_char_p, ((c_double * 3) * 3), c_double_p, - c_int_p] -libspice.ckgpav_c.argtypes = [c_int, c_double, c_double, c_char_p, ((c_double * 3) * 3), (c_double * 3), - c_double_p, c_int_p] +libspice.ckgp_c.argtypes = [ + c_int, + c_double, + c_double, + c_char_p, + ((c_double * 3) * 3), + c_double_p, + c_int_p, +] +libspice.ckgpav_c.argtypes = [ + c_int, + c_double, + c_double, + c_char_p, + ((c_double * 3) * 3), + (c_double * 3), + c_double_p, + c_int_p, +] libspice.cklpf_c.argtypes = [c_char_p, c_int_p] libspice.ckopn_c.argtypes = [c_char_p, c_char_p, c_int, c_int_p] libspice.ckupf_c.argtypes = [c_int] -libspice.ckw01_c.argtypes = [c_int, c_double, c_double, c_int, c_char_p, c_int, c_char_p, c_int, c_double_p, - POINTER(c_double * 4), POINTER(c_double * 3)] -libspice.ckw02_c.argtypes = [c_int, c_double, c_double, c_int, c_char_p, c_char_p, c_int, c_double_p, - c_double_p, POINTER(c_double * 4), POINTER(c_double * 3), c_double_p] -libspice.ckw03_c.argtypes = [c_int, c_double, c_double, c_int, c_char_p, c_int, c_char_p, c_int, c_double_p, - POINTER(c_double * 4), POINTER(c_double * 3), c_int, c_double_p] -libspice.ckw05_c.argtypes = [c_int, c_int, c_int, c_double, c_double, c_int, c_char_p, c_int, c_char_p, c_int, - c_double_p, c_void_p, c_double, c_int, c_double_p] +libspice.ckw01_c.argtypes = [ + c_int, + c_double, + c_double, + c_int, + c_char_p, + c_int, + c_char_p, + c_int, + c_double_p, + POINTER(c_double * 4), + POINTER(c_double * 3), +] +libspice.ckw02_c.argtypes = [ + c_int, + c_double, + c_double, + c_int, + c_char_p, + c_char_p, + c_int, + c_double_p, + c_double_p, + POINTER(c_double * 4), + POINTER(c_double * 3), + c_double_p, +] +libspice.ckw03_c.argtypes = [ + c_int, + c_double, + c_double, + c_int, + c_char_p, + c_int, + c_char_p, + c_int, + c_double_p, + POINTER(c_double * 4), + POINTER(c_double * 3), + c_int, + c_double_p, +] +libspice.ckw05_c.argtypes = [ + c_int, + c_int, + c_int, + c_double, + c_double, + c_int, + c_char_p, + c_int, + c_char_p, + c_int, + c_double_p, + c_void_p, + c_double, + c_int, + c_double_p, +] libspice.clight_c.argtypes = None libspice.clight_c.restype = c_double libspice.clpool_c.argtypes = None @@ -127,12 +209,26 @@ libspice.cposr_c.argtypes = [c_char_p, c_char_p, c_int] libspice.cposr_c.restype = c_int libspice.cvpool_c.argtypes = [c_char_p, c_int_p] -libspice.cyllat_c.argtypes = [c_double, c_double, c_double, c_double_p, c_double_p, c_double_p] +libspice.cyllat_c.argtypes = [ + c_double, + c_double, + c_double, + c_double_p, + c_double_p, + c_double_p, +] libspice.cylrec_c.argtypes = [c_double, c_double, c_double, (c_double * 3)] -libspice.cylsph_c.argtypes = [c_double, c_double, c_double, c_double_p, c_double_p, c_double_p] +libspice.cylsph_c.argtypes = [ + c_double, + c_double, + c_double, + c_double_p, + c_double_p, + c_double_p, +] ######################################################################################################################## -#D +# D libspice.dafac_c.argtypes = [c_int, c_int, c_int, c_void_p] libspice.dafbbs_c.argtypes = [c_int] @@ -152,8 +248,16 @@ libspice.dafopw_c.argtypes = [c_char_p, c_int_p] libspice.dafps_c.argtypes = [c_int, c_int, c_double_p, c_int_p, c_double_p] libspice.dafrda_c.argtypes = [c_int, c_int, c_int, c_double_p] -libspice.dafrfr_c.argtypes = [c_int, c_int, c_int_p, c_int_p, c_char_p, c_int_p, c_int_p, - c_int_p] +libspice.dafrfr_c.argtypes = [ + c_int, + c_int, + c_int_p, + c_int_p, + c_char_p, + c_int_p, + c_int_p, + c_int_p, +] libspice.dafrs_c.argtype = [c_double_p] libspice.dafus_c.argtypes = [c_double_p, c_int, c_int, c_double_p, c_int_p] libspice.dasac_c.argtypes = [c_int, c_int, c_int, c_void_p] @@ -163,14 +267,44 @@ libspice.dashfn_c.argtypes = [c_int, c_int, c_char_p] libspice.dasopr_c.argtypes = [c_char_p, c_int_p] libspice.dasopw_c.argtypes = [c_char_p, c_int_p] -libspice.dasonw_.argtypes = [c_char_p, c_char_p, c_char_p, c_int_p, c_int_p, c_int, c_int, c_int] -libspice.dasrfr_c.argtypes = [c_int, c_int, c_int, c_char_p, c_char_p, c_int_p, c_int_p, c_int_p, c_int_p] +libspice.dasonw_.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_int_p, + c_int_p, + c_int, + c_int, + c_int, +] +libspice.dasrfr_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_char_p, + c_int_p, + c_int_p, + c_int_p, + c_int_p, +] libspice.dcyldr_c.argtypes = [c_double, c_double, c_double, (c_double * 3) * 3] libspice.deltet_c.argtypes = [c_double, c_char_p, c_double_p] libspice.det_c.argtypes = [(c_double * 3) * 3] libspice.det_c.restype = c_double -libspice.dgeodr_c.argtypes = [c_double, c_double, c_double, c_double, c_double, (c_double * 3) * 3] -libspice.diags2_c.argtypes = [(c_double * 2) * 2, (c_double * 2) * 2, (c_double * 2) * 2] +libspice.dgeodr_c.argtypes = [ + c_double, + c_double, + c_double, + c_double, + c_double, + (c_double * 3) * 3, +] +libspice.diags2_c.argtypes = [ + (c_double * 2) * 2, + (c_double * 2) * 2, + (c_double * 2) * 2, +] libspice.diff_c.argtypes = [s_cell_p, s_cell_p, s_cell_p] libspice.dlabbs_c.argtypes = [c_int, s_dla_p, c_int_p] libspice.dlabfs_c.argtypes = [c_int, s_dla_p, c_int_p] @@ -178,67 +312,248 @@ libspice.dlafps_c.argtypes = [c_int, s_dla_p, s_dla_p, c_int_p] libspice.dlatdr_c.argtypes = [c_double, c_double, c_double, (c_double * 3) * 3] libspice.dp2hx_c.argtypes = [c_double, c_int, c_char_p, c_int_p] -libspice.dpgrdr_c.argtypes = [c_char_p, c_double, c_double, c_double, c_double, c_double, (c_double * 3) * 3] +libspice.dpgrdr_c.argtypes = [ + c_char_p, + c_double, + c_double, + c_double, + c_double, + c_double, + (c_double * 3) * 3, +] libspice.dpmax_c.argtypes = None libspice.dpmax_c.restype = c_double libspice.dpmin_c.argtypes = None libspice.dpmin_c.restype = c_double libspice.dpr_c.restype = c_double libspice.drdcyl_c.argtypes = [c_double, c_double, c_double, (c_double * 3) * 3] -libspice.drdgeo_c.argtypes = [c_double, c_double, c_double, c_double, c_double, (c_double * 3) * 3] +libspice.drdgeo_c.argtypes = [ + c_double, + c_double, + c_double, + c_double, + c_double, + (c_double * 3) * 3, +] libspice.drdlat_c.argtypes = [c_double, c_double, c_double, (c_double * 3) * 3] -libspice.drdpgr_c.argtypes = [c_char_p, c_double, c_double, c_double, c_double, c_double, (c_double * 3) * 3] +libspice.drdpgr_c.argtypes = [ + c_char_p, + c_double, + c_double, + c_double, + c_double, + c_double, + (c_double * 3) * 3, +] libspice.drdsph_c.argtypes = [c_double, c_double, c_double, (c_double * 3) * 3] -libspice.dskb02_c.argtypes = [c_int, s_dla_p, c_int_p, c_int_p, c_int_p, ((c_double * 3) * 2), c_double_p, (c_double*3), (c_int*3), c_int_p, c_int_p, c_int_p, c_int_p] +libspice.dskb02_c.argtypes = [ + c_int, + s_dla_p, + c_int_p, + c_int_p, + c_int_p, + ((c_double * 3) * 2), + c_double_p, + (c_double * 3), + (c_int * 3), + c_int_p, + c_int_p, + c_int_p, + c_int_p, +] libspice.dskcls_c.argtypes = [c_int, c_int] libspice.dskd02_c.argtypes = [c_int, s_dla_p, c_int, c_int, c_int, c_int_p, c_double_p] -libspice.dskgd_c.argtypes = [c_int, s_dla_p, s_dsk_p] +libspice.dskgd_c.argtypes = [c_int, s_dla_p, s_dsk_p] libspice.dskgtl_c.argtypes = [c_int, c_double_p] libspice.dski02_c.argtypes = [c_int, s_dla_p, c_int, c_int, c_int, c_int_p, c_int_p] -libspice.dskmi2_c.argtypes = [c_int, POINTER(c_double * 3), c_int, POINTER(c_int * 3), c_double, c_int, c_int, c_int, c_int, c_int, c_int, POINTER(c_int * 2), c_double_p, c_int_p] +libspice.dskmi2_c.argtypes = [ + c_int, + POINTER(c_double * 3), + c_int, + POINTER(c_int * 3), + c_double, + c_int, + c_int, + c_int, + c_int, + c_int, + c_int, + POINTER(c_int * 2), + c_double_p, + c_int_p, +] libspice.dskn02_c.argtypes = [c_int, s_dla_p, c_int, c_double_p] libspice.dskobj_c.argtypes = [c_char_p, s_cell_p] libspice.dskopn_c.argtypes = [c_char_p, c_char_p, c_int, c_int_p] libspice.dskp02_c.argtypes = [c_int, s_dla_p, c_int, c_int, c_int_p, POINTER(c_int * 3)] -libspice.dskrb2_c.argtypes = [c_int, POINTER(c_double * 3), c_int, POINTER(c_int * 3), c_int, c_double_p, c_double_p, c_double_p] +libspice.dskrb2_c.argtypes = [ + c_int, + POINTER(c_double * 3), + c_int, + POINTER(c_int * 3), + c_int, + c_double_p, + c_double_p, + c_double_p, +] libspice.dsksrf_c.argtypes = [c_char_p, c_int, s_cell_p] libspice.dskstl_c.argtypes = [c_int, c_double] -libspice.dskv02_c.argtypes = [c_int, s_dla_p, c_int, c_int, c_int_p, POINTER(c_double * 3)] -libspice.dskw02_c.argtypes = [c_int, c_int, c_int, c_int, c_char_p, c_int, c_double_p, c_double, c_double, c_double, c_double, c_double, c_double, c_double, c_double, c_int, POINTER(c_double * 3), c_int, POINTER(c_int * 3), c_double_p, c_int_p] -libspice.dskx02_c.argtypes = [c_int, s_dla_p, c_double * 3, c_double * 3, c_int_p, c_double_p, c_int_p] -libspice.dskxsi_c.argtypes = [c_int, c_char_p, c_int, c_int_p, c_double, c_char_p, c_double * 3, c_double * 3, c_int, c_int, c_double * 3, c_int_p, s_dla_p, s_dsk_p, c_double_p, c_int_p, c_int_p] -libspice.dskxv_c.argtypes = [c_int, c_char_p, c_int, c_int_p, c_double, c_char_p, c_int, POINTER(c_double *3), POINTER(c_double * 3), POINTER(c_double * 3), c_int_p] +libspice.dskv02_c.argtypes = [ + c_int, + s_dla_p, + c_int, + c_int, + c_int_p, + POINTER(c_double * 3), +] +libspice.dskw02_c.argtypes = [ + c_int, + c_int, + c_int, + c_int, + c_char_p, + c_int, + c_double_p, + c_double, + c_double, + c_double, + c_double, + c_double, + c_double, + c_double, + c_double, + c_int, + POINTER(c_double * 3), + c_int, + POINTER(c_int * 3), + c_double_p, + c_int_p, +] +libspice.dskx02_c.argtypes = [ + c_int, + s_dla_p, + c_double * 3, + c_double * 3, + c_int_p, + c_double_p, + c_int_p, +] +libspice.dskxsi_c.argtypes = [ + c_int, + c_char_p, + c_int, + c_int_p, + c_double, + c_char_p, + c_double * 3, + c_double * 3, + c_int, + c_int, + c_double * 3, + c_int_p, + s_dla_p, + s_dsk_p, + c_double_p, + c_int_p, + c_int_p, +] +libspice.dskxv_c.argtypes = [ + c_int, + c_char_p, + c_int, + c_int_p, + c_double, + c_char_p, + c_int, + POINTER(c_double * 3), + POINTER(c_double * 3), + POINTER(c_double * 3), + c_int_p, +] libspice.dskz02_c.argtypes = [c_int, s_dla_p, c_int_p, c_int_p] libspice.dsphdr_c.argtypes = [c_double, c_double, c_double, (c_double * 3) * 3] libspice.dtpool_c.argtypes = [c_char_p, c_int_p, c_int_p, c_char_p] libspice.ducrss_c.argtypes = [c_double * 6, c_double * 6, c_double * 6] libspice.dvcrss_c.argtypes = [c_double * 6, c_double * 6, c_double * 6] -libspice.dvdot_c.argtypes = [c_double * 6, c_double * 6] -libspice.dvdot_c.restype = c_double -libspice.dvhat_c.argtypes = [c_double * 6, c_double * 6] +libspice.dvdot_c.argtypes = [c_double * 6, c_double * 6] +libspice.dvdot_c.restype = c_double +libspice.dvhat_c.argtypes = [c_double * 6, c_double * 6] libspice.dvnorm_c.argtypes = [c_double * 6] -libspice.dvnorm_c.restype = c_double +libspice.dvnorm_c.restype = c_double libspice.dvpool_c.argtypes = [c_char_p] -libspice.dvsep_c.argtypes = [c_double * 6, c_double * 6] -libspice.dvsep_c.restype = c_double +libspice.dvsep_c.argtypes = [c_double * 6, c_double * 6] +libspice.dvsep_c.restype = c_double ######################################################################################################################## # E libspice.edlimb_c.argtypes = [c_double, c_double, c_double, (c_double * 3), s_elip_p] -libspice.edterm_c.argtypes = [c_char_p, c_char_p, c_char_p, c_double, c_char_p, - c_char_p, c_char_p, c_int, c_double_p, - (c_double * 3), c_void_p] -libspice.ekacec_c.argtypes = [c_int, c_int, c_int, c_char_p, c_int, c_int, c_void_p, c_int] +libspice.edterm_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + c_int, + c_double_p, + (c_double * 3), + c_void_p, +] +libspice.ekacec_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_int, + c_int, + c_void_p, + c_int, +] libspice.ekaced_c.argtypes = [c_int, c_int, c_int, c_char_p, c_int, c_double_p, c_int] libspice.ekacei_c.argtypes = [c_int, c_int, c_int, c_char_p, c_int, c_int_p, c_int] -libspice.ekaclc_c.argtypes = [c_int, c_int, c_char_p, c_int, c_void_p, c_int_p, c_int_p, c_int_p, - c_int_p] -libspice.ekacld_c.argtypes = [c_int, c_int, c_char_p, c_double_p, c_int_p, c_int_p, - c_int_p, c_int_p] -libspice.ekacli_c.argtypes = [c_int, c_int, c_char_p, c_int_p, c_int_p, c_int_p, c_int_p, - c_int_p] +libspice.ekaclc_c.argtypes = [ + c_int, + c_int, + c_char_p, + c_int, + c_void_p, + c_int_p, + c_int_p, + c_int_p, + c_int_p, +] +libspice.ekacld_c.argtypes = [ + c_int, + c_int, + c_char_p, + c_double_p, + c_int_p, + c_int_p, + c_int_p, + c_int_p, +] +libspice.ekacli_c.argtypes = [ + c_int, + c_int, + c_char_p, + c_int_p, + c_int_p, + c_int_p, + c_int_p, + c_int_p, +] libspice.ekappr_c.argtypes = [c_int, c_int, c_int_p] -libspice.ekbseg_c.argtypes = [c_int, c_char_p, c_int, c_int, c_void_p, c_int, c_void_p, c_int_p] +libspice.ekbseg_c.argtypes = [ + c_int, + c_char_p, + c_int, + c_int, + c_void_p, + c_int, + c_void_p, + c_int_p, +] libspice.ekccnt_c.argtypes = [c_char_p, c_int_p] libspice.ekcii_c.argtypes = [c_char_p, c_int, c_int, c_char_p, s_eka_p] libspice.ekcls_c.argtypes = [c_int] @@ -248,8 +563,18 @@ libspice.ekgc_c.argtypes = [c_int, c_int, c_int, c_int, c_char_p, c_int_p, c_int_p] libspice.ekgd_c.argtypes = [c_int, c_int, c_int, c_double_p, c_int_p, c_int_p] libspice.ekgi_c.argtypes = [c_int, c_int, c_int, c_int_p, c_int_p, c_int_p] -libspice.ekifld_c.argtypes = [c_int, c_char_p, c_int, c_int, c_int, c_void_p, c_int, c_void_p, c_int_p, - c_int_p] +libspice.ekifld_c.argtypes = [ + c_int, + c_char_p, + c_int, + c_int, + c_int, + c_void_p, + c_int, + c_void_p, + c_int_p, + c_int_p, +] libspice.ekinsr_c.argtypes = [c_int, c_int, c_int] libspice.eklef_c.argtypes = [c_char_p, c_int_p] libspice.eknelt_c.argtypes = [c_int, c_int] @@ -261,16 +586,54 @@ libspice.ekopr_c.argtypes = [c_char_p, c_int_p] libspice.ekops_c.argtypes = [c_int_p] libspice.ekopw_c.argtypes = [c_char_p, c_int_p] -libspice.ekpsel_c.argtypes = [c_char_p, c_int, c_int, c_int, c_int_p, c_int_p, c_int_p, - c_int_p, c_int_p, c_void_p, c_void_p, - c_int_p, c_char_p] +libspice.ekpsel_c.argtypes = [ + c_char_p, + c_int, + c_int, + c_int, + c_int_p, + c_int_p, + c_int_p, + c_int_p, + c_int_p, + c_void_p, + c_void_p, + c_int_p, + c_char_p, +] # POINTER(stypes.SpiceEKDataType), POINTER(stypes.SpiceEKExprClass), c_void_p, c_void_p, -libspice.ekrcec_c.argtypes = [c_int, c_int, c_int, c_char_p, c_int, c_int_p, c_void_p, c_int_p] -libspice.ekrced_c.argtypes = [c_int, c_int, c_int, c_char_p, c_int_p, c_double_p, c_int_p] +libspice.ekrcec_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_int, + c_int_p, + c_void_p, + c_int_p, +] +libspice.ekrced_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_int_p, + c_double_p, + c_int_p, +] libspice.ekrcei_c.argtypes = [c_int, c_int, c_int, c_char_p, c_int_p, c_int_p, c_int_p] libspice.ekssum_c.argtypes = [c_int, c_int, s_eks_p] libspice.ektnam_c.argtypes = [c_int, c_int, c_char_p] -libspice.ekucec_c.argtypes = [c_int, c_int, c_int, c_char_p, c_int, c_int, c_void_p, c_int] +libspice.ekucec_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_int, + c_int, + c_void_p, + c_int, +] libspice.ekuced_c.argtypes = [c_int, c_int, c_int, c_char_p, c_int, c_double_p, c_int] libspice.ekucei_c.argtypes = [c_int, c_int, c_int, c_char_p, c_int, c_int_p, c_int] libspice.ekuef_c.argtypes = [c_int] @@ -281,8 +644,14 @@ libspice.elemd_c.restype = c_int libspice.elemi_c.argtypes = [c_int, s_cell_p] libspice.elemi_c.restype = c_int -libspice.eqncpv_c.argtypes = [c_double, c_double, (c_double * 9), c_double, c_double, - (c_double * 6)] +libspice.eqncpv_c.argtypes = [ + c_double, + c_double, + (c_double * 9), + c_double, + c_double, + (c_double * 6), +] libspice.eqstr_c.argtypes = [c_char_p, c_char_p] libspice.eqstr_c.restype = c_int libspice.erract_c.argtypes = [c_char_p, c_int, c_char_p] @@ -293,11 +662,30 @@ libspice.errprt_c.argtypes = [c_char_p, c_int, c_char_p] libspice.esrchc_c.argtypes = [c_char_p, c_int, c_int, c_void_p] libspice.esrchc_c.restype = c_int -libspice.et2lst_c.argtypes = [c_double, c_int, c_double, c_char_p, c_int, c_int, c_int_p, c_int_p, - c_int_p, c_char_p, c_char_p] +libspice.et2lst_c.argtypes = [ + c_double, + c_int, + c_double, + c_char_p, + c_int, + c_int, + c_int_p, + c_int_p, + c_int_p, + c_char_p, + c_char_p, +] libspice.et2utc_c.argtypes = [c_double, c_char_p, c_int, c_int, c_char_p] libspice.etcal_c.argtypes = [c_double, c_int, c_char_p] -libspice.eul2m_c.argtypes = [c_double, c_double, c_double, c_int, c_int, c_int, (c_double * 3) * 3] +libspice.eul2m_c.argtypes = [ + c_double, + c_double, + c_double, + c_int, + c_int, + c_int, + (c_double * 3) * 3, +] libspice.eul2xf_c.argtypes = [(c_double * 6), c_int, c_int, c_int, (c_double * 6) * 6] libspice.ev2lin_.argtypes = [c_double_p, c_double_p, c_double_p, c_double_p] libspice.exists_c.argtypes = [c_char_p] @@ -310,10 +698,25 @@ libspice.failed_c.argtypes = None libspice.failed_c.restype = c_int libspice.fn2lun_.argtypes = [c_char_p, c_int_p, c_int] -libspice.fovray_c.argtypes = [c_char_p, (c_double * 3), c_char_p, c_char_p, c_char_p, - c_double_p, c_int_p] -libspice.fovtrg_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, - c_char_p, c_double_p, c_int_p] +libspice.fovray_c.argtypes = [ + c_char_p, + (c_double * 3), + c_char_p, + c_char_p, + c_char_p, + c_double_p, + c_int_p, +] +libspice.fovtrg_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double_p, + c_int_p, +] libspice.frame_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] libspice.frinfo_c.argtypes = [c_int, c_int_p, c_int_p, c_int_p, c_int_p] libspice.frmnam_c.argtypes = [c_int, c_int, c_char_p] @@ -325,62 +728,280 @@ libspice.gcpool_c.argtypes = [c_char_p, c_int, c_int, c_int, c_int_p, c_void_p, c_int_p] libspice.gdpool_c.argtypes = [c_char_p, c_int, c_int, c_int_p, c_double_p, c_int_p] -libspice.georec_c.argtypes = [c_double, c_double, c_double, c_double, c_double, (c_double * 3)] +libspice.georec_c.argtypes = [ + c_double, + c_double, + c_double, + c_double, + c_double, + (c_double * 3), +] libspice.getcml_c.argtypes = [c_int, c_char_p] libspice.getelm_c.argtypes = [c_int, c_int, c_void_p, c_double_p, c_double_p] libspice.getfat_c.argtypes = [c_char_p, c_int, c_int, c_char_p, c_char_p] -libspice.getfov_c.argtypes = [c_int, c_int, c_int, c_int, c_char_p, c_char_p, (c_double * 3), c_int_p, - POINTER(c_double * 3)] +libspice.getfov_c.argtypes = [ + c_int, + c_int, + c_int, + c_int, + c_char_p, + c_char_p, + (c_double * 3), + c_int_p, + POINTER(c_double * 3), +] libspice.getmsg_c.argtypes = [c_char_p, c_int, c_char_p] -libspice.gfbail_c.restype = c_int +libspice.gfbail_c.restype = c_int libspice.gfclrh_c.argtypes = None -libspice.gfdist_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_double, c_double, c_double, c_int, - s_cell_p, s_cell_p] -libspice.gfevnt_c.argtypes = [callbacks.UDSTEP, callbacks.UDREFN, c_char_p, c_int, c_int, - c_void_p, c_void_p, c_double_p, c_int_p, c_int_p, c_char_p, - c_double, c_double, c_double, c_int, callbacks.UDREPI, callbacks.UDREPU, - callbacks.UDREPF, c_int, c_int, callbacks.UDBAIL, s_cell_p, s_cell_p] - -libspice.gffove_c.argtypes = [c_char_p, c_char_p, (c_double*3), - c_char_p, c_char_p, c_char_p, c_char_p, c_double, - callbacks.UDSTEP, callbacks.UDREFN, c_int, callbacks.UDREPI, callbacks.UDREPU, - callbacks.UDREPF, c_int, callbacks.UDBAIL, s_cell_p, s_cell_p] +libspice.gfdist_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + c_double, + c_double, + c_int, + s_cell_p, + s_cell_p, +] +libspice.gfevnt_c.argtypes = [ + callbacks.UDSTEP, + callbacks.UDREFN, + c_char_p, + c_int, + c_int, + c_void_p, + c_void_p, + c_double_p, + c_int_p, + c_int_p, + c_char_p, + c_double, + c_double, + c_double, + c_int, + callbacks.UDREPI, + callbacks.UDREPU, + callbacks.UDREPF, + c_int, + c_int, + callbacks.UDBAIL, + s_cell_p, + s_cell_p, +] + +libspice.gffove_c.argtypes = [ + c_char_p, + c_char_p, + (c_double * 3), + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + callbacks.UDSTEP, + callbacks.UDREFN, + c_int, + callbacks.UDREPI, + callbacks.UDREPU, + callbacks.UDREPF, + c_int, + callbacks.UDBAIL, + s_cell_p, + s_cell_p, +] libspice.gfinth_c.argtypes = [c_int] -libspice.gfilum_c.argtupes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, - c_char_p, (c_double * 3), c_char_p, c_double, c_double, - c_double, c_int, s_cell_p, s_cell_p] -libspice.gfocce_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, - c_char_p, c_char_p, c_char_p, c_char_p, c_double, - callbacks.UDSTEP, callbacks.UDREFN, c_int, callbacks.UDREPI, callbacks.UDREPU, - callbacks.UDREPF, c_int, callbacks.UDBAIL, s_cell_p, s_cell_p] -libspice.gfoclt_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, - c_double, s_cell_p, s_cell_p] -libspice.gfpa_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_double, c_double, - c_double, c_int, s_cell_p, s_cell_p] -libspice.gfposc_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_double, c_double, - c_double, c_int, s_cell_p, s_cell_p] +libspice.gfilum_c.argtupes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_char_p, + c_double, + c_double, + c_double, + c_int, + s_cell_p, + s_cell_p, +] +libspice.gfocce_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + callbacks.UDSTEP, + callbacks.UDREFN, + c_int, + callbacks.UDREPI, + callbacks.UDREPU, + callbacks.UDREPF, + c_int, + callbacks.UDBAIL, + s_cell_p, + s_cell_p, +] +libspice.gfoclt_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + s_cell_p, + s_cell_p, +] +libspice.gfpa_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + c_double, + c_double, + c_int, + s_cell_p, + s_cell_p, +] +libspice.gfposc_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + c_double, + c_double, + c_int, + s_cell_p, + s_cell_p, +] libspice.gfrefn_c.argtypes = [c_double, c_double, c_int, c_int, c_double_p] libspice.gfrepf_c.argtypes = None libspice.gfrepi_c.argtypes = [s_cell_p, c_char_p, c_char_p] libspice.gfrepu_c.argtypes = [c_double, c_double, c_double] -libspice.gfrfov_c.argtypes = [c_char_p, (c_double * 3), c_char_p, c_char_p, c_char_p, c_double, - s_cell_p, s_cell_p] -libspice.gfrr_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_double, c_double, c_double, c_int, - s_cell_p, s_cell_p] -libspice.gfsep_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, - c_double, c_double, c_double, c_int, s_cell_p, s_cell_p] -libspice.gfsntc_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, (c_double * 3), c_char_p, - c_char_p, c_char_p, c_double, c_double, c_double, c_int, s_cell_p, - s_cell_p] +libspice.gfrfov_c.argtypes = [ + c_char_p, + (c_double * 3), + c_char_p, + c_char_p, + c_char_p, + c_double, + s_cell_p, + s_cell_p, +] +libspice.gfrr_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + c_double, + c_double, + c_int, + s_cell_p, + s_cell_p, +] +libspice.gfsep_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + c_double, + c_double, + c_int, + s_cell_p, + s_cell_p, +] +libspice.gfsntc_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_char_p, + c_char_p, + c_char_p, + c_double, + c_double, + c_double, + c_int, + s_cell_p, + s_cell_p, +] libspice.gfsstp_c.argtypes = [c_double] libspice.gfstep_c.argtypes = [c_double, c_double_p] libspice.gfstol_c.argtypes = [c_double] -libspice.gfsubc_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_double, - c_double, c_double, c_int, s_cell_p, s_cell_p] -libspice.gftfov_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, c_double, - s_cell_p, s_cell_p] -libspice.gfudb_c.argtypes = [callbacks.UDFUNS, callbacks.UDFUNB, c_double, s_cell_p, s_cell_p] -libspice.gfuds_c.argtypes = [callbacks.UDFUNS, callbacks.UDFUNB, c_char_p, c_double, c_double, c_double, c_int, s_cell_p, s_cell_p] +libspice.gfsubc_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + c_double, + c_double, + c_int, + s_cell_p, + s_cell_p, +] +libspice.gftfov_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + s_cell_p, + s_cell_p, +] +libspice.gfudb_c.argtypes = [ + callbacks.UDFUNS, + callbacks.UDFUNB, + c_double, + s_cell_p, + s_cell_p, +] +libspice.gfuds_c.argtypes = [ + callbacks.UDFUNS, + callbacks.UDFUNB, + c_char_p, + c_double, + c_double, + c_double, + c_int, + s_cell_p, + s_cell_p, +] libspice.gipool_c.argtypes = [c_char_p, c_int, c_int, c_int_p, c_int_p, c_int_p] libspice.gnpool_c.argtypes = [c_char_p, c_int, c_int, c_int, c_int_p, c_void_p, c_int_p] @@ -388,46 +1009,113 @@ # H libspice.halfpi_c.restype = c_double -libspice.hrmint_c.argtypes = [c_int, c_double_p, c_double_p, c_double, c_double_p, c_double_p, c_double_p] +libspice.hrmint_c.argtypes = [ + c_int, + c_double_p, + c_double_p, + c_double, + c_double_p, + c_double_p, + c_double_p, +] libspice.hx2dp_c.argtypes = [c_char_p, c_int, c_double_p, c_int_p, c_char_p] ######################################################################################################################## # I -libspice.ident_c.argtypes = [(c_double * 3) * 3] -libspice.illum_c.argtypes = [c_char_p, c_double, c_char_p, c_char_p, (c_double * 3), c_double_p, - c_double_p, c_double_p] -libspice.ilumin_c.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_char_p, c_char_p, (c_double * 3), - c_double_p, (c_double * 3), c_double_p, c_double_p, - c_double_p] -libspice.illumf_c.argtypes = [c_char_p, c_char_p, c_char_p, c_double, c_char_p, c_char_p, c_char_p, (c_double * 3), c_double_p, (c_double * 3), c_double_p, c_double_p, c_double_p, c_int_p, c_int_p] -libspice.illumg_c.argtypes = [c_char_p, c_char_p, c_char_p, c_double, c_char_p, c_char_p, c_char_p, (c_double * 3), c_double_p, (c_double * 3), c_double_p, c_double_p, c_double_p] -libspice.inedpl_c.argtypes = [c_double, c_double, c_double, s_plan_p, s_elip_p, - c_int_p] -libspice.inelpl_c.argtypes = [s_elip_p, s_plan_p, c_int_p, (c_double * 3), - (c_double * 3)] +libspice.ident_c.argtypes = [(c_double * 3) * 3] +libspice.illum_c.argtypes = [ + c_char_p, + c_double, + c_char_p, + c_char_p, + (c_double * 3), + c_double_p, + c_double_p, + c_double_p, +] +libspice.ilumin_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_double_p, + (c_double * 3), + c_double_p, + c_double_p, + c_double_p, +] +libspice.illumf_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_double_p, + (c_double * 3), + c_double_p, + c_double_p, + c_double_p, + c_int_p, + c_int_p, +] +libspice.illumg_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_double_p, + (c_double * 3), + c_double_p, + c_double_p, + c_double_p, +] +libspice.inedpl_c.argtypes = [c_double, c_double, c_double, s_plan_p, s_elip_p, c_int_p] +libspice.inelpl_c.argtypes = [ + s_elip_p, + s_plan_p, + c_int_p, + (c_double * 3), + (c_double * 3), +] libspice.insrtc_c.argtypes = [c_char_p, s_cell_p] libspice.insrtd_c.argtypes = [c_double, s_cell_p] libspice.insrti_c.argtypes = [c_int, s_cell_p] -libspice.inter_c.argtypes = [s_cell_p, s_cell_p, s_cell_p] -libspice.inrypl_c.argtypes = [(c_double * 3), (c_double * 3), s_plan_p, c_int_p, (c_double * 3)] -libspice.intmax_c.restype = c_int -libspice.intmin_c.restype = c_int +libspice.inter_c.argtypes = [s_cell_p, s_cell_p, s_cell_p] +libspice.inrypl_c.argtypes = [ + (c_double * 3), + (c_double * 3), + s_plan_p, + c_int_p, + (c_double * 3), +] +libspice.intmax_c.restype = c_int +libspice.intmin_c.restype = c_int libspice.invert_c.argtypes = [(c_double * 3) * 3, (c_double * 3) * 3] libspice.invort_c.argtypes = [(c_double * 3) * 3, (c_double * 3) * 3] libspice.isordv_c.argtypes = [c_int_p, c_int] -libspice.isordv_c.restype = c_int +libspice.isordv_c.restype = c_int libspice.isrchc_c.argtypes = [c_char_p, c_int, c_int, c_void_p] -libspice.isrchc_c.restype = c_int +libspice.isrchc_c.restype = c_int libspice.isrchd_c.argtypes = [c_double, c_int, c_double_p] -libspice.isrchd_c.restype = c_int +libspice.isrchd_c.restype = c_int libspice.isrchi_c.argtypes = [c_int, c_int, c_int_p] -libspice.isrchi_c.restype = c_int -libspice.isrot_c.argtypes = [(c_double * 3) * 3, c_double, c_double] -libspice.isrot_c.restype = c_int +libspice.isrchi_c.restype = c_int +libspice.isrot_c.argtypes = [(c_double * 3) * 3, c_double, c_double] +libspice.isrot_c.restype = c_int libspice.iswhsp_c.argtypes = [c_char_p] -libspice.iswhsp_c.restype = c_int +libspice.iswhsp_c.restype = c_int ######################################################################################################################## # J @@ -439,45 +1127,121 @@ ######################################################################################################################## # K -libspice.kclear_c.restype = None -libspice.kdata_c.argtypes = [c_int, c_char_p, c_int, c_int, c_int, c_char_p, c_char_p, c_char_p, c_int_p, - c_int_p] -libspice.kinfo_c.argtypes = [c_char_p, c_int, c_int, c_char_p, c_char_p, c_int_p, c_int_p] +libspice.kclear_c.restype = None +libspice.kdata_c.argtypes = [ + c_int, + c_char_p, + c_int, + c_int, + c_int, + c_char_p, + c_char_p, + c_char_p, + c_int_p, + c_int_p, +] +libspice.kinfo_c.argtypes = [ + c_char_p, + c_int, + c_int, + c_char_p, + c_char_p, + c_int_p, + c_int_p, +] libspice.ktotal_c.argtypes = [c_char_p, c_int_p] libspice.kplfrm_c.argtypes = [c_int, s_cell_p] -libspice.kxtrct_c.argtypes = [c_char_p, c_int, c_void_p, c_int, c_int, c_int, c_char_p, c_int_p, c_char_p] +libspice.kxtrct_c.argtypes = [ + c_char_p, + c_int, + c_void_p, + c_int, + c_int, + c_int, + c_char_p, + c_int_p, + c_char_p, +] ######################################################################################################################## # L libspice.lastnb_c.argtypes = [c_char_p] -libspice.lastnb_c.restype = c_int -libspice.latcyl_c.argtypes = [c_double, c_double, c_double, c_double_p, c_double_p, c_double_p] +libspice.lastnb_c.restype = c_int +libspice.latcyl_c.argtypes = [ + c_double, + c_double, + c_double, + c_double_p, + c_double_p, + c_double_p, +] libspice.latrec_c.argtypes = [c_double, c_double, c_double, (c_double) * 3] -libspice.latsph_c.argtypes = [c_double, c_double, c_double, c_double_p, c_double_p, c_double_p] -libspice.latsrf_c.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_int, c_void_p, c_void_p] -libspice.lcase_c.argtypes = [c_char_p, c_int, c_char_p] +libspice.latsph_c.argtypes = [ + c_double, + c_double, + c_double, + c_double_p, + c_double_p, + c_double_p, +] +libspice.latsrf_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_char_p, + c_int, + c_void_p, + c_void_p, +] +libspice.lcase_c.argtypes = [c_char_p, c_int, c_char_p] libspice.ldpool_c.argtypes = [c_char_p] -libspice.lgrind_c.argtypes = [c_int, c_double_p, c_double_p, c_double_p, c_double, c_double_p, c_double_p] -libspice.limbpt_c.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_char_p, c_char_p, c_char_p, (c_double * 3), c_double, c_int, c_double, c_double, c_int, c_int_p, c_void_p, c_double_p, c_void_p] +libspice.lgrind_c.argtypes = [ + c_int, + c_double_p, + c_double_p, + c_double_p, + c_double, + c_double_p, + c_double_p, +] +libspice.limbpt_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_double, + c_int, + c_double, + c_double, + c_int, + c_int_p, + c_void_p, + c_double_p, + c_void_p, +] libspice.lmpool_c.argtypes = [c_void_p, c_int, c_int] libspice.lparse_c.argtypes = [c_char_p, c_char_p, c_int, c_int, c_int_p, c_void_p] libspice.lparsm_c.argtypes = [c_char_p, c_char_p, c_int, c_int, c_int_p, c_void_p] libspice.lparss_c.argtypes = [c_char_p, c_char_p, s_cell_p] -libspice.lspcn_c.argtypes = [c_char_p, c_double, c_char_p] -libspice.lspcn_c.restype = c_double -libspice.ltime_c.argtypes = [c_double, c_int, c_char_p, c_int, c_double_p, c_double_p] +libspice.lspcn_c.argtypes = [c_char_p, c_double, c_char_p] +libspice.lspcn_c.restype = c_double +libspice.ltime_c.argtypes = [c_double, c_int, c_char_p, c_int, c_double_p, c_double_p] libspice.lstlec_c.argtypes = [c_char_p, c_int, c_int, c_void_p] -libspice.lstlec_c.restype = c_int +libspice.lstlec_c.restype = c_int libspice.lstled_c.argtypes = [c_double, c_int, c_double_p] -libspice.lstled_c.restype = c_int +libspice.lstled_c.restype = c_int libspice.lstlei_c.argtypes = [c_int, c_int, c_int_p] -libspice.lstlei_c.restype = c_int +libspice.lstlei_c.restype = c_int libspice.lstltc_c.argtypes = [c_char_p, c_int, c_int, c_void_p] -libspice.lstltc_c.restype = c_int +libspice.lstltc_c.restype = c_int libspice.lstltd_c.argtypes = [c_double, c_int, c_double_p] -libspice.lstltd_c.restype = c_int +libspice.lstltd_c.restype = c_int libspice.lstlti_c.argtypes = [c_int, c_int, c_int_p] -libspice.lstlti_c.restype = c_int +libspice.lstlti_c.restype = c_int libspice.lx4dec_c.argtypes = [c_char_p, c_int, c_int_p, c_int_p] libspice.lx4num_c.argtypes = [c_char_p, c_int, c_int_p, c_int_p] libspice.lx4sgn_c.argtypes = [c_char_p, c_int, c_int_p, c_int_p] @@ -486,15 +1250,25 @@ ######################################################################################################################## # M -libspice.m2eul_c.argtypes = [(c_double * 3) * 3, c_int, c_int, c_int, c_double_p, c_double_p, - c_double_p] +libspice.m2eul_c.argtypes = [ + (c_double * 3) * 3, + c_int, + c_int, + c_int, + c_double_p, + c_double_p, + c_double_p, +] libspice.m2q_c.argtypes = [(c_double * 3) * 3, (c_double * 4)] libspice.matchi_c.argtypes = [c_char_p, c_char_p, c_char, c_char] libspice.matchi_c.restype = c_int libspice.matchw_c.argtypes = [c_char_p, c_char_p, c_char, c_char] libspice.matchw_c.restype = c_int libspice.maxd_c.restype = c_double -libspice.mequ_c.argtypes = [(c_double * 3) * 3, (c_double * 3) * 3, ] +libspice.mequ_c.argtypes = [ + (c_double * 3) * 3, + (c_double * 3) * 3, +] libspice.mequg_c.argtypes = [c_void_p, c_int, c_int, c_void_p] libspice.mtxm_c.argtypes = [(c_double * 3) * 3, (c_double * 3) * 3, (c_double * 3) * 3] libspice.mtxmg_c.argtypes = [c_void_p, c_void_p, c_int, c_int, c_int, c_void_p] @@ -515,19 +1289,48 @@ libspice.ncpos_c.restype = c_int libspice.ncposr_c.argtypes = [c_char_p, c_char_p, c_int] libspice.ncposr_c.restype = c_int -libspice.nearpt_c.argtypes = [(c_double * 3), c_double, c_double, c_double, (c_double * 3), c_double_p] -libspice.npedln_c.argtypes = [c_double, c_double, c_double, (c_double * 3), (c_double * 3), (c_double * 3), - c_double_p] +libspice.nearpt_c.argtypes = [ + (c_double * 3), + c_double, + c_double, + c_double, + (c_double * 3), + c_double_p, +] +libspice.npedln_c.argtypes = [ + c_double, + c_double, + c_double, + (c_double * 3), + (c_double * 3), + (c_double * 3), + c_double_p, +] libspice.npelpt_c.argtypes = [(c_double * 3), s_elip_p, (c_double * 3), c_double_p] -libspice.nplnpt_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3), (c_double * 3), c_double_p] +libspice.nplnpt_c.argtypes = [ + (c_double * 3), + (c_double * 3), + (c_double * 3), + (c_double * 3), + c_double_p, +] libspice.nvc2pl_c.argtypes = [(c_double * 3), c_double, s_plan_p] libspice.nvp2pl_c.argtypes = [(c_double * 3), (c_double * 3), s_plan_p] ######################################################################################################################## # O -libspice.occult_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_char_p, - c_char_p, c_char_p, c_char_p, c_double, - c_int_p] +libspice.occult_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + c_double, + c_int_p, +] libspice.ordc_c.argtypes = [c_char_p, s_cell_p] libspice.ordc_c.restype = c_int libspice.ordd_c.argtypes = [c_double, s_cell_p] @@ -549,11 +1352,31 @@ libspice.pcklof_c.argtypes = [c_char_p, c_int_p] libspice.pckopn_c.argtypes = [c_char_p, c_char_p, c_int, c_int_p] libspice.pckuof_c.argtypes = [c_int] -libspice.pckw02_c.argtypes = [c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_double, c_int, c_int, c_double_p, c_double] +libspice.pckw02_c.argtypes = [ + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_double, + c_int, + c_int, + c_double_p, + c_double, +] libspice.pcpool_c.argtypes = [c_char_p, c_int, c_int, c_void_p] libspice.pdpool_c.argtypes = [c_char_p, c_int, c_double_p] libspice.pipool_c.argtypes = [c_char_p, c_int, c_int_p] -libspice.pgrrec_c.argtypes = [c_char_p, c_double, c_double, c_double, c_double, c_double, (c_double * 3)] +libspice.pgrrec_c.argtypes = [ + c_char_p, + c_double, + c_double, + c_double, + c_double, + c_double, + (c_double * 3), +] libspice.phaseq_c.argtypes = [c_double, c_char_p, c_char_p, c_char_p, c_char_p] libspice.phaseq_c.restype = c_double libspice.pi_c.restype = c_double @@ -564,8 +1387,20 @@ libspice.pltar_c.argtypes = [c_int, c_void_p, c_int, c_void_p] libspice.pltar_c.restype = c_double libspice.pltexp_c.argtypes = [(c_double * 3) * 3, c_double, (c_double * 3) * 3] -libspice.pltnp_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3), (c_double * 3), (c_double * 3), c_double_p] -libspice.pltnrm_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3), (c_double * 3)] +libspice.pltnp_c.argtypes = [ + (c_double * 3), + (c_double * 3), + (c_double * 3), + (c_double * 3), + (c_double * 3), + c_double_p, +] +libspice.pltnrm_c.argtypes = [ + (c_double * 3), + (c_double * 3), + (c_double * 3), + (c_double * 3), +] libspice.pltvol_c.argtypes = [c_int, c_void_p, c_int, c_void_p] libspice.pltvol_c.restype = c_double libspice.polyds_c.argtype = [c_double_p, c_int, c_int, c_double, c_double_p] @@ -580,7 +1415,13 @@ libspice.psv2pl_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3), s_plan_p] libspice.putcml_c.argtypes = [c_int, c_char_p] libspice.pxform_c.argtypes = [c_char_p, c_char_p, c_double, (c_double * 3) * 3] -libspice.pxfrm2_c.argtypes = [c_char_p, c_char_p, c_double, c_double, (c_double * 3) * 3] +libspice.pxfrm2_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_double, + (c_double * 3) * 3, +] ######################################################################################################################## # Q @@ -597,11 +1438,24 @@ libspice.raxisa_c.argtypes = [(c_double * 3) * 3, (c_double * 3), c_double_p] libspice.rdtext_c.argtypes = [c_char_p, c_int, c_char_p, c_int_p] libspice.reccyl_c.argtypes = [(c_double * 3), c_double_p, c_double_p, c_double_p] -libspice.recgeo_c.argtypes = [(c_double * 3), c_double, c_double, c_double_p, c_double_p, - c_double_p] +libspice.recgeo_c.argtypes = [ + (c_double * 3), + c_double, + c_double, + c_double_p, + c_double_p, + c_double_p, +] libspice.reclat_c.argtypes = [(c_double * 3), c_double_p, c_double_p, c_double_p] -libspice.recpgr_c.argtypes = [c_char_p, (c_double * 3), c_double, c_double, c_double_p, c_double_p, - c_double_p] +libspice.recpgr_c.argtypes = [ + c_char_p, + (c_double * 3), + c_double, + c_double, + c_double_p, + c_double_p, + c_double_p, +] libspice.recrad_c.argtypes = [(c_double * 3), c_double_p, c_double_p, c_double_p] libspice.recsph_c.argtypes = [(c_double * 3), c_double_p, c_double_p, c_double_p] libspice.reordc_c.argtypes = [c_int_p, c_int, c_int, c_void_p] @@ -611,147 +1465,592 @@ libspice.removc_c.argtypes = [c_char_p, s_cell_p] libspice.removd_c.argtypes = [c_double, s_cell_p] libspice.removi_c.argtypes = [c_int, s_cell_p] -libspice.repmc_c.argtypes = [c_char_p, c_char_p, c_char_p, c_int, c_char_p] +libspice.repmc_c.argtypes = [c_char_p, c_char_p, c_char_p, c_int, c_char_p] libspice.repmct_c.argtypes = [c_char_p, c_char_p, c_int, c_char, c_int, c_char_p] -libspice.repmd_c.argtypes = [c_char_p, c_char_p, c_double, c_int, c_int, c_char_p] -libspice.repmf_c.argtypes = [c_char_p, c_char_p, c_double, c_int, c_char, c_int, c_char_p] -libspice.repmi_c.argtypes = [c_char_p, c_char_p, c_int, c_int, c_char_p] +libspice.repmd_c.argtypes = [c_char_p, c_char_p, c_double, c_int, c_int, c_char_p] +libspice.repmf_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_int, + c_char, + c_int, + c_char_p, +] +libspice.repmi_c.argtypes = [c_char_p, c_char_p, c_int, c_int, c_char_p] libspice.repmot_c.argtypes = [c_char_p, c_char_p, c_int, c_char, c_int, c_char_p] -libspice.reset_c.argtypes = None +libspice.reset_c.argtypes = None libspice.return_c.argtypes = None -libspice.return_c.restype = c_int +libspice.return_c.restype = c_int libspice.rotate_c.argtypes = [c_double, c_int, (c_double * 3) * 3] libspice.rotmat_c.argtypes = [(c_double * 3) * 3, c_double, c_int, (c_double * 3) * 3] libspice.rotvec_c.argtypes = [(c_double * 3), c_double, c_int, (c_double * 3)] -libspice.rpd_c.restype = c_double -libspice.rquad_c.argtypes = [c_double, c_double, c_double, (c_double * 2), (c_double * 2)] +libspice.rpd_c.restype = c_double +libspice.rquad_c.argtypes = [ + c_double, + c_double, + c_double, + (c_double * 2), + (c_double * 2), +] ######################################################################################################################## # S -libspice.saelgv_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3), (c_double * 3)] -libspice.scard_c.argtypes = [c_int, s_cell_p] +libspice.saelgv_c.argtypes = [ + (c_double * 3), + (c_double * 3), + (c_double * 3), + (c_double * 3), +] +libspice.scard_c.argtypes = [c_int, s_cell_p] libspice.scdecd_c.argtypes = [c_int, c_double, c_int, c_char_p] -libspice.sce2c_c.argtypes = [c_int, c_double, c_double_p] -libspice.sce2s_c.argtypes = [c_int, c_double, c_int, c_char_p] -libspice.sce2t_c.argtypes = [c_int, c_double, c_double_p] +libspice.sce2c_c.argtypes = [c_int, c_double, c_double_p] +libspice.sce2s_c.argtypes = [c_int, c_double, c_int, c_char_p] +libspice.sce2t_c.argtypes = [c_int, c_double, c_double_p] libspice.scencd_c.argtypes = [c_int, c_char_p, c_double_p] -libspice.scfmt_c.argtypes = [c_int, c_double, c_int, c_char_p] +libspice.scfmt_c.argtypes = [c_int, c_double, c_int, c_char_p] libspice.scpart_c.argtypes = [c_int, c_int_p, c_double_p, c_double_p] -libspice.scs2e_c.argtypes = [c_int, c_char_p, c_double_p] -libspice.sct2e_c.argtypes = [c_int, c_double, c_double_p] +libspice.scs2e_c.argtypes = [c_int, c_char_p, c_double_p] +libspice.sct2e_c.argtypes = [c_int, c_double, c_double_p] libspice.sctiks_c.argtypes = [c_int, c_char_p, c_double_p] -libspice.sdiff_c.argtypes = [s_cell_p, s_cell_p, s_cell_p] -libspice.set_c.argtypes = [s_cell_p, c_char_p, s_cell_p] -libspice.set_c.restype = c_int +libspice.sdiff_c.argtypes = [s_cell_p, s_cell_p, s_cell_p] +libspice.set_c.argtypes = [s_cell_p, c_char_p, s_cell_p] +libspice.set_c.restype = c_int libspice.setmsg_c.argtypes = [c_char_p] libspice.shellc_c.argtypes = [c_int, c_int, c_void_p] libspice.shelld_c.argtypes = [c_int, c_double_p] libspice.shelli_c.argtypes = [c_int, c_int_p] libspice.sigerr_c.argtypes = [c_char_p] -libspice.sincpt_c.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_char_p, c_char_p, c_char_p, (c_double * 3), - (c_double * 3), c_double_p, (c_double * 3), c_int_p] -libspice.spd_c.restype = c_double -libspice.sphcyl_c.argtypes = [c_double, c_double, c_double, c_double_p, c_double_p, c_double_p] -libspice.sphlat_c.argtypes = [c_double, c_double, c_double, c_double_p, c_double_p, c_double_p] +libspice.sincpt_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + (c_double * 3), + c_double_p, + (c_double * 3), + c_int_p, +] +libspice.spd_c.restype = c_double +libspice.sphcyl_c.argtypes = [ + c_double, + c_double, + c_double, + c_double_p, + c_double_p, + c_double_p, +] +libspice.sphlat_c.argtypes = [ + c_double, + c_double, + c_double, + c_double_p, + c_double_p, + c_double_p, +] libspice.sphrec_c.argtypes = [c_double, c_double, c_double, (c_double * 3)] libspice.spk14a_c.argtypes = [c_int, c_int, c_double_p, c_double_p] -libspice.spk14b_c.argtypes = [c_int, c_char_p, c_int, c_int, c_char_p, c_double, c_double, c_int] +libspice.spk14b_c.argtypes = [ + c_int, + c_char_p, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_int, +] libspice.spk14e_c.argtypes = [c_int] -libspice.spkacs_c.argtypes = [c_int, c_double, c_char_p, c_char_p, c_int, (c_double * 6), c_double_p, - c_double_p] -libspice.spkapo_c.argtypes = [c_int, c_double, c_char_p, (c_double * 6), c_char_p, (c_double * 3), c_double_p] -libspice.spkapp_c.argtypes = [c_int, c_double, c_char_p, (c_double * 6), c_char_p, (c_double * 6), c_double_p] -libspice.spkaps_c.argtypes = [c_int, c_double, c_char_p, c_char_p, (c_double * 6), (c_double * 6), (c_double * 6), - c_double_p, c_double_p] +libspice.spkacs_c.argtypes = [ + c_int, + c_double, + c_char_p, + c_char_p, + c_int, + (c_double * 6), + c_double_p, + c_double_p, +] +libspice.spkapo_c.argtypes = [ + c_int, + c_double, + c_char_p, + (c_double * 6), + c_char_p, + (c_double * 3), + c_double_p, +] +libspice.spkapp_c.argtypes = [ + c_int, + c_double, + c_char_p, + (c_double * 6), + c_char_p, + (c_double * 6), + c_double_p, +] +libspice.spkaps_c.argtypes = [ + c_int, + c_double, + c_char_p, + c_char_p, + (c_double * 6), + (c_double * 6), + (c_double * 6), + c_double_p, + c_double_p, +] libspice.spkcls_c.argtypes = [c_int] libspice.spkcov_c.argtypes = [c_char_p, c_int, s_cell_p] -libspice.spkcpo_c.argtypes = [c_char_p, c_double, c_char_p, c_char_p, c_char_p, - (c_double * 3), c_char_p, c_char_p, (c_double * 6), - c_double_p] -libspice.spkcpt_c.argtypes = [(c_double * 3), c_char_p, c_char_p, c_double, c_char_p, - c_char_p, c_char_p, c_char_p, (c_double * 6), - c_double_p] -libspice.spkcvo_c.argtypes = [c_char_p, c_double, c_char_p, c_char_p, c_char_p, - (c_double * 6), c_double, c_char_p, c_char_p, - (c_double * 6), c_double_p] -libspice.spkcvt_c.argtypes = [(c_double * 6), c_double, c_char_p, c_char_p, c_double, - c_char_p, c_char_p, c_char_p, c_char_p, (c_double * 6), - c_double_p] -libspice.spkez_c.argtypes = [c_int, c_double, c_char_p, c_char_p, c_int, (c_double * 6), c_double_p] -libspice.spkezp_c.argtypes = [c_int, c_double, c_char_p, c_char_p, c_int, (c_double * 3), c_double_p] -libspice.spkezr_c.argtypes = [c_char_p, c_double, c_char_p, c_char_p, c_char_p, (c_double * 6), c_double_p] -libspice.spkgeo_c.argtypes = [c_int, c_double, c_char_p, c_int, (c_double * 6), c_double_p] -libspice.spkgps_c.argtypes = [c_int, c_double, c_char_p, c_int, (c_double * 3), c_double_p] +libspice.spkcpo_c.argtypes = [ + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_char_p, + c_char_p, + (c_double * 6), + c_double_p, +] +libspice.spkcpt_c.argtypes = [ + (c_double * 3), + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + (c_double * 6), + c_double_p, +] +libspice.spkcvo_c.argtypes = [ + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + (c_double * 6), + c_double, + c_char_p, + c_char_p, + (c_double * 6), + c_double_p, +] +libspice.spkcvt_c.argtypes = [ + (c_double * 6), + c_double, + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + (c_double * 6), + c_double_p, +] +libspice.spkez_c.argtypes = [ + c_int, + c_double, + c_char_p, + c_char_p, + c_int, + (c_double * 6), + c_double_p, +] +libspice.spkezp_c.argtypes = [ + c_int, + c_double, + c_char_p, + c_char_p, + c_int, + (c_double * 3), + c_double_p, +] +libspice.spkezr_c.argtypes = [ + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + (c_double * 6), + c_double_p, +] +libspice.spkgeo_c.argtypes = [ + c_int, + c_double, + c_char_p, + c_int, + (c_double * 6), + c_double_p, +] +libspice.spkgps_c.argtypes = [ + c_int, + c_double, + c_char_p, + c_int, + (c_double * 3), + c_double_p, +] libspice.spklef_c.argtypes = [c_char_p, c_int_p] -libspice.spkltc_c.argtypes = [c_int, c_double, c_char_p, c_char_p, (c_double * 6), (c_double * 6), c_double_p, - c_double_p] +libspice.spkltc_c.argtypes = [ + c_int, + c_double, + c_char_p, + c_char_p, + (c_double * 6), + (c_double * 6), + c_double_p, + c_double_p, +] libspice.spkobj_c.argtypes = [c_char_p, s_cell_p] libspice.spkopa_c.argtypes = [c_char_p, c_int_p] libspice.spkopn_c.argtypes = [c_char_p, c_char_p, c_int, c_int_p] -libspice.spkpds_c.argtypes = [c_int, c_int, c_char_p, c_int, c_double, c_double, (c_double * 5)] -libspice.spkpos_c.argtypes = [c_char_p, c_double, c_char_p, c_char_p, c_char_p, (c_double * 3), c_double_p] -libspice.spkpvn_c.argtypes = [c_int, (c_double * 5), c_double, c_int_p, - (c_double * 6), c_int_p] -libspice.spksfs_c.argtypes = [c_int, c_double, c_int, c_int_p, - (c_double * 5), c_char_p, c_int_p] +libspice.spkpds_c.argtypes = [ + c_int, + c_int, + c_char_p, + c_int, + c_double, + c_double, + (c_double * 5), +] +libspice.spkpos_c.argtypes = [ + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_double_p, +] +libspice.spkpvn_c.argtypes = [ + c_int, + (c_double * 5), + c_double, + c_int_p, + (c_double * 6), + c_int_p, +] +libspice.spksfs_c.argtypes = [ + c_int, + c_double, + c_int, + c_int_p, + (c_double * 5), + c_char_p, + c_int_p, +] libspice.spkssb_c.argtypes = [c_int, c_double, c_char_p, (c_double * 6)] -libspice.spksub_c.argtypes = [c_int, (c_double * 5), c_char_p, c_double, c_double, c_int] -libspice.spkuds_c.argtypes = [(c_double * 5), c_int_p, c_int_p, c_int_p, c_int_p, - c_double_p, c_double_p, c_int_p, c_int_p] +libspice.spksub_c.argtypes = [ + c_int, + (c_double * 5), + c_char_p, + c_double, + c_double, + c_int, +] +libspice.spkuds_c.argtypes = [ + (c_double * 5), + c_int_p, + c_int_p, + c_int_p, + c_int_p, + c_double_p, + c_double_p, + c_int_p, + c_int_p, +] libspice.spkuef_c.argtypes = [c_int] -libspice.spkw02_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_double, c_int, c_int, - c_double_p, c_double] -libspice.spkw03_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_double, c_int, c_int, - c_double_p, c_double] -libspice.spkw05_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_double, c_int, - POINTER(c_double * 6), c_double_p] -libspice.spkw08_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_int, c_int, - POINTER(c_double * 6), c_double, c_double] -libspice.spkw09_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_int, c_int, - POINTER(c_double * 6), c_double_p] -libspice.spkw10_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, (c_double * 8), c_int, - c_double_p, c_double_p] -libspice.spkw12_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_int, c_int, - POINTER(c_double * 6), c_double, c_double] -libspice.spkw13_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_int, c_int, - POINTER(c_double * 6), c_double_p] -libspice.spkw15_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_double, (c_double * 3), - (c_double * 3), c_double, c_double, c_double, (c_double * 3), c_double, c_double, - c_double] -libspice.spkw17_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_double, (c_double * 9), - c_double, c_double] -libspice.spkw18_c.argtypes = [c_int, c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_int, c_int, c_void_p, c_double_p] -libspice.spkw20_c.argtypes = [c_int, c_int, c_int, c_char_p, c_double, c_double, c_char_p, c_double, c_int, c_int, c_double_p, c_double, c_double, c_double, c_double] +libspice.spkw02_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_double, + c_int, + c_int, + c_double_p, + c_double, +] +libspice.spkw03_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_double, + c_int, + c_int, + c_double_p, + c_double, +] +libspice.spkw05_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_double, + c_int, + POINTER(c_double * 6), + c_double_p, +] +libspice.spkw08_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_int, + c_int, + POINTER(c_double * 6), + c_double, + c_double, +] +libspice.spkw09_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_int, + c_int, + POINTER(c_double * 6), + c_double_p, +] +libspice.spkw10_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + (c_double * 8), + c_int, + c_double_p, + c_double_p, +] +libspice.spkw12_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_int, + c_int, + POINTER(c_double * 6), + c_double, + c_double, +] +libspice.spkw13_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_int, + c_int, + POINTER(c_double * 6), + c_double_p, +] +libspice.spkw15_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_double, + (c_double * 3), + (c_double * 3), + c_double, + c_double, + c_double, + (c_double * 3), + c_double, + c_double, + c_double, +] +libspice.spkw17_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_double, + (c_double * 9), + c_double, + c_double, +] +libspice.spkw18_c.argtypes = [ + c_int, + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_int, + c_int, + c_void_p, + c_double_p, +] +libspice.spkw20_c.argtypes = [ + c_int, + c_int, + c_int, + c_char_p, + c_double, + c_double, + c_char_p, + c_double, + c_int, + c_int, + c_double_p, + c_double, + c_double, + c_double, + c_double, +] libspice.srfc2s_c.argtypes = [c_int, c_int, c_int, c_char_p, c_int_p] libspice.srfcss_c.argtypes = [c_int, c_char_p, c_int, c_char_p, c_int_p] -libspice.srfnrm_c.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_int, c_void_p, c_void_p] +libspice.srfnrm_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_char_p, + c_int, + c_void_p, + c_void_p, +] libspice.srfrec_c.argtypes = [c_int, c_double, c_double, (c_double * 3)] libspice.srfs2c_c.argtypes = [c_char_p, c_char_p, c_int_p, c_int_p] libspice.srfscc_c.argtypes = [c_char_p, c_int, c_int_p, c_int_p] -libspice.size_c.argtypes = [s_cell_p] -libspice.size_c.restype = c_int -libspice.srfxpt_c.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_char_p, c_char_p, (c_double * 3), - (c_double * 3), c_double_p, c_double_p, (c_double * 3), c_int_p] -libspice.ssize_c.argtypes = [c_int, s_cell_p] +libspice.size_c.argtypes = [s_cell_p] +libspice.size_c.restype = c_int +libspice.srfxpt_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + (c_double * 3), + c_double_p, + c_double_p, + (c_double * 3), + c_int_p, +] +libspice.ssize_c.argtypes = [c_int, s_cell_p] libspice.stelab_c.argtypes = [(c_double * 3), (c_double * 3)] -libspice.stpool_c.argtypes = [c_char_p, c_int, c_char_p, c_int, c_char_p, c_int_p, c_int_p] +libspice.stpool_c.argtypes = [ + c_char_p, + c_int, + c_char_p, + c_int, + c_char_p, + c_int_p, + c_int_p, +] libspice.str2et_c.argtypes = [c_char_p, c_double_p] -libspice.subpnt_c.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_char_p, c_char_p, (c_double * 3), - c_double_p, (c_double * 3)] -libspice.subpt_c.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_char_p, (c_double * 3), c_double_p] -libspice.subslr_c.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_char_p, c_char_p, (c_double * 3), - c_double_p, (c_double * 3)] -libspice.subsol_c.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_char_p, (c_double * 3)] -libspice.sumai_c.argtypes = [c_int_p, c_int] -libspice.sumai_c.restype = c_int -libspice.sumad_c.argtypes = [c_double_p, c_int] -libspice.sumad_c.restype = c_double -libspice.surfnm_c.argtypes = [c_double, c_double, c_double, (c_double * 3), (c_double * 3)] -libspice.surfpt_c.argtypes = [(c_double * 3), (c_double * 3), c_double, c_double, - c_double, (c_double * 3), c_int_p] -libspice.surfpv_c.argtypes = [(c_double * 6), (c_double * 6), c_double, c_double, c_double, (c_double * 6), - c_int_p] +libspice.subpnt_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_double_p, + (c_double * 3), +] +libspice.subpt_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + (c_double * 3), + c_double_p, +] +libspice.subslr_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_double_p, + (c_double * 3), +] +libspice.subsol_c.argtypes = [ + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + (c_double * 3), +] +libspice.sumai_c.argtypes = [c_int_p, c_int] +libspice.sumai_c.restype = c_int +libspice.sumad_c.argtypes = [c_double_p, c_int] +libspice.sumad_c.restype = c_double +libspice.surfnm_c.argtypes = [ + c_double, + c_double, + c_double, + (c_double * 3), + (c_double * 3), +] +libspice.surfpt_c.argtypes = [ + (c_double * 3), + (c_double * 3), + c_double, + c_double, + c_double, + (c_double * 3), + c_int_p, +] +libspice.surfpv_c.argtypes = [ + (c_double * 6), + (c_double * 6), + c_double, + c_double, + c_double, + (c_double * 6), + c_int_p, +] libspice.swpool_c.argtypes = [c_char_p, c_int, c_int, c_void_p] libspice.sxform_c.argtypes = [c_char_p, c_char_p, c_double, (c_double * 6) * 6] libspice.szpool_c.argtypes = [c_char_p, c_int_p, c_int_p] @@ -759,141 +2058,216 @@ ######################################################################################################################## # T -libspice.termpt_c.argtypes = [c_char_p, c_char_p, c_char_p, c_double, c_char_p, c_char_p, c_char_p, c_char_p, (c_double * 3), c_double, c_int, c_double, c_double, c_int, c_int_p, c_void_p, c_double_p, c_void_p] +libspice.termpt_c.argtypes = [ + c_char_p, + c_char_p, + c_char_p, + c_double, + c_char_p, + c_char_p, + c_char_p, + c_char_p, + (c_double * 3), + c_double, + c_int, + c_double, + c_double, + c_int, + c_int_p, + c_void_p, + c_double_p, + c_void_p, +] libspice.timdef_c.argtypes = [c_char_p, c_char_p, c_int, c_char_p] libspice.timout_c.argtypes = [c_double, c_char_p, c_int, c_char_p] libspice.tipbod_c.argtypes = [c_char_p, c_int, c_double, (c_double * 3) * 3] libspice.tisbod_c.argtypes = [c_char_p, c_int, c_double, (c_double * 6) * 6] libspice.tkfram_.argtypes = [c_int_p, (c_double * 3) * 3, c_int_p, c_int_p] libspice.tkvrsn_c.argtypes = [c_char_p] -libspice.tkvrsn_c.restype = c_char_p +libspice.tkvrsn_c.restype = c_char_p libspice.tparse_c.argtypes = [c_char_p, c_int, c_double_p, c_char_p] libspice.tpictr_c.argtypes = [c_char_p, c_int, c_int, c_char_p, c_int_p, c_char_p] -libspice.trace_c.argtypes = [(c_double * 3) * 3] -libspice.trace_c.restype = c_double +libspice.trace_c.argtypes = [(c_double * 3) * 3] +libspice.trace_c.restype = c_double libspice.trcdep_c.argtypes = [c_int_p] libspice.trcnam_c.argtypes = [c_int, c_int, c_char_p] libspice.trcoff_c.argtypes = None libspice.tsetyr_c.argtypes = [c_int] -libspice.twopi_c.restype = c_double -libspice.twovec_c.argtypes = [(c_double * 3), c_int, (c_double * 3), c_int, (c_double * 3) * 3] -libspice.txtopn_.argtypes = [c_char_p, c_int_p, c_int] -libspice.tyear_c.restype = c_double +libspice.twopi_c.restype = c_double +libspice.twovec_c.argtypes = [ + (c_double * 3), + c_int, + (c_double * 3), + c_int, + (c_double * 3) * 3, +] +libspice.txtopn_.argtypes = [c_char_p, c_int_p, c_int] +libspice.tyear_c.restype = c_double ######################################################################################################################## # U -libspice.ucase_c.argtypes = [c_char_p, c_int, c_char_p] -libspice.ucrss_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] -libspice.uddc_c.argtypes = [callbacks.UDFUNS, c_double, c_double, c_int_p] -libspice.uddc_c.restype = None -libspice.uddf_c.argtypes = [callbacks.UDFUNS, c_double, c_double, c_double_p] -libspice.uddf_c.restype = None -libspice.udf_c.argtypes = [c_double, c_double_p] -libspice.udf_c.restype = None -libspice.union_c.argtypes = [s_cell_p, s_cell_p, s_cell_p] +libspice.ucase_c.argtypes = [c_char_p, c_int, c_char_p] +libspice.ucrss_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] +libspice.uddc_c.argtypes = [callbacks.UDFUNS, c_double, c_double, c_int_p] +libspice.uddc_c.restype = None +libspice.uddf_c.argtypes = [callbacks.UDFUNS, c_double, c_double, c_double_p] +libspice.uddf_c.restype = None +libspice.udf_c.argtypes = [c_double, c_double_p] +libspice.udf_c.restype = None +libspice.union_c.argtypes = [s_cell_p, s_cell_p, s_cell_p] libspice.unitim_c.argtypes = [c_double, c_char_p, c_char_p] -libspice.unitim_c.restype = c_double +libspice.unitim_c.restype = c_double libspice.unload_c.argtypes = [c_char_p] -libspice.unorm_c.argtypes = [(c_double * 3), (c_double * 3), c_double_p] +libspice.unorm_c.argtypes = [(c_double * 3), (c_double * 3), c_double_p] libspice.unormg_c.argtypes = [c_double_p, c_int, c_double_p, c_double_p] libspice.utc2et_c.argtypes = [c_char_p, c_double_p] ######################################################################################################################## # V -libspice.vadd_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] -libspice.vaddg_c.argtypes = [c_double_p, c_double_p, c_int, c_double_p] -libspice.valid_c.argtypes = [c_int, c_int, s_cell_p] -libspice.vcrss_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] -libspice.vdist_c.argtypes = [(c_double * 3), (c_double * 3)] -libspice.vdist_c.restype = c_double +libspice.vadd_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] +libspice.vaddg_c.argtypes = [c_double_p, c_double_p, c_int, c_double_p] +libspice.valid_c.argtypes = [c_int, c_int, s_cell_p] +libspice.vcrss_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] +libspice.vdist_c.argtypes = [(c_double * 3), (c_double * 3)] +libspice.vdist_c.restype = c_double libspice.vdistg_c.argtypes = [c_double_p, c_double_p, c_int] -libspice.vdistg_c.restype = c_double -libspice.vdot_c.argtypes = [(c_double * 3), (c_double * 3)] -libspice.vdot_c.restype = c_double -libspice.vdotg_c.argtypes = [c_double_p, c_double_p, c_int] -libspice.vdotg_c.restype = c_double -libspice.vequ_c.argtypes = [(c_double * 3), (c_double * 3)] -libspice.vequg_c.argtypes = [c_double_p, c_int, c_double_p] -libspice.vhat_c.argtypes = [(c_double * 3), (c_double * 3)] -libspice.vhatg_c.argtypes = [c_double_p, c_int, c_double_p] -libspice.vlcom_c.argtypes = [c_double, (c_double * 3), c_double, (c_double * 3), (c_double * 3)] -libspice.vlcom3_c.argtypes = [c_double, (c_double * 3), c_double, (c_double * 3), c_double, (c_double * 3), - (c_double * 3)] -libspice.vlcomg_c.argtypes = [c_int, c_double, c_double_p, c_double, c_double_p, c_double_p] +libspice.vdistg_c.restype = c_double +libspice.vdot_c.argtypes = [(c_double * 3), (c_double * 3)] +libspice.vdot_c.restype = c_double +libspice.vdotg_c.argtypes = [c_double_p, c_double_p, c_int] +libspice.vdotg_c.restype = c_double +libspice.vequ_c.argtypes = [(c_double * 3), (c_double * 3)] +libspice.vequg_c.argtypes = [c_double_p, c_int, c_double_p] +libspice.vhat_c.argtypes = [(c_double * 3), (c_double * 3)] +libspice.vhatg_c.argtypes = [c_double_p, c_int, c_double_p] +libspice.vlcom_c.argtypes = [ + c_double, + (c_double * 3), + c_double, + (c_double * 3), + (c_double * 3), +] +libspice.vlcom3_c.argtypes = [ + c_double, + (c_double * 3), + c_double, + (c_double * 3), + c_double, + (c_double * 3), + (c_double * 3), +] +libspice.vlcomg_c.argtypes = [ + c_int, + c_double, + c_double_p, + c_double, + c_double_p, + c_double_p, +] libspice.vminug_c.argtypes = [c_double_p, c_int, c_double_p] libspice.vminus_c.argtypes = [(c_double * 3), (c_double * 3)] -libspice.vnorm_c.restype = c_double -libspice.vnorm_c.argstype = [stypes.emptyDoubleVector(3)] -libspice.vnormg_c.restype = c_double +libspice.vnorm_c.restype = c_double +libspice.vnorm_c.argstype = [stypes.empty_double_vector(3)] +libspice.vnormg_c.restype = c_double libspice.vnormg_c.argstype = [c_double_p, c_int] -libspice.vpack_c.argtypes = [c_double, c_double, c_double, (c_double * 3)] -libspice.vperp_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] -libspice.vprjp_c.argtypes = [(c_double * 3), s_plan_p, (c_double * 3)] -libspice.vprjpi_c.argtypes = [(c_double * 3), s_plan_p, s_plan_p, (c_double * 3), - c_int_p] -libspice.vproj_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] -libspice.vrelg_c.argtypes = [c_double_p, c_double_p, c_int] -libspice.vrelg_c.restype = c_double -libspice.vrel_c.argtypes = [(c_double * 3), (c_double * 3)] -libspice.vrel_c.restype = c_double -libspice.vrotv_c.argtypes = [(c_double * 3), (c_double * 3), c_double, (c_double * 3)] -libspice.vscl_c.argtypes = [c_double, (c_double * 3), (c_double * 3)] -libspice.vsclg_c.argtypes = [c_double, c_double_p, c_int, c_double_p] -libspice.vsep_c.argtypes = [(c_double * 3), (c_double * 3)] -libspice.vsep_c.restype = c_double -libspice.vsepg_c.argtypes = [c_double_p, c_double_p, c_int] -libspice.vsepg_c.restype = c_double -libspice.vsub_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] -libspice.vsubg_c.argtypes = [c_double_p, c_double_p, c_int, c_double_p] -libspice.vtmv_c.argtypes = [(c_double * 3), (c_double * 3) * 3, (c_double * 3)] -libspice.vtmv_c.restype = c_double -libspice.vtmvg_c.argtypes = [c_double_p, c_void_p, c_double_p, c_int, c_int] -libspice.vtmvg_c.restype = c_double +libspice.vpack_c.argtypes = [c_double, c_double, c_double, (c_double * 3)] +libspice.vperp_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] +libspice.vprjp_c.argtypes = [(c_double * 3), s_plan_p, (c_double * 3)] +libspice.vprjpi_c.argtypes = [ + (c_double * 3), + s_plan_p, + s_plan_p, + (c_double * 3), + c_int_p, +] +libspice.vproj_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] +libspice.vrelg_c.argtypes = [c_double_p, c_double_p, c_int] +libspice.vrelg_c.restype = c_double +libspice.vrel_c.argtypes = [(c_double * 3), (c_double * 3)] +libspice.vrel_c.restype = c_double +libspice.vrotv_c.argtypes = [(c_double * 3), (c_double * 3), c_double, (c_double * 3)] +libspice.vscl_c.argtypes = [c_double, (c_double * 3), (c_double * 3)] +libspice.vsclg_c.argtypes = [c_double, c_double_p, c_int, c_double_p] +libspice.vsep_c.argtypes = [(c_double * 3), (c_double * 3)] +libspice.vsep_c.restype = c_double +libspice.vsepg_c.argtypes = [c_double_p, c_double_p, c_int] +libspice.vsepg_c.restype = c_double +libspice.vsub_c.argtypes = [(c_double * 3), (c_double * 3), (c_double * 3)] +libspice.vsubg_c.argtypes = [c_double_p, c_double_p, c_int, c_double_p] +libspice.vtmv_c.argtypes = [(c_double * 3), (c_double * 3) * 3, (c_double * 3)] +libspice.vtmv_c.restype = c_double +libspice.vtmvg_c.argtypes = [c_double_p, c_void_p, c_double_p, c_int, c_int] +libspice.vtmvg_c.restype = c_double libspice.vupack_c.argtypes = [(c_double * 3), c_double_p, c_double_p, c_double_p] -libspice.vzero_c.argtypes = [(c_double * 3)] -libspice.vzero_c.restype = c_int +libspice.vzero_c.argtypes = [(c_double * 3)] +libspice.vzero_c.restype = c_int libspice.vzerog_c.argtypes = [c_double_p, c_int] -libspice.vzerog_c.restype = c_int +libspice.vzerog_c.restype = c_int ######################################################################################################################## # W libspice.wncard_c.argtypes = [s_cell_p] -libspice.wncard_c.restype = c_int +libspice.wncard_c.restype = c_int libspice.wncomd_c.argtypes = [c_double, c_double, s_cell_p, s_cell_p] libspice.wncond_c.argtypes = [c_double, c_double, s_cell_p] libspice.wndifd_c.argtypes = [s_cell_p, s_cell_p, s_cell_p] libspice.wnelmd_c.argtypes = [c_double, s_cell_p] -libspice.wnelmd_c.restype = c_int +libspice.wnelmd_c.restype = c_int libspice.wnexpd_c.argtypes = [c_double, c_double, s_cell_p] libspice.wnextd_c.argtypes = [c_char, s_cell_p] libspice.wnfetd_c.argtypes = [s_cell_p, c_int, c_double_p, c_double_p] libspice.wnfild_c.argtypes = [c_double, s_cell_p] libspice.wnfltd_c.argtypes = [c_double, s_cell_p] libspice.wnincd_c.argtypes = [c_double, c_double, s_cell_p] -libspice.wnincd_c.restype = c_int +libspice.wnincd_c.restype = c_int libspice.wninsd_c.argtypes = [c_double, c_double, s_cell_p] libspice.wnintd_c.argtypes = [s_cell_p, s_cell_p, s_cell_p] libspice.wnreld_c.argtypes = [s_cell_p, c_char_p, s_cell_p] -libspice.wnreld_c.restype = c_int -libspice.wnsumd_c.argtypes = [s_cell_p, c_double_p, c_double_p, c_double_p, - c_int_p, c_int_p] +libspice.wnreld_c.restype = c_int +libspice.wnsumd_c.argtypes = [ + s_cell_p, + c_double_p, + c_double_p, + c_double_p, + c_int_p, + c_int_p, +] libspice.wnunid_c.argtypes = [s_cell_p, s_cell_p, s_cell_p] libspice.wnvald_c.argtypes = [c_int, c_int, s_cell_p] libspice.writln_.argtypes = [c_char_p, c_int_p, c_int] ######################################################################################################################## # X -libspice.xf2eul_c.argtypes = [(c_double * 6) * 6, c_int, c_int, c_int, (c_double * 6), c_int_p] +libspice.xf2eul_c.argtypes = [ + (c_double * 6) * 6, + c_int, + c_int, + c_int, + (c_double * 6), + c_int_p, +] libspice.xf2rav_c.argtypes = [(c_double * 6) * 6, (c_double * 3) * 3, (c_double * 3)] -libspice.xfmsta_c.argtypes = [(c_double * 6), c_char_p, c_char_p, c_char_p, (c_double * 6)] -libspice.xpose_c.argtypes = [(c_double * 3) * 3, (c_double * 3) * 3] +libspice.xfmsta_c.argtypes = [ + (c_double * 6), + c_char_p, + c_char_p, + c_char_p, + (c_double * 6), +] +libspice.xpose_c.argtypes = [(c_double * 3) * 3, (c_double * 3) * 3] libspice.xpose6_c.argtypes = [(c_double * 6) * 6, (c_double * 6) * 6] libspice.xposeg_c.argtypes = [c_void_p, c_int, c_int, c_void_p] ######################################################################################################################## # Z -libspice.zzdynrot_.argtypes = [c_int_p, c_int_p, c_double_p, (c_double * 3) * 3, c_int_p] +libspice.zzdynrot_.argtypes = [ + c_int_p, + c_int_p, + c_double_p, + (c_double * 3) * 3, + c_int_p, +] libspice.zzgetcml_c.argtypes = [c_int, c_char_p, c_int] libspice.zzgfsavh_c.argtypes = [c_int] -#libspice.zzsynccl_c.argtypes = [None] +# libspice.zzsynccl_c.argtypes = [None] diff --git a/spiceypy/utils/support_types.py b/spiceypy/utils/support_types.py index 84510493..5f7acc38 100644 --- a/spiceypy/utils/support_types.py +++ b/spiceypy/utils/support_types.py @@ -45,15 +45,25 @@ import six import collections -from ctypes import c_char_p, c_int, c_double,\ - c_char, c_void_p, sizeof, \ - Array, create_string_buffer, cast, Structure, \ - string_at +from ctypes import ( + c_char_p, + c_int, + c_double, + c_char, + c_void_p, + sizeof, + Array, + create_string_buffer, + cast, + Structure, + string_at, +) import numpy from numpy import ctypeslib as numpc + # Collection of supporting functions for wrapper functions -__author__ = 'AndrewAnnex' +__author__ = "AndrewAnnex" errorformat = """ ================================================================================ @@ -75,6 +85,7 @@ class SpiceyError(Exception): SpiceyError wraps CSPICE errors. :type value: str """ + def __init__(self, value, found=None): self.value = value self.found = found @@ -83,22 +94,23 @@ def __str__(self): return self.value -def toDoubleVector(x): +def to_double_vector(x): return DoubleArray.from_param(param=x) -def toDoubleMatrix(x): +def to_double_matrix(x): return DoubleMatrix.from_param(param=x) -def toIntVector(x): +def to_int_vector(x): return IntArray.from_param(param=x) -def toIntMatrix(x): +def to_int_matrix(x): return IntMatrix.from_param(param=x) -def isiterable(i): + +def is_iterable(i): """ From stackoverflow https://stackoverflow.com/questions/1055360/how-to-tell-a-variable-is-iterable-but-not-a-string/44328500#44328500 :param i: input collection @@ -107,28 +119,28 @@ def isiterable(i): return isinstance(i, collections.Iterable) and not isinstance(i, six.string_types) -def toPythonString(inString): - if isinstance(inString, c_char_p): - return toPythonString(inString.value) +def to_python_string(in_string): + if isinstance(in_string, c_char_p): + return to_python_string(in_string.value) if six.PY2: - return string_at(inString).rstrip() + return string_at(in_string).rstrip() elif six.PY3: - return bytes.decode(string_at(inString), errors="ignore").rstrip() + return bytes.decode(string_at(in_string), errors="ignore").rstrip() -def emptyCharArray(xLen=None, yLen=None): - if not yLen: - yLen = 1 - if not xLen: - xLen = 1 - if isinstance(xLen, c_int): - xLen = xLen.value - if isinstance(yLen, c_int): - yLen = yLen.value - return ((c_char * xLen) * yLen)() +def empty_char_array(x_len=None, y_len=None): + if not y_len: + y_len = 1 + if not x_len: + x_len = 1 + if isinstance(x_len, c_int): + x_len = x_len.value + if isinstance(y_len, c_int): + y_len = y_len.value + return ((c_char * x_len) * y_len)() -def emptyDoubleMatrix(x=3, y=3): +def empty_double_matrix(x=3, y=3): if isinstance(x, c_int): x = x.value if isinstance(y, c_int): @@ -136,14 +148,14 @@ def emptyDoubleMatrix(x=3, y=3): return ((c_double * x) * y)() -def emptyDoubleVector(n): +def empty_double_vector(n): if isinstance(n, c_int): n = n.value - assert(isinstance(n, int)) + assert isinstance(n, int) return (c_double * n)() -def emptyIntMatrix(x=3, y=3): +def empty_int_matrix(x=3, y=3): if isinstance(x, c_int): x = x.value if isinstance(y, c_int): @@ -151,14 +163,14 @@ def emptyIntMatrix(x=3, y=3): return ((c_int * x) * y)() -def emptyIntVector(n): +def empty_int_vector(n): if isinstance(n, c_int): n = n.value - assert (isinstance(n, int)) + assert isinstance(n, int) return (c_int * n)() -def cVectorToPython(x): +def c_vector_to_python(x): """ Convert the c vector data into the correct python data type (numpy arrays or strings) @@ -172,12 +184,14 @@ def cVectorToPython(x): elif isinstance(x[0], float): return numpy.frombuffer(x, dtype=numpy.float64).copy() elif isinstance(x[0].value, bytes): - return [toPythonString(y) for y in x] + return [to_python_string(y) for y in x] + -def cIntVectorToBoolPython(x): +def c_int_vector_to_bool_python(x): return numpc.as_array(x).copy().astype(bool) -def cMatrixToNumpy(x): + +def c_matrix_to_numpy(x): """ Convert a ctypes 2d array (or matrix) into a numpy array for python use :param x: thing to convert @@ -186,40 +200,40 @@ def cMatrixToNumpy(x): return numpc.as_array(x).copy() -def stringToCharP(inobject, inlen=None): +def string_to_char_p(inobject, inlen=None): """ :param inobject: input string, int for getting null string of length of int :param inlen: optional parameter, length of a given string can be specified :return: """ if inlen and isinstance(inobject, str): - return create_string_buffer(inobject.encode(encoding='UTF-8'), inlen) + return create_string_buffer(inobject.encode(encoding="UTF-8"), inlen) if isinstance(inobject, bytes): return inobject if isinstance(inobject, c_int): - return stringToCharP(" " * inobject.value) + return string_to_char_p(" " * inobject.value) if isinstance(inobject, int): - return stringToCharP(" " * inobject) + return string_to_char_p(" " * inobject) if isinstance(inobject, numpy.str_): - return c_char_p(inobject.encode(encoding='utf-8')) - return c_char_p(inobject.encode(encoding='UTF-8')) + return c_char_p(inobject.encode(encoding="utf-8")) + return c_char_p(inobject.encode(encoding="UTF-8")) -def listToCharArray(arg, xLen=None, yLen=None): - assert isiterable(arg) - if not yLen: - yLen = len(arg) - if not xLen: - xLen = max(len(s) for s in arg) + 1 - if isinstance(xLen, c_int): - xLen = xLen.value - if isinstance(yLen, c_int): - yLen = yLen.value - return ((c_char * xLen) * yLen)(*[stringToCharP(l, inlen=xLen) for l in arg]) +def list_to_char_array(arg, x_len=None, y_len=None): + assert is_iterable(arg) + if not y_len: + y_len = len(arg) + if not x_len: + x_len = max(len(s) for s in arg) + 1 + if isinstance(x_len, c_int): + x_len = x_len.value + if isinstance(y_len, c_int): + y_len = y_len.value + return ((c_char * x_len) * y_len)(*[string_to_char_p(l, inlen=x_len) for l in arg]) -def listToCharArrayPtr(input, xLen=None, yLen=None): - return cast(listToCharArray(input, xLen=xLen, yLen=yLen), c_char_p) +def list_to_char_array_ptr(input, x_len=None, y_len=None): + return cast(list_to_char_array(input, x_len=x_len, y_len=y_len), c_char_p) class DoubleArrayType: @@ -227,8 +241,8 @@ class DoubleArrayType: # inspiration from python cookbook 3rd edition def from_param(self, param): typename = type(param).__name__ - if hasattr(self, 'from_' + typename): - return getattr(self, 'from_' + typename)(param) + if hasattr(self, "from_" + typename): + return getattr(self, "from_" + typename)(param) elif isinstance(param, Array): return param else: @@ -249,12 +263,14 @@ def from_ndarray(self, param): # return param.data_as(POINTER(c_double)) # the above older method does not work with # functions which take vectors of known size - return numpc.as_ctypes(param.astype(numpy.float64, casting='same_kind', copy=False)) + return numpc.as_ctypes( + param.astype(numpy.float64, casting="same_kind", copy=False) + ) # Cast from array.array objects def from_array(self, param): - if param.typecode != 'd': - raise TypeError('must be an array of doubles') + if param.typecode != "d": + raise TypeError("must be an array of doubles") return self.from_list(param) @@ -263,8 +279,8 @@ class DoubleMatrixType: # inspiration from python cookbook 3rd edition def from_param(self, param): typename = type(param).__name__ - if hasattr(self, 'from_' + typename): - return getattr(self, 'from_' + typename)(param) + if hasattr(self, "from_" + typename): + return getattr(self, "from_" + typename)(param) elif isinstance(param, Array): return param else: @@ -272,21 +288,29 @@ def from_param(self, param): # Cast from lists/tuples def from_list(self, param): - val = ((c_double * len(param[0])) * len(param))(*[DoubleArray.from_param(x) for x in param]) + val = ((c_double * len(param[0])) * len(param))( + *[DoubleArray.from_param(x) for x in param] + ) return val # Cast from Tuple def from_tuple(self, param): - val = ((c_double * len(param[0])) * len(param))(*[DoubleArray.from_param(x) for x in param]) + val = ((c_double * len(param[0])) * len(param))( + *[DoubleArray.from_param(x) for x in param] + ) return val # Cast from a numpy array def from_ndarray(self, param): - return numpc.as_ctypes(param.astype(numpy.float64, casting='same_kind', copy=False)) + return numpc.as_ctypes( + param.astype(numpy.float64, casting="same_kind", copy=False) + ) # Cast from a numpy matrix def from_matrix(self, param): - return numpc.as_ctypes(param.astype(numpy.float64, casting='same_kind', copy=False)) + return numpc.as_ctypes( + param.astype(numpy.float64, casting="same_kind", copy=False) + ) class IntArrayType: @@ -294,8 +318,8 @@ class IntArrayType: # inspiration from python cookbook 3rd edition def from_param(self, param): typename = type(param).__name__ - if hasattr(self, 'from_' + typename): - return getattr(self, 'from_' + typename)(param) + if hasattr(self, "from_" + typename): + return getattr(self, "from_" + typename)(param) elif isinstance(param, Array): return param else: @@ -314,12 +338,14 @@ def from_tuple(self, param): # Cast from a numpy array def from_ndarray(self, param): # cspice always uses a int size half as big as the float, ie int32 if a float64 system default - return numpc.as_ctypes(param.astype(numpy.int32, casting='same_kind', copy=False)) + return numpc.as_ctypes( + param.astype(numpy.int32, casting="same_kind", copy=False) + ) # Cast from array.array objects def from_array(self, param): - if param.typecode != 'i': - raise TypeError('must be an array of ints') + if param.typecode != "i": + raise TypeError("must be an array of ints") return self.from_list(param) @@ -328,8 +354,8 @@ class IntMatrixType: # inspiration from python cookbook 3rd edition def from_param(self, param): typename = type(param).__name__ - if hasattr(self, 'from_' + typename): - return getattr(self, 'from_' + typename)(param) + if hasattr(self, "from_" + typename): + return getattr(self, "from_" + typename)(param) elif isinstance(param, Array): return param else: @@ -337,23 +363,31 @@ def from_param(self, param): # Cast from lists/tuples def from_list(self, param): - val = ((c_int * len(param[0])) * len(param))(*[IntArray.from_param(x) for x in param]) + val = ((c_int * len(param[0])) * len(param))( + *[IntArray.from_param(x) for x in param] + ) return val # Cast from Tuple def from_tuple(self, param): - val = ((c_int * len(param[0])) * len(param))(*[IntArray.from_param(x) for x in param]) + val = ((c_int * len(param[0])) * len(param))( + *[IntArray.from_param(x) for x in param] + ) return val # Cast from a numpy array def from_ndarray(self, param): # cspice always uses a int size half as big as the float, ie int32 if a float64 system default - return numpc.as_ctypes(param.astype(numpy.int32, casting='same_kind', copy=False)) + return numpc.as_ctypes( + param.astype(numpy.int32, casting="same_kind", copy=False) + ) # Cast from a numpy matrix def from_matrix(self, param): # cspice always uses a int size half as big as the float, ie int32 if a float64 system default - return numpc.as_ctypes(param.astype(numpy.int32, casting='same_kind', copy=False)) + return numpc.as_ctypes( + param.astype(numpy.int32, casting="same_kind", copy=False) + ) DoubleArray = DoubleArrayType() @@ -366,45 +400,48 @@ def from_matrix(self, param): class Plane(Structure): - _fields_ = [ - ('_normal', c_double * 3), - ('_constant', c_double) - ] + _fields_ = [("_normal", c_double * 3), ("_constant", c_double)] @property def normal(self): - return cVectorToPython(self._normal) + return c_vector_to_python(self._normal) @property def constant(self): return self._constant def __str__(self): - return '' % (', '.join([str(x) for x in self._normal]), self._constant) + return "" % ( + ", ".join([str(x) for x in self._normal]), + self._constant, + ) class Ellipse(Structure): _fields_ = [ - ('_center', c_double * 3), - ('_semi_major', c_double * 3), - ('_semi_minor', c_double * 3) + ("_center", c_double * 3), + ("_semi_major", c_double * 3), + ("_semi_minor", c_double * 3), ] @property def center(self): - return cVectorToPython(self._center) + return c_vector_to_python(self._center) @property def semi_major(self): - return cVectorToPython(self._semi_major) + return c_vector_to_python(self._semi_major) @property def semi_minor(self): - return cVectorToPython(self._semi_minor) + return c_vector_to_python(self._semi_minor) def __str__(self): - return '' % \ - (self.center, self.semi_major, self.semi_minor) + return "" % ( + self.center, + self.semi_major, + self.semi_minor, + ) class DataType(object): @@ -425,22 +462,23 @@ def __init__(self): class SpiceDSKDescr(Structure): _fields_ = [ - ('_surfce', c_int), - ('_center', c_int), - ('_dclass', c_int), - ('_dtype', c_int), - ('_frmcde', c_int), - ('_corsys', c_int), - ('_corpar', c_double * 10), - ('_co1min', c_double), - ('_co1max', c_double), - ('_co2min', c_double), - ('_co2max', c_double), - ('_co3min', c_double), - ('_co3max', c_double), - ('_start', c_double), - ('_stop', c_double), + ("_surfce", c_int), + ("_center", c_int), + ("_dclass", c_int), + ("_dtype", c_int), + ("_frmcde", c_int), + ("_corsys", c_int), + ("_corpar", c_double * 10), + ("_co1min", c_double), + ("_co1max", c_double), + ("_co2min", c_double), + ("_co2max", c_double), + ("_co3min", c_double), + ("_co3max", c_double), + ("_start", c_double), + ("_stop", c_double), ] + @property def surfce(self): return self._surfce @@ -467,7 +505,7 @@ def corsys(self): @property def corpar(self): - return cVectorToPython(self._corpar) + return c_vector_to_python(self._corpar) @property def co1min(self): @@ -504,15 +542,16 @@ def stop(self): class SpiceDLADescr(Structure): _fields_ = [ - ('_bwdptr', c_int), - ('_fwdptr', c_int), - ('_ibase', c_int), - ('_isize', c_int), - ('_dbase', c_int), - ('_dsize', c_int), - ('_cbase', c_int), - ('_csize', c_int) + ("_bwdptr", c_int), + ("_fwdptr", c_int), + ("_ibase", c_int), + ("_isize", c_int), + ("_dbase", c_int), + ("_dsize", c_int), + ("_cbase", c_int), + ("_csize", c_int), ] + @property def bwdptr(self): return self._bwdptr @@ -548,31 +587,30 @@ def csize(self): class SpiceEKDataType(c_int): _SPICE_CHR = c_int(0) - _SPICE_DP = c_int(1) + _SPICE_DP = c_int(1) _SPICE_INT = c_int(2) _SPICE_TIME = c_int(3) _SPICE_BOOL = c_int(4) - _fields_ = [ - ('SPICE_CHR', _SPICE_CHR), - ('SPICE_DP', _SPICE_DP), - ('SPICE_INT', _SPICE_INT), - ('SPICE_TIME', _SPICE_TIME), - ('SPICE_BOOL', _SPICE_BOOL), + ("SPICE_CHR", _SPICE_CHR), + ("SPICE_DP", _SPICE_DP), + ("SPICE_INT", _SPICE_INT), + ("SPICE_TIME", _SPICE_TIME), + ("SPICE_BOOL", _SPICE_BOOL), ] - SPICE_CHR = _SPICE_CHR.value - SPICE_DP = _SPICE_DP.value - SPICE_INT = _SPICE_INT.value + SPICE_CHR = _SPICE_CHR.value + SPICE_DP = _SPICE_DP.value + SPICE_INT = _SPICE_INT.value SPICE_TIME = _SPICE_TIME.value SPICE_BOOL = _SPICE_BOOL.value -def emptySpiceEKDataTypeVector(n): +def empty_spice_ek_data_type_vector(n): if isinstance(n, c_int): n = n.value - assert(isinstance(n, int)) + assert isinstance(n, int) return (SpiceEKDataType * n)() @@ -582,9 +620,9 @@ class SpiceEKExprClass(c_int): _SPICE_EK_EXP_EXPR = c_int(2) _fields_ = [ - ('SPICE_EK_EXP_COL', _SPICE_EK_EXP_COL), - ('SPICE_EK_EXP_FUNC', _SPICE_EK_EXP_FUNC), - ('SPICE_EK_EXP_EXPR', _SPICE_EK_EXP_EXPR) + ("SPICE_EK_EXP_COL", _SPICE_EK_EXP_COL), + ("SPICE_EK_EXP_FUNC", _SPICE_EK_EXP_FUNC), + ("SPICE_EK_EXP_EXPR", _SPICE_EK_EXP_EXPR), ] SPICE_EK_EXP_COL = _SPICE_EK_EXP_COL.value @@ -595,29 +633,26 @@ class SpiceEKExprClass(c_int): class SpiceSPK18Subtype(c_int): _S18TP0 = c_int(0) _S18TP1 = c_int(1) - S18TP0 = _S18TP0.value - S18TP1 = _S18TP1.value - _fields_ = [ - ('S18TP0', _S18TP0), - ('S18TP1', _S18TP1) - ] + S18TP0 = _S18TP0.value + S18TP1 = _S18TP1.value + _fields_ = [("S18TP0", _S18TP0), ("S18TP1", _S18TP1)] -def emptySpiceEKExprClassVector(n): +def empty_spice_ek_expr_class_vector(n): if isinstance(n, c_int): n = n.value - assert(isinstance(n, int)) + assert isinstance(n, int) return (SpiceEKExprClass * n)() class SpiceEKAttDsc(Structure): _fields_ = [ - ('_cclass', c_int), - ('_dtype', SpiceEKDataType), - ('_strlen', c_int), - ('_size', c_int), - ('_indexd', c_int), - ('_nullok', c_int) + ("_cclass", c_int), + ("_dtype", SpiceEKDataType), + ("_strlen", c_int), + ("_size", c_int), + ("_indexd", c_int), + ("_nullok", c_int), ] @property @@ -645,22 +680,31 @@ def nullok(self): return bool(self._nullok) def __str__(self): - return '' % \ - (self.cclass, self.dtype, self.strlen, self.size, self.indexd, self.nullok) + return ( + "" + % ( + self.cclass, + self.dtype, + self.strlen, + self.size, + self.indexd, + self.nullok, + ) + ) class SpiceEKSegSum(Structure): _fields_ = [ - ('_tabnam', c_char * 65), - ('_nrows', c_int), - ('_ncols', c_int), - ('_cnames', (c_char * 100) * 33), - ('_cdescrs', SpiceEKAttDsc * 100) + ("_tabnam", c_char * 65), + ("_nrows", c_int), + ("_ncols", c_int), + ("_cnames", (c_char * 100) * 33), + ("_cdescrs", SpiceEKAttDsc * 100), ] @property def tabnam(self): - return toPythonString(self._tabnam) + return to_python_string(self._tabnam) @property def nrows(self): @@ -672,33 +716,44 @@ def ncols(self): @property def cnames(self): - return cVectorToPython(self._cnames)[0:self.ncols] + return c_vector_to_python(self._cnames)[0 : self.ncols] @property def cdescrs(self): - return self._cdescrs[0:self.ncols] + return self._cdescrs[0 : self.ncols] def __str__(self): - return '' % (self.tabnam, self.nrows, self.ncols, self.cnames, self.cdescrs) + return ( + "" + % (self.tabnam, self.nrows, self.ncols, self.cnames, self.cdescrs) + ) # SpiceCell implementation below is inpart from github.com/DaRasch/spiceminer/ # and modified as needed for this author, maybe we should work together? -### helper classes/functions ### -BITSIZE = {'char': sizeof(c_char), 'int': sizeof(c_int), 'double': sizeof(c_double), 'bool': sizeof(c_int), 'time': sizeof(c_int)} +# helper classes/functions +BITSIZE = { + "char": sizeof(c_char), + "int": sizeof(c_int), + "double": sizeof(c_double), + "bool": sizeof(c_int), + "time": sizeof(c_int), +} def _char_getter(data_p, index, length): - return toPythonString((c_char * length).from_address(data_p + index * length * BITSIZE['char'])) + return to_python_string( + (c_char * length).from_address(data_p + index * length * BITSIZE["char"]) + ) def _double_getter(data_p, index, length): - return c_double.from_address(data_p + index * BITSIZE['double']).value + return c_double.from_address(data_p + index * BITSIZE["double"]).value def _int_getter(data_p, index, length): - return c_int.from_address(data_p + index * BITSIZE['int']).value + return c_int.from_address(data_p + index * BITSIZE["int"]).value def SPICEDOUBLE_CELL(size): @@ -711,6 +766,7 @@ def SPICEDOUBLE_CELL(size): """ return SpiceCell.double(size) + def SPICEINT_CELL(size): """ Returns a Int Spice Cell with a given size @@ -721,6 +777,7 @@ def SPICEINT_CELL(size): """ return SpiceCell.integer(size) + def SPICECHAR_CELL(size, length): """ Returns a Char Spice Cell with a given size @@ -733,6 +790,7 @@ def SPICECHAR_CELL(size, length): """ return SpiceCell.character(size, length) + def SPICEBOOL_CELL(size): """ Returns a Bool Spice Cell with a given size @@ -743,6 +801,7 @@ def SPICEBOOL_CELL(size): """ return SpiceCell.bool(size) + def SPICETIME_CELL(size): """ Returns a Time Spice Cell with a given size @@ -755,25 +814,34 @@ def SPICETIME_CELL(size): class SpiceCell(Structure): - #Most written by DaRasch, see included MIT license at file header - DATATYPES_ENUM = {'char': 0, 'double': 1, 'int': 2, 'time': 3, 'bool': 4} + # Most written by DaRasch, see included MIT license at file header + DATATYPES_ENUM = {"char": 0, "double": 1, "int": 2, "time": 3, "bool": 4} DATATYPES_GET = [_char_getter, _double_getter] + [_int_getter] * 3 baseSize = 6 minCharLen = 6 CTRLBLOCK = 6 _fields_ = [ - ('dtype', c_int), - ('length', c_int), - ('size', c_int), - ('card', c_int), - ('isSet', c_int), - ('adjust', c_int), - ('init', c_int), - ('base', c_void_p), - ('data', c_void_p) + ("dtype", c_int), + ("length", c_int), + ("size", c_int), + ("card", c_int), + ("isSet", c_int), + ("adjust", c_int), + ("init", c_int), + ("base", c_void_p), + ("data", c_void_p), ] - def __init__(self, dtype=None, length=None, size=None, card=None, isSet=None, base=None, data=None): + def __init__( + self, + dtype=None, + length=None, + size=None, + card=None, + isSet=None, + base=None, + data=None, + ): super(SpiceCell, self).__init__() self.dtype = dtype self.length = length @@ -786,10 +854,21 @@ def __init__(self, dtype=None, length=None, size=None, card=None, isSet=None, ba self.data = data def __str__(self): - return '' % \ - (self.dtype, self.length, self.size, self.card, self.isSet, - self.adjust, self.init, self.base, self.data) + return ( + "" + % ( + self.dtype, + self.length, + self.size, + self.card, + self.isSet, + self.adjust, + self.init, + self.base, + self.data, + ) + ) def is_int(self): return self.dtype == 2 @@ -812,36 +891,78 @@ def is_set(self): @classmethod def character(cls, size, length): base = (c_char * ((cls.CTRLBLOCK + size) * length))() - data = (c_char * (size * length)).from_buffer(base, cls.CTRLBLOCK * BITSIZE['char'] * length) - instance = cls(cls.DATATYPES_ENUM['char'], length, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p)) + data = (c_char * (size * length)).from_buffer( + base, cls.CTRLBLOCK * BITSIZE["char"] * length + ) + instance = cls( + cls.DATATYPES_ENUM["char"], + length, + size, + 0, + 1, + cast(base, c_void_p), + cast(data, c_void_p), + ) return instance @classmethod def integer(cls, size): base = (c_int * (cls.CTRLBLOCK + size))() - data = (c_int * size).from_buffer(base, cls.CTRLBLOCK * BITSIZE['int']) - instance = cls(cls.DATATYPES_ENUM['int'], 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p)) + data = (c_int * size).from_buffer(base, cls.CTRLBLOCK * BITSIZE["int"]) + instance = cls( + cls.DATATYPES_ENUM["int"], + 0, + size, + 0, + 1, + cast(base, c_void_p), + cast(data, c_void_p), + ) return instance @classmethod def double(cls, size): base = (c_double * (cls.CTRLBLOCK + size))() - data = (c_double * size).from_buffer(base, cls.CTRLBLOCK * BITSIZE['double']) - instance = cls(cls.DATATYPES_ENUM['double'], 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p)) + data = (c_double * size).from_buffer(base, cls.CTRLBLOCK * BITSIZE["double"]) + instance = cls( + cls.DATATYPES_ENUM["double"], + 0, + size, + 0, + 1, + cast(base, c_void_p), + cast(data, c_void_p), + ) return instance @classmethod def bool(cls, size): base = (c_int * (cls.CTRLBLOCK + size))() - data = (c_int * size).from_buffer(base, cls.CTRLBLOCK * BITSIZE['bool']) - instance = cls(cls.DATATYPES_ENUM['bool'], 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p)) + data = (c_int * size).from_buffer(base, cls.CTRLBLOCK * BITSIZE["bool"]) + instance = cls( + cls.DATATYPES_ENUM["bool"], + 0, + size, + 0, + 1, + cast(base, c_void_p), + cast(data, c_void_p), + ) return instance @classmethod def time(cls, size): base = (c_int * (cls.CTRLBLOCK + size))() - data = (c_int * size).from_buffer(base, cls.CTRLBLOCK * BITSIZE['time']) - instance = cls(cls.DATATYPES_ENUM['time'], 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p)) + data = (c_int * size).from_buffer(base, cls.CTRLBLOCK * BITSIZE["time"]) + instance = cls( + cls.DATATYPES_ENUM["time"], + 0, + size, + 0, + 1, + cast(base, c_void_p), + cast(data, c_void_p), + ) return instance def __len__(self): @@ -859,19 +980,24 @@ def __contains__(self, key): def __getitem__(self, key): getter = SpiceCell.DATATYPES_GET[self.dtype] if isinstance(key, slice): - #TODO Typechecking + # TODO Typechecking if self.card == 0: return [] else: start, stop, step = key.indices(self.card) - return [getter(self.data, i, self.length) for i in six.moves.range(start, stop, step)] + return [ + getter(self.data, i, self.length) + for i in six.moves.range(start, stop, step) + ] elif key in six.moves.range(-self.card, self.card): index = key if key >= 0 else self.card - abs(key) return getter(self.data, index, self.length) elif not isinstance(key, int): - raise TypeError('SpiceCell indices must be integers, not {}'.format(type(key))) + raise TypeError( + "SpiceCell indices must be integers, not {}".format(type(key)) + ) else: - raise IndexError('SpiceCell index out of range') + raise IndexError("SpiceCell index out of range") def reset(self): self.card = 0 @@ -887,7 +1013,7 @@ def __eq__(self, other): """ if len(self) != len(other): return False - if not hasattr(other, '__iter__'): + if not hasattr(other, "__iter__"): return False if isinstance(other, SpiceCell): if other.dtype != self.dtype: @@ -899,10 +1025,11 @@ def __eq__(self, other): return False return True + # Spice Cell classes -class Cell_Time(SpiceCell): +class Cell_Time(SpiceCell): def __init__(self, size): """ Init a Time Spice Cell with a given size and length @@ -910,11 +1037,13 @@ def __init__(self, size): :type size: int """ base = (c_int * (6 + size))() - data = (c_int * size).from_buffer(base, 6 * BITSIZE['time']) - super(Cell_Time, self).__init__(3, 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p)) + data = (c_int * size).from_buffer(base, 6 * BITSIZE["time"]) + super(Cell_Time, self).__init__( + 3, 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p) + ) -class Cell_Bool(SpiceCell): +class Cell_Bool(SpiceCell): def __init__(self, size): """ Init a Bool Spice Cell with a given size and length @@ -922,11 +1051,13 @@ def __init__(self, size): :type size: int """ base = (c_int * (6 + size))() - data = (c_int * size).from_buffer(base, 6 * BITSIZE['bool']) - super(Cell_Bool, self).__init__(4, 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p)) + data = (c_int * size).from_buffer(base, 6 * BITSIZE["bool"]) + super(Cell_Bool, self).__init__( + 4, 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p) + ) -class Cell_Int(SpiceCell): +class Cell_Int(SpiceCell): def __init__(self, size): """ Init a Int Spice Cell with a given size and length @@ -934,11 +1065,13 @@ def __init__(self, size): :type size: int """ base = (c_int * (6 + size))() - data = (c_int * size).from_buffer(base, 6 * BITSIZE['int']) - super(Cell_Int, self).__init__(2, 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p)) + data = (c_int * size).from_buffer(base, 6 * BITSIZE["int"]) + super(Cell_Int, self).__init__( + 2, 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p) + ) -class Cell_Double(SpiceCell): +class Cell_Double(SpiceCell): def __init__(self, size): """ Init a Double Spice Cell with a given size and length @@ -946,11 +1079,13 @@ def __init__(self, size): :type size: int """ base = (c_double * (6 + size))() - data = (c_double * size).from_buffer(base, 6 * BITSIZE['double']) - super(Cell_Double, self).__init__(1, 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p)) + data = (c_double * size).from_buffer(base, 6 * BITSIZE["double"]) + super(Cell_Double, self).__init__( + 1, 0, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p) + ) -class Cell_Char(SpiceCell): +class Cell_Char(SpiceCell): def __init__(self, size, length): """ Init a Char Spice Cell with a given size and length @@ -960,5 +1095,9 @@ def __init__(self, size, length): :type length: int """ base = (c_char * ((6 + size) * length))() - data = (c_char * (size * length)).from_buffer(base, 6 * BITSIZE['char'] * length) - super(Cell_Char, self).__init__(0, length, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p)) + data = (c_char * (size * length)).from_buffer( + base, 6 * BITSIZE["char"] * length + ) + super(Cell_Char, self).__init__( + 0, length, size, 0, 1, cast(base, c_void_p), cast(data, c_void_p) + )