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 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], t=t,use_physical=False)\ -evaluatePotentials(pot,thiso[0],0., t=t, use_physical=False)\ +thiso[4]**2./2. else: return nu.array([evaluatePotentials(pot,thiso[0,ii],thiso[3,ii], t=t[ii],use_physical=False)\ -evaluatePotentials(pot,thiso[0,ii],0., 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 '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], t=t,use_physical=False)\ +thiso[1]**2./2.\ +thiso[2]**2./2.\ +thiso[4]**2./2. else: return nu.array([evaluatePotentials(pot,thiso[0,ii],thiso[3,ii], t=t[ii],use_physical=False)\ +thiso[1,ii]**2./2.\ +thiso[2,ii]**2./2.\ +thiso[4,ii]**2./2. for ii in range(len(t))])
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': return plot.bovy_plot(nu.array(self.t), nu.array(self.EzJz) / self.EzJz[0], *args, **kwargs) elif d1 == 'z': return plot.bovy_plot(self.orbit[:, 3], nu.array(self.EzJz) / self.EzJz[0], *args, **kwargs) elif d1 == 'R': return plot.bovy_plot(self.orbit[:, 0], nu.array(self.EzJz) / self.EzJz[0], *args, **kwargs) elif d1 == 'vR': return plot.bovy_plot(self.orbit[:, 1], nu.array(self.EzJz) / self.EzJz[0], *args, **kwargs) elif d1 == 'vT': return plot.bovy_plot(self.orbit[:, 2], nu.array(self.EzJz) / self.EzJz[0], *args, **kwargs) elif d1 == 'vz': return 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.,t=self.t[ii], use_physical=False)+ self.orbit[ii,4]**2./2.)/\ nu.sqrt(evaluateDensities(pot,self.orbit[ii,0],0., 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': return plot.bovy_plot(nu.array(self.t), nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'z': return plot.bovy_plot(self.orbit[:,3], nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'R': return plot.bovy_plot(self.orbit[:,0], nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'vR': return plot.bovy_plot(self.orbit[:,1], nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'vT': return plot.bovy_plot(self.orbit[:,2], nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs) elif d1 == 'vz': return plot.bovy_plot(self.orbit[:,4], nu.array(self.EzJz)/self.EzJz[0], *args,**kwargs)