Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/GitHub actions #56

Open
wants to merge 66 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
41f8ebc
Merge tag 'v1.2.1' into develop
nsoblath Jun 6, 2020
2d40849
Merge tag 'v1.2.2' into develop
nsoblath Jun 8, 2020
f21d7f9
can use helium instead of krypton as second gas
cclaessens Jun 12, 2020
6ec42ec
FakeDataGenerator using KrComplexLineShape
cclaessens Jun 12, 2020
a6ec33b
added scatter_proportion configurable
cclaessens Jun 12, 2020
7130957
small fixes
cclaessens Jun 12, 2020
8897a18
scatter_spectra.npy file does not need to pre-exist. KrLineshapeFunct…
cclaessens Jun 12, 2020
754024b
Added delta base shape option; removed extra input to spectrum_func_1
Jun 12, 2020
fd8e7bd
Merge branch 'feature/helium-in-lineshape' of https://github.com/proj…
Jun 12, 2020
0c8e97f
some fixes
cclaessens Jun 12, 2020
c10eccd
Added option to normalize complex lineshape
Jun 12, 2020
14425bd
Merge branch 'feature/helium-in-lineshape' of https://github.com/proj…
Jun 12, 2020
f984639
Fixed errors
Jun 12, 2020
e733607
iminuit binned data fitter
cclaessens Jun 13, 2020
b5b2db1
Fixed wrong var name for survival prob
Jun 14, 2020
ea6af4e
added Ar scatter
huyanxy Jun 14, 2020
13d77de
added Ar scatter
huyanxy Jun 14, 2020
9002d63
info only printed when print level is 1
cclaessens Jun 17, 2020
6a3ff1d
Merge branch 'feature/helium-in-lineshape' into feature/iminuit_histo…
cclaessens Jun 18, 2020
8ee8a2f
Removed lineshape normalization option (was not working)
Jun 19, 2020
e89af4a
Install iminuit in the Dockerfile (temporary; will eventually be done…
nsoblath Jun 24, 2020
d427805
returning lists
cclaessens Jul 8, 2020
24c54be
added results logging for print_level 1
cclaessens Jul 11, 2020
f13d44b
option to tilt efficiency curve
cclaessens Jul 11, 2020
d75f524
Merge pull request #44 from project8/feature/iminuit_in_docker
cclaessens Jul 13, 2020
7b8cebe
added return True to remove configure error
cclaessens Jul 14, 2020
40e6060
Added option to set maxf for testing
Jul 17, 2020
51afbb0
Pulling changes from origin
Jul 17, 2020
a2a91aa
Cosmetic changes; added to description of num_points_in_std_array
Jul 17, 2020
6cdc763
Merge pull request #43 from project8/feature/helium-in-lineshape
cclaessens Jul 21, 2020
cb423c4
Merge branch 'develop' into feature/iminuit_histogram_fitter
cclaessens Jul 27, 2020
afa7fa9
added error message for expectation < 0
cclaessens Aug 16, 2020
d1b654c
moved BinnedDataFitter to Fitters
cclaessens Aug 16, 2020
227216f
reverted changes in fake data generator
cclaessens Aug 16, 2020
6c9bb9c
added new test script to test.sh
cclaessens Aug 16, 2020
fbe046c
added molecular final states in fake data generator
cclaessens Aug 16, 2020
81279a9
added final state spectrum
cclaessens Aug 16, 2020
a2c146f
final state spectrum shifted so largest binding energy is 0.
cclaessens Aug 18, 2020
36e8da5
back to get_param_states() because of backwards compatibility
cclaessens Aug 18, 2020
a6d2ec5
Changed name of PDF to model because it isn't actually a pdf. Extende…
cclaessens Aug 18, 2020
3d91729
Added option to pass already binned data
cclaessens Aug 19, 2020
fa42e79
minor rearrangements in test script
cclaessens Aug 19, 2020
fbd21ba
Merge pull request #45 from project8/feature/iminuit_histogram_fitter
cclaessens Aug 19, 2020
22f365e
small fix in fake data generator
cclaessens Oct 20, 2020
5e9b212
I believe we are not using this file anymore
cclaessens Oct 26, 2020
407ba35
Update setup.py
guiguem Oct 26, 2020
c78f987
fix type error in IO_test script
cclaessens Oct 26, 2020
8a2079a
Adding a iminiut super simple tester which should pass tests while th…
guiguem Oct 26, 2020
efc315d
added iminuit test more similar to BinnedDataFitter
cclaessens Oct 27, 2020
56b5161
print_level=1 was causing the problem
cclaessens Oct 27, 2020
2b30d7e
Merge pull request #50 from project8/feature/iminuit_check
cclaessens Oct 28, 2020
5c68ffb
Merge pull request #48 from project8/develop
cclaessens Oct 28, 2020
5d06520
added logger error output in BinnedDataFitter and made min_energy in …
cclaessens Nov 16, 2020
f105e41
removed commented plots
cclaessens Jan 5, 2021
888cba4
iminuit.from_array_func and others were removed in iminuit >= 2
cclaessens Jan 5, 2021
0d43ce8
start values required...
cclaessens Jan 5, 2021
3c125b7
Merge pull request #46 from project8/feature/molecular_final_states
cclaessens Jan 6, 2021
1afb3da
remove KrLineShapeFunctions from misc/__init__.py
cclaessens Jan 7, 2021
260f19d
Merge pull request #49 from project8/feature/remove_KrLineshapeFuncti…
cclaessens Jan 7, 2021
ec13135
Default settings were a problem if fit function had not exactly 3 fit…
cclaessens May 14, 2021
7056449
Merge pull request #54 from project8/feature/binned_data_fitter_fixes
cclaessens Jun 4, 2021
ee8e58b
Add workflow for publishing the docker image
MCFlowMace Jun 29, 2021
baea5bc
Merge branch 'hotfix/1.2.3' into feature/github-actions
MCFlowMace Jul 2, 2021
242fcf1
Update to full workflow
MCFlowMace Jul 2, 2021
a6e189c
Add trigger for p8compute build
MCFlowMace Jul 2, 2021
726eca9
Add master branch to triggers of publish workflow
MCFlowMace Jul 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 206 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@

name: Publish

on:

push:
branches: [ master, main, develop, feature/github-actions]
tags: 'v*.*.*'

pull_request:
branches: '*'
types: opened

release:
types: [published]

workflow_dispatch:

repository_dispatch:
types: [release-event]

jobs:

init:
runs-on: ubuntu-latest
outputs:
build_type: ${{ steps.setvars.outputs.build_type }}
luna_version: ${{ steps.setversion.outputs.luna_version }}

steps:
- name: Cancel previous workflow
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Set variables
id: setvars
#Only build the tests in a debug build, tests currently don't build in release mode
run: |
echo ${{github.base_ref}}
echo ${{github.ref}}
if [[ "${{github.base_ref}}" == "develop" || "${{github.ref}}" == "refs/heads/develop" ]]; then
echo "::set-output name=build_type::DEBUG"
echo Debug build
else
echo "::set-output name=build_type::RELEASE"
fi

- name: Set Luna version
id: setversion
run: |
git clone https://github.com/project8/luna_base.git
cd luna_base
echo "::set-output name=luna_version::$(git describe --abbrev=0 --tags)"

test_linux:
runs-on: ubuntu-latest
needs: [init]

strategy:
matrix:
build_type: [DEBUG, RELEASE]
compiler: [gcc]
fail-fast: false

steps:
- name: Checkout the repo
uses: actions/checkout@v2
with:
submodules: recursive

- name: Set env
run: |
if [[ "${{matrix.compiler}}" == "gcc" ]]; then
echo "CXX_VAL=g++" >> $GITHUB_ENV
else
echo "CXX_VAL=clang++" >> $GITHUB_ENV
fi

- name: Print config
run: |
echo Build type: ${{ matrix.build_type }}
echo Compiler: ${{ matrix.compiler }} ${{ env.CXX_VAL }}
echo Luna version: ${{ needs.init.outputs.luna_version }}

- name: Build with docker
run: |
cd ${{github.workspace}}
docker build \
--build-arg IMG_USER=project8 \
--build-arg IMG_REPO=p8compute_dependencies \
--build-arg IMG_TAG=${{ needs.init.outputs.luna_version }} \
--build-arg MERMITHID_TAG=test \
--build-arg build_type=${{matrix.build_type}} \
--build-arg CC_VAL=${{matrix.compiler}} \
--build-arg CXX_VAL=${{env.CXX_VAL}} \
--tag project8/mermithid:test \
.

publish:
if: github.event_name != 'pull_request'
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: [init, test_linux]
steps:

- name: Check out the repo
uses: actions/checkout@v2
with:
submodules: recursive

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
with:
images: project8/mermithid

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: setup_buildx
uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: --debug

- name: List platforms
run: |
echo Platforms: ${{ steps.setup_buildx.outputs.platforms }}

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set env
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Print config
run: |
echo Release version: ${{ env.RELEASE_VERSION }}
echo Luna version: ${{ needs.init.outputs.luna_version }}

- name: Push to Docker Hub
id: build_push
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: |
IMG_USER=project8
IMG_REPO=p8compute_dependencies
IMG_TAG=${{ needs.init.outputs.luna_version }}
MERMITHID_TAG=${{ env.RELEASE_VERSION }}
build_type=${{needs.init.outputs.build_type}}
tags: ${{ steps.docker_meta.outputs.tags }}

# disabled due to error
# doc:
# name: Build documentation
# runs-on: ubuntu-latest
# #needs: [init, test_linux]
# steps:
#
# - name: Check out the repo
# uses: actions/checkout@v2
# with:
# submodules: recursive
# fetch-depth: 0
#
# - name: Install dependencies
# run: |
# sudo apt-get update
# DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
# tree \
# doxygen \
# python3-sphinx \
# graphviz
# pip install sphinxcontrib-blockdiag
# pip install sphinxcontrib-contentui
#
# - name: Build docs
# run: |
# cd Documentation
# make

notify-packages:

if: (github.event_name == 'push' && contains(github.ref, 'refs/tags/') )
|| github.event_name == 'release'
|| github.event_name == 'workflow_dispatch'
|| github.event_name == 'repository_dispatch'
name: Trigger new docker P8Compute image
runs-on: ubuntu-latest
needs: [publish]

steps:

- name: Repository dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: project8/luna
event-type: release-event
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ FROM ${IMG_USER}/${IMG_REPO}:${IMG_TAG} as mermithid_common
ARG build_type=Release
ENV MERMITHID_BUILD_TYPE=$build_type

ENV MERMITHID_TAG=v1.2.2
ARG MERMITHID_TAG=beta
ENV MERMITHID_TAG=${MERMITHID_TAG}
ENV MERMITHID_BUILD_PREFIX=/usr/local/p8/mermithid/$MERMITHID_TAG

ARG CC_VAL=gcc
ENV CC=${CC_VAL}
ARG CXX_VAL=g++
ENV CXX=${CXX_VAL}

RUN mkdir -p $MERMITHID_BUILD_PREFIX &&\
chmod -R 777 $MERMITHID_BUILD_PREFIX/.. &&\
cd $MERMITHID_BUILD_PREFIX &&\
Expand All @@ -22,6 +28,10 @@ RUN mkdir -p $MERMITHID_BUILD_PREFIX &&\
echo 'export PYTHONPATH=$MERMITHID_BUILD_PREFIX/$(python3 -m site --user-site | sed "s%$(python3 -m site --user-base)%%"):$PYTHONPATH' >> setup.sh &&\
/bin/true

RUN source $COMMON_BUILD_PREFIX/setup.sh &&\
pip install iminuit &&\
/bin/true

########################
FROM mermithid_common as mermithid_done

Expand Down
4 changes: 4 additions & 0 deletions mermithid/misc/ComplexLineShapeUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def aseev_func_tail(energy_loss_array, gas_type):
A2, omeg2, eps2 = 0.195, 14.13, 10.60
elif gas_type=="Kr":
A2, omeg2, eps2 = 0.4019, 22.31, 16.725
elif gas_type=="He":
A2, omeg2, eps2 = 0.1187, 33.40, 10.43
elif gas_type=="Ar":
A2, omeg2, eps2 = 0.3344, 21.91, 21.14
return A2*omeg2**2./(omeg2**2.+4*(energy_loss_array-eps2)**2.)

#convert oscillator strength into energy loss spectrum
Expand Down
65 changes: 48 additions & 17 deletions mermithid/misc/FakeTritiumDataFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from __future__ import absolute_import

import numpy as np
import json

from scipy.special import gamma
from scipy import integrate
Expand All @@ -18,7 +19,6 @@

from mermithid.misc.Constants import *
from mermithid.misc.ConversionFunctions import *
from mermithid.misc.KrLineshapeFunctions import *

"""
Constants and functions used by processors/TritiumSpectrum/FakeDataGenerator.py
Expand Down Expand Up @@ -147,13 +147,42 @@ def spectral_rate_in_window(K, Q, mnu, Kmin):
else:
return 0.


def beta_rates(K, Q, mnu, index):
beta_rates = np.zeros(len(K))
nu_mass_shape = ((Q - K[index])**2 -mnu**2)**0.5
beta_rates[index] = GF**2.*Vud**2*Mnuc2/(2.*np.pi**3)*ephasespace(K[index], Q)*(Q - K[index])*nu_mass_shape
return beta_rates



# Unsmeared eta spectrum without a lower energy bound
def spectral_rate(K, Q, mnu):
if Q-mnu > K > 0:
return GF**2.*Vud**2*Mnuc2/(2.*np.pi**3)*ephasespace(K, Q)*(Q - K)*np.sqrt((Q - K)**2 - (mnu)**2)
def spectral_rate(K, Q, mnu, final_state_array):

if isinstance(K, list) or isinstance(K, np.ndarray):
N_states = len(final_state_array[0])
beta_rates_array = np.zeros([N_states, len(K)])

Q_states = Q+final_state_array[0]-np.max(final_state_array[0])

index = [np.where(K < Q_states[i]-mnu) for i in range(N_states)]

beta_rates_array = [beta_rates(K, Q_states[i], mnu, index[i])*final_state_array[1][i] for i in range(N_states)]
to_return = np.nansum(beta_rates_array, axis=0)/np.nansum(final_state_array[1])

return to_return

else:
return 0.
#np.heaviside(Q-mnu-K, 0.5)*np.heaviside(K-V0, 0.5)

return_value = 0.

for i, e_binding in enumerate(final_state_array[0]):
# binding energies are negative
Q_state = Q+e_binding
if Q_state-mnu > K > 0:
return_value += final_state_array[1][i] *(GF**2.*Vud**2*Mnuc2/(2.*np.pi**3)*ephasespace(K, Q_state)*(Q_state - K)*np.sqrt((Q_state - K)**2 - (mnu)**2))

return return_value/np.sum(final_state_array[1])


#Flat background with lower and upper bounds Kmin and Kmax
Expand All @@ -169,12 +198,12 @@ def bkgd_rate():
return 1.


##Lineshape option: In this case, simply a Gaussian
#def gaussian(x,a):
# return 1/((2.*np.pi)**0.5*a[0])*(np.exp(-0.5*((x-a[1])/a[0])**2))
#Lineshape option: In this case, simply a Gaussian
def gaussian(x,a):
return 1/((2.*np.pi)**0.5*a[0])*(np.exp(-0.5*((x-a[1])/a[0])**2))


#Normalized simplified linesahape with scattering
#Normalized simplified lineshape with scattering
def simplified_ls(K, Kcenter, FWHM, prob, p0, p1, p2, p3):
sig0 = FWHM/float(2*np.sqrt(2*np.log(2)))
shape = gaussian(K, [sig0, Kcenter])
Expand Down Expand Up @@ -245,7 +274,8 @@ def convolved_bkgd_rate(K, Kmin, Kmax, lineshape, ls_params, min_energy, max_ene

#Convolution of signal and lineshape using scipy.signal.convolve
def convolved_spectral_rate_arrays(K, Q, mnu, Kmin,
lineshape, ls_params, min_energy, max_energy):
lineshape, ls_params, min_energy, max_energy,
complexLineShape, final_state_array):
"""K is an array-like object
"""
logger.info('Using scipy convolve')
Expand All @@ -263,11 +293,12 @@ def convolved_spectral_rate_arrays(K, Q, mnu, Kmin,
elif lineshape=='simplified_scattering' or lineshape=='simplified':
lineshape_rates = simplified_ls(K_lineshape, 0, ls_params[0], ls_params[1], ls_params[2], ls_params[3], ls_params[4], ls_params[5])
elif lineshape=='detailed_scattering' or lineshape=='detailed':
lineshape_rates = spectrum_func(K_lineshape/1000., ls_params[0], 0, ls_params[1], 1)

beta_rates = np.zeros(len(K))
for i,ke in enumerate(K):
beta_rates[i] = spectral_rate(ke, Q, mnu)
lineshape_rates = complexLineShape.spectrum_func_1(K_lineshape/1000., ls_params[0], 0, 1, ls_params[1])

beta_rates = spectral_rate(K, Q, mnu, final_state_array) #np.zeros(len(K))
#for i,ke in enumerate(K):
# beta_rates[i] = spectral_rate(ke, Q, mnu, final_state_array)

#Convolving
convolved = convolve(beta_rates, lineshape_rates, mode='same')
Expand All @@ -278,7 +309,7 @@ def convolved_spectral_rate_arrays(K, Q, mnu, Kmin,


#Convolution of background and lineshape using scipy.signal.convolve
def convolved_bkgd_rate_arrays(K, Kmin, Kmax, lineshape, ls_params, min_energy, max_energy):
def convolved_bkgd_rate_arrays(K, Kmin, Kmax, lineshape, ls_params, min_energy, max_energy, complexLineShape):
"""K is an array-like object
"""
energy_half_range = max(max_energy, abs(min_energy))
Expand All @@ -294,7 +325,7 @@ def convolved_bkgd_rate_arrays(K, Kmin, Kmax, lineshape, ls_params, min_energy,
elif lineshape=='simplified_scattering' or lineshape=='simplified':
lineshape_rates = simplified_ls(K_lineshape, 0, ls_params[0], ls_params[1], ls_params[2], ls_params[3], ls_params[4], ls_params[5])
elif lineshape=='detailed_scattering' or lineshape=='detailed':
lineshape_rates = spectrum_func(K_lineshape/1000., ls_params[0], 0, ls_params[1], 1)
lineshape_rates = complexLineShape.spectrum_func_1(K_lineshape/1000., ls_params[0], 0, 1, ls_params[1])

bkgd_rates = np.full(len(K), bkgd_rate())
if len(K) < len(K_lineshape):
Expand Down
Loading