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.
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
......
......@@ -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)
......
......@@ -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()],
......
......@@ -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)
......
......@@ -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*angstrom, incident_angle, 0)
simulation.setBeamParameters(0.1*nm, 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])
ba.plot_colormap(real_data,
bp.plot_colormap(real_data,
title="\"Real\" data - #" +
str(i_dataset + 1),
zmin=1,
zmax=zmax,
intensity_min=1,
intensity_max=zmax,
zlabel="")
plt.subplot(canvas[1 + i_dataset*3])
ba.plot_colormap(simul_data,
bp.plot_colormap(simul_data,
title="Simulated data - #" +
str(i_dataset + 1),
zmin=1,
zmax=zmax,
intensity_min=1,
intensity_max=zmax,
zlabel="")
plt.subplot(canvas[2 + i_dataset*3])
ba.plot_colormap(chi2_map,
bp.plot_colormap(chi2_map,
title="Chi2 map - #" + str(i_dataset + 1),
zmin=0.001,
zmax=10,
intensity_min=0.001,
intensity_max=10,
zlabel="")
@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