Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Experimental Physics
Quantum Circuits
python-repo
Commits
0c3a68f0
Commit
0c3a68f0
authored
Aug 25, 2020
by
Christian Schneider
Browse files
Removed overfitted horizontal offset
parent
107cb99b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
29 deletions
+11
-29
DataModule/mfit.py
DataModule/mfit.py
+11
-29
No files found.
DataModule/mfit.py
View file @
0c3a68f0
...
...
@@ -32,14 +32,13 @@ def lorentz_function(x, x0, gamma, offset, amplitude):
return
amplitude
*
(
gamma
/
2
)
**
2
/
(
(
x
-
x0
)
**
2
+
(
gamma
/
2
)
**
2
)
+
offset
def
exp_func
(
x
,
tau
,
amp
,
vert_offset
,
hor_offset
):
return
amp
*
np
.
exp
(
-
(
x
+
hor_offset
)
/
tau
)
+
vert_offset
def
exp_func
(
x
,
tau
,
amp
,
vert_offset
):
return
amp
*
np
.
exp
(
-
(
x
)
/
tau
)
+
vert_offset
def
T2_func
(
x
,
tau
,
f
,
phase
,
amp
,
vert_offset
,
hor_offset
):
return
(
amp
*
np
.
cos
(
2
*
np
.
pi
*
f
*
(
x
+
hor_offset
)
+
phase
)
*
np
.
exp
(
-
(
x
+
hor_offset
)
/
tau
)
+
vert_offset
)
def
T2_func
(
x
,
tau
,
f
,
phase
,
amp
,
vert_offset
):
return
(
amp
*
np
.
cos
(
2
*
np
.
pi
*
f
*
(
x
)
+
phase
)
*
np
.
exp
(
-
(
x
)
/
tau
))
+
vert_offset
class
fit_plugin
(
object
):
...
...
@@ -129,7 +128,7 @@ class fit_plugin(object):
# Qubit fit functions ######################################################
def
T1
(
self
,
tau0
=
None
,
amp0
=
None
,
vert_offset0
=
None
,
hor_offset0
=
None
,
def
T1
(
self
,
tau0
=
None
,
amp0
=
None
,
vert_offset0
=
None
,
plot
=
True
,
print_results
=
True
,
plot_init
=
False
):
"""Fit exponential decay to data
...
...
@@ -141,8 +140,6 @@ class fit_plugin(object):
Amplitude in units of y axis
vert_offset0 : float
Y Offset in y units
hor_offset : float
X Offset in x units
plot : bool
Plot fit after successful fitting
print_results : bool
...
...
@@ -157,12 +154,6 @@ class fit_plugin(object):
else
:
vert_offset_guess
=
vert_offset0
# Horizontal offset
if
hor_offset0
is
None
:
hor_offset_guess
=
self
.
_data
.
x
[
0
]
else
:
hor_offset_guess
=
hor_offset0
# Amplitude
if
amp0
is
None
:
amp_guess
=
self
.
_data
.
y
[
0
]
-
self
.
_data
.
y
[
-
1
]
...
...
@@ -181,19 +172,18 @@ class fit_plugin(object):
# Init pars to guess values ############################################
params
=
gmodel
.
make_params
(
tau
=
tau_guess
,
amp
=
amp_guess
,
vert_offset
=
vert_offset_guess
,
hor_offset
=
hor_offset_guess
)
vert_offset
=
vert_offset_guess
)
# Fitting ##############################################################
self
.
_fit_routine
(
gmodel
,
params
,
plot
,
print_results
,
plot_init
)
def
T2
(
self
,
tau0
=
None
,
f0
=
None
,
phase0
=
None
,
amp0
=
None
,
vert_offset0
=
None
,
hor_offset0
=
None
,
plot
=
True
,
print_results
=
True
,
plot_init
=
False
):
plot
=
True
,
print_results
=
True
,
plot_init
=
False
):
"""Fit T2 decay to data
Function used for fitting
math:`amp \cos{2\pi f (x
-hor_offset
) + \phase} \exp{-(
x
-hor_offset
)/
\t
au) + vert_offset`
math:`amp \cos{2\pi f (x) + \phase} \exp{-(
x)/
\t
au) + vert_offset`
"""
...
...
@@ -205,13 +195,6 @@ class fit_plugin(object):
else
:
vert_offset_guess
=
vert_offset0
# Horizontal offset
# Guess: first element in x
if
hor_offset0
is
None
:
hor_offset_guess
=
self
.
_data
.
x
[
0
]
else
:
hor_offset_guess
=
hor_offset0
# Decay time
# Guess: A tenth of x range
if
tau0
is
None
:
...
...
@@ -264,8 +247,7 @@ class fit_plugin(object):
f
=
f_guess
,
phase
=
phase_guess
,
amp
=
amp_guess
,
vert_offset
=
vert_offset_guess
,
hor_offset
=
hor_offset_guess
)
vert_offset
=
vert_offset_guess
)
# Set boundaries
params
[
'tau'
].
min
=
0
params
[
'f'
].
min
=
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment