dmsky package¶
Module contents¶
Dark matter skymaps.
Priors on J-factor¶
-
class
dmsky.priors.
PriorFunctor
(funcname, scale=1.0)[source]¶ Bases:
object
A functor class that wraps simple functions we use to make priors on parameters.
-
funcname
¶ A string identifying the function.
-
log_value
(x)[source]¶ Return the log of the function value
Parameters: x (numpy.ndarray) – Input values Returns: y – Output values, same shape as x Return type: numpy.ndarray
-
marginalization_bins
()[source]¶ Binning to use to do the marginalization integrals
Default is to marginalize over two decades, centered on mean, using 1000 bins
-
normalization
()[source]¶ Normalization, i.e. the integral of the function over the normalization_range.
-
profile_bins
()[source]¶ The binning to use to do the profile fitting
Default is to profile over +-5 sigma, Centered on mean, using 100 bins
-
scale
¶ The scale factor applied to input values
-
-
class
dmsky.priors.
FunctionPrior
(funcname, mu, sigma, fn, lnfn=None, scale=1.0)[source]¶ Bases:
dmsky.priors.PriorFunctor
Implementation of a prior that simply wraps an existing function
-
log_value
(x)[source]¶ “Return the log of the function value
Parameters: x (numpy.ndarray) – Input values Returns: y – Output values, same shape as x Return type: numpy.ndarray
-
-
class
dmsky.priors.
GaussPrior
(mu, sigma, scale=1.0)[source]¶ Bases:
dmsky.priors.FunctionPrior
Implemenation of a Prior that wraps a Gaussian
-
class
dmsky.priors.
LGaussPrior
(mu, sigma, scale=1.0)[source]¶ Bases:
dmsky.priors.FunctionPrior
Implemenation of a Prior that wraps a log Gaussian
-
class
dmsky.priors.
LGaussLogPrior
(mu, sigma, scale=1.0)[source]¶ Bases:
dmsky.priors.FunctionPrior
Implemenation of a Prior that wraps the inverse of the log of a Gaussian (i.e., x and y axes are swapped) The prior is implemented in log-space.
-
class
dmsky.priors.
LGaussLikePrior
(mu, sigma, scale=1.0)[source]¶ Bases:
dmsky.priors.FunctionPrior
Implemenation of a Prior that wraps the inverse of the log of a Gaussian (i.e., x and y axes are swapped)
-
class
dmsky.priors.
LognormPrior
(mu, sigma, scale=1.0)[source]¶ Bases:
dmsky.priors.PriorFunctor
A wrapper around the lognormal function.
A note on the highly confusing scipy.stats.lognorm function… The three inputs to this function are:
s : This is the variance of the underlying gaussian distribution
scale = 1.0 : This is the mean of the linear-space lognormal distribution. The mean of the underlying normal distribution occurs at ln(scale)
loc = 0 : This linearly shifts the distribution in x (DO NOT USE)
The convention is different for numpy.random.lognormal
mean : This is the mean of the underlying normal distribution (so mean = log(scale))
sigma : This is the standard deviation of the underlying normal distribution (so sigma = s)
For random sampling: numpy.random.lognormal(mean, sigma, size)
mean : This is the mean of the underlying normal distribution (so mean = exp(scale))
sigma : This is the standard deviation of the underlying normal distribution (so sigma = s)
scipy.stats.lognorm.rvs(s, scale, loc, size)
s : This is the standard deviation of the underlying normal distribution
scale : This is the mean of the generated random sample scale = exp(mean)
Remember, pdf in log space is plot( log(x), stats.lognorm(sigma,scale=exp(mean)).pdf(x)*x )
Parameters:
-
class
dmsky.priors.
FileFuncPrior
(filename, scale=1.0)[source]¶ Bases:
dmsky.priors.PriorFunctor
A wrapper around the interpolated function.
Parameters: filename (string) – File with the function parameters
Dark Matter Denisty Porfiles¶
-
class
dmsky.density.
DensityProfile
(**kwargs)[source]¶ Bases:
pymodeler.model.Model
Am abstract base class for DM density profiles
At a minimum sub-classes need to implement the self._rho(r) method to compute the density as a function of radius from the center of the halo
-
deriv_params
¶ Return the list of paramters we can take derivatives w.r.t.
-
mass
(r=None)[source]¶ Compute the mass of the object out to a particular radius.
Parameters: r (numpy.array or float) – The radii Returns: values – Return values, same shape as the input radii Return type: numpy.array
-
rho
(r)[source]¶ Return the density for given radii.
Parameters: r (numpy.array or float) – The radii Returns: values – Return values, same shape as the input radii Return type: numpy.array
-
rho_deriv
(r, paramNames)[source]¶ - Return the derivatives of the density as a function of radius,
- w.r.t. a list of parameters
Parameters: - r (numpy.array or float) – The radii
- paramNames (list) – The names of the parameters to differentiation w.r.t.
Returns: matrix – An n x m array, where: n is the number of radii m is the number of parameters
Return type: numpy.array
-
rho_uncertainty
(r)[source]¶ Calculate the uncertainty of the density at given radii
Parameters: r (numpy.array or float) – The radii Returns: values – Return values, same shape as the input radii Return type: numpy.array
-
-
class
dmsky.density.
UniformProfile
(**kwargs)[source]¶ Bases:
dmsky.density.DensityProfile
Uniform spherical profile rho(r) = rhos for r <= rs rho(r) = 0 otherwise
-
class
dmsky.density.
IsothermalProfile
(**kwargs)[source]¶ Bases:
dmsky.density.DensityProfile
Non-Singular Isothermal Profile: Begeman et al. MNRAS 249, 523 (1991) http://adsabs.harvard.edu/full/1991MNRAS.249..523B rho(r) = rhos/(1+(r/rs))**2
-
class
dmsky.density.
BurkertProfile
(**kwargs)[source]¶ Bases:
dmsky.density.DensityProfile
Burkert ApJ 447, L25 (1995) [Eqn. 2] http://arxiv.org/abs/astro-ph/9504041 rho(r) = rho0 * r0**3 / ( (r + r0)*(r**2+r0**2) ) ==> rho(r) = rhos / ( (1+r/rs)*(1+(r/rs)**2) )
-
class
dmsky.density.
NFWProfile
(**kwargs)[source]¶ Bases:
dmsky.density.DensityProfile
Navarro, Frenk, and White, ApJ 462, 563 (1996) http://arxiv.org/abs/astro-ph/9508025 rho(r) = rhos / ((r/rs) * (1+r/rs)**2)
-
class
dmsky.density.
GNFWProfile
(**kwargs)[source]¶ Bases:
dmsky.density.DensityProfile
Generalized NFW Profile Strigari et al. ApJ 678, 614 (2008) [Eqn. 3] http://arxiv.org/abs/0709.1510 rho(r) = rhos / ( (r/rs)**gamma * (1+r/rs)**(3-gamma))
-
deriv_params
¶ Return the list of paramters we can take derivatives w.r.t.
-
-
class
dmsky.density.
EinastoProfile
(**kwargs)[source]¶ Bases:
dmsky.density.DensityProfile
Einasto profile Einasto Trudy Inst. Astrofiz. Alma-Ata 5, 87 (1965) (Russian) [Eqn. 4] http://adsabs.harvard.edu/abs/1965TrAlm…5…87E rho(r) = rhos*exp(-2*((r/rs)**alpha-1)/alpha) ==>
-
deriv_params
¶ Return the list of paramters we can take derivatives w.r.t.
-
-
class
dmsky.density.
ZhouProfile
(**kwargs)[source]¶ Bases:
dmsky.density.DensityProfile
Generalized double power-law models Zhou MNRAS 278, 488 (1996) [Eqn. 1] http://arxiv.org/abs/astro-ph/9509122 rho(r) = C * (r/rs)**-gamma * (1 + (r/rs)**1/alpha))**-(beta-gamma)*alpha C = 4 * rhos
also see… Zhou MNRAS 287, 525 (1997) [Eqn. 2] http://arxiv.org/abs/astro-ph/9605029 Strigari et al., Nature 454 (2008) [Eqn. 8] http://arxiv.org/abs/0808.3772
-
deriv_params
¶ Return the list of paramters we can take derivatives w.r.t.
-
Line of sight integration¶
-
class
dmsky.jcalc.
LoSFn
(dp, d, xi, alpha=3.0)[source]¶ Bases:
object
Integrand function (luminosity density) for LoS integration. The parameter alpha introduces a change of variables:
x’ = x^(1/alpha).
A value of alpha > 1 samples the integrand closer to x = 0 (distance of closest approach). The change of variables requires the substitution:
dx = alpha * (x’)^(alpha-1) dx’
-
class
dmsky.jcalc.
LoSAnnihilate
(dp, d, xi, alpha=3.0)[source]¶ Bases:
dmsky.jcalc.LoSFn
Integrand function for LoS annihilation (J-factor).
-
class
dmsky.jcalc.
LoSAnnihilate_Deriv
(dp, d, xi, paramNames, alpha=3.0)[source]¶ Bases:
dmsky.jcalc.LoSFn
Integrand function for LoS annihilation (J-factor).
-
class
dmsky.jcalc.
LoSDecay
(dp, d, xi, alpha=3.0)[source]¶ Bases:
dmsky.jcalc.LoSFn
Integrand function for LoS decay (D-factor).
-
class
dmsky.jcalc.
LoSDecay_Deriv
(dp, d, xi, paramNames, alpha=1.0)[source]¶ Bases:
dmsky.jcalc.LoSFn
Integrand function for LoS decay (D-factor).
-
class
dmsky.jcalc.
LoSIntegral
(density, dhalo, alpha=3.0, ann=True, derivPar=None)[source]¶ Bases:
object
Slowest (and most accurate?) LoS integral. Uses scipy.integrate.quad with a change of variables to better sample the LoS close to the halo center.
-
angularIntegral
(angle=None)[source]¶ Compute the solid-angle integrated j-value within a given radius
Parameters: angle (numpy.ndarray or None) – Maximum integration angle (in degrees) If None, use the ‘rmax’ and ‘dhalo’ parameters. Returns: values – Return values, same shape as the input xp Return type: numpy.array
-
name
¶ Return the name of this profile
-
rmax
¶ Return the maximum integration radius
-
-
class
dmsky.jcalc.
LoSIntegralFast
(density, dhalo, alpha=3.0, ann=True, nsteps=400, derivPar=None)[source]¶ Bases:
dmsky.jcalc.LoSIntegral
Vectorized version of LoSIntegral that performs midpoint integration with a fixed number of steps.
-
rmax
¶ Return the maximum integration radius
-
-
class
dmsky.jcalc.
LoSIntegralInterp
(density, dhalo, alpha=3.0, ann=True, nsteps=400, derivPar=None)[source]¶ Bases:
dmsky.jcalc.LoSIntegralFast
Interpolate fast integral a for even faster look-up.
-
create_func
(dhalo)[source]¶ Create the spline function
Parameters: dhalo (numpy.ndarray) – Array of halo distances Returns: func – A function that return J-factor as a function of psi and dhalo Return type: function
-
create_profile
(dhalo, nsteps=None)[source]¶ Create a spatial J-factor profile
Parameters: - dhalo (numpy.ndarray) – Array of halo distances
- nsteps (int) – Number of steps for vectorization
Returns: - dhalo, psi (numpy.meshgrid) – Array of halo distances and angular offsets
- jval (numpy.array) – Corresponding J-factors
-
-
class
dmsky.jcalc.
LoSIntegralFile
(dp, dist, filename, ann=True)[source]¶ Bases:
dmsky.jcalc.LoSIntegralInterp
Interpolate over a pre-generated file.
NOT IMPLEMENTED YET
Dark matter targets¶
-
class
dmsky.targets.
Target
(**kwargs)[source]¶ Bases:
pymodeler.model.Model
A DM search target
-
create_dmap
(npix=150, subsample=4, coordsys='CEL', projection='AIT')[source]¶ Create a D-factor map
Parameters: Returns: - image (numpy.ndarray) – Image data
- pix (numpy.ndarray) – Pixel coordinatates
- wcs (WCS.wcs) – WCS object for map
-
create_jmap
(npix=150, subsample=4, coordsys='CEL', projection='AIT')[source]¶ Create a J-factor map
Parameters: Returns: - image (numpy.ndarray) – Image data
- pix (numpy.ndarray) – Pixel coordinatates
- wcs (WCS.wcs) – WCS object for map
-
dsigma
(ra, dec)[source]¶ Return the uncertainty of J in any direction
Parameters: - ra (numpy.ndarray) – Right-accension (in degrees)
- dec (numpy.ndarray) – Declination (in degrees)
Returns: values – Return values, same shape as the input ra, dec
Return type: numpy.array
-
dvalue
(ra, dec)[source]¶ Return the D-factor in any direction
Parameters: - ra (numpy.ndarray) – Right-accension (in degrees)
- dec (numpy.ndarray) – Declination (in degrees)
Returns: values – Return values, same shape as the input ra, dec
Return type: numpy.array
-
jsigma
(ra, dec)[source]¶ Return the uncertainty of J in any direction
Parameters: - ra (numpy.ndarray) – Right-accension (in degrees)
- dec (numpy.ndarray) – Declination (in degrees)
Returns: values – Return values, same shape as the input ra, dec
Return type: numpy.array
-
jvalue
(ra, dec)[source]¶ Return the J-factor in any direction
Parameters: - ra (numpy.ndarray) – Right-accension (in degrees)
- dec (numpy.ndarray) – Declination (in degrees)
Returns: values – Return values, same shape as the input ra, dec
Return type: numpy.array
-
write_d_rad_file
(d_rad_file=None, npts=50, minpsi=0.0001)[source]¶ Write a text file with the D-fractor radial profile
Parameters:
-
write_dmap
(filename, npix=150, clobber=False, map_kwargs=None, file_kwargs=None)¶ Write the D-factor to a template map.
-
write_dmap_wcs
(filename, npix=150, clobber=False, map_kwargs=None, file_kwargs=None)[source]¶ Write the D-factor to a template map.
-
write_j_rad_file
(j_rad_file=None, npts=50, minpsi=0.0001)[source]¶ Write a text file with the J-fractor radial profile
Parameters:
-
write_jmap
(filename, npix=150, clobber=False, map_kwargs=None, file_kwargs=None)¶ Write the J-factor to a template map.
-
-
class
dmsky.targets.
Galactic
(**kwargs)[source]¶ Bases:
dmsky.targets.Target
Class to add specifics for Galactic DM targets
-
class
dmsky.targets.
Dwarf
(**kwargs)[source]¶ Bases:
dmsky.targets.Target
Class to add specifics for Dwarf Galaxy DM targets
-
j_photo
(a=18.17, b=0.23)[source]¶ Photometric J-factor from Eq 14 of Pace & Strigari (2019) [1802.06811v2]
J = 10^{a} * (Lv / 1e4 Lsun)^{b} * (D/100 kpc)^-2 * (rhalf/100 pc)^-0.5For Pace & Strigari (2019): a = 18.17, b = 0.23 For Pace & Strigari 1802.06811v1: a = 17.93, b = 0.32
Parameters: - a (normalization exponent) –
- b (luminosity scaling) –
Returns: J
Return type: photometric J-factor within 0.5 deg
-
-
class
dmsky.targets.
Galaxy
(**kwargs)[source]¶ Bases:
dmsky.targets.Target
Class to add specifics for Galaxy DM targets
-
class
dmsky.targets.
Cluster
(**kwargs)[source]¶ Bases:
dmsky.targets.Target
Class to add specifics for Galaxy Cluster DM targets
-
class
dmsky.targets.
Isotropic
(**kwargs)[source]¶ Bases:
dmsky.targets.Target
Class to add specifics for Isotropic DM targets
Plotting fucntions¶
Module for plotting stuff in dmsky.
-
dmsky.plotting.
plot_density
(name, targets, xlims=None, nstep=100)[source]¶ Make a plot of the density as a function of distance from the target center.
Parameters: Returns: - fig (matplotlib.Figure)
- ax (matplotlib.Axes)
- leg (matplotlib.Legend)
-
dmsky.plotting.
plot_j_integ
(name, targets, xlims=None, nstep=100, ylims=None)[source]¶ Make a plot of the integrated J-factor as a function of the angle from the target center.
Parameters: Returns: - fig (matplotlib.Figure)
- ax (matplotlib.Axes)
- leg (matplotlib.Legend)
Skymap class¶
Roster class¶
-
class
dmsky.roster.
Roster
(*targets, **kwargs)[source]¶ Bases:
collections.OrderedDict
A self-consistent set of search targets, typically with exactly one version for any given target.
Top-level bookkeeping¶
Factory for generating instances of classes
-
dmsky.factory.
factory
(cls, module=None, **kwargs)[source]¶ Factory for creating objects. Arguments are passed directly to the constructor of the chosen class.
Parameters: Returns: object – Newly created object
Return type: object
-
class
dmsky.library.
ObjectLibrary
(path=None)[source]¶ Bases:
object
Library that keeps track of object we are building
-
class
dmsky.targets.
TargetLibrary
(path=None)[source]¶ Bases:
dmsky.library.ObjectLibrary
A top-level object, keeping track of all the Target objects that we have created
-
create_target
(name, version=None, default='default', **kwargs)[source]¶ Create a Target
Parameters: Returns: target – The newly created Target
Return type: Target
-
-
class
dmsky.roster.
RosterLibrary
(path=None)[source]¶ Bases:
dmsky.library.ObjectLibrary
A top-level object, keeping track of all the Roster objects that we have created