Ejemplo n.º 1
0
def test_elastic():
    ref = 33.19098343826968

    isclose(wr.rate_wimp_std(1, **opts), ref)

    # Test numericalunits.reset_units() does not affect results
    nu.reset_units(123)
    isclose(wr.rate_wimp_std(1, **opts), ref)

    # Test vectorized call
    energies = np.linspace(0.01, 40, 100)
    dr = wr.rate_wimp_std(energies, **opts)
    assert dr[0] == wr.rate_wimp_std(0.01, **opts)
Ejemplo n.º 2
0
def test_halo_scaling():
    #check that passing rho multiplies the rate correctly:
    ref = 33.19098343826968

    isclose(
        wr.rate_wimp_std(1,
                         halo_model=wr.StandardHaloModel(rho_dm=0.3 * nu.GeV /
                                                         nu.c0**2 / nu.cm**3),
                         **opts), ref)
Ejemplo n.º 3
0
    def __init__(self, *args, wimp_kwargs=None, **kwargs):
        # Compute the energy spectrum in a given time range
        # Times used by wimprates are J2000 timestamps
        assert self.n_time_bins >= 1, "Need >= 1 time bin"
        if hasattr(self, 'n_in'):
            raise RuntimeError(
                "n_in is gone! Use n_time_bins to control accuracy, or set "
                "pretend_wimps_dont_modulate to use a time-averaged spectrum.")

        times = np.linspace(wr.j2000(self.t_start.value),
                            wr.j2000(self.t_stop.value), self.n_time_bins + 1)
        time_centers = self.bin_centers(times)

        if wimp_kwargs is None:
            # No arguments given at all;
            # use default mass, xsec and energy range
            wimp_kwargs = dict(mw=self.mw,
                               sigma_nucleon=self.sigma_nucleon,
                               es=self.es)
        else:
            assert 'mw' in wimp_kwargs and 'sigma_nucleon' in wimp_kwargs, \
                "Pass at least 'mw' and 'sigma_nucleon' in wimp_kwargs"
            if 'es' not in wimp_kwargs:
                # Energies not given, use default energy bin edges
                wimp_kwargs['es'] = self.es

        es = wimp_kwargs['es']
        es_centers = self.bin_centers(es)
        del wimp_kwargs['es']  # To avoid confusion centers / edges

        # Transform wimp_kwargs to arguments that can be passed to wimprates
        # which means transforming es from edges to centers
        spectra = np.array([
            wr.rate_wimp_std(t=t, es=es_centers, **wimp_kwargs) * np.diff(es)
            for t in time_centers
        ])
        assert spectra.shape == (len(time_centers), len(es_centers))

        self.energy_hist = Histdd.from_histogram(spectra,
                                                 bin_edges=(times, es))

        if self.pretend_wimps_dont_modulate:
            self.energy_hist.histogram = (
                np.ones_like(self.energy_hist.histogram) *
                self.energy_hist.sum(axis=0).histogram.reshape(1, -1) /
                self.n_time_bins)

        # Initialize the rest of the source, needs to be after energy_hist is
        # computed because of _populate_tensor_cache
        super().__init__(*args, **kwargs)
Ejemplo n.º 4
0
    def __init__(self, *args, wimp_kwargs=None, **kwargs):
        # Compute the energy spectrum in a given time range
        # Times used by wimprates are J2000 timestamps
        assert self.n_in > 1, \
            f"Number of time bin edges needs to be at least 2"
        times = np.linspace(wr.j2000(date=self.t_start),
                            wr.j2000(date=self.t_stop), self.n_in)
        time_centers = self.bin_centers(times)

        if wimp_kwargs is None:
            # No arguments given at all;
            # use default mass, xsec and energy range
            wimp_kwargs = dict(mw=self.mw,
                               sigma_nucleon=self.sigma_nucleon,
                               es=self.es)
        else:
            assert 'mw' in wimp_kwargs and 'sigma_nucleon' in wimp_kwargs, \
                "Pass at least 'mw' and 'sigma_nucleon' in wimp_kwargs"
            if 'es' not in wimp_kwargs:
                # Energies not given, use default energy bin edges
                wimp_kwargs['es'] = self.es

        es = wimp_kwargs['es']
        es_centers = self.bin_centers(es)
        del wimp_kwargs['es']  # To avoid confusion centers / edges

        # Transform wimp_kwargs to arguments that can be passed to wimprates
        # which means transforming es from edges to centers
        spectra = np.array([
            wr.rate_wimp_std(t=t, es=es_centers, **wimp_kwargs) * np.diff(es)
            for t in time_centers
        ])
        assert spectra.shape == (len(time_centers), len(es_centers))

        self.energy_hist = Histdd.from_histogram(spectra,
                                                 bin_edges=(times, es))
        # Initialize the rest of the source, needs to be after energy_hist is
        # computed because of _populate_tensor_cache
        super().__init__(*args, **kwargs)
Ejemplo n.º 5
0
def test_brems():
    isclose(wr.rate_wimp_std(1, detection_mechanism='bremsstrahlung', **opts),
            0.00017062652972332665)
Ejemplo n.º 6
0
def test_migdal():
    isclose(wr.rate_wimp_std(1, detection_mechanism='migdal', **opts),
            0.2610240963512907)
Ejemplo n.º 7
0
def test_spindependent():
    isclose(wr.rate_wimp_std(1, interaction='SD_n_central', **opts),
            0.00021779266679860948)
Ejemplo n.º 8
0
def test_lightmediator():
    isclose(wr.rate_wimp_std(1, m_med=1e-3, **opts), 0.0005502663384403058)
Ejemplo n.º 9
0
This file is adapted from the laidbax tutorial notebook - https://github.com/XENON1T/laidbax/blob/master/notebooks/Tutorial.ipynb
For a WIMP with mass 500 GeV/c^2 and cross section 1e-45
"""

import numpy as np
import random
import matplotlib.pyplot as plt

import wimprates
import numericalunits as nu
import blueice as bi
from laidbax import base_model
import pandas as pd

energies = np.linspace(0.01, 100, 100)
dr = wimprates.rate_wimp_std(energies, mw=500,
                             sigma_nucleon=1e-45) / (1000 * 365)

plt.plot(energies, dr)
plt.xlabel("Recoil energy [keV]")
plt.ylabel("Rate [events per (keV kg day)]")
plt.title("$m_\chi = 500$ GeV/c${}^2$, $\sigma_\chi = 10^{-45}$ cm${}^2$")
plt.xlim(0, energies.max())
plt.ylim(0, None)
plt.show()

#m = bi.Model(base_model.config)
source_config = {
    'energy_distribution': (energies, dr),
    'name': 'WIMP',
    'label': 'WIMP particles',
    'recoil_type': 'nr',