Changeset 14198
- Timestamp:
- 06/21/12 15:43:11 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/sandbox/dneise/mc_pulses_for_sabrina/gen_TH1D.py
r13468 r14198 7 7 import sys 8 8 from ROOT import * 9 from scipy import interpolate 10 11 #from plotters import Plotter 12 import matplotlib.pyplot as plt 9 13 10 14 class SignalGenerator(object): … … 105 109 time, maxprob, mean, median = np.loadtxt( file_name, delimiter=',', unpack=True) 106 110 csv_data = maxprob 111 112 # shift the input data such, that the left baseline is equal to zero 113 csv_data = csv_data - csv_data[:50].mean() 114 115 # I want the data to be longer than they are, so I add 1000 slices left and right 116 self.csv_data = np.zeros(2000 + len(csv_data)) 117 118 for i in range(len(csv_data)): 119 self.csv_data[1000+i] = csv_data[i] 120 for i in range(1000): 121 self.csv_data[i] = csv_data[:50].mean() 122 self.csv_data[-1*i] = csv_data[-50:].mean() 123 124 # fermi dirac distribution for weighting the input data. 125 # we do not believe the right tail is really higher than zero, so we make it go to zero. 126 weight_function = lambda x : 1. / (1 + np.exp((x - 1200.)/25.)) 127 x = np.arange(0,len(self.csv_data),1) 128 weights = map(weight_function, x) 129 130 bla = self.csv_data.copy() 131 132 self.csv_data = weights * self.csv_data 133 134 tck = interpolate.splrep(x, self.csv_data ,s=50) 135 tck2 = interpolate.splrep(x, bla ,s=50) 136 137 xnew = np.arange(0,len(self.csv_data), 0.1) 138 ynew = interpolate.splev(xnew,tck,der=0) 139 ynew2 = interpolate.splev(xnew,tck2,der=0) 140 141 plt.figure() 142 plt.plot(x,self.csv_data,'.:k',xnew,ynew,'b',x, weights, '.:r', x,bla,'.:g',xnew,ynew2,'m') 143 plt.show() 144 raw_input('stop') 107 145 108 146 # csv data was downshifted, I shift it up here
Note:
See TracChangeset
for help on using the changeset viewer.