[Spice_discussion] Another Python interface to SPICE

Andrew Annex ama6fy at virginia.edu
Sat Sep 27 07:59:17 PDT 2014


Hello everyone!

Although I had not planned to announce it here until late October, I have
been writing my own python wrapper for SPICE called SpiceyPy for fun. This
grew from my work porting PySPICE into Python 3, I figured out that it
would be possible to wrap CSpice by first constructing a shared library of
spice from the provided static ones, and then using the standard ctypes
module
<https://docs.python.org/3/library/ctypes.html?highlight=ctypes#module-ctypes>
to
then write wrapper functions in pure python.

The advantage to the approach I took was that I was able to quickly write
wrapper functions and extend the function of the wrapper library. For
example, SpiceyPy currently runs in both Python 2 and 3 environments. Using
python only has also allowed me to closely integrate Numpy into the
wrapper, arrays and matrices are returned as numpy arrays for example. I
also have begun to mirror the vectorized functions available in ICY in my
wrapper.

As of writing this email, for N65 I have wrapper functions for 514
functions (around 98% of CSPICE). Also I have written unit tests, for 446
functions (around 85% of CSPICE). Most of these tests are lifted from the
CSPICE and ICY documentation.

Currently I do not support the Geometry Finder functions that use
callbacks, but it should be possible to support those, I have never used
them before so writing tests will be difficult without some help. Also I am
currently in the process of writing tests and fixing my wrapper functions
dealing with Event Kernels.

As for what is supported, a lot is. You can write most CK and SPK kernel
types, functions like EDLIMB and EDTERM are supported, I also support Cells
and Windows. In fact it is easier to talk about what I don't currently
support as I did in part above.  For specifics on which functions are
supported please look at this
<https://github.com/AndrewAnnex/SpiceyPy/wiki/Wrapper-Completion> page, I
update that page semi frequently so the test_wrapper.py file is more
representative and provides a good amount of example usage of SpiceyPy
<https://github.com/AndrewAnnex/SpiceyPy/blob/master/test/test_wrapper.py>.

I welcome feedback and in particular contributions to SpiceyPy, github
allows for code contributions to be easily discussed and merged in. If you
want to help out, email me or just go ahead and start sending me pull
requests. The current task is to get as many of the wrapper functions
written and tested as possible. I want to get my Coverall.io score to be
near 95% before I will be satisfied, you can view the current coverage here
<https://coveralls.io/r/AndrewAnnex/SpiceyPy>.

I am currently developing SpiceyPy on OS X 10.9.5, and I assume that it
works on most modern *NIX systems. Again I develop SpiceyPy on Python
3.4.1, Python 2.7.x is also supported but I would not recommend using any
python older than that as I have not tested it in such an environment. Make
sure you have the following python packages installed prior to installing
SpiceyPy: Numpy, Six, and Pytest.

If you have trouble installing SpiceyPy I will try to find some time this
weekend to update the Readme to be a bit clearer, but for now just download
and unzip the project, and run python setup.py install, it should
automatically download the correct version of CSPICE N65 for you. If it
doesn't just post an issue on the github page, and I will try to help when
I have time.

Here is the link to SpiceyPy! <https://github.com/AndrewAnnex/SpiceyPy>*


*P.S.: For those who I contacted about SpiceyPy previously, I have changed
my github username. The links above now point to the correct account.

-- 
Andrew Annex
University of Virginia, Class of 2014
College of Arts and Sciences, B.S. Environmental Science

On Fri, Sep 26, 2014 at 8:08 PM, Acton, Charles H (392N) <
charles.h.acton at jpl.nasa.gov> wrote:

>  FYI, for those interested in Python interfaces to SPICE.
>
>  Chuck Acton
>
>
>
>  From: Andrew Annex <ama6fy at virginia.edu <mailto:ama6fy at virginia.edu>
> <ama6fy at virginia.edu%3E>>
> Date: Sunday, September 7, 2014 10:32 AM
> To: "charles.h.acton at jpl.nasa.gov <mailto:charles.h.acton at jpl.nasa.gov>
> <charles.h.acton at jpl.nasa.gov%3E>"
> <charles.h.acton at jpl.nasa.gov <mailto:charles.h.acton at jpl.nasa.gov>
> <charles.h.acton at jpl.nasa.gov%3E>>
> Subject: Re: A new Python wrapper for Spice, SpiceyPy
>
>  Hello again Mr. Acton, I just wanted to check in with you again and to
> update
> you on the progress I have been making with my Python wrapper for CSPICE.
> Over
> the past two months I have wrote a substantial number of tests for my
> python
> functions, most of them are directly from the C and ICY documentation. The
> purpose of these tests is that they are in a automated test suite, which
> can be
> run to ensure that I made no breaking changes. I have fixed numerous
> errors in
> my own code and I have also learned a lot about spice in general so
> although it
> was a lot of work I am glad I made the decision to write them. As of now,
> and
> this can be seen on the github page, I have around 82% test coverage,
> meaning
> about 82% of the wrapper functions have some test called for it. What
> remains is
> most of the event kernel functions and a number of spk related functions,
> as
> well as the geometry finder functions. In essence there are around 100
> functions
> that remain untested. In other areas I have made some important changes
> such as
> defaulting to exporting numpy arrays for functions that return numeric
> arrays
> and matrices. I am also in the process of writing wrapper functions for
> the new
> functions added in the N65 release, which I have at least partially
> completed.
>    So while plenty of work remains, the wrapper is maturing. I will
> probably
> email you again in another month or two, to give you another progress
> update. If
> naif members find to time to try out SpiceyPy I would love feedback and or
> contributions to the project via pull requests on github.
>
>  Thanks again,
> -Andrew
>
>
> _______________________________________________
> Spice_discussion mailing list
> Spice_discussion at naif.jpl.nasa.gov
> http://naif.jpl.nasa.gov/mailman/listinfo/spice_discussion
>
>


-- 
Andrew Annex
University of Virginia, Class of 2014
College of Arts and Sciences, B.S. Environmental Science
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://naif.jpl.nasa.gov/pipermail/spice_discussion/attachments/20140927/cdfd1d79/attachment-0001.html>


More information about the Spice_discussion mailing list