Skip to content

Commit 6bcb609

Browse files
committed
Simplified fitting of pulse train experiment
- Simplified fitting by removing row-dependent offsets in the fitting function
1 parent 9e79bdd commit 6bcb609

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

Qanalysis/time_domain.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -961,23 +961,19 @@ def __init__(self, correction, repetition, signal):
961961
self.popt = None
962962
self.pcov = None
963963

964-
def fit_func(self, repetition, eps0, N1, *args):
964+
def fit_func(self, repetition, eps0, N1, A, B):
965965
"""
966966
Fitting Function for Pulse Train experiment.
967967
"""
968-
969968
N = len(repetition) // self.n_correction
970-
971-
A = args[:self.n_correction]
972-
B = args[self.n_correction:]
973969

974970
decay = [np.exp(-repetition[(i * N):((i + 1) * N)] / N1)
975971
for i in range(self.n_correction)]
976972
oscillation = [np.cos(np.pi * (1 + eps0) *
977973
(1 + self.correction[i]) *
978974
(2 * repetition[(i * N):((i + 1) * N)] + 0.5))
979975
for i in range(self.n_correction)]
980-
return np.hstack([A[i] * decay[i] * oscillation[i] + B[i]
976+
return np.hstack([A * decay[i] * oscillation[i] + B
981977
for i in range(self.n_correction)])
982978

983979
def _guess_init_params(self):
@@ -995,8 +991,7 @@ def _guess_init_params(self):
995991

996992
zero_idx = np.argmin(np.var(self.signal, axis=-1))
997993

998-
self.p0 = [-self.correction[zero_idx],
999-
N1, *([A0] * self.n_correction), *([B0] * self.n_correction)]
994+
self.p0 = [-self.correction[zero_idx], N1, A0, B0]
1000995

1001996
def analyze(self, p0=None, plot=True, **kwargs):
1002997
"""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "Qanalysis"
7-
version = "0.2.0"
7+
version = "0.2.1"
88
authors = [
99
{ name="Eunjong Kim", email="ekim7206@gmail.com" },
1010
]

0 commit comments

Comments
 (0)