Commit 3af54351 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Repaired fit55

parent b59d542d
...@@ -93,7 +93,7 @@ def get_simulation(q_axis, parameters, polarization, analyzer): ...@@ -93,7 +93,7 @@ def get_simulation(q_axis, parameters, polarization, analyzer):
scan.setAbsoluteQResolution(distr, parameters["q_res"]) scan.setAbsoluteQResolution(distr, parameters["q_res"])
simulation.beam().setPolarization(polarization) simulation.beam().setPolarization(polarization)
simulation.setAnalyzerProperties(analyzer, 1, 0.5) simulation.detector().setAnalyzerProperties(analyzer, 1, 0.5)
simulation.setScan(scan) simulation.setScan(scan)
return simulation return simulation
......
...@@ -34,6 +34,7 @@ from matplotlib import pyplot as plt ...@@ -34,6 +34,7 @@ from matplotlib import pyplot as plt
import numpy as np import numpy as np
from os import path from os import path
import bornagain as ba import bornagain as ba
import ba_plot
from scipy.optimize import differential_evolution from scipy.optimize import differential_evolution
...@@ -151,7 +152,7 @@ def chi_2(real_data, sim_data, weights): ...@@ -151,7 +152,7 @@ def chi_2(real_data, sim_data, weights):
Computes chi_2 metrics and returns its value Computes chi_2 metrics and returns its value
""" """
sim_data_upsc = np.multiply(weights, sim_data) sim_data_upsc = np.multiply(weights, sim_data)
sim_data_upsc[sim_data_upsc is 0] = 1e-30 sim_data_upsc[sim_data_upsc==0] = 1e-30
real_data_upsc = np.multiply(weights, real_data) real_data_upsc = np.multiply(weights, real_data)
diff = real_data_upsc - sim_data_upsc diff = real_data_upsc - sim_data_upsc
return np.sum(np.divide(np.multiply(diff, diff), sim_data_upsc)) return np.sum(np.divide(np.multiply(diff, diff), sim_data_upsc))
...@@ -270,7 +271,7 @@ def plot_result(sim_result, ref_result, bin_start=0, bin_end=-1): ...@@ -270,7 +271,7 @@ def plot_result(sim_result, ref_result, bin_start=0, bin_end=-1):
get_real_data_values(bin_start, bin_end), sim_result.axis(), get_real_data_values(bin_start, bin_end), sim_result.axis(),
sim_data, ref_result.axis(), ref_data) sim_data, ref_result.axis(), ref_data)
xlabel = ba.get_axes_labels(sim_result, ba.Axes.DEFAULT)[0] xlabel = ba_plot.get_axes_labels(sim_result, ba.Axes.DEFAULT)[0]
ylabel = "Intensity" ylabel = "Intensity"
plt.xlabel(xlabel, fontsize=16) plt.xlabel(xlabel, fontsize=16)
plt.ylabel(ylabel, fontsize=16) plt.ylabel(ylabel, fontsize=16)
......
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