本文整理汇总了Python中galpy.potential_src.Potential.Potential类的典型用法代码示例。如果您正苦于以下问题:Python Potential类的具体用法?Python Potential怎么用?Python Potential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Potential类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self,amp=1.,pot=None,ro=None,vo=None,_init=None,**kwargs):
"""
NAME:
__init__
PURPOSE:
initialize a WrapperPotential, a super-class for wrapper potentials
INPUT:
amp - amplitude to be applied to the potential (default: 1.)
pot - Potential instance or list thereof; the amplitude of this will be grown by this wrapper
OUTPUT:
(none)
HISTORY:
2017-06-26 - Started - Bovy (UofT)
"""
if not _init: return None # Don't run __init__ at the end of setup
Potential.__init__(self,amp=amp,ro=ro,vo=vo)
self._pot= pot
self.isNonAxi= _isNonAxi(self._pot)
示例2: __init__
def __init__(self,amp=1.,alpha=1.,normalize=False):
"""
NAME:
__init__
PURPOSE:
initialize a power-law-density potential
INPUT:
amp - amplitude to be applied to the potential (default: 1)
alpha - inner power
normalize - if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
OUTPUT:
(none)
HISTORY:
2010-07-10 - Written - Bovy (NYU)
"""
Potential.__init__(self,amp=amp)
self.alpha= alpha
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)):
self.normalize(normalize)
self.hasC= True
self.hasC_dxdv= True
示例3: __init__
def __init__(self,amp=1.,a=5.,alpha=1.5,beta=3.5,normalize=False,
ro=None,vo=None):
"""
NAME:
__init__
PURPOSE:
initialize a two-power-density potential
INPUT:
amp - amplitude to be applied to the potential (default: 1); can be a Quantity with units of mass or Gxmass
a - scale radius (can be Quantity)
alpha - inner power
beta - outer power
normalize - if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
(none)
HISTORY:
2010-07-09 - Started - Bovy (NYU)
"""
if alpha == round(alpha) and beta == round(beta):
Potential.__init__(self,amp=amp,ro=ro,vo=vo,amp_units='mass')
integerSelf= TwoPowerIntegerSphericalPotential(amp=1.,a=a,
alpha=int(alpha),
beta=int(beta),
normalize=False)
self.integerSelf= integerSelf
else:
Potential.__init__(self,amp=amp,ro=ro,vo=vo,amp_units='mass')
self.integerSelf= None
if _APY_LOADED and isinstance(a,units.Quantity):
a= a.to(units.kpc).value/self._ro
self.a= a
self._scale= self.a
self.alpha= alpha
self.beta= beta
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)): #pragma: no cover
self.normalize(normalize)
return None
示例4: __init__
def __init__(self,orbit,amp=1.,GM=.06,
ro=None,vo=None,
softening=None,
softening_model='plummer',softening_length=0.01):
"""
NAME:
__init__
PURPOSE:
initialize a MovingObjectPotential
INPUT:
orbit - the Orbit of the object (Orbit object)
amp= - amplitude to be applied to the potential (default: 1); can be a Quantity with units of mass or Gxmass
GM - 'mass' of the object (degenerate with amp, don't use both); can be a Quantity with units of mass or Gxmass
Softening: either provide
a) softening= with a ForceSoftening-type object
b) softening_model= type of softening to use ('plummer')
softening_length= (optional; can be Quantity)
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
(none)
HISTORY:
2011-04-10 - Started - Bovy (NYU)
"""
Potential.__init__(self,amp=amp*GM,ro=ro,vo=vo,amp_units='mass')
if _APY_LOADED and isinstance(softening_length,units.Quantity):
softening_length= softening_length.to(units.kpc).value/self._ro
# Make sure we aren't getting physical outputs
self._orb= copy.deepcopy(orbit)
self._orb.turn_physical_off()
if softening is None:
if softening_model.lower() == 'plummer':
self._softening= PlummerSoftening(softening_length=softening_length)
else:
self._softening= softening
self.isNonAxi= True
return None
示例5: __init__
def __init__(self,amp=1.,alpha=0.5,q=0.9,core=_CORE,normalize=False,r1=1.,
ro=None,vo=None):
"""
NAME:
__init__
PURPOSE:
initialize a flattened power-law potential
INPUT:
amp - amplitude to be applied to the potential (default: 1); can be a Quantity with units of velocity-squared
alpha - power
q - flattening
core - core radius (can be Quantity)
r1= (1.) reference radius for amplitude (can be Quantity)
normalize - if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
(none)
HISTORY:
2013-01-09 - Written - Bovy (IAS)
"""
Potential.__init__(self,amp=amp,ro=ro,vo=vo,amp_units='velocity2')
if _APY_LOADED and isinstance(core,units.Quantity):
core= core.to(units.kpc).value/self._ro
if _APY_LOADED and isinstance(r1,units.Quantity):
r1= r1.to(units.kpc).value/self._ro
self.alpha= alpha
self.q2= q**2.
self.core2= core**2.
# Back to old definition
self._amp*= r1**self.alpha
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)): #pragma: no cover
self.normalize(normalize)
self.hasC= True
self.hasC_dxdv= True
示例6: __init__
def __init__(self,amp=1.,hr=1./3.,
maxiter=_MAXITER,tol=0.001,normalize=False,
ro=None,vo=None,
new=True,glorder=100):
"""
NAME:
__init__
PURPOSE:
initialize a razor-thin-exponential disk potential
INPUT:
amp - amplitude to be applied to the potential (default: 1); can be a Quantity with units of surface-mass or Gxsurface-mass
hr - disk scale-length (can be Quantity)
tol - relative accuracy of potential-evaluations
maxiter - scipy.integrate keyword
normalize - if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
RazorThinExponentialDiskPotential object
HISTORY:
2012-12-27 - Written - Bovy (IAS)
"""
Potential.__init__(self,amp=amp,ro=ro,vo=vo,amp_units='surfacedensity')
if _APY_LOADED and isinstance(hr,units.Quantity):
hr= hr.to(units.kpc).value/self._ro
self._new= new
self._glorder= glorder
self._hr= hr
self._scale= self._hr
self._alpha= 1./self._hr
self._maxiter= maxiter
self._tol= tol
self._glx, self._glw= nu.polynomial.legendre.leggauss(self._glorder)
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)): #pragma: no cover
self.normalize(normalize)
示例7: __init__
def __init__(self,amp=1.,core=_CORE,q=1.,b=None,normalize=False,
ro=None,vo=None):
"""
NAME:
__init__
PURPOSE:
initialize a logarithmic potential
INPUT:
amp - amplitude to be applied to the potential (default: 1); can be a Quantity with units of velocity-squared
core - core radius at which the logarithm is cut (can be Quantity)
q - potential flattening (z/q)**2.
b= (None) if set, shape parameter in y-direction (y --> y/b; see definition)
normalize - if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
(none)
HISTORY:
2010-04-02 - Started - Bovy (NYU)
"""
Potential.__init__(self,amp=amp,ro=ro,vo=vo,amp_units='velocity2')
if _APY_LOADED and isinstance(core,units.Quantity):
core= core.to(units.kpc).value/self._ro
self.hasC= True
self.hasC_dxdv= True
self._core2= core**2.
self._q= q
self._b= b
if not self._b is None:
self.isNonAxi= True
self._1m1overb2= 1.-1./self._b**2.
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)): #pragma: no cover
self.normalize(normalize)
self._nemo_accname= 'LogPot'
return None
示例8: __init__
def __init__(self,amp=1.,alpha=1.,rc=1.,normalize=False,r1=1.,
ro=None,vo=None):
"""
NAME:
__init__
PURPOSE:
initialize a power-law-density potential
INPUT:
amp= amplitude to be applied to the potential (default: 1); can be a Quantity with units of mass density or Gxmass density
alpha= inner power
rc= cut-off radius (can be Quantity)
r1= (1.) reference radius for amplitude (can be Quantity)
normalize= if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
(none)
HISTORY:
2013-06-28 - Written - Bovy (IAS)
"""
Potential.__init__(self,amp=amp,ro=ro,vo=vo,amp_units='density')
if _APY_LOADED and isinstance(r1,units.Quantity):
r1= r1.to(units.kpc).value/self._ro
if _APY_LOADED and isinstance(rc,units.Quantity):
rc= rc.to(units.kpc).value/self._ro
self.alpha= alpha
# Back to old definition
self._amp*= r1**self.alpha
self.rc= rc
self._scale= self.rc
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)): #pragma: no cover
self.normalize(normalize)
self.hasC= True
self.hasC_dxdv= True
self._nemo_accname= 'PowSphwCut'
示例9: __init__
def __init__(self, s, num_threads=None,nazimuths=4,
ro=None,vo=None):
"""
NAME:
__init__
PURPOSE:
Initialize a SnapshotRZ potential object
INPUT:
s - a simulation snapshot loaded with pynbody
num_threads= (4) number of threads to use for calculation
nazimuths= (4) number of azimuths to average over
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
instance
HISTORY:
2013 - Written - Rok Roskar (ETH)
2014-11-24 - Edited for merging into main galpy - Bovy (IAS)
"""
if not _PYNBODY_LOADED:
raise ImportError("The SnapShotRZPotential class is designed to work with pynbody snapshots, which cannot be loaded (probably because it is not installed) -- obtain from pynbody.github.io")
Potential.__init__(self,amp=1.0,ro=ro,vo=vo)
self._s = s
self._point_hash = {}
if num_threads is None:
self._num_threads= pynbody.config['number_of_threads']
else:
self._num_threads = num_threads
# Set up azimuthal averaging
self._naz= nazimuths
self._cosaz= np.cos(np.arange(self._naz,dtype='float')\
/self._naz*2.*np.pi)
self._sinaz= np.sin(np.arange(self._naz,dtype='float')\
/self._naz*2.*np.pi)
self._zones= np.ones(self._naz)
self._zzeros= np.zeros(self._naz)
return None
示例10: __init__
def __init__(self,amp=1.,a=5.,alpha=1.5,beta=3.5,normalize=False):
"""
NAME:
__init__
PURPOSE:
initialize a two-power-density potential
INPUT:
amp - amplitude to be applied to the potential (default: 1)
a - "scale" (in terms of Ro)
alpha - inner power
beta - outer power
normalize - if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
OUTPUT:
(none)
HISTORY:
2010-07-09 - Started - Bovy (NYU)
"""
self.a= a
self._scale= self.a
self.alpha= alpha
self.beta= beta
if alpha == round(alpha) and beta == round(beta):
Potential.__init__(self,amp=amp)
integerSelf= TwoPowerIntegerSphericalPotential(amp=1.,a=a,
alpha=int(alpha),
beta=int(beta),
normalize=False)
self.integerSelf= integerSelf
else:
Potential.__init__(self,amp=amp)
self.integerSelf= None
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)): #pragma: no cover
self.normalize(normalize)
return None
示例11: __init__
def __init__(self,amp=1.,a=1.,b=0.1,normalize=False,
ro=None,vo=None):
"""
NAME:
__init__
PURPOSE:
initialize a Miyamoto-Nagai potential
INPUT:
amp - amplitude to be applied to the potential (default: 1); can be a Quantity with units of mass or Gxmass
a - scale length (can be Quantity)
b - scale height (can be Quantity)
normalize - if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
(none)
HISTORY:
2010-07-09 - Started - Bovy (NYU)
"""
Potential.__init__(self,amp=amp,ro=ro,vo=vo,amp_units='mass')
if _APY_LOADED and isinstance(a,units.Quantity):
a= a.to(units.kpc).value/self._ro
if _APY_LOADED and isinstance(b,units.Quantity):
b= b.to(units.kpc).value/self._ro
self._a= a
self._scale= self._a
self._b= b
self._b2= self._b**2.
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)):
self.normalize(normalize)
self.hasC= True
self.hasC_dxdv= True
self._nemo_accname= 'MiyamotoNagai'
示例12: __init__
def __init__(self,amp=1.,ro=1.,hr=1./3.,
maxiter=_MAXITER,tol=0.001,normalize=False,
new=True,glorder=100):
"""
NAME:
__init__
PURPOSE:
initialize a razor-thin-exponential disk potential
INPUT:
amp - amplitude to be applied to the potential (default: 1)
hr - disk scale-length in terms of ro
tol - relative accuracy of potential-evaluations
maxiter - scipy.integrate keyword
normalize - if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
OUTPUT:
RazorThinExponentialDiskPotential object
HISTORY:
2012-12-27 - Written - Bovy (IAS)
"""
Potential.__init__(self,amp=amp)
self._new= new
self._glorder= glorder
self._ro= ro
self._hr= hr
self._scale= self._hr
self._alpha= 1./self._hr
self._maxiter= maxiter
self._tol= tol
self._glx, self._glw= nu.polynomial.legendre.leggauss(self._glorder)
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)): #pragma: no cover
self.normalize(normalize)
示例13: __init__
def __init__(self,orbit,amp=1.,GM=.06,
softening=None,
softening_model='plummer',softening_length=0.01):
"""
NAME:
__init__
PURPOSE:
initialize a MovingObjectPotential
INPUT:
orbit - the Orbit of the object (Orbit object)
amp= - amplitude to be applied to the potential (default: 1)
GM - 'mass' of the object (degenerate with amp)
Softening: either provide
a) softening= with a ForceSoftening-type object
b) softening_model= type of softening to use ('plummer')
softening_length= (optional)
OUTPUT:
(none)
HISTORY:
2011-04-10 - Started - Bovy (NYU)
"""
Potential.__init__(self,amp=amp)
self._gm= GM
self._orb= orbit
if softening is None:
if softening_model.lower() == 'plummer':
self._softening= PlummerSoftening(softening_length=softening_length)
else:
self._softening= softening
self.isNonAxi= True
return None
示例14: __init__
def __init__(self,amp=1.,ac=5.,Delta=1.,normalize=False,
ro=None,vo=None):
"""
NAME:
__init__
PURPOSE:
initialize a Kuzmin-Kutuzov Staeckel potential
INPUT:
amp - amplitude to be applied to the potential (default: 1); can be a Quantity with units of mass density or Gxmass density
ac - axis ratio of the coordinate surfaces; (a/c) = sqrt(-alpha) / sqrt(-gamma) (default: 5.)
Delta - focal distance that defines the spheroidal coordinate system (default: 1.); Delta=sqrt(gamma-alpha) (can be Quantity)
normalize - if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
(none)
HISTORY:
2015-02-15 - Written - Trick (MPIA)
"""
Potential.__init__(self,amp=amp,ro=ro,vo=vo,amp_units='mass')
if _APY_LOADED and isinstance(Delta,units.Quantity):
Delta= Delta.to(units.kpc).value/self._ro
self._ac = ac
self._Delta = Delta
self._gamma = self._Delta**2 / (1.-self._ac**2)
self._alpha = self._gamma - self._Delta**2
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)):
self.normalize(normalize)
self.hasC = True
self.hasC_dxdv = True
示例15: __init__
def __init__(self,amp=1.,alpha=1.,normalize=False,r1=1.,
ro=None,vo=None):
"""
NAME:
__init__
PURPOSE:
initialize a power-law-density potential
INPUT:
amp - amplitude to be applied to the potential (default: 1); can be a Quantity with units of mass density or Gxmass density
alpha - inner power
r1= (1.) reference radius for amplitude (can be Quantity)
normalize - if True, normalize such that vc(1.,0.)=1., or, if given as a number, such that the force is this fraction of the force necessary to make vc(1.,0.)=1.
ro=, vo= distance and velocity scales for translation into internal units (default from configuration file)
OUTPUT:
(none)
HISTORY:
2010-07-10 - Written - Bovy (NYU)
"""
Potential.__init__(self,amp=amp,ro=ro,vo=vo,amp_units='mass')
if _APY_LOADED and isinstance(r1,units.Quantity):
r1= r1.to(units.kpc).value/self._ro
self.alpha= alpha
# Back to old definition
if self.alpha != 3.:
self._amp*= r1**(self.alpha-3.)*4.*nu.pi/(3.-self.alpha)
if normalize or \
(isinstance(normalize,(int,float)) \
and not isinstance(normalize,bool)):
self.normalize(normalize)
self.hasC= True
self.hasC_dxdv= True