[Spice_discussion] PySPICE

K.-Michael Aye kmichael.aye at googlemail.com
Tue Mar 22 04:52:30 PDT 2011


Dear all,

I just wanted to let you know, that with the help of Roberto we got his PySPICE code working on current Snow Leopard Macbooks. 
The current restriction is that cells and windows are not implemented (yet, some start is provided by Roberto), but if you can live without it, it allows already beautifully simple SPICE workings:

from matplotlib.pylab import plot,show
from spice import *
import datetime
import sys

furnsh('bepic.mk')

radii = bodvrd('MERCURY','RADII',3)
print radii
daterange=['2021 JAN 30 12:00:00.000', '2022 MAY 02 03:42:42.623']

et1 = utc2et(daterange[0])
et2 = utc2et(daterange[1])
print et2utc(et2,'ISOC',5)
times = linspace(et1,et2,100)
print et2utc(times[-1],'ISOC',5)

distances = []
for t in times:
    try:
        pos = spkpos('mercury',t,'j2000','none','mpo')
    except SpiceException:
        print 'caught error'
        sys.exit(1)
    distances.append(vnorm(pos[0]))
    
plot(times,array(distances)-radii[1][0])
show()

His code is available at
https://github.com/rca/PySPICE

Have fun!
Michael




More information about the Spice_discussion mailing list