From 637c55e9716df004ec5777ed6a463f20479f63a7 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Wed, 6 Apr 2022 13:54:03 +0200
Subject: [PATCH] angle labels now correctly in deg

---
 Examples/ff/SasPyramid4.py | 10 +++++-----
 Examples/ff/bornplot2.py   | 13 ++++++++-----
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/Examples/ff/SasPyramid4.py b/Examples/ff/SasPyramid4.py
index 4b29ec6d098..48ee8dc0494 100755
--- a/Examples/ff/SasPyramid4.py
+++ b/Examples/ff/SasPyramid4.py
@@ -2,10 +2,10 @@
 
 import bornagain as ba
 from bornagain import nm, deg
-import bornplot2 as bp
+import bornplot2 as bp2
 
 m_particle = ba.HomogeneousMaterial("Particle", 1e-5, 0)
-det = ba.SphericalDetector(200, 5*deg, 2.5*deg, 2.5*deg)
+npix = 200
 
 def simulate_at(omega):
     title = r'$\omega=%d^\circ$' % omega
@@ -14,10 +14,10 @@ def simulate_at(omega):
     particle = ba.Particle(m_particle, ff)
     particle.setRotation(ba.RotationZ(omega*deg))
 
-    result = bp.run_simulation_with_particle(det, particle)
-    return bp.NamedResult(result, title)
+    result = bp2.run_sas_with_particle(npix, particle)
+    return bp2.NamedResult(result, title)
 
 namedResults = [simulate_at(omega) for omega in [0, 30]]
 
-bp.make_plot_row(namedResults, det, "ff_Pyramid4")
+bp2.make_plot_row(namedResults, "ff_Pyramid4")
 # bp.save_results(namedResults, "ff_Pyramid4")
diff --git a/Examples/ff/bornplot2.py b/Examples/ff/bornplot2.py
index 053cbf3a1e8..f35dbc27066 100644
--- a/Examples/ff/bornplot2.py
+++ b/Examples/ff/bornplot2.py
@@ -12,6 +12,7 @@ mpl.rcParams['image.interpolation'] = 'none'
 
 import bornagain as ba
 from bornagain import deg, angstrom
+from bornagain import ba_plot as bp
 
 
 class NamedResult:
@@ -87,11 +88,11 @@ class MultiPlot:
         cb.set_label(r'$\left|F(q)\right|^2/V^{\,2}$', fontsize=self.fontsize)
 
 
-def make_plot_row(namedResults, det, name):
-    make_plot(namedResults, det, name, len(namedResults))
+def make_plot_row(namedResults, name):
+    make_plot(namedResults, name, len(namedResults))
 
 
-def make_plot(namedResults, det, name, ncol):
+def make_plot(namedResults, name, ncol):
     """
     Make a plot consisting of one detector image for each Result in results,
     plus one common color scale.
@@ -109,9 +110,10 @@ def make_plot(namedResults, det, name, ncol):
     for i in range(len(namedResults)):
         item = namedResults[i]
         ax = multiPlot.axes[i]
+        axes_limits = bp.get_axes_limits(item.result, ba.Axes.UNDEFINED)
         im = ax.imshow(item.result.array(),
                        norm=norm,
-                       extent=rectangle(det),
+                       extent=axes_limits,
                        aspect=1)
         ax.set_xlabel(r'$\phi_{\rm f} (^{\circ})$', fontsize=multiPlot.fontsize)
         if i % ncol == 0:
@@ -148,12 +150,13 @@ def sas_sample_with_particle(particle):
     return multi_layer
 
 
-def run_simulation_with_particle(det, particle):
+def run_sas_with_particle(npix, particle):
     """
     Run simulation and plot results
     """
     sample = sas_sample_with_particle(particle)
     beam = ba.Beam(1, 1*angstrom, ba.Direction(1e-8*deg, 0))
+    det = ba.SphericalDetector(npix, 5*deg, 2.5*deg, 2.5*deg)
     simulation = ba.ScatteringSimulation(beam, sample, det)
     simulation.runSimulation()
     return simulation.result()
-- 
GitLab