From 6afaeb73d8c355738ba2a5798638a5e29c994c8e Mon Sep 17 00:00:00 2001 From: Yannick Ulrich <yannick.ulrich@psi.ch> Date: Fri, 28 Feb 2020 12:39:30 +0100 Subject: [PATCH] minor changes to #17 --- pymule/__init__.py | 5 +++-- pymule/errortools.py | 11 +++++++++++ pymule/plot.py | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pymule/__init__.py b/pymule/__init__.py index 5489e16..02eb442 100644 --- a/pymule/__init__.py +++ b/pymule/__init__.py @@ -18,7 +18,8 @@ __all__ = [ 'addsets', 'scaleset', 'errorband', 'kplot', 'watermark', 'pi', 'alpha', 'GF', 'conv', 'Mmu', 'Mel', 'Mtau', - 'importvegas', 'exportvegas', 'mulify', 'colours' + 'importvegas', 'exportvegas', 'mulify', 'colours', 'printnumber', + 'chisq' ] @@ -29,7 +30,7 @@ from vegas import importvegas, exportvegas from errortools import mergenumbers, plusnumbers, dividenumbers, timesnumbers,\ mergeplots, addplots, divideplots, scaleplot, \ combineplots, combineNplots, \ - integratehistogram, mergebins + integratehistogram, mergebins, printnumber, chisq from loader import importreg, pattern, setup, sigma, \ mergeset, mergeseeds, mergefks, \ addsets, scaleset diff --git a/pymule/errortools.py b/pymule/errortools.py index 4c95b85..1a529a3 100644 --- a/pymule/errortools.py +++ b/pymule/errortools.py @@ -1,6 +1,17 @@ import numpy as np +def chisq(values): + if type(values) == list: + values = np.array(values) + weight = sum(1 / values[:,1]**2) + value = sum(values[:,0] / values[:,1]**2 / weight) + chi = 1./len(values) * sum( + ((values[:,0]-value) / values[:,1])**2 + ) + return chi + + def mergenumbers(values, quiet=False): if type(values) == list: values = np.array(values) diff --git a/pymule/plot.py b/pymule/plot.py index e424da0..6eb0236 100644 --- a/pymule/plot.py +++ b/pymule/plot.py @@ -17,6 +17,7 @@ rc('text.latex', preamble="\n".join([ '\\newcommand{\\D}{\\mathrm{d}}' ])) + def setup_pgf(): plt.rcParams.update({ "pgf.texsystem": "pdflatex", -- GitLab