Commit f67b34e6 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

repair fit52

parent 724d90ce
...@@ -10,6 +10,7 @@ after that to find precise minimum location. ...@@ -10,6 +10,7 @@ after that to find precise minimum location.
import numpy as np import numpy as np
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
import bornagain as ba import bornagain as ba
import ba_fitmonitor
from bornagain import deg, angstrom, nm from bornagain import deg, angstrom, nm
...@@ -80,7 +81,8 @@ def run_fitting(): ...@@ -80,7 +81,8 @@ def run_fitting():
fit_objective = ba.FitObjective() fit_objective = ba.FitObjective()
fit_objective.addSimulationAndData(get_simulation, real_data, 1) fit_objective.addSimulationAndData(get_simulation, real_data, 1)
fit_objective.initPrint(10) fit_objective.initPrint(10)
fit_objective.initPlot(10) observer = ba_fitmonitor.PlotterGISAS()
fit_objective.initPlot(10, observer)
""" """
Setting fitting parameters with starting values. Setting fitting parameters with starting values.
Here we select starting values being quite far from true values Here we select starting values being quite far from true values
......
...@@ -10,6 +10,7 @@ scale and background factors. ...@@ -10,6 +10,7 @@ scale and background factors.
import numpy as np import numpy as np
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
import bornagain as ba import bornagain as ba
import ba_fitmonitor
from bornagain import deg, angstrom, nm from bornagain import deg, angstrom, nm
...@@ -90,7 +91,8 @@ def run_fitting(): ...@@ -90,7 +91,8 @@ def run_fitting():
fit_objective.addSimulationAndData(get_simulation, real_data, 1) fit_objective.addSimulationAndData(get_simulation, real_data, 1)
fit_objective.initPrint(10) fit_objective.initPrint(10)
fit_objective.initPlot(10) observer = ba_fitmonitor.PlotterGISAS()
fit_objective.initPlot(10, observer)
params = ba.Parameters() params = ba.Parameters()
params.add("radius", 5.*nm, vary=False) params.add("radius", 5.*nm, vary=False)
......
...@@ -5,6 +5,7 @@ Fitting example: fit along slices ...@@ -5,6 +5,7 @@ Fitting example: fit along slices
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
import bornagain as ba import bornagain as ba
import ba_plot
from bornagain import deg, angstrom, nm from bornagain import deg, angstrom, nm
phi_slice_value = 0.0 # position of vertical slice in deg phi_slice_value = 0.0 # position of vertical slice in deg
...@@ -93,7 +94,7 @@ class PlotObserver: ...@@ -93,7 +94,7 @@ class PlotObserver:
representing slices on top. representing slices on top.
""" """
plt.subplots_adjust(wspace=0.2, hspace=0.2) 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 # line representing vertical slice
plt.plot([phi_slice_value, phi_slice_value], plt.plot([phi_slice_value, phi_slice_value],
[data.getYmin(), data.getYmax()], [data.getYmin(), data.getYmax()],
......
...@@ -7,6 +7,7 @@ import numpy as np ...@@ -7,6 +7,7 @@ import numpy as np
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
import bornagain as ba import bornagain as ba
from bornagain import deg, angstrom, nm from bornagain import deg, angstrom, nm
import ba_fitmonitor
def get_sample(params): def get_sample(params):
...@@ -118,7 +119,8 @@ def run_fitting(): ...@@ -118,7 +119,8 @@ def run_fitting():
fit_objective = ba.FitObjective() fit_objective = ba.FitObjective()
fit_objective.addSimulationAndData(get_simulation, real_data, 1) fit_objective.addSimulationAndData(get_simulation, real_data, 1)
fit_objective.initPrint(10) fit_objective.initPrint(10)
fit_objective.initPlot(10) observer = ba_fitmonitor.PlotterGISAS()
fit_objective.initPlot(10, observer)
params = ba.Parameters() params = ba.Parameters()
params.add("radius", 6.*nm, min=4, max=8) params.add("radius", 6.*nm, min=4, max=8)
......
...@@ -7,8 +7,8 @@ import numpy as np ...@@ -7,8 +7,8 @@ import numpy as np
import matplotlib import matplotlib
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
import bornagain as ba import bornagain as ba
from bornagain import deg, angstrom, nm from bornagain import deg, nm
import ba_plot as bp
def get_sample(params): def get_sample(params):
""" """
...@@ -46,7 +46,7 @@ def get_simulation(params): ...@@ -46,7 +46,7 @@ def get_simulation(params):
simulation = ba.GISASSimulation() simulation = ba.GISASSimulation()
simulation.setDetectorParameters(50, -1.5*deg, 1.5*deg, 50, 0, 2*deg) simulation.setDetectorParameters(50, -1.5*deg, 1.5*deg, 50, 0, 2*deg)
simulation.setBeamParameters(1*angstrom, incident_angle, 0) simulation.setBeamParameters(0.1*nm, incident_angle, 0)
simulation.beam().setIntensity(1e+08) simulation.beam().setIntensity(1e+08)
simulation.setSample(get_sample(params)) simulation.setSample(get_sample(params))
return simulation return simulation
...@@ -108,24 +108,24 @@ class PlotObserver(): ...@@ -108,24 +108,24 @@ class PlotObserver():
zmax = real_data.histogram2d().getMaximum() zmax = real_data.histogram2d().getMaximum()
plt.subplot(canvas[i_dataset*3]) plt.subplot(canvas[i_dataset*3])
ba.plot_colormap(real_data, bp.plot_colormap(real_data,
title="\"Real\" data - #" + title="\"Real\" data - #" +
str(i_dataset + 1), str(i_dataset + 1),
zmin=1, intensity_min=1,
zmax=zmax, intensity_max=zmax,
zlabel="") zlabel="")
plt.subplot(canvas[1 + i_dataset*3]) plt.subplot(canvas[1 + i_dataset*3])
ba.plot_colormap(simul_data, bp.plot_colormap(simul_data,
title="Simulated data - #" + title="Simulated data - #" +
str(i_dataset + 1), str(i_dataset + 1),
zmin=1, intensity_min=1,
zmax=zmax, intensity_max=zmax,
zlabel="") zlabel="")
plt.subplot(canvas[2 + i_dataset*3]) plt.subplot(canvas[2 + i_dataset*3])
ba.plot_colormap(chi2_map, bp.plot_colormap(chi2_map,
title="Chi2 map - #" + str(i_dataset + 1), title="Chi2 map - #" + str(i_dataset + 1),
zmin=0.001, intensity_min=0.001,
zmax=10, intensity_max=10,
zlabel="") zlabel="")
@staticmethod @staticmethod
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment