Commit 81450d60 authored by mantid-builder's avatar mantid-builder
Browse files

Merge remote-tracking branch 'origin/release-next'

parents e8e07541 fdad2bce
......@@ -353,7 +353,7 @@ class SANSILLAutoProcess(DataProcessorAlgorithm):
'DefaultQBinning', 'BinningFactor',
'OutputBinning', 'NPixelDivision',
'NumberOfWedges', 'WedgeAngle', 'WedgeOffset',
'AsymmetricWedges', 'IQxQyLogBinning'])
'AsymmetricWedges', 'IQxQyLogBinning', 'WavelengthRange'])
self.setPropertyGroup('OutputType', 'Integration Options')
self.setPropertyGroup('CalculateResolution', 'Integration Options')
......@@ -684,7 +684,8 @@ class SANSILLAutoProcess(DataProcessorAlgorithm):
DeltaQ=(self.deltaq[i]
if len(self.deltaq) == self.dimensionality
else self.deltaq[0]),
IQxQyLogBinning=self.getProperty('IQxQyLogBinning').value
IQxQyLogBinning=self.getProperty('IQxQyLogBinning').value,
WavelengthRange=self.getProperty('WavelengthRange').value
)
# wedges ungrouping and renaming
......
......@@ -7,7 +7,8 @@
from mantid.api import PythonAlgorithm, MatrixWorkspaceProperty, WorkspaceUnitValidator, WorkspaceGroupProperty, \
PropertyMode, MatrixWorkspace, NumericAxis
from mantid.kernel import EnabledWhenProperty, FloatArrayProperty, Direction, StringListValidator, \
IntBoundedValidator, FloatBoundedValidator, PropertyCriterion, LogicOperator
IntBoundedValidator, FloatBoundedValidator, PropertyCriterion, LogicOperator, FloatArrayOrderedPairsValidator, \
FloatArrayLengthValidator, CompositeValidator
from mantid.simpleapi import *
from MildnerCarpenter import *
import numpy as np
......@@ -20,6 +21,7 @@ class SANSILLIntegration(PythonAlgorithm):
_output_type = ''
_resolution = ''
_masking_criterion = ''
_lambda_range = []
def category(self):
return 'ILL\\SANS'
......@@ -152,27 +154,39 @@ class SANSILLIntegration(PythonAlgorithm):
self.setPropertyGroup('MaxQxy', 'I(Qx,Qy) Options')
self.setPropertyGroup('DeltaQ', 'I(Qx,Qy) Options')
self.setPropertyGroup('IQxQyLogBinning', 'I(Qx,Qy) Options')
self.declareProperty(name='BinMaskingCriteria', defaultValue='',
doc='Criteria to mask bins, used for TOF mode,'
' for example to discard high and low lambda ranges;'
'see MaskBinsIf algorithm for details.')
self.declareProperty(WorkspaceGroupProperty('PanelOutputWorkspaces', '',
direction=Direction.Output,
optional=PropertyMode.Optional),
doc='The name of the output workspace group for detector panels.')
self.setPropertyGroup('PanelOutputWorkspaces', 'I(Q) Options')
lambda_range_validator = CompositeValidator()
lambda_range_validator.add(FloatArrayOrderedPairsValidator())
lambda_range_validator.add(FloatArrayLengthValidator(2))
self.declareProperty(FloatArrayProperty('WavelengthRange', [1., 10.], validator=lambda_range_validator),
doc='Wavelength range [Angstrom] to be used in integration (TOF only).')
def PyExec(self):
self._input_ws = self.getPropertyValue('InputWorkspace')
self._output_type = self.getPropertyValue('OutputType')
self._resolution = self.getPropertyValue('CalculateResolution')
self._output_ws = self.getPropertyValue('OutputWorkspace')
self._masking_criterion = self.getPropertyValue('BinMaskingCriteria')
if self._masking_criterion:
MaskBinsIf(InputWorkspace=self._input_ws, OutputWorkspace=self._input_ws+'_masked', Criterion=self._masking_criterion)
self._input_ws = self._input_ws+'_masked'
self._lambda_range = self.getProperty('WavelengthRange').value
is_tof = mtd[self._input_ws].getRun().getLogData('tof_mode').value == 'TOF' # D33 only
if is_tof:
cut_input_ws = self._input_ws+'_cut'
CropWorkspaceRagged(InputWorkspace=self._input_ws,
OutputWorkspace=cut_input_ws,
XMin=self._lambda_range[0],
XMax=self._lambda_range[1])
self._input_ws = cut_input_ws
# re-calculate the Q-range after lambda cut
CalculateDynamicRange(Workspace=self._input_ws,
ComponentNames=['back_detector',
'front_detector_right',
'front_detector_left',
'front_detector_top',
'front_detector_bottom'])
self._integrate(self._input_ws, self._output_ws)
self.setProperty('OutputWorkspace', self._output_ws)
panels_out_ws = self.getPropertyValue('PanelOutputWorkspaces')
......@@ -189,6 +203,8 @@ class SANSILLIntegration(PythonAlgorithm):
panel_outputs.append(out_ws)
GroupWorkspaces(InputWorkspaces=panel_outputs, OutputWorkspace=panels_out_ws)
self.setProperty('PanelOutputWorkspaces', mtd[panels_out_ws])
if is_tof:
DeleteWorkspace(self._input_ws)
def _integrate(self, in_ws, out_ws, panel=None):
if self._output_type == 'I(Q)' or self._output_type == 'I(Phi,Q)':
......
......@@ -102,7 +102,7 @@ class SANSILLIntegrationTest(unittest.TestCase):
# TOF resolution is not yet implemented
SANSILLIntegration(InputWorkspace='sample', OutputWorkspace='iq')
self._check_output(mtd['iq'])
self.assertEqual(mtd['iq'].blocksize(), 217)
self.assertEqual(mtd['iq'].blocksize(), 162)
def _check_output(self, ws, spectra = 1):
self.assertTrue(ws)
......
......@@ -23,7 +23,8 @@ class ILL_D11_Test(systemtesting.MantidSystemTest):
mtd.clear()
def validate(self):
self.tolerance = 1e-5
self.tolerance = 1e-3
self.tolerance_is_rel_err = True
self.disableChecking = ['Instrument']
return ['iq', 'ILL_SANS_D11_IQ.nxs']
......@@ -83,7 +84,8 @@ class ILL_D22_Test(systemtesting.MantidSystemTest):
mtd.clear()
def validate(self):
self.tolerance = 1e-5
self.tolerance = 1e-3
self.tolerance_is_rel_err = True
self.disableChecking = ['Instrument']
return ['iq', 'ILL_SANS_D22_IQ_v2.nxs']
......@@ -144,7 +146,8 @@ class ILL_D33_VTOF_Test(systemtesting.MantidSystemTest):
mtd.clear()
def validate(self):
self.tolerance = 1e-4
self.tolerance = 1e-3
self.tolerance_is_rel_err = True
self.disableChecking = ['Instrument']
return ['iq', 'ILL_SANS_D33_VTOF_IQ.nxs']
......@@ -169,8 +172,7 @@ class ILL_D33_VTOF_Test(systemtesting.MantidSystemTest):
SANSILLReduction(Run='093410', ProcessAs='Sample', BeamInputWorkspace='beam', TransmissionInputWorkspace='str',
ContainerInputWorkspace='can', MaskedInputWorkspace='mask', OutputWorkspace='sample', FluxInputWorkspace='flux')
# I(Q)
SANSILLIntegration(InputWorkspace='sample', OutputBinning='0.005,-0.1,1',
OutputWorkspace='iq', BinMaskingCriteria='x<1 || x>10')
SANSILLIntegration(InputWorkspace='sample', OutputBinning='0.005,-0.1,1', OutputWorkspace='iq')
class ILL_D33_LTOF_Test(systemtesting.MantidSystemTest):
......@@ -188,7 +190,8 @@ class ILL_D33_LTOF_Test(systemtesting.MantidSystemTest):
mtd.clear()
def validate(self):
self.tolerance = 1e-5
self.tolerance = 1e-3
self.tolerance_is_rel_err = True
self.disableChecking = ['Instrument']
return ['iq', 'ILL_SANS_D33_LTOF_IQ.nxs']
......@@ -214,8 +217,7 @@ class ILL_D33_LTOF_Test(systemtesting.MantidSystemTest):
ContainerInputWorkspace='can', MaskedInputWorkspace='mask', OutputWorkspace='sample', FluxInputWorkspace='flux')
# I(Q)
SANSILLIntegration(InputWorkspace='sample', OutputBinning='0.005,-0.1,1',
OutputWorkspace='iq', BinMaskingCriteria='x<1 || x>10')
SANSILLIntegration(InputWorkspace='sample', OutputBinning='0.005,-0.1,1', OutputWorkspace='iq')
class ILL_D33_Test(systemtesting.MantidSystemTest):
......@@ -234,6 +236,7 @@ class ILL_D33_Test(systemtesting.MantidSystemTest):
def validate(self):
self.tolerance = 1e-3
self.tolerance_is_rel_err = True
self.disableChecking = ['Instrument']
return ['iq', 'ILL_SANS_D33_IQ.nxs']
......
b2736c2cb28e09bf50bb8e8ef4c9363f
1bca86d19953d25aff9f7760152ca1ee
91857b64e5158f9cd37fc283d546c111
cf34cccaef9056684cc7260069cde554
0a71d5f25a650b287e594221cccfe662
7c281c94d46eaad721e672db3de4eef5
......@@ -68,9 +68,12 @@ Bugfixes
- Fixed a bug with editing legends in-situ on Linux platforms.
- Fixed a bug in SliceViewer that caused shown data to not update correctly when changing axis selection.
- 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 bug in supplying display indices when viewinng axes changed in non-orthog view.
- 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>`
......@@ -8,8 +8,6 @@ SANS Changes
Improvements
############
- Add support for D11, D16, D22 and D33 in the :ref:`MaskBTP <algm-MaskBTP>` algorithm.
.. warning:: **Developers:** Sort changes under appropriate heading
putting new features at the top of the section, followed by
improvements, followed by bug fixes.
......@@ -20,15 +18,17 @@ Algorithms and instruments
Improvements
############
- Added instrument definitions for the two new PSD based multi-panel SANS instruments D11B and D22B at the ILL.
- In :ref:`SANSILLAutoProcess <algm-SANSILLAutoProcess>`, the beam radius can be different for each distance.
A new parameter, TransmissionBeamRadius, has been added to set the beam radius for transmission experiments.
The default value of all beam radii is now 0.1m.
- With :ref:`SANSILLAutoProcess <algm-SANSILLAutoProcess>`, if sample thickness is set to -1, the algorithm will try to get it
from the nexus file.
- With :ref:`SANSILLAutoProcess <algm-SANSILLAutoProcess>`, the output workspace will get its title from the nexus file.
- The Rectangle option for :ref:`SolidAngle <algm-SolidAngle>` is now supported for ILL's D22 and D33.
- Add loader and MaskBTP support for D11B and D22B.
- Added instrument definitions for the two new PSD based multi-panel SANS instruments D11B and D22B at the ILL.
- Added support for D11, D16, D22 and D33 in the :ref:`MaskBTP <algm-MaskBTP>` algorithm.
- Several improvements have been done in ILL SANS suite :ref:`SANSILLAutoProcess <algm-SANSILLAutoProcess>`:
- The beam radius can be different for each distance.
- A new parameter, TransmissionBeamRadius, has been added to set the beam radius for transmission measurements.
- The default value of all the beam radii is now 0.1m.
- If sample thickness is set to -1, the algorithm will try to get it from the nexus file itself.
- The output workspace will get its title from the nexus file.
- WavelengthRange is exposed to the algorithm, which is crucial for TOF reduction.
- The Rectangle option for :ref:`SolidAngle <algm-SolidAngle>` is now supported for ILL's D22 and D33.
- Added loader and MaskBTP support for D11B and D22B.
Bugfixes
########
......
......@@ -259,8 +259,8 @@ class SliceViewerModel:
except (AttributeError, KeyError): # run can be None so no .get()
# assume orthogonal projection
proj_matrix = np.diag([1., 1., 1.])
display_indices = slice_info.transform([0, 1, 2]).astype(int)
display_indices = list(range(0, proj_matrix.shape[0]))
display_indices.pop(slice_info.z_index)
return NonOrthogonalTransform.from_lattice(lattice,
x_proj=proj_matrix[:, display_indices[0]],
y_proj=proj_matrix[:, display_indices[1]])
......
......@@ -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)
......
......@@ -567,7 +567,7 @@ class SliceViewerModelTest(unittest.TestCase):
self.assertRaises(RuntimeError, model.create_nonorthogonal_transform, (0, 1, 2))
@patch("mantidqt.widgets.sliceviewer.model.NonOrthogonalTransform")
def test_create_non_orthogonal_transform_uses_W_if_avilable(self, mock_nonortho_trans):
def test_create_non_orthogonal_transform_uses_W_if_available(self, mock_nonortho_trans):
ws = _create_mock_workspace(IMDEventWorkspace,
SpecialCoordinateSystem.HKL,
has_oriented_lattice=True)
......@@ -584,11 +584,11 @@ class SliceViewerModelTest(unittest.TestCase):
mock_nonortho_trans.from_lattice.assert_called_once_with(
lattice,
x_proj=ArraysEqual(np.array([1, 0, 0])),
x_proj=ArraysEqual(np.array([0, 0, 1])),
y_proj=ArraysEqual(np.array([1, 1, 0])))
@patch("mantidqt.widgets.sliceviewer.model.NonOrthogonalTransform")
def test_create_non_orthogonal_transform_uses_identity_if_W_unavilable(
def test_create_non_orthogonal_transform_uses_identity_if_W_unavailable(
self, mock_nonortho_trans):
ws = _create_mock_workspace(IMDEventWorkspace,
SpecialCoordinateSystem.HKL,
......@@ -604,7 +604,7 @@ class SliceViewerModelTest(unittest.TestCase):
mock_nonortho_trans.from_lattice.assert_called_once_with(
lattice,
x_proj=ArraysEqual(np.array([0, 1, 0])),
x_proj=ArraysEqual(np.array([1, 0, 0])),
y_proj=ArraysEqual(np.array([0, 0, 1])))
def test_get_dim_limits_returns_limits_for_display_dimensions_for_matrix(self):
......
......@@ -32,7 +32,7 @@ set(CXXTEST_EXTRA_HEADER_INCLUDE
mtd_add_qt_tests(
TARGET_NAME MantidQtInterfacesIndirectTest
QT_VERSION 4
QT_VERSION 5
SRC ${TEST_FILES}
INCLUDE_DIRS
../../../../Framework/CurveFitting/inc
......@@ -53,11 +53,16 @@ mtd_add_qt_tests(
gmock
${POCO_LIBRARIES}
${Boost_LIBRARIES}
QT4_LINK_LIBS
Qwt5
PythonInterfaceCore
${PYTHON_LIBRARIES}
QT5_LINK_LIBS
Qt5::OpenGL
Qt5::Concurrent
MTD_QT_LINK_LIBS
MantidScientificInterfacesIndirect
MantidQtWidgetsCommon
MantidQtWidgetsPlotting
MantidQtWidgetsMplCpp
PARENT_DEPENDENCIES
GUITests)
......@@ -110,6 +110,8 @@ public:
IDA::WorkspaceIndex spectrum));
MOCK_METHOD2(setResolution,
void(const std::string &name, TableDatasetIndex index));
MOCK_METHOD2(setExcludeRegion,
void(const std::string &exclude, FitDomainIndex index));
MOCK_CONST_METHOD1(getWorkspace,
Mantid::API::MatrixWorkspace_sptr(FitDomainIndex index));
......
......@@ -16,6 +16,7 @@
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidKernel/WarningSuppressions.h"
#include "MantidQtWidgets/MplCpp/BackendQt.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
using namespace Mantid::API;
......@@ -60,6 +61,7 @@ GNU_DIAG_ON_SUGGEST_OVERRIDE
class IndirectPlotterTest : public CxxTest::TestSuite {
public:
IndirectPlotterTest() : m_ads(AnalysisDataService::Instance()) {
MantidQt::Widgets::MplCpp::backendModule();
m_ads.clear();
}
......@@ -86,22 +88,18 @@ public:
TS_ASSERT(m_plotter);
}
void
test_that_plotSpectra_will_attempt_to_run_python_code_using_the_IPyRunner() {
void test_that_plotSpectra_will_not_throw() {
m_ads.addOrReplace(WORKSPACE_NAME, createMatrixWorkspace(5, 5));
EXPECT_CALL(*m_pyRunner, runPythonCode(_)).Times(1);
m_plotter->plotSpectra(WORKSPACE_NAME, WORKSPACE_INDICES);
TS_ASSERT_THROWS_NOTHING(
m_plotter->plotSpectra(WORKSPACE_NAME, WORKSPACE_INDICES));
}
void
test_that_plotBins_will_attempt_to_run_python_code_using_the_IPyRunner() {
void test_that_plotBins_will_not_throw() {
m_ads.addOrReplace(WORKSPACE_NAME, createMatrixWorkspace(5, 5));
EXPECT_CALL(*m_pyRunner, runPythonCode(_)).Times(1);
m_plotter->plotBins(WORKSPACE_NAME, WORKSPACE_INDICES);
TS_ASSERT_THROWS_NOTHING(
m_plotter->plotBins(WORKSPACE_NAME, WORKSPACE_INDICES));
}
void
......
......@@ -6,6 +6,7 @@
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidPythonInterface/core/Testing/PythonInterpreterGlobalFixture.h"
#include "MantidQtWidgets/Common/Testing/QApplicationGlobalFixture.h"
//------------------------------------------------------------------------------
......@@ -14,4 +15,5 @@
// We rely on cxxtest only including this file once so that the following
// statements do not cause multiple-definition errors.
//------------------------------------------------------------------------------
static PythonInterpreterGlobalFixture PYTHON_INTERPRETER;
static QApplicationGlobalFixture MAIN_QAPPLICATION;
......@@ -175,7 +175,8 @@ class RundexSettings(object):
"MaxQxy",
"DeltaQ",
"IQxQyLogBinning",
"OutputPanels"
"OutputPanels",
"WavelengthRange"
],
SANS_PSCAN : [
"SensitivityMap",
......
Supports Markdown
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