Skip to content

Commit

Permalink
Merge branch 'master' into feature/10846_notifications_peaks_viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jan 19, 2015
2 parents b8ba123 + aae3a70 commit 9d1d4c6
Show file tree
Hide file tree
Showing 66 changed files with 2,187 additions and 745 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/Build/CMake/CommonSetup.cmake
Expand Up @@ -54,7 +54,7 @@ add_definitions ( -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG )
find_package ( Poco 1.4.2 REQUIRED )
include_directories( SYSTEM ${POCO_INCLUDE_DIRS} )

find_package ( Nexus 4.3.0 REQUIRED )
find_package ( Nexus 4.3.1 REQUIRED )
include_directories ( SYSTEM ${NEXUS_INCLUDE_DIR} )

find_package ( MuParser REQUIRED )
Expand Down
23 changes: 18 additions & 5 deletions Code/Mantid/Build/CMake/LinuxPackageScripts.cmake
Expand Up @@ -23,9 +23,19 @@ endif()
set ( CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${LIB_DIR};${CMAKE_INSTALL_PREFIX}/${PLUGINS_DIR};${CMAKE_INSTALL_PREFIX}/${PVPLUGINS_DIR} )

###########################################################################
# LD_PRELOAD libraries
# LD_PRELOAD TCMalloc
###########################################################################
set ( EXTRA_LDPRELOAD_LIBS "${TCMALLOC_LIBRARIES}" )
# User systems will only have the libraries and not the symbolic link
# so we must set the preload to the versioned library. We will assume it is
# in the same location as the system that the package was built on
if ( TCMALLOC_LIBRARIES )
execute_process ( COMMAND readlink --no-newline --canonicalize-existing ${TCMALLOC_LIBRARIES}
OUTPUT_VARIABLE TCMALLOC_PRELOAD
RESULT_VARIABLE READLINK_RESULT )
if ( READLINK_RESULT EQUAL 1 )
message ( FATAL_ERROR "Unable to find real file that tcmalloc symlink, ${TCMALLOC_LIBRARIES}, points to." )
endif()
endif()

###########################################################################
# Environment scripts (profile.d)
Expand Down Expand Up @@ -84,10 +94,12 @@ set ( POST_UNINSTALL_FILE ${CMAKE_CURRENT_BINARY_DIR}/postrm )

if ( "${UNIX_DIST}" MATCHES "RedHatEnterprise" OR "${UNIX_DIST}" MATCHES "^Fedora" ) # RHEL/Fedora
if ( "${UNIX_CODENAME}" MATCHES "Santiago" ) # el6
set ( WRAPPER_COMMAND "scl enable mantidlibs" )
set ( WRAPPER_PREFIX "scl enable mantidlibs \"" )
set ( WRAPPER_POSTFIX "\"" )
set ( EXTRA_LDPATH "/usr/lib64/paraview" )
else()
set ( WRAPPER_COMMAND "eval" )
set ( WRAPPER_PREFIX "" )
set ( WRAPPER_POSTFIX "" )
endif()

if ( NOT MPI_BUILD )
Expand All @@ -106,7 +118,8 @@ if ( "${UNIX_DIST}" MATCHES "RedHatEnterprise" OR "${UNIX_DIST}" MATCHES "^Fedor
set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${POST_UNINSTALL_FILE} )
endif()
elseif ( "${UNIX_DIST}" MATCHES "Ubuntu" )
set ( WRAPPER_COMMAND "eval" )
set ( WRAPPER_PREFIX "" )
set ( WRAPPER_POSTFIX "" )

if ( NOT MPI_BUILD )
configure_file ( ${CMAKE_MODULE_PATH}/Packaging/deb/scripts/deb_pre_inst.in
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Build/CMake/Packaging/launch_mantidplot.sh.in
Expand Up @@ -9,7 +9,7 @@ SCRIPTFILE=$(readlink -f "$0")
INSTALLDIR=$(echo $SCRIPTFILE | sed -r -e 's|^(.*)/(.*)$|\1|g') #.* is greedy and eats up until the final slash

# Define extra libraries and load paths
LOCAL_PRELOAD=$(readlink -f @EXTRA_LDPRELOAD_LIBS@)
LOCAL_PRELOAD=@TCMALLOC_PRELOAD@
if [ -n "${LD_PRELOAD}" ]; then
LOCAL_PRELOAD=${LOCAL_PRELOAD}:${LD_PRELOAD}
fi
Expand All @@ -21,4 +21,4 @@ else
fi

# Launch
LD_PRELOAD=${LOCAL_PRELOAD} TCMALLOC_RELEASE_RATE=${TCM_RELEASE} LD_LIBRARY_PATH=${LOCAL_LDPATH} @WRAPPER_COMMAND@ "$INSTALLDIR/@MANTIDPLOT_EXEC@ $*"
LD_PRELOAD=${LOCAL_PRELOAD} TCMALLOC_RELEASE_RATE=${TCM_RELEASE} LD_LIBRARY_PATH=${LOCAL_LDPATH} @WRAPPER_PREFIX@$INSTALLDIR/@MANTIDPLOT_EXEC@ $*@WRAPPER_POSTFIX@
2 changes: 1 addition & 1 deletion Code/Mantid/Build/CMake/VersionNumber.cmake
@@ -1,7 +1,7 @@
# Set the version number here for MantidVersion and the package filenames

set ( VERSION_MAJOR 3 )
set ( VERSION_MINOR 2 )
set ( VERSION_MINOR 3 )

# UNCOMMENT the next 'set' line to 'force' the patch version number to
# a value (instead of using the count coming out of 'git describe')
Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/CMakeLists.txt
Expand Up @@ -185,7 +185,7 @@ if ( ENABLE_CPACK )
message ( STATUS " CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}" )

# rhel requirements
set ( CPACK_RPM_PACKAGE_REQUIRES "boost >= 1.34.1,qt4 >= 4.2,nexus,nexus-python,gsl,glibc,qwtplot3d-qt4,muParser,numpy" )
set ( CPACK_RPM_PACKAGE_REQUIRES "boost >= 1.34.1,qt4 >= 4.2,nexus >= 4.3.1,nexus-python >= 4.3.1,gsl,glibc,qwtplot3d-qt4,muParser,numpy" )
# OCE
set( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},OCE-draw,OCE-foundation,OCE-modeling,OCE-ocaf,OCE-visualization")
# Qwt is qwt5-qt4 in RHEL7
Expand All @@ -199,7 +199,7 @@ if ( ENABLE_CPACK )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},python-ipython >= 1.1.0" )
# scipy & matplotlib
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},scipy,python-matplotlib" )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},mxml,hdf,hdf5" )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},mxml,hdf,hdf5,jsoncpp" )

if( "${UNIX_CODENAME}" MATCHES "Santiago" )
# On RHEL6 we have to use an updated qscintilla to fix an auto complete bug
Expand All @@ -222,7 +222,7 @@ if ( ENABLE_CPACK )
"libboost-python${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION},"
"libnexus0 (>= 4.3),libgsl0ldbl,libqtcore4 (>= 4.2),libqtgui4 (>= 4.2),libqt4-opengl (>= 4.2),"
"libqt4-xml (>= 4.2),libqt4-svg (>= 4.2),libqt4-qt3support (>= 4.2),qt4-dev-tools,"
"libqwt5-qt4,libqwtplot3d-qt4-0,python-numpy,python-sip,python-qt4" )
"libqwt5-qt4,libqwtplot3d-qt4-0,python-numpy,python-sip,python-qt4,libjsoncpp0" )
set ( PERFTOOLS_DEB_PACKAGE "libgoogle-perftools0 (>= 1.7)" )
if( "${UNIX_CODENAME}" MATCHES "lucid" )
list ( APPEND DEPENDS_LIST ",libqscintilla2-5,"
Expand Down
41 changes: 34 additions & 7 deletions Code/Mantid/Framework/Algorithms/src/AsymmetryCalc.cpp
Expand Up @@ -50,26 +50,37 @@ void AsymmetryCalc::exec() {
// Get original workspace
API::MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace");

// Make an intermediate workspace and prepare it for asymmetry calculation
API::MatrixWorkspace_sptr tmpWS;
if (forward_list.size() > 1 || backward_list.size() > 1) {
// If forward or backward lists have more than 1 entries spectra need to be grouped

// First group spectra from the backward list leaving the rest ungrouped
API::IAlgorithm_sptr group = createChildAlgorithm("GroupDetectors");
group->setProperty("InputWorkspace", inputWS);
group->setProperty("SpectraList", backward_list);
group->setProperty("KeepUngroupedSpectra", true);
group->execute();
tmpWS = group->getProperty("OutputWorkspace");

// Then group spectra from the forward list leaving the rest ungrouped
group = createChildAlgorithm("GroupDetectors");
group->setProperty("InputWorkspace", tmpWS);
group->setProperty("SpectraList", forward_list);
group->setProperty("KeepUngroupedSpectra", true);
group->execute();
tmpWS = group->getProperty("OutputWorkspace");

// The order of grouping leaves the forward spectra group in the first histogram
// and the barckward one is the second
forward = 0;
backward = 1;
} else {
// If the forward and backward lists are empty or have at most 1 index
// there is no need for grouping and the input workspace can be used
// directly
tmpWS = inputWS;

// get workspace indices from spectra ids for forward and backward
std::vector<specid_t> specIDs(2);
specIDs[0] = forward;
Expand All @@ -86,14 +97,21 @@ void AsymmetryCalc::exec() {
backward = static_cast<int>(indices[1]);
}

// Create a workspace with only one spectra for forward
const size_t blocksize = inputWS->blocksize();
assert( tmpWS->blocksize() == blocksize );
const bool isInputHistogram = inputWS->isHistogramData();

// Create a point data workspace with only one spectra for forward
API::MatrixWorkspace_sptr outputWS = API::WorkspaceFactory::Instance().create(
inputWS, 1, inputWS->readX(0).size(), inputWS->blocksize());
inputWS, 1, blocksize, blocksize);

// Get the reference to the input x values.
auto& tmpX = tmpWS->readX(forward);

// Calculate asymmetry for each time bin
// F-aB / F+aB
Progress prog(this, 0.0, 1.0, tmpWS->blocksize());
for (size_t j = 0; j < tmpWS->blocksize(); ++j) {
Progress prog(this, 0.0, 1.0, blocksize);
for (size_t j = 0; j < blocksize; ++j) {
// cal F-aB
double numerator =
tmpWS->dataY(forward)[j] - alpha * tmpWS->dataY(backward)[j];
Expand Down Expand Up @@ -121,16 +139,25 @@ void AsymmetryCalc::exec() {
}
outputWS->dataE(0)[j] = error;

// set the x values
if ( isInputHistogram )
{
outputWS->dataX(0)[j] = ( tmpX[j] + tmpX[j+1] ) / 2;
}
else
{
outputWS->dataX(0)[j] = tmpX[j];
}

prog.report();
}

// Copy the imput time bins on to the output
outputWS->dataX(0) = inputWS->readX(0);
assert( outputWS->dataX(0).size() == blocksize );

// Update Y axis units
outputWS->setYUnit("Asymmetry");

setProperty("OutputWorkspace", outputWS);
setProperty("OutputWorkspace", outputWS);
}

} // namespace Algorithm
Expand Down
17 changes: 15 additions & 2 deletions Code/Mantid/Framework/Algorithms/src/Integration.cpp
Expand Up @@ -28,8 +28,7 @@ using namespace DataObjects;
*/
void Integration::init() {
declareProperty(
new WorkspaceProperty<>("InputWorkspace", "", Direction::Input,
boost::make_shared<HistogramValidator>()),
new WorkspaceProperty<>("InputWorkspace", "", Direction::Input),
"The input workspace to integrate.");
declareProperty(
new WorkspaceProperty<>("OutputWorkspace", "", Direction::Output),
Expand Down Expand Up @@ -254,6 +253,7 @@ void Integration::exec() {
*/
MatrixWorkspace_const_sptr Integration::getInputWorkspace() {
MatrixWorkspace_sptr temp = getProperty("InputWorkspace");

if (temp->id() == "RebinnedOutput") {
// Clean the input workspace in the RebinnedOutput case for nan's and
// inf's in order to treat the data correctly later.
Expand All @@ -268,6 +268,19 @@ MatrixWorkspace_const_sptr Integration::getInputWorkspace() {
alg->executeAsChildAlg();
temp = alg->getProperty("OutputWorkspace");
}

// To integrate point data it will be converted to histograms
if ( !temp->isHistogramData() )
{
auto alg = this->createChildAlgorithm("ConvertToHistogram");
alg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", temp);
std::string outName = "_" + temp->getName() + "_histogram";
alg->setProperty("OutputWorkspace", outName);
alg->executeAsChildAlg();
temp = alg->getProperty("OutputWorkspace");
temp->isDistribution(true);
}

return temp;
}

Expand Down
54 changes: 45 additions & 9 deletions Code/Mantid/Framework/Algorithms/src/TOFSANSResolutionByPixel.cpp
Expand Up @@ -9,9 +9,11 @@
#include "MantidKernel/RebinParamsValidator.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/VectorHelper.h"
#include "MantidKernel/Interpolation.h"
#include "MantidKernel/BoundedValidator.h"

#include "boost/math/special_functions/fpclassify.hpp"
#include "MantidKernel/BoundedValidator.h"


namespace Mantid {
namespace Algorithms {
Expand All @@ -38,8 +40,10 @@ void TOFSANSResolutionByPixel::init() {
"Sample aperture radius (mm).");
declareProperty("SourceApertureRadius", 0.0, positiveDouble,
"Source aperture radius (mm).");
declareProperty("SigmaModerator", 0.0, positiveDouble,
"Sigma moderator spread (microsec).");
declareProperty(new WorkspaceProperty<>(
"SigmaModerator", "", Direction::Input,
boost::make_shared<WorkspaceUnitValidator>("Wavelength")),
"Sigma moderator spread in units of microsec as a function of wavelenght.");
}

/*
Expand All @@ -59,7 +63,33 @@ void TOFSANSResolutionByPixel::exec() {
deltaR /= 1000.0;
R1 /= 1000.0;
R2 /= 1000.0;
const double sigmaModeratorMicroSec = getProperty("SigmaModerator");

const MatrixWorkspace_sptr sigmaModeratorVSwavelength = getProperty("SigmaModerator");

// create interpolation table from sigmaModeratorVSwavelength
Kernel::Interpolation lookUpTable;

const MantidVec xInterpolate = sigmaModeratorVSwavelength->readX(0);
const MantidVec yInterpolate = sigmaModeratorVSwavelength->readY(0);

// prefer the input to be a pointworkspace and create interpolation function
if ( sigmaModeratorVSwavelength->isHistogramData() )
{
g_log.notice() << "mid-points of SigmaModerator histogram bins will be used for interpolation.";

for (size_t i = 0; i < xInterpolate.size()-1; ++i)
{
const double midpoint = xInterpolate[i+1] - xInterpolate[i];
lookUpTable.addPoint(midpoint, yInterpolate[i]);
}
}
else
{
for (size_t i = 0; i < xInterpolate.size(); ++i)
{
lookUpTable.addPoint(xInterpolate[i], yInterpolate[i]);
}
}

const V3D samplePos = inOutWS->getInstrument()->getSample()->getPos();
const V3D sourcePos = inOutWS->getInstrument()->getSource()->getPos();
Expand Down Expand Up @@ -111,16 +141,22 @@ void TOFSANSResolutionByPixel::exec() {
MantidVec &yIn = inOutWS->dataY(i);
const size_t xLength = xIn.size();

// for each wavelenght bin of each pixel calculate a q-resolution
for (size_t j = 0; j < xLength - 1; j++) {
// Calculate q. Alternatively q could be calculated using ConvertUnit
// use the midpoint of each bin
const double wl = (xIn[j + 1] + xIn[j]) / 2.0;
// Calculate q. Alternatively q could be calculated using ConvertUnit
const double q = factor / wl;

// wavelenght spread from bin assumed to be
const double sigmaSpreadFromBin = xIn[j + 1] - xIn[j];

// wavelenght spread from moderatorm, converted from microseconds to wavelengths
const double sigmaModerator = lookUpTable.value(wl) * 3.9560 / (1000.0 * Lsum);

// calculate wavelenght resolution from moderator and histogram time bin
// width and
// convert to from unit of micro-seconds to Aangstrom
const double sigmaLambda =
sigmaModeratorMicroSec * 3.9560 / (1000.0 * Lsum);
const double sigmaLambda = std::sqrt(sigmaSpreadFromBin*sigmaSpreadFromBin/12.0 +
sigmaModerator*sigmaModerator);

// calculate sigmaQ for a given lambda and pixel
const double sigmaOverLambdaTimesQ = q * sigmaLambda / wl;
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/Algorithms/test/AsymmetryCalcTest.h
Expand Up @@ -76,6 +76,7 @@ class AsymmetryCalcTest : public CxxTest::TestSuite

//Use a range as cxxtest seems to complain about the accuracy
TS_ASSERT_DELTA(outputWS->dataY(0)[100],0.2965,0.005);
TS_ASSERT( !outputWS->isHistogramData() );
}

void test_single_spectra()
Expand All @@ -99,6 +100,7 @@ class AsymmetryCalcTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS( outputWS->readY(0)[0], -0.5 ); // == (1 - 3)/(1 + 3)
TS_ASSERT_EQUALS( outputWS->readY(0)[6], -0.5 ); // == (1 - 3)/(1 + 3)
TS_ASSERT_EQUALS( outputWS->readY(0)[9], -0.5 ); // == (1 - 3)/(1 + 3)
TS_ASSERT( !outputWS->isHistogramData() );
}

void test_yUnitLabel()
Expand Down

0 comments on commit 9d1d4c6

Please sign in to comment.