From 2b70cb3073ccd66c52a3f9ea2e15a385028c7df4 Mon Sep 17 00:00:00 2001
From: Dmitry Yurov <d.yurov@fz-juelich.de>
Date: Tue, 19 Feb 2019 15:47:31 +0100
Subject: [PATCH] Deploy SimulationResult::axis in examples and plot utils.

Redmine: #2305
---
 .../TimeOfFlightReflectometry.py              |  4 +---
 Wrap/python/plot_utils.py                     | 19 +++++++++----------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/Examples/python/simulation/ex06_Reflectometry/TimeOfFlightReflectometry.py b/Examples/python/simulation/ex06_Reflectometry/TimeOfFlightReflectometry.py
index cc9a2278b76..5854aca34f0 100644
--- a/Examples/python/simulation/ex06_Reflectometry/TimeOfFlightReflectometry.py
+++ b/Examples/python/simulation/ex06_Reflectometry/TimeOfFlightReflectometry.py
@@ -87,9 +87,7 @@ def plot(result_wl, result_qz):
 
     ba.plot_simulation_result(result_qz, postpone_show=True)
 
-    wl_sim_data = result_wl.data()
-    wl_axis = wl_sim_data.getAxis(0).getBinCenters()
-    plt.semilogy(wl_axis, result_wl.array(), 'ko', markevery=10)
+    plt.semilogy(result_wl.axis(), result_wl.array(), 'ko', markevery=10)
     plt.legend([r'$q_z$-defined beam',
                 r'$\lambda$-defined beam'],
                loc='upper right')
diff --git a/Wrap/python/plot_utils.py b/Wrap/python/plot_utils.py
index b1d0fba48c4..b2eee37e9e2 100644
--- a/Wrap/python/plot_utils.py
+++ b/Wrap/python/plot_utils.py
@@ -167,9 +167,8 @@ def plot_specular_simulation_result(result, ymin=None, ymax=None, units=ba.AxesU
     :param units: units on the x-axis
     """
 
-    data = result.data(units)
-    intensity = data.getArray()
-    x_axis = data.getAxis(0).getBinCenters()
+    intensity = result.array()
+    x_axis = result.axis(units)
     ymax = np.amax(intensity) * 2.0 if ymax is None else ymax
     ymin = max(np.amin(intensity) * 0.5, 1e-18 * ymax) if ymin is None else ymin
 
@@ -456,12 +455,12 @@ class PlotterSpecular(Plotter):
 
     def plot_graph(self, fit_objective):
         # retrieving data from fit suite
-        real_data = fit_objective.experimentalData().data()
-        sim_data = fit_objective.simulationResult().data()
+        real_data = fit_objective.experimentalData()
+        sim_data = fit_objective.simulationResult()
 
         # data values
-        sim_values = sim_data.getArray()
-        real_values = real_data.getArray()
+        sim_values = sim_data.array()
+        real_values = real_data.array()
 
         # default font properties dictionary to use
         font = {'family': 'serif',
@@ -469,11 +468,11 @@ class PlotterSpecular(Plotter):
                 'size': label_fontsize}
 
         plt.subplot(self.gs[0])
-        plt.semilogy(sim_data.getAxis(0).getBinCenters(), sim_values, 'b',
-                     real_data.getAxis(0).getBinCenters(), real_values, 'k--')
+        plt.semilogy(sim_data.axis(), sim_values, 'b',
+                     real_data.axis(), real_values, 'k--')
         plt.ylim((0.5 * np.min(real_values), 5 * np.max(real_values)))
 
-        xlabel = get_axes_labels(fit_objective.experimentalData(), ba.AxesUnits.DEFAULT)[0]
+        xlabel = get_axes_labels(real_data, ba.AxesUnits.DEFAULT)[0]
         plt.legend(['BornAgain', 'Reference'], loc='upper right', prop=font)
         plt.xlabel(xlabel, fontdict=font)
         plt.ylabel("Intensity", fontdict=font)
-- 
GitLab