Skip to content

Commit

Permalink
Merge pull request #6 from JoranAngevaare/add_ci_to_fork
Browse files Browse the repository at this point in the history
Tweaks to add_ci
  • Loading branch information
JoranAngevaare authored Aug 17, 2022
2 parents d2d5544 + a00aa2a commit 1ae5151
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,21 @@ jobs:
- name: Install requirements for tests and latest strax
run: |
# Requirements for running the notebooks as a pytest
pip install nbmake pytest-xdist
pip install cython ipython
pip install nbconvert==6.4.3 nbmake pytest-xdist pytest coverage coveralls pytest-cov pytest-notebook ipython_genutils
# Several optional packages that are imported in the notebooks
pip install git+https://github.com/XENON1T/laidbax
python setup.py develop
- name: Test package
if: matrix.test == 'pytest'
run: coverage run --source=pema -m pytest -vs --log-level=DEBUG --durations 0
run:
pytest --cov wimprates -v --nbmake notebooks/*.ipynb --durations 0 --nb-coverage
- name: Coveralls
env:
NUMBA_DISABLE_JIT: 1
if: matrix.test == 'coveralls'
run: coverage run --source=wimprates -m pytest -v --nbmake -n=auto notebooks/*.ipynb --durations 0
run:
pytest --cov wimprates -v --nbmake notebooks/*.ipynb --durations 0 --nb-coverage
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 3 additions & 1 deletion notebooks/Checks, plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@
" wimps = None\n",
"\n",
"es = np.logspace(-2, 3.5, 100)\n",
"# Reduce the number a bit to get the results quicker\n",
"mchi = mchi[::5]\n",
"ms = mchi / gevcsq\n",
"rates = []\n",
"rates_bs = []\n",
Expand Down Expand Up @@ -475,7 +477,7 @@
" ax.set_ylabel(label, color=color)\n",
" ax.tick_params('y', colors=color)\n",
"\n",
"v = v_earth + v_esc\n",
"v = v_earth() + v_esc\n",
"plt.plot(mchi / gevcsq, \n",
" 4 * mchi * mn / (mchi + mn)**2 * (mchi * v**2 /2) / nu.keV,\n",
" linestyle=':', c='b'\n",
Expand Down
27 changes: 8 additions & 19 deletions notebooks/Spin-dependent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
Expand All @@ -32,9 +30,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stderr",
Expand All @@ -48,16 +44,14 @@
"source": [
"try:\n",
" plt.style.use('latex_thesis')\n",
"except FileNotFoundError:\n",
"except (FileNotFoundError, OSError):\n",
" print(\"Can't use my favourite plotting style... oh well\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -76,7 +70,6 @@
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [],
Expand Down Expand Up @@ -122,9 +115,7 @@
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -184,9 +175,7 @@
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -265,7 +254,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -279,7 +268,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.5"
"version": "3.10.4"
}
},
"nbformat": 4,
Expand Down
26 changes: 16 additions & 10 deletions wimprates/bremsstrahlung.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ def to_itp(fn):
f2 = to_itp('atomic_form_2')


def vmin_w(w, mw):
def vmin_w(w, mw, material):
"""Minimum wimp velocity to emit a Bremsstrahlung photon w
:param w: Bremsstrahlung photon energy
:param mw: WIMP mass
From Kouvaris/Pradler [arxiv:1607.01789v2], equation in text below eq. 10
"""
return (2 * w / wr.mu_nucleus(mw))**0.5
return (2 * w / wr.mu_nucleus(mw, material))**0.5


def erec_bound(sign, w, v, mw):
def erec_bound(sign, w, v, mw, material):
"""Bremsstrahlung scattering recoil energy kinematic limits
From Kouvaris/Pradler [arxiv:1607.01789v2], eq. between 8 and 9,
simplified by vmin (see above)
Expand All @@ -44,8 +44,8 @@ def erec_bound(sign, w, v, mw):
"""
return (wr.mu_nucleus(mw)**2 * v**2 / wr.mn()
* (1
- vmin_w(w, mw)**2 / (2 * v**2)
+ sign * (1 - vmin_w(w, mw)**2 / v**2)**0.5))
- vmin_w(w, mw, material)**2 / (2 * v**2)
+ sign * (1 - vmin_w(w, mw, material)**2 / v**2)**0.5))


def sigma_w_erec(w, erec, v, mw, sigma_nucleon,
Expand Down Expand Up @@ -75,7 +75,9 @@ def sigma_w_erec(w, erec, v, mw, sigma_nucleon,


def sigma_w(w, v, mw, sigma_nucleon,
interaction='SI', m_med=float('inf'), **kwargs):
material,
interaction='SI', m_med=float('inf'),
**kwargs):
"""Differential Bremsstrahlung WIMP-nucleus cross section
:param w: Bremsstrahlung photon energy
Expand All @@ -94,15 +96,16 @@ def integrand(erec):
return sigma_w_erec(w, erec, v, mw, sigma_nucleon, interaction, m_med)

return quad(integrand,
erec_bound(-1, w, v, mw),
erec_bound(+1, w, v, mw),
erec_bound(-1, w, v, mw, material=material),
erec_bound(+1, w, v, mw, material=material),
**kwargs)[0]


@export
@wr.vectorize_first
def rate_bremsstrahlung(w, mw, sigma_nucleon, interaction='SI',
m_med=float('inf'), t=None,
material='Xe',
halo_model=None, **kwargs):
"""Differential rate per unit detector mass and recoil energy of
Bremsstrahlung elastic WIMP-nucleus scattering.
Expand All @@ -124,13 +127,16 @@ def rate_bremsstrahlung(w, mw, sigma_nucleon, interaction='SI',
(e.g. error tolerance).
"""
halo_model = wr.StandardHaloModel() if halo_model is None else halo_model
vmin = vmin_w(w, mw)
vmin = vmin_w(w, mw, material)

if vmin >= wr.v_max(t, halo_model.v_esc):
return 0

def integrand(v):
return (sigma_w(w, v, mw, sigma_nucleon, interaction, m_med) *
return (sigma_w(w, v, mw, sigma_nucleon,
interaction=interaction,
m_med=m_med,
material=material) *
v * halo_model.velocity_dist(v, t))

return halo_model.rho_dm / mw * (1 / wr.mn()) * quad(
Expand Down

0 comments on commit 1ae5151

Please sign in to comment.