Skip to content
Snippets Groups Projects
Commit 4cd133cc authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Specular1Par: exp and sim match, but output scale still wrong

parent 2abd032c
No related branches found
No related tags found
1 merge request!1968Equip read-in experimental data with coordinates, also allowing for alpha.
...@@ -13,14 +13,10 @@ from bornagain import angstrom, ba_fitmonitor ...@@ -13,14 +13,10 @@ from bornagain import angstrom, ba_fitmonitor
def load_data(): def load_data():
datadir = os.getenv('BA_DATA_DIR', '') datadir = os.getenv('BA_DATA_DIR', '')
data_fname = os.path.join(datadir, "specular/genx_alternating_layers.dat.gz") fname = os.path.join(datadir, "specular/genx_alternating_layers.dat.gz")
expdata = np.loadtxt(data_fname, usecols=(0, 1), skiprows=3) flags = ba.ImportSettings1D("2alpha (deg)", "#", "", 1, 2)
return ba.readData1D(fname, ba.csv1D, flags)
# convert double incident angle (degs) to incident angle (radians)
expdata[:, 0] *= np.pi/360
return (expdata[:, 0], expdata[:, 1])
def get_sample(P): def get_sample(P):
...@@ -45,7 +41,7 @@ def get_sample(P): ...@@ -45,7 +41,7 @@ def get_sample(P):
def get_simulation(P): def get_simulation(P):
scan = ba.AlphaScan(ba.ListScan("alpha (rad)", exp_x)) scan = ba.AlphaScan(expData.xAxis())
scan.setWavelength(1.54*angstrom) scan.setWavelength(1.54*angstrom)
sample = get_sample(P) sample = get_sample(P)
...@@ -53,13 +49,13 @@ def get_simulation(P): ...@@ -53,13 +49,13 @@ def get_simulation(P):
if __name__ == '__main__': if __name__ == '__main__':
exp_x, exp_y = load_data() expData = load_data()
P = ba.Parameters() P = ba.Parameters()
P.add("thickness_Ti", 50*angstrom, min=10*angstrom, max=60*angstrom) P.add("thickness_Ti", 50*angstrom, min=10*angstrom, max=60*angstrom)
fit_objective = ba.FitObjective() fit_objective = ba.FitObjective()
fit_objective.addSimulationAndData(get_simulation, exp_y, 1) fit_objective.addFitPair(get_simulation, expData, 1)
fit_objective.initPrint(10) fit_objective.initPrint(10)
plot_observer = ba_fitmonitor.PlotterSpecular(pause=0.5) plot_observer = ba_fitmonitor.PlotterSpecular(pause=0.5)
......
...@@ -13,14 +13,10 @@ from bornagain import angstrom, ba_fitmonitor ...@@ -13,14 +13,10 @@ from bornagain import angstrom, ba_fitmonitor
def load_data(): def load_data():
datadir = os.getenv('BA_DATA_DIR', '') datadir = os.getenv('BA_DATA_DIR', '')
data_fname = os.path.join(datadir, "specular/genx_alternating_layers.dat.gz") fname = os.path.join(datadir, "specular/genx_alternating_layers.dat.gz")
expdata = np.loadtxt(data_fname, usecols=(0, 1), skiprows=3) flags = ba.ImportSettings1D("2alpha (deg)", "#", "", 1, 2)
return ba.readData1D(fname, ba.csv1D, flags)
# convert double incident angle (degs) to incident angle (radians)
expdata[:, 0] *= np.pi/360
return (expdata[:, 0], expdata[:, 1])
def get_sample(P): def get_sample(P):
...@@ -45,7 +41,7 @@ def get_sample(P): ...@@ -45,7 +41,7 @@ def get_sample(P):
def get_simulation(P): def get_simulation(P):
scan = ba.AlphaScan(ba.ListScan("alpha (rad)", exp_x)) scan = ba.AlphaScan(expData.xAxis())
scan.setWavelength(1.54*angstrom) scan.setWavelength(1.54*angstrom)
sample = get_sample(P) sample = get_sample(P)
...@@ -53,13 +49,13 @@ def get_simulation(P): ...@@ -53,13 +49,13 @@ def get_simulation(P):
if __name__ == '__main__': if __name__ == '__main__':
exp_x, exp_y = load_data() expData = load_data()
P = ba.Parameters() P = ba.Parameters()
P.add("thickness_Ti", 50*angstrom, min=10*angstrom, max=60*angstrom) P.add("thickness_Ti", 50*angstrom, min=10*angstrom, max=60*angstrom)
fit_objective = ba.FitObjective() fit_objective = ba.FitObjective()
fit_objective.addSimulationAndData(get_simulation, exp_y, 1) fit_objective.addFitPair(get_simulation, expData, 1)
fit_objective.initPrint(10) fit_objective.initPrint(10)
plot_observer = ba_fitmonitor.PlotterSpecular(pause=0.5) plot_observer = ba_fitmonitor.PlotterSpecular(pause=0.5)
......
...@@ -15,8 +15,7 @@ def load_data(): ...@@ -15,8 +15,7 @@ def load_data():
datadir = os.getenv('BA_DATA_DIR', '') datadir = os.getenv('BA_DATA_DIR', '')
fname = os.path.join(datadir, "specular/genx_alternating_layers.dat.gz") fname = os.path.join(datadir, "specular/genx_alternating_layers.dat.gz")
raise Exception("TODO: treat data as angle(deg)") flags = ba.ImportSettings1D("2alpha (deg)", "#", "", 1, 2)
flags = ba.ImportSettings1D("#", "", 1, 2)
return ba.readData1D(fname, ba.csv1D, flags) return ba.readData1D(fname, ba.csv1D, flags)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment