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
mlz
BornAgain
Commits
f67b34e6
Commit
f67b34e6
authored
Mar 16, 2021
by
Wuttke, Joachim
Browse files
repair fit52
parent
724d90ce
Changes
5
Hide whitespace changes
Inline
Side-by-side
Examples/fit51_Basic/consecutive_fitting.py
View file @
f67b34e6
...
...
@@ -10,6 +10,7 @@ after that to find precise minimum location.
import
numpy
as
np
from
matplotlib
import
pyplot
as
plt
import
bornagain
as
ba
import
ba_fitmonitor
from
bornagain
import
deg
,
angstrom
,
nm
...
...
@@ -80,7 +81,8 @@ def run_fitting():
fit_objective
=
ba
.
FitObjective
()
fit_objective
.
addSimulationAndData
(
get_simulation
,
real_data
,
1
)
fit_objective
.
initPrint
(
10
)
fit_objective
.
initPlot
(
10
)
observer
=
ba_fitmonitor
.
PlotterGISAS
()
fit_objective
.
initPlot
(
10
,
observer
)
"""
Setting fitting parameters with starting values.
Here we select starting values being quite far from true values
...
...
Examples/fit52_Advanced/find_background.py
View file @
f67b34e6
...
...
@@ -10,6 +10,7 @@ scale and background factors.
import
numpy
as
np
from
matplotlib
import
pyplot
as
plt
import
bornagain
as
ba
import
ba_fitmonitor
from
bornagain
import
deg
,
angstrom
,
nm
...
...
@@ -90,7 +91,8 @@ def run_fitting():
fit_objective
.
addSimulationAndData
(
get_simulation
,
real_data
,
1
)
fit_objective
.
initPrint
(
10
)
fit_objective
.
initPlot
(
10
)
observer
=
ba_fitmonitor
.
PlotterGISAS
()
fit_objective
.
initPlot
(
10
,
observer
)
params
=
ba
.
Parameters
()
params
.
add
(
"radius"
,
5.
*
nm
,
vary
=
False
)
...
...
Examples/fit52_Advanced/fit_along_slices.py
View file @
f67b34e6
...
...
@@ -5,6 +5,7 @@ Fitting example: fit along slices
from
matplotlib
import
pyplot
as
plt
import
bornagain
as
ba
import
ba_plot
from
bornagain
import
deg
,
angstrom
,
nm
phi_slice_value
=
0.0
# position of vertical slice in deg
...
...
@@ -93,7 +94,7 @@ class PlotObserver:
representing slices on top.
"""
plt
.
subplots_adjust
(
wspace
=
0.2
,
hspace
=
0.2
)
ba
.
plot_histogram
(
data
,
title
=
"Experimental data"
)
ba
_plot
.
plot_histogram
(
data
,
title
=
"Experimental data"
)
# line representing vertical slice
plt
.
plot
([
phi_slice_value
,
phi_slice_value
],
[
data
.
getYmin
(),
data
.
getYmax
()],
...
...
Examples/fit52_Advanced/fit_with_masks.py
View file @
f67b34e6
...
...
@@ -7,6 +7,7 @@ import numpy as np
from
matplotlib
import
pyplot
as
plt
import
bornagain
as
ba
from
bornagain
import
deg
,
angstrom
,
nm
import
ba_fitmonitor
def
get_sample
(
params
):
...
...
@@ -118,7 +119,8 @@ def run_fitting():
fit_objective
=
ba
.
FitObjective
()
fit_objective
.
addSimulationAndData
(
get_simulation
,
real_data
,
1
)
fit_objective
.
initPrint
(
10
)
fit_objective
.
initPlot
(
10
)
observer
=
ba_fitmonitor
.
PlotterGISAS
()
fit_objective
.
initPlot
(
10
,
observer
)
params
=
ba
.
Parameters
()
params
.
add
(
"radius"
,
6.
*
nm
,
min
=
4
,
max
=
8
)
...
...
Examples/fit52_Advanced/multiple_datasets.py
View file @
f67b34e6
...
...
@@ -7,8 +7,8 @@ import numpy as np
import
matplotlib
from
matplotlib
import
pyplot
as
plt
import
bornagain
as
ba
from
bornagain
import
deg
,
angstrom
,
nm
from
bornagain
import
deg
,
nm
import
ba_plot
as
bp
def
get_sample
(
params
):
"""
...
...
@@ -46,7 +46,7 @@ def get_simulation(params):
simulation
=
ba
.
GISASSimulation
()
simulation
.
setDetectorParameters
(
50
,
-
1.5
*
deg
,
1.5
*
deg
,
50
,
0
,
2
*
deg
)
simulation
.
setBeamParameters
(
1
*
angstro
m
,
incident_angle
,
0
)
simulation
.
setBeamParameters
(
0.1
*
n
m
,
incident_angle
,
0
)
simulation
.
beam
().
setIntensity
(
1e+08
)
simulation
.
setSample
(
get_sample
(
params
))
return
simulation
...
...
@@ -108,24 +108,24 @@ class PlotObserver():
zmax
=
real_data
.
histogram2d
().
getMaximum
()
plt
.
subplot
(
canvas
[
i_dataset
*
3
])
b
a
.
plot_colormap
(
real_data
,
b
p
.
plot_colormap
(
real_data
,
title
=
"
\"
Real
\"
data - #"
+
str
(
i_dataset
+
1
),
z
min
=
1
,
z
max
=
zmax
,
intensity_
min
=
1
,
intensity_
max
=
zmax
,
zlabel
=
""
)
plt
.
subplot
(
canvas
[
1
+
i_dataset
*
3
])
b
a
.
plot_colormap
(
simul_data
,
b
p
.
plot_colormap
(
simul_data
,
title
=
"Simulated data - #"
+
str
(
i_dataset
+
1
),
z
min
=
1
,
z
max
=
zmax
,
intensity_
min
=
1
,
intensity_
max
=
zmax
,
zlabel
=
""
)
plt
.
subplot
(
canvas
[
2
+
i_dataset
*
3
])
b
a
.
plot_colormap
(
chi2_map
,
b
p
.
plot_colormap
(
chi2_map
,
title
=
"Chi2 map - #"
+
str
(
i_dataset
+
1
),
z
min
=
0.001
,
z
max
=
10
,
intensity_
min
=
0.001
,
intensity_
max
=
10
,
zlabel
=
""
)
@
staticmethod
...
...
Write
Preview
Supports
Markdown
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