Skip to content

Commit

Permalink
Convenience function to compute the density and mean frequency simult…
Browse files Browse the repository at this point in the history
…aneously for speed-up
  • Loading branch information
jobovy committed Feb 5, 2016
1 parent 52b6357 commit 1e649a3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions galpy/df_src/streampepperdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,14 @@ def _density_par(self,dangle,tdisrupt=None,approx=True,
-1.,1.,
limit=100,epsabs=1.e-06,epsrel=1.e-06)[0]\
*smooth_dens
def _densityAndOmega_par_approx(self,dangle):
"""Convenience function to return both, avoiding doubling the computational time"""
# First get the approximate PD
ul,da,ti,c0,c1= self._approx_pdf(dangle,False)
return (self._density_par_approx(dangle,self._tdisrupt,False,False,
ul,da,ti,c0,c1),
self._meanOmega_approx(dangle,self._tdisrupt,False,
ul,da,ti,c0,c1))

def _density_par_approx(self,dangle,tdisrupt,
force_indiv_impacts,
Expand Down Expand Up @@ -843,10 +851,15 @@ def meanOmega(self,dangle,oned=False,approx=True,
return self._progenitor_Omega+dO1D*self._dsigomeanProgDirection\
*self._sigMeanSign

def _meanOmega_approx(self,dangle,tdisrupt,force_indiv_impacts):
def _meanOmega_approx(self,dangle,tdisrupt,force_indiv_impacts,
*args):
"""Compute the mean frequency as a function of parallel angle using the
spline representations"""
ul,da,ti,c0,c1= self._approx_pdf(dangle,force_indiv_impacts)
if len(args) == 0:
ul,da,ti,c0,c1= self._approx_pdf(dangle,force_indiv_impacts)
else:
ul,da,ti,c0,c1= args
ul= copy.copy(ul)
# Get the density in various forms
dens_arr= self._density_par_approx(dangle,tdisrupt,force_indiv_impacts,
True,
Expand Down

0 comments on commit 1e649a3

Please sign in to comment.