Fixed bug in Corr._init_() , added auto_gamma argument to plateaus and updated the examples.

This commit is contained in:
JanNeuendorf 2022-02-18 09:46:07 +01:00
parent 032b0b5116
commit 951233ab79
4 changed files with 40 additions and 42 deletions

View file

@ -56,8 +56,8 @@ class Corr:
N = data_input.shape[0]
input_as_list = []
for t in range(T):
if any([(item.content[t][0] is None) for item in data_input.flatten()]):
if not all([(item.content[t][0] is None) for item in data_input.flatten()]):
if any([(item.content[t] is None) for item in data_input.flatten()]):
if not all([(item.content[t] is None) for item in data_input.flatten()]):
warnings.warn("Input ill-defined at different timeslices. Conversion leads to data loss!", RuntimeWarning)
input_as_list.append(None)
else:
@ -645,7 +645,7 @@ class Corr:
result = least_squares(xs, ys, function, silent=silent, **kwargs)
return result
def plateau(self, plateau_range=None, method="fit"):
def plateau(self, plateau_range=None, method="fit", auto_gamma=False):
""" Extract a plateau value from a Corr object
Parameters
@ -657,6 +657,8 @@ class Corr:
method to extract the plateau.
'fit' fits a constant to the plateau region
'avg', 'average' or 'mean' just average over the given timeslices.
auto_gamma : bool
apply gamma_method with default parameters to the Corr. Defaults to None
"""
if not plateau_range:
if self.prange:
@ -667,6 +669,8 @@ class Corr:
raise Exception("Correlator must be projected before getting a plateau.")
if(all([self.content[t] is None for t in range(plateau_range[0], plateau_range[1] + 1)])):
raise Exception("plateau is undefined at all timeslices in plateaurange.")
if auto_gamma:
self.gamma_method()
if method == "fit":
def const_func(a, t):
return a[0]