Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/python
# this demo script shows how to use Agama library in galpy:
# creating a galpy-compatible potential, integrating an orbit and using the action finder
import galpy.potential, galpy.actionAngle, galpy.orbit
import pygama as agama
import numpy, matplotlib, matplotlib.pyplot as plt, time
matplotlib.rcParams['legend.frameon']=False
### set up galpy potential
g_pot = galpy.potential.MWPotential2014
### set up equivalent potential from the Agama library
agama.setUnits( mass=1., length=8., velocity=220)
a_pot = agama.AgamaPotential("../data/MWPotential2014galpy.ini")
c_pot = a_pot._pot # the instance of raw Agama potential
### initialization of the action finder needs to be done once for the given potential
dt = time.time()
c_actfinder = agama.ActionFinder(c_pot, interp=False)
print 'Time to set up action finder: %.4g s' % (time.time()-dt)
### we have a faster but less accurate "interpolated action finder", which takes a bit longer to initialize
dt = time.time()
i_actfinder = agama.ActionFinder(c_pot, interp=True)
print 'Time to set up interpolated action finder: %.4g s' % (time.time()-dt)
### conversion from prolate spheroidal to cylindrical coords