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

File diff suppressed because one or more lines are too long

View file

@ -393,7 +393,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
@ -407,7 +407,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.8.8"
}
},
"nbformat": 4,

File diff suppressed because one or more lines are too long

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]