From 2cb7c75ffdc881fe06995dbb99f1dcb570b429c2 Mon Sep 17 00:00:00 2001
From: Dmitry Yurov <d.yurov@fz-juelich.de>
Date: Mon, 11 Mar 2019 15:44:00 +0100
Subject: [PATCH] Add time of flight reflectometry to PyPersitence

---
 .../TimeOfFlightReflectometry.py                  |  10 +++++-----
 .../Python/PyPersistence/CMakeLists.txt           |   1 +
 .../Python/TimeOfFlightReflectometry.int.gz       | Bin 0 -> 246 bytes
 3 files changed, 6 insertions(+), 5 deletions(-)
 create mode 100644 Tests/ReferenceData/Python/TimeOfFlightReflectometry.int.gz

diff --git a/Examples/python/simulation/ex06_Reflectometry/TimeOfFlightReflectometry.py b/Examples/python/simulation/ex06_Reflectometry/TimeOfFlightReflectometry.py
index 41e3111f506..75d997344e7 100644
--- a/Examples/python/simulation/ex06_Reflectometry/TimeOfFlightReflectometry.py
+++ b/Examples/python/simulation/ex06_Reflectometry/TimeOfFlightReflectometry.py
@@ -13,8 +13,6 @@ import numpy as np
 import bornagain as ba
 from bornagain import angstrom
 
-qzs = np.linspace(0.01, 1.0, 500, dtype=float)  # qz-values
-
 
 def get_sample():
     """
@@ -44,27 +42,29 @@ def get_sample():
     return multi_layer
 
 
-def get_simulation():
+def get_simulation(scan_size=500):
     """
     Defines and returns specular simulation
     with a qz-defined beam
     """
+    qzs = np.linspace(0.01, 1.0, scan_size, dtype=float)  # qz-values
     scan = ba.QSpecScan(qzs)
     simulation = ba.SpecularSimulation()
     simulation.setScan(scan)
     return simulation
 
 
-def run_simulation(simulation):
+def run_simulation():
     """
     Runs simulation and returns its result.
     """
     sample = get_sample()
+    simulation = get_simulation()
     simulation.setSample(sample)
     simulation.runSimulation()
     return simulation.result()
 
 
 if __name__ == '__main__':
-    result = run_simulation(get_simulation())
+    result = run_simulation()
     ba.plot_simulation_result(result)
diff --git a/Tests/Functional/Python/PyPersistence/CMakeLists.txt b/Tests/Functional/Python/PyPersistence/CMakeLists.txt
index 18c2b8530fc..90b26b4371c 100644
--- a/Tests/Functional/Python/PyPersistence/CMakeLists.txt
+++ b/Tests/Functional/Python/PyPersistence/CMakeLists.txt
@@ -59,6 +59,7 @@ test_example("simulation/ex05_BeamAndDetector/ConstantBackground" 2e-10)
 test_example("simulation/ex06_Reflectometry/BasicSpecularSimulation" 2e-10)
 test_example("simulation/ex06_Reflectometry/BeamAngularDivergence" 2e-10)
 test_example("simulation/ex06_Reflectometry/BeamFullDivergence" 2e-10)
+test_example("simulation/ex06_Reflectometry/TimeOfFlightReflectometry" 2e-10)
 
 test_example("simulation/ex07_Miscellaneous/CylindersInAverageLayer" 2e-10)
 test_example("simulation/ex07_Miscellaneous/DepthProbe" 2e-10)
diff --git a/Tests/ReferenceData/Python/TimeOfFlightReflectometry.int.gz b/Tests/ReferenceData/Python/TimeOfFlightReflectometry.int.gz
new file mode 100644
index 0000000000000000000000000000000000000000..14cf9685e10e264b8d7ec060602e2637428e1ceb
GIT binary patch
literal 246
zcmV<S015veiwFP!00000|7FlUYr`-Q2H;)4LL^H|9dV!1-I&s)TldnzP*c1(5F6V3
z`$z=SxV=H3=Uz@9`}ll1Psgu*oZ{=W4AVR=m-x~zeF$M6`=4<>KzKWi)ABve!?Erk
zc1>Z|#V)=>0_-3m)rA-~)fy~YYdO*XIn7(sYPoDpsukNBS2O=R4?iB;?LXTyFx~ft
zCxBSXle?Q`CugzY0N50hQqBmR)eTprq)dVZ6kSVIx@C=33z?uWt;$K&3xhDT+-1Ga
w6=Vif|2+-C)Ht&^wyfMHNMR>K6-BM8O>_MXLqb#H?5l=w1t47hFu(x-0HBI;0{{R3

literal 0
HcmV?d00001

-- 
GitLab