def _wrap_pot_func(self,attribute): if attribute == '_evaluate': return evaluatePotentials elif attribute == '_dens': return evaluateDensities elif attribute == '_Rforce': return evaluateRforces elif attribute == '_zforce': return evaluatezforces elif attribute == '_phiforce': return evaluatephiforces elif attribute == '_R2deriv': return evaluateR2derivs elif attribute == '_z2deriv': return evaluatez2derivs elif attribute == '_Rzderiv': return evaluateRzderivs elif attribute == '_phi2deriv': return lambda p,R,Z,phi=0.,t=0.: \ evaluatePotentials(p,R,Z,phi=phi,t=t,dphi=2) elif attribute == '_Rphideriv': return lambda p,R,Z,phi=0.,t=0.: \ evaluatePotentials(p,R,Z,phi=phi,t=t,dR=1,dphi=1) else: #pragma: no cover raise AttributeError("Attribute %s not found in for this WrapperPotential" % attribute)
def _wrap_pot_func(self,attribute): if attribute == '_evaluate': return evaluatePotentials elif attribute == '_dens': return evaluateDensities elif attribute == '_Rforce': return evaluateRforces elif attribute == '_zforce': return evaluatezforces elif attribute == '_phiforce': return evaluatephiforces elif attribute == '_R2deriv': return evaluateR2derivs elif attribute == '_z2deriv': return evaluatez2derivs elif attribute == '_Rzderiv': return evaluateRzderivs elif attribute == '_phi2deriv': return lambda p,R,Z,phi=0.,t=0.: \ evaluatePotentials(p,R,Z,phi=phi,t=t,dphi=2) elif attribute == '_Rphideriv': return lambda p,R,Z,phi=0.,t=0.: \ evaluatePotentials(p,R,Z,phi=phi,t=t,dR=1,dphi=1) else: #pragma: no cover raise AttributeError("Attribute %s not found in for this WrapperPotential" % attribute)
def plotEzJz(self,*args,**kwargs): """ NAME: plotEzJz PURPOSE: plot E_z(.)/sqrt(dens(R)) along the orbit INPUT: pot= Potential instance or list of instances in which the orbit was integrated d1= - plot Ez vs d1: e.g., 't', 'z', 'R', 'vR', 'vT', 'vz' +bovy_plot.bovy_plot inputs OUTPUT: figure to output device HISTORY: 2010-08-08 - Written - Bovy (NYU) """ labeldict= {'t':r'$t$','R':r'$R$','vR':r'$v_R$','vT':r'$v_T$', 'z':r'$z$','vz':r'$v_z$','phi':r'$\phi$', 'x':r'$x$','y':r'$y$','vx':r'$v_x$','vy':r'$v_y$'} if not 'pot' in kwargs: try: pot= self._pot except AttributeError: raise AttributeError("Integrate orbit first or specify pot=") else: pot= kwargs.pop('pot') d1= kwargs.pop('d1','t') self.EzJz= [(evaluatePotentials(pot,self.orbit[ii,0],self.orbit[ii,3], t=self.t[ii],use_physical=False)- evaluatePotentials(pot,self.orbit[ii,0],0., phi= self.orbit[ii,5],t=self.t[ii], use_physical=False)+ self.orbit[ii,4]**2./2.)/\ nu.sqrt(evaluateDensities(pot,self.orbit[ii,0],0., phi=self.orbit[ii,5], t=self.t[ii], use_physical=False))\ for ii in range(len(self.t))] if not 'xlabel' in kwargs: kwargs['xlabel']= labeldict[d1] if not 'ylabel' in kwargs: kwargs['ylabel']= r'$E_z/\sqrt{\rho}$' if d1 == 't': plot.bovy_plot(nu.array(self.t),nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'z': plot.bovy_plot(self.orbit[:,3],nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'R': plot.bovy_plot(self.orbit[:,0],nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'vR': plot.bovy_plot(self.orbit[:,1],nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'vT': plot.bovy_plot(self.orbit[:,2],nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'vz': plot.bovy_plot(self.orbit[:,4],nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs)
def plotEzJz(self,*args,**kwargs): """ NAME: plotEzJz PURPOSE: plot E_z(.)/sqrt(dens(R)) along the orbit INPUT: pot= Potential instance or list of instances in which the orbit was integrated d1= - plot Ez vs d1: e.g., 't', 'z', 'R', 'vR', 'vT', 'vz' +bovy_plot.bovy_plot inputs OUTPUT: figure to output device HISTORY: 2010-08-08 - Written - Bovy (NYU) """ labeldict= {'t':r'$t$','R':r'$R$','vR':r'$v_R$','vT':r'$v_T$', 'z':r'$z$','vz':r'$v_z$','phi':r'$\phi$', 'x':r'$x$','y':r'$y$','vx':r'$v_x$','vy':r'$v_y$'} if not 'pot' in kwargs: try: pot= self._pot except AttributeError: raise AttributeError("Integrate orbit first or specify pot=") else: pot= kwargs.pop('pot') d1= kwargs.pop('d1','t') self.EzJz= [(evaluatePotentials(pot,self.orbit[ii,0],self.orbit[ii,3], t=self.t[ii],use_physical=False)- evaluatePotentials(pot,self.orbit[ii,0],0., phi= self.orbit[ii,5],t=self.t[ii], use_physical=False)+ self.orbit[ii,4]**2./2.)/\ nu.sqrt(evaluateDensities(pot,self.orbit[ii,0],0., phi=self.orbit[ii,5], t=self.t[ii], use_physical=False))\ for ii in range(len(self.t))] if not 'xlabel' in kwargs: kwargs['xlabel']= labeldict[d1] if not 'ylabel' in kwargs: kwargs['ylabel']= r'$E_z/\sqrt{\rho}$' if d1 == 't': plot.bovy_plot(nu.array(self.t),nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'z': plot.bovy_plot(self.orbit[:,3],nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'R': plot.bovy_plot(self.orbit[:,0],nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'vR': plot.bovy_plot(self.orbit[:,1],nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'vT': plot.bovy_plot(self.orbit[:,2],nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'vz': plot.bovy_plot(self.orbit[:,4],nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs)
def plotEz(self,*args,**kwargs): """ NAME: plotEz PURPOSE: plot E_z(.) along the orbit INPUT: pot= Potential instance or list of instances in which the orbit was integrated d1= - plot Ez vs d1: e.g., 't', 'z', 'R', 'vR', 'vT', 'vz' +bovy_plot.bovy_plot inputs OUTPUT: figure to output device HISTORY: 2010-07-10 - Written - Bovy (NYU) """ labeldict= {'t':r'$t$','R':r'$R$','vR':r'$v_R$','vT':r'$v_T$', 'z':r'$z$','vz':r'$v_z$','phi':r'$\phi$', 'x':r'$x$','y':r'$y$','vx':r'$v_x$','vy':r'$v_y$'} if not kwargs.has_key('pot'): try: pot= self._pot except AttributeError: raise AttributeError("Integrate orbit first or specify pot=") else: pot= kwargs['pot'] kwargs.pop('pot') if kwargs.has_key('d1'): d1= kwargs['d1'] kwargs.pop('d1') else: d1= 't' self.Ezs= [evaluatePotentials(self.orbit[ii,0],self.orbit[ii,3],pot, t=self.t[ii])- evaluatePotentials(self.orbit[ii,0],0.,pot,t=self.t[ii])+ self.orbit[ii,4]**2./2. for ii in range(len(self.t))] if not kwargs.has_key('xlabel'): kwargs['xlabel']= labeldict[d1] if not kwargs.has_key('ylabel'): kwargs['ylabel']= r'$E_z$' if d1 == 't': plot.bovy_plot(nu.array(self.t),nu.array(self.Ezs)/self.Ezs[0], *args,**kwargs) elif d1 == 'z': plot.bovy_plot(self.orbit[:,3],nu.array(self.Ezs)/self.Ezs[0], *args,**kwargs) elif d1 == 'R': plot.bovy_plot(self.orbit[:,0],nu.array(self.Ezs)/self.Ezs[0], *args,**kwargs) elif d1 == 'vR': plot.bovy_plot(self.orbit[:,1],nu.array(self.Ezs)/self.Ezs[0], *args,**kwargs) elif d1 == 'vT': plot.bovy_plot(self.orbit[:,2],nu.array(self.Ezs)/self.Ezs[0], *args,**kwargs) elif d1 == 'vz': plot.bovy_plot(self.orbit[:,4],nu.array(self.Ezs)/self.Ezs[0], *args,**kwargs)
def Ez(self,*args,**kwargs): """ NAME: Ez PURPOSE: calculate the vertical energy INPUT: t - (optional) time at which to get the energy pot= potential instance or list of such instances OUTPUT: vertical energy HISTORY: 2013-11-30 - Written - Bovy (IAS) """ if not kwargs.has_key('pot') or kwargs['pot'] is None: try: pot= self._pot except AttributeError: raise AttributeError("Integrate orbit or specify pot=") if kwargs.has_key('pot') and kwargs['pot'] is None: kwargs.pop('pot') else: pot= kwargs['pot'] kwargs.pop('pot') if len(args) > 0: t= args[0] else: t= 0. #Get orbit thiso= self(*args,**kwargs) onet= (len(thiso.shape) == 1) if onet: return evaluatePotentials(thiso[0],thiso[3],pot, phi=thiso[5],t=t)\ -evaluatePotentials(thiso[0],0.,pot, phi=thiso[5],t=t)\ +thiso[4]**2./2. else: return nu.array([evaluatePotentials(thiso[0,ii],thiso[3,ii], pot,phi=thiso[5,ii], t=t[ii])\ -evaluatePotentials(thiso[0,ii],0., pot,phi=thiso[5,ii], t=t[ii])\ +thiso[4,ii]**2./2. for ii in range(len(t))])
def Ez(self,*args,**kwargs): """ NAME: Ez PURPOSE: calculate the vertical energy INPUT: t - (optional) time at which to get the energy pot= potential instance or list of such instances OUTPUT: vertical energy HISTORY: 2013-11-30 - Written - Bovy (IAS) """ if not 'pot' in kwargs or kwargs['pot'] is None: try: pot= self._pot except AttributeError: raise AttributeError("Integrate orbit or specify pot=") if 'pot' in kwargs and kwargs['pot'] is None: kwargs.pop('pot') else: pot= kwargs.pop('pot') if len(args) > 0: t= args[0] else: t= 0. #Get orbit thiso= self(*args,**kwargs) onet= (len(thiso.shape) == 1) if onet: return evaluatePotentials(pot,thiso[0],thiso[3], phi=thiso[5],t=t,use_physical=False)\ -evaluatePotentials(pot,thiso[0],0., phi=thiso[5],t=t, use_physical=False)\ +thiso[4]**2./2. else: return nu.array([evaluatePotentials(pot,thiso[0,ii],thiso[3,ii], phi=thiso[5,ii], t=t[ii],use_physical=False)\ -evaluatePotentials(pot,thiso[0,ii],0., phi=thiso[5,ii], t=t[ii],use_physical=False)\ +thiso[4,ii]**2./2. for ii in range(len(t))])
def E(self,*args,**kwargs): """ NAME: E PURPOSE: calculate the energy INPUT: t - (optional) time at which to get the radius pot= RZPotential instance or list thereof OUTPUT: energy HISTORY: 2010-09-15 - Written - Bovy (NYU) """ if not kwargs.has_key('pot') or kwargs['pot'] is None: try: pot= self._pot except AttributeError: raise AttributeError("Integrate orbit or specify pot=") if kwargs.has_key('pot') and kwargs['pot'] is None: kwargs.pop('pot') else: pot= kwargs['pot'] kwargs.pop('pot') if len(args) > 0: t= args[0] else: t= 0. #Get orbit thiso= self(*args,**kwargs) onet= (len(thiso.shape) == 1) if onet: return evaluatePotentials(thiso[0],thiso[3],pot, t=t)\ +thiso[1]**2./2.\ +thiso[2]**2./2.\ +thiso[4]**2./2. else: return nu.array([evaluatePotentials(thiso[0,ii],thiso[3,ii], pot, t=t[ii])\ +thiso[1,ii]**2./2.\ +thiso[2,ii]**2./2.\ +thiso[4,ii]**2./2. for ii in range(len(t))])
def E(self, *args, **kwargs): """ NAME: E PURPOSE: calculate the energy INPUT: t - (optional) time at which to get the radius pot= potential instance or list of such instances OUTPUT: energy HISTORY: 2010-09-15 - Written - Bovy (NYU) """ if not kwargs.has_key('pot') or kwargs['pot'] is None: try: pot = self._pot except AttributeError: raise AttributeError("Integrate orbit or specify pot=") if kwargs.has_key('pot') and kwargs['pot'] is None: kwargs.pop('pot') else: pot = kwargs['pot'] kwargs.pop('pot') if len(args) > 0: t = args[0] else: t = 0. #Get orbit thiso = self(*args, **kwargs) onet = (len(thiso.shape) == 1) if onet: return evaluatePotentials(thiso[0],thiso[3],thispot, phi=thiso[5],t=t)\ +thiso[1]**2./2.\ +thiso[2]**2./2.\ +thiso[4]**2./2. else: return nu.array([evaluatePotentials(thiso[0,ii],thiso[3,ii], pot,phi=thiso[5,ii], t=t[ii])\ +thiso[1,ii]**2./2.\ +thiso[2,ii]**2./2.\ +thiso[4,ii]**2./2. for ii in range(len(t))])
def plotEz(self, *args, **kwargs): """ NAME: plotEz PURPOSE: plot E_z(.) along the orbit INPUT: pot - Potential instance or list of instances in which the orbit was integrated +bovy_plot.bovy_plot inputs OUTPUT: figure to output device HISTORY: 2010-07-10 - Written - Bovy (NYU) """ labeldict = { 't': r'$t$', 'R': r'$R$', 'vR': r'$v_R$', 'vT': r'$v_T$', 'z': r'$z$', 'vz': r'$v_z$', 'phi': r'$\phi$', 'x': r'$x$', 'y': r'$y$', 'vx': r'$v_x$', 'vy': r'$v_y$' } if not kwargs.has_key('pot'): try: pot = self._pot except AttributeError: raise AttributeError("Integrate orbit first or specify pot=") else: pot = kwargs['pot'] kwargs.pop('pot') if kwargs.has_key('d1'): d1 = kwargs['d1'] kwargs.pop('d1') else: d1 = 't' self.Ezs = [ evaluatePotentials(self.orbit[ii, 0], self.orbit[ii, 3], pot, phi=self.orbit[ii, 5], t=self.t[ii]) - evaluatePotentials(self.orbit[ii, 0], 0., pot, phi=self.orbit[ii, 5], t=self.t[ii]) + self.orbit[ii, 4]**2. / 2. for ii in range(len(self.t)) ] if not kwargs.has_key('xlabel'): kwargs['xlabel'] = labeldict[d1] if not kwargs.has_key('ylabel'): kwargs['ylabel'] = r'$E_z$' if d1 == 't': plot.bovy_plot(nu.array(self.t), nu.array(self.Ezs) / self.Ezs[0], *args, **kwargs) elif d1 == 'z': plot.bovy_plot(self.orbit[:, 3], nu.array(self.Ezs) / self.Ezs[0], *args, **kwargs) elif d1 == 'R': plot.bovy_plot(self.orbit[:, 0], nu.array(self.Ezs) / self.Ezs[0], *args, **kwargs) elif d1 == 'vR': plot.bovy_plot(self.orbit[:, 1], nu.array(self.Ezs) / self.Ezs[0], *args, **kwargs) elif d1 == 'vT': plot.bovy_plot(self.orbit[:, 2], nu.array(self.Ezs) / self.Ezs[0], *args, **kwargs) elif d1 == 'vz': plot.bovy_plot(self.orbit[:, 4], nu.array(self.Ezs) / self.Ezs[0], *args, **kwargs) elif d1 == 'phi': plot.bovy_plot(self.orbit[:, 5], nu.array(self.Ezs) / self.Ezs[0], *args, **kwargs)