Commit 7dec3c6a authored by Carsten Richter's avatar Carsten Richter

Merge branch 'minor-updates' into 'master'

Test update + minor updates

See merge request !102
parents d07ddef6 f49d3238
Pipeline #6848 passed with stages
in 4 minutes and 50 seconds
......@@ -133,17 +133,8 @@ class TestPeakFitter(ParametricTestCase):
def setUpClass(cls):
config.DEFAULT_PROCESS_NUMBER = 2 # Limit number of processes
cls._tmpdir = tempfile.mkdtemp()
test_resources.getdir('qspace.zip')
test_resources.getdir('fit_2018_03.zip')
@classmethod
def tearDownClass(cls):
tmpdir = cls._tmpdir
if tmpdir is not None:
shutil.rmtree(tmpdir)
cls._tmpdir = None
test_resources.getdir('fit_2018_12.zip')
def setUp(self):
self._tmpTestDir = tempfile.mkdtemp()
......@@ -183,7 +174,7 @@ class TestPeakFitter(ParametricTestCase):
results.to_fit_h5(fit_out)
fit_ref = test_resources.getfile(
'fit_2018_03/{0}'.format(params['fit_f']))
'fit_2018_12/{0}'.format(params['fit_f']))
fit_ref_h5 = FitH5(fit_ref)
fit_out_h5 = FitH5(fit_out)
......
......@@ -71,7 +71,7 @@ def gaussian(x, area, center, sigma):
:param float sigma:
:rtype: numpy.ndarray
"""
return (area * (1. / (_SQRT_2_PI * sigma)) *
return ((area / (_SQRT_2_PI * sigma)) *
numpy.exp(-0.5 * ((x - center) / sigma) ** 2))
......@@ -85,26 +85,25 @@ def project(data, hits=None):
:rtype: List[numpy.ndarray]
"""
if hits is not None:
with warnings.catch_warnings():
warnings.simplefilter('ignore', RuntimeWarning)
tmp = hits.sum(2)
hits0_sum = tmp.sum(1)
hits1_sum = tmp.sum(0)
hits2_sum = hits.sum((0,1))
hits2_sum = hits.sum((0, 1))
else:
hits0_sum = hits1_sum = hits2_sum = 1
tmp = data.sum(2)
dim0_sum = tmp.sum(1) / hits0_sum
dim1_sum = tmp.sum(0) / hits1_sum
dim2_sum = data.sum((0,1)) / hits2_sum
with warnings.catch_warnings():
warnings.simplefilter('ignore', RuntimeWarning)
dim0_sum = tmp.sum(1) / hits0_sum
dim1_sum = tmp.sum(0) / hits1_sum
dim2_sum = data.sum((0, 1)) / hits2_sum
# to get smth that resembles the sum rather than the mean,
# one can here multiply element wise by the summed 2D area
if hits is not None:
dim0_sum[hits0_sum<=0] = 0
dim1_sum[hits1_sum<=0] = 0
dim2_sum[hits2_sum<=0] = 0
dim0_sum[hits0_sum <= 0] = 0
dim1_sum[hits1_sum <= 0] = 0
dim2_sum[hits2_sum <= 0] = 0
return dim0_sum, dim1_sum, dim2_sum
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment