diff options
Diffstat (limited to 'utils/plot')
-rwxr-xr-x | utils/plot | 50 |
1 files changed, 2 insertions, 48 deletions
@@ -15,15 +15,6 @@ # this program. If not, see <https://www.gnu.org/licenses/>. from __future__ import print_function, division -import yaml -try: - from yaml import CLoader as Loader -except ImportError: - from yaml.loader import SafeLoader as Loader - -import numpy as np -from scipy.stats import iqr -from matplotlib.lines import Line2D # on retina screens, the default plots are way too small # by using Qt5 and setting QT_AUTO_SCREEN_SCALE_FACTOR=1 @@ -31,51 +22,14 @@ from matplotlib.lines import Line2D import matplotlib matplotlib.use("Qt5Agg") -IDP_E_MINUS = 20 -IDP_MU_MINUS = 22 - -SNOMAN_MASS = { - 20: 0.511, - 21: 0.511, - 22: 105.658, - 23: 105.658 -} - -def plot_hist(x, label=None): - # determine the bin width using the Freedman Diaconis rule - # see https://en.wikipedia.org/wiki/Freedman%E2%80%93Diaconis_rule - h = 2*iqr(x)/len(x)**(1/3) - n = max(int((np.max(x)-np.min(x))/h),10) - bins = np.linspace(np.min(x),np.max(x),n) - plt.hist(x, bins=bins, histtype='step', label=label) - -def plot_legend(n): - plt.figure(n) - ax = plt.gca() - handles, labels = ax.get_legend_handles_labels() - new_handles = [Line2D([],[],c=h.get_edgecolor()) for h in handles] - plt.legend(handles=new_handles,labels=labels) - -def get_stats(x): - """ - Returns a tuple (mean, error mean, std, error std) for the values in x. - - The formula for the standard error on the standard deviation comes from - https://stats.stackexchange.com/questions/156518. - """ - mean = np.mean(x) - std = np.std(x) - n = len(x) - u4 = np.mean((x-mean)**4) - error = np.sqrt((u4-(n-3)*std**4/(n-1))/n)/(2*std) - return mean, std/np.sqrt(n), std, error - if __name__ == '__main__': import argparse import matplotlib.pyplot as plt import numpy as np import h5py import pandas as pd + from sddm import IDP_E_MINUS, IDP_MU_MINUS, SNOMAN_MASS + from sddm.plot import plot_hist, plot_legend, get_stats parser = argparse.ArgumentParser("plot fit results") parser.add_argument("filenames", nargs='+', help="input files") |