Unverified Commit 4165e023 authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony Committed by GitHub
Browse files

Merge pull request #30403 from...

Merge pull request #30403 from mantidproject/29087_fix_sliceviewer_plotting_elliptical_shell_integrated_peaks

Fix plotting of elliptical bg shell in sliceviewer
parents e412af07 7f069482
......@@ -69,7 +69,9 @@ Bugfixes
- Fixed bug supplying rebin arguments for non-orthogonal data in sliceviewer that meant that not all the availible data within the axes limits were being plotted.
- Fixed a crash in SliceViewer when hovering the cursor over Direct or Indirect data.
- Fixed a crash when using broken e notation for axis limits in plot settings
- Fixed bug in plotting elliptical shell of integrated peaks in sliceviewer - the inner background radius is now correct.
- Fixed a bug in error bars tab in plot settings where the Error Every property was not being shown correctly
- Fixed a bug where the fit action (Fit > Fit) in the fit browser wasn't disabled if all the functions were individually removed.
:ref:`Release 6.0.0 <v6.0.0>`
......@@ -18,6 +18,7 @@ from .painter import Painted
class EllipsoidalIntergratedPeakRepresentation():
"""Provide methods to display a representation of a slice through an
Ellipsoidally intgerated region around a Peak"""
@classmethod
def draw(cls, peak_origin, peak_shape, slice_info, painter, fg_color, bg_color):
"""
......@@ -98,6 +99,7 @@ def _signal_ellipsoid_info(shape_info, transform):
:param shape_info: A dictionary of ellipsoid properties
:param transform: Transform function to move to the slice frame
"""
def to_ndarray(axis_field):
s = shape_info[axis_field]
return np.array([float(x) for x in s.split()], dtype=float)
......@@ -121,7 +123,7 @@ def _bkgd_ellipsoid_info(shape_info, transform):
shape_info["background_inner_radius1"]), float(shape_info["background_inner_radius2"])
a, b, c = transform((a, b, c))
inner_a, inner_b, inner_c = transform((inner_a, inner_b, inner_c))
width = max((a, b, c)) - max((inner_a, inner_b, inner_c))
width = (max((a, b, c)) - max((inner_a, inner_b, inner_c))) / max((a, b, c)) # fractional width of shell
return (a, b, c, width)
......@@ -184,7 +186,7 @@ def calculate_ellipsoid_matrix(axis_a, axis_b, axis_c, a, b, c):
"""
# Create matrix whose eigenvalues are squares of semi-axes lengths
# and eigen vectors define principle axis vectors
axes_lengths = np.diag((1 / a**2, 1 / b**2, 1 / c**2))
axes_lengths = np.diag((1 / a ** 2, 1 / b ** 2, 1 / c ** 2))
# yapf: disable
axes_dir = np.array((
(axis_a[0], axis_b[0], axis_c[0]),
......@@ -207,7 +209,7 @@ def slice_ellipsoid_matrix(origin, zp, ellipMatrix):
A = ellipMatrix[:2, :2]
A[1, 0] = ellipMatrix[0, 1]
B = 2 * z * ellipMatrix[:2, 2]
c = ellipMatrix[2][2] * z**2
c = ellipMatrix[2][2] * z ** 2
# Using quadratic completion we can get rid of ( or rather refactor) the linear
# term:
......
......@@ -22,13 +22,15 @@ class EllipticalShell(Patch):
"""
Elliptical shell patch.
"""
def __str__(self):
return f"EllipticalShell(center={self.center}, width={self.width}, height={self.height}, thick={self.thick}, angle={self.angle})"
def __init__(self, center, width, height, thick, angle=0.0, **kwargs):
"""
Draw an elliptical ring centered at *x*, *y* center with outer width (horizontal diameter)
*width* and outer height (vertical diameter) *height* with a ring thickness of *thick*
*width* and outer height (vertical diameter) *height* with a fractional ring thickness of *thick*
( [r_outer - r_inner]/r_outer where r is the major radius).
Valid kwargs are:
%(Patch)s
"""
......@@ -46,7 +48,7 @@ class EllipticalShell(Patch):
arc = Path.arc(theta1=0.0, theta2=360.0)
# Draw the outer unit circle followed by a reversed and scaled inner circle
v1 = arc.vertices
v2 = arc.vertices[::-1] * float(1.0 - self.thick)
v2 = arc.vertices[::-1] * float(1.0 - self.thick) # self.thick is fractional thickness
v = np.vstack([v1, v2, v1[0, :], (0, 0)])
c = np.hstack([arc.codes, arc.codes, Path.MOVETO, Path.CLOSEPOLY])
c[len(arc.codes)] = Path.MOVETO
......@@ -81,6 +83,7 @@ class MplPainter():
"""
Implementation of a PeakPainter that uses matplotlib to draw
"""
def __init__(self, view):
"""
:param view: An object defining an axes property.
......@@ -176,6 +179,7 @@ class MplPainter():
class Painted():
"""Combine a collection of artists with the painter that created them"""
def __init__(self, painter, artists, effective_bbox=None):
"""
:param painter: A reference to the painter responsible for
......
......@@ -66,7 +66,7 @@ class EllipsoidalIntergratedPeakRepresentationTest(unittest.TestCase):
fg_color=fg_color,
bkgd_width=4.8,
bkgd_height=5.2,
thickness=0.1,
thickness=0.1 / 2.6,
bg_color=bg_color)
def test_draw_respects_transform(self, compute_alpha_mock):
......@@ -95,7 +95,7 @@ class EllipsoidalIntergratedPeakRepresentationTest(unittest.TestCase):
fg_color=fg_color,
bkgd_width=4.4,
bkgd_height=4.77,
thickness=0.1,
thickness=0.1 / 2.6,
bg_color=bg_color)
# private
......@@ -166,7 +166,7 @@ class EllipsoidalIntergratedPeakRepresentationSliceEllipsoidTest(unittest.TestCa
expected_minar_radius,
expected_angle))
zp = np.sin(np.pi/3)
zp = np.sin(np.pi / 3)
expected_slice_origin = (0, 0, zp)
expected_major_radius = 0.5 # cos(pi/3)
expected_minar_radius = 0.5 # cos(pi/3)
......
Markdown is supported
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