Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
whuie2
experiment-control
Commits
c199ff62
Commit
c199ff62
authored
Jan 17, 2022
by
whooie
Browse files
account for possible angling in lmfit_gaussian
parent
28a28a9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/imaging.py
View file @
c199ff62
...
...
@@ -299,8 +299,13 @@ def lmfit_gaussian(data, dA, k=None):
sx
=
params
[
"sx"
]
y0
=
params
[
"y0"
]
sy
=
params
[
"sy"
]
th
=
params
[
"theta"
]
B
=
params
[
"B"
]
return
A
*
np
.
exp
(
-
((
_X
-
x0
)
/
sx
)
**
2
-
((
_Y
-
y0
)
/
sy
)
**
2
)
+
B
_Xrel
=
_X
-
x0
_Yrel
=
_Y
-
y0
_Xrot
=
np
.
cos
(
th
)
*
_Xrel
+
np
.
sin
(
th
)
*
_Yrel
_Yrot
=
-
np
.
sin
(
th
)
*
_Xrel
+
np
.
cos
(
th
)
*
_Yrel
return
A
*
np
.
exp
(
-
(
_Xrot
/
sx
)
**
2
-
(
_Yrot
/
sy
)
**
2
)
+
B
def
residual
(
params
:
lmfit
.
Parameters
):
m
=
model
(
params
)
...
...
@@ -312,6 +317,7 @@ def lmfit_gaussian(data, dA, k=None):
params
.
add
(
"sx"
,
value
=
(
x
.
max
()
-
x
.
min
())
/
12
)
params
.
add
(
"y0"
,
value
=
y0
)
params
.
add
(
"sy"
,
value
=
(
y
.
max
()
-
y
.
min
())
/
12
)
params
.
add
(
"theta"
,
value
=
0.0
,
min
=
0.0
,
max
=
np
.
pi
/
2
)
params
.
add
(
"B"
,
value
=
data
.
mean
())
fit
=
lmfit
.
minimize
(
residual
,
params
)
if
not
fit
.
success
:
...
...
@@ -331,5 +337,6 @@ def lmfit_gaussian(data, dA, k=None):
print
(
fit
.
params
[
"sx"
])
print
(
fit
.
params
[
"y0"
])
print
(
fit
.
params
[
"sy"
])
print
(
fit
.
params
[
"theta"
])
return
float
(
fit
.
params
[
"sx"
]),
float
(
fit
.
params
[
"sy"
])
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