diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index 36762eea..a95060c6 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -176,7 +176,7 @@ class Corr: sp_vec = sp_vec/np.sqrt(sp_vec@sp_vec) return sp_vec - def deriv(self, symmetric=False): #Defaults to forward derivative f'(t)=f(t+1)-f(t) + def deriv(self, symmetric=True): #Defaults to symmetric derivative if not symmetric: newcontent = [] for t in range(self.T - 1): @@ -198,7 +198,20 @@ class Corr: raise Exception('Derivative is undefined at all timeslices') return Corr(newcontent, padding_back=1, padding_front=1) - def m_eff(self, variant='log', guess=1.0): + + def second_deriv(self): + newcontent = [] + for t in range(1, self.T-1): + if (self.content[t-1] is None) or (self.content[t+1] is None): + newcontent.append(None) + else: + newcontent.append((self.content[t + 1] - 2 * self.content[t] + self.content[t - 1])) + if(all([x is None for x in newcontent])): + raise Exception("Derivative is undefined at all timeslices") + return Corr(newcontent, padding_back=1, padding_front=1) + + +def m_eff(self, variant='log', guess=1.0): """Returns the effective mass of the correlator as correlator object Parameters @@ -609,116 +622,3 @@ class Corr: return self * y def __radd__(self,y): return self + y - - - -##One of the most common tasks is to select a range for a plateau or a fit. This is best done visually. -#def GUI_range_finder(corr, current_range=None): -# T=corr.T -# if corr.N!=1: -# raise Exception("The Corr needs to be projected to select a range.") -# #We need to define few helper functions for the Gui -# def get_figure(corr,values): -# fig = matplotlib.figure.Figure(figsize=(7, 4), dpi=100) -# fig.clf() -# x,y,err=corr.plottable() -# ax=fig.add_subplot(111,label="main")#.plot(t, 2 * np.sin(2 * np.pi * t)) -# end=int(max(values["range_start"],values["range_end"])) -# start=int(min(values["range_start"],values["range_end"])) -# db=[0.1,0.2,0.8] -# ax.errorbar(x,y,err, fmt="-o",color=[0.4,0.6,0.8]) -# ax.errorbar(x[start:end],y[start:end],err[start:end], fmt="-o",color=db) -# offset=int(0.3*(end-start)) -# xrange=[max(min(start-1,int(start-offset)),0),min(max(int(end+offset),end+1),T-1)] -# ax.grid() -# if values["Plateau"]: -# plateau=corr.plateau([start,end]) -# ax.hlines(plateau.value,0,T+1,lw=plateau.dvalue,color="red",alpha=0.5) -# ax.hlines(plateau.value,0,T+1,lw=1,color="red") -# ax.set_title(r"Current Plateau="+str(plateau)[4:-1]) -# if(values["Crop X"]): -# ax.set_xlim(xrange) -# ax.set_xticks([x for x in ax.get_xticks() if (x-int(x)==0) and (0<=x