Skip to content

Commit

Permalink
Refs #8550. Merge remote-tracking branch 'origin/master' into 8550
Browse files Browse the repository at this point in the history
Conflicts:
	Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/MuonAnalysis.h
  • Loading branch information
arturbekasov committed Dec 9, 2013
2 parents 0589c2f + 670b76d commit 8b16f3c
Show file tree
Hide file tree
Showing 97 changed files with 7,020 additions and 1,847 deletions.
4 changes: 3 additions & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/ICatalog.h
Expand Up @@ -50,7 +50,9 @@ class DLLExport ICatalog
/// logout from catalog
virtual void logout()=0;
///Search investigations
virtual void search(const ICat::CatalogSearchParam&,ITableWorkspace_sptr &)=0;
virtual void search(const ICat::CatalogSearchParam&,ITableWorkspace_sptr&, const int &offset,const int &limit)=0;
/// Obtain the number of results returned by the search method.
virtual int64_t getNumberOfSearchResults(const ICat::CatalogSearchParam&)=0;
/// search logged in users data
virtual void myData(ITableWorkspace_sptr &)=0;
/// get datasets.
Expand Down
7 changes: 1 addition & 6 deletions Code/Mantid/Framework/API/src/ScopedWorkspace.cpp
Expand Up @@ -55,12 +55,7 @@ namespace API
*/
ScopedWorkspace::operator bool() const
{
AnalysisDataServiceImpl& ads = AnalysisDataService::Instance();

if ( ads.doesExist(m_name) )
return ads.retrieveWS<Workspace>(m_name);
else
return false;
return AnalysisDataService::Instance().doesExist(m_name);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions Code/Mantid/Framework/API/test/AnalysisDataServiceTest.h
Expand Up @@ -430,6 +430,17 @@ class AnalysisDataServiceTest : public CxxTest::TestSuite

}

void test_adding_null_workspace()
{
auto nullWS = MockWorkspace_sptr();

// Shouldn't be able to add null pointers
TS_ASSERT_THROWS( ads.add("null_workspace", nullWS ), std::runtime_error );
TS_ASSERT_THROWS( ads.addOrReplace("null_workspace", nullWS ), std::runtime_error );

TS_ASSERT( ! ads.doesExist("null_workspace") );
}

private:

/// If replace=true then usea addOrReplace
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Algorithms/src/AsymmetryCalc.cpp
Expand Up @@ -162,6 +162,9 @@ void AsymmetryCalc::exec()
//Copy the imput time bins on to the output
outputWS->dataX(0) = inputWS->readX(0);

// Update Y axis label
outputWS->setYUnitLabel("Asymmetry");

setProperty("OutputWorkspace", outputWS);
}

Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Algorithms/src/RemoveExpDecay.cpp
Expand Up @@ -179,6 +179,9 @@ void MuonRemoveExpDecay::exec()
PARALLEL_CHECK_INTERUPT_REGION
}

// Update Y axis label
outputWS->setYUnitLabel("Asymmetry");

setProperty("OutputWorkspace", outputWS);
}

Expand Down
24 changes: 24 additions & 0 deletions Code/Mantid/Framework/Algorithms/test/AsymmetryCalcTest.h
Expand Up @@ -101,6 +101,30 @@ class AsymmetryCalcTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS( outputWS->readY(0)[9], -0.5 ); // == (1 - 3)/(1 + 3)
}

void test_yUnitLabel()
{
const std::string outputWSName = "AsymmetryCalcTest_yUnitLabel_OutputWS";

auto ws = WorkspaceCreationHelper::Create2DWorkspace(2,1);

AsymmetryCalc alg;
alg.initialize();
alg.setProperty("InputWorkspace", ws);
alg.setProperty("OutputWorkspace", outputWSName);
alg.execute();

auto result = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(outputWSName);

TS_ASSERT(result);

if( result )
{
TS_ASSERT_EQUALS( result->YUnitLabel(), "Asymmetry" );
}

AnalysisDataService::Instance().remove(outputWSName);
}

private:
AsymmetryCalc asymCalc;
Mantid::DataHandling::LoadMuonNexus2 loader;
Expand Down
61 changes: 61 additions & 0 deletions Code/Mantid/Framework/Algorithms/test/FindPeaksTest.h
Expand Up @@ -5,8 +5,12 @@
#include "MantidTestHelpers/WorkspaceCreationHelper.h"

#include "MantidAlgorithms/FindPeaks.h"

#include "MantidAPI/MatrixWorkspace.h"
#include "MantidDataHandling/LoadNexusProcessed.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataObjects/Workspace2D.h"

#include <fstream>

using Mantid::Algorithms::FindPeaks;
Expand Down Expand Up @@ -65,6 +69,7 @@ class FindPeaksTest : public CxxTest::TestSuite
TS_ASSERT_DELTA( peaklist->Double(6,1), 1.24, 0.01 );
TS_ASSERT_DELTA( peaklist->Double(7,1), 1.52, 0.01 );
TS_ASSERT_DELTA( peaklist->Double(8,1), 2.14, 0.01 );

}

void LoadPG3_733()
Expand Down Expand Up @@ -96,4 +101,60 @@ class FindPeaksTest : public CxxTest::TestSuite
private:
};

//=================================================================================================
/** Performance test with large workspaces.
*/

class FindPeaksTestPerformance : public CxxTest::TestSuite
{
Mantid::API::MatrixWorkspace_sptr m_dataWS;

public:
static FindPeaksTestPerformance *createSuite() { return new FindPeaksTestPerformance(); }
static void destroySuite( FindPeaksTestPerformance *suite ) { delete suite; }

/** Constructor
*/
FindPeaksTestPerformance()
{

}

/** Set up workspaces
*/
void setUp()
{
// Load data file
Mantid::DataHandling::LoadNexusProcessed loader;
loader.initialize();
loader.setProperty("Filename","focussed.nxs");
loader.setProperty("OutputWorkspace", "FindPeaksTest_peaksWS");
loader.execute();

m_dataWS = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
AnalysisDataService::Instance().retrieve("FindPeaksTest_peaksWS"));

return;
}

/** Find peaks by auto-determine peaks' positions
*/
void test_FindPeaksAutoPeakPositions()
{
// Find peaks (Test)
FindPeaks finder;
if ( !finder.isInitialized() ) finder.initialize();

if (!m_dataWS)
throw std::runtime_error("Unable to get input matrix workspace. ");
finder.setPropertyValue("InputWorkspace","FindPeaksTest_peaksWS");
finder.setPropertyValue("PeakPositions", "0.8089, 0.9571, 1.0701,1.2356,1.5133,2.1401");
finder.setPropertyValue("PeaksList","FindPeaksTest_foundpeaks");

finder.execute();
}

}; // end of class FindPeaksTestPerformance


#endif /*FINDPEAKSTEST_H_*/
32 changes: 29 additions & 3 deletions Code/Mantid/Framework/Algorithms/test/RemoveExpDecayTest.h
Expand Up @@ -3,12 +3,14 @@

#include <cxxtest/TestSuite.h>

#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/Workspace.h"
#include "MantidAlgorithms/RemoveExpDecay.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidAlgorithms/RemoveExpDecay.h"
#include "MantidAPI/Workspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"

#include <stdexcept>

using namespace Mantid::Algorithms;
Expand Down Expand Up @@ -90,6 +92,30 @@ class RemoveExpDecayTest : public CxxTest::TestSuite
}
}

void test_yUnitLabel()
{
const std::string outputWSName = "RemoveExpDecayTest_yUnitLabel_OutputWS";

auto ws = WorkspaceCreationHelper::Create2DWorkspace(1,1);

MuonRemoveExpDecay alg;
alg.initialize();
alg.setProperty("InputWorkspace", ws);
alg.setProperty("OutputWorkspace", outputWSName);
alg.execute();

auto result = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(outputWSName);

TS_ASSERT(result);

if( result )
{
TS_ASSERT_EQUALS( result->YUnitLabel(), "Asymmetry" );
}

AnalysisDataService::Instance().remove(outputWSName);
}


private:
MuonRemoveExpDecay alg;
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Crystal/CMakeLists.txt
Expand Up @@ -25,6 +25,7 @@ set ( SRC_FILES
src/NormaliseVanadium.cpp
src/OptimizeCrystalPlacement.cpp
src/OptimizeExtinctionParameters.cpp
src/OptimizeLatticeForCellType.cpp
src/PeakHKLErrors.cpp
src/PeakIntegration.cpp
src/PeakIntensityVsRadius.cpp
Expand Down Expand Up @@ -80,6 +81,7 @@ set ( INC_FILES
inc/MantidCrystal/NormaliseVanadium.h
inc/MantidCrystal/OptimizeCrystalPlacement.h
inc/MantidCrystal/OptimizeExtinctionParameters.h
inc/MantidCrystal/OptimizeLatticeForCellType.h
inc/MantidCrystal/PeakHKLErrors.h
inc/MantidCrystal/PeakIntegration.h
inc/MantidCrystal/PeakIntensityVsRadius.h
Expand Down Expand Up @@ -132,6 +134,7 @@ set ( TEST_FILES
MaskPeaksWorkspaceTest.h
NormaliseVanadiumTest.h
OptimizeCrystalPlacementTest.h
OptimizeLatticeForCellTypeTest.h
PeakHKLErrorsTest.h
PeakIntegrationTest.h
PeakIntensityVsRadiusTest.h
Expand Down
Expand Up @@ -49,6 +49,7 @@ namespace Crystal
std::string readHeader( Mantid::DataObjects::PeaksWorkspace_sptr outWS, std::ifstream& in,double &T0 );

void appendFile( Mantid::DataObjects::PeaksWorkspace_sptr outWS, std::string filename);
void checkNumberPeaks( Mantid::DataObjects::PeaksWorkspace_sptr outWS, std::string filename );

};

Expand Down
@@ -0,0 +1,73 @@
#ifndef MANTID_CRYSTAL_OptimizeLatticeForCellType_H_
#define MANTID_CRYSTAL_OptimizeLatticeForCellType_H_

#include "MantidAPI/Algorithm.h"
#include "MantidKernel/System.h"
#include "MantidDataObjects/OffsetsWorkspace.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include <gsl/gsl_blas.h>
#include <gsl/gsl_multifit_nlin.h>
#include <gsl/gsl_multimin.h>
#include <gsl/gsl_statistics.h>

namespace Mantid
{
namespace Crystal
{
/**
Find the offsets for each detector
@author Vickie Lynch, SNS
@date 02/06/2012
Copyright &copy; 2009 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport OptimizeLatticeForCellType: public API::Algorithm
{
public:
/// Default constructorMatrix
OptimizeLatticeForCellType();
/// Destructor
virtual ~OptimizeLatticeForCellType();
/// Algorithm's name for identification overriding a virtual method
virtual const std::string name() const { return "OptimizeLatticeForCellType"; }
/// Algorithm's version for identification overriding a virtual method
virtual int version() const { return 1; }
/// Algorithm's category for identification overriding a virtual method
virtual const std::string category() const { return "Crystal"; }
/// Call TOFLattice as a Child Algorithm to get statistics of the peaks
double optLattice(std::string inname, std::string cell_type, std::vector<double> & params);

private:
/// Sets documentation strings for this algorithm
virtual void initDocs();
// Overridden Algorithm methods
void init();
void exec();
/// Static reference to the logger class
static Kernel::Logger& g_log;

};

} // namespace Algorithm
} // namespace Mantid

#endif /*MANTID_CRYSTAL_OptimizeLatticeForCellType_H_*/
25 changes: 24 additions & 1 deletion Code/Mantid/Framework/Crystal/src/LoadIsawPeaks.cpp
Expand Up @@ -584,8 +584,29 @@ namespace Crystal
}

}
//-----------------------------------------------------------------------------------------------
/** Count the peaks from a .peaks file and compare with the workspace
* @param outWS :: the workspace in which to place the information
* @param filename :: path to the .peaks file
*/
void LoadIsawPeaks::checkNumberPeaks( PeaksWorkspace_sptr outWS, std::string filename )
{


// Open the file
std::ifstream in( filename.c_str() );
std::string first;
int NumberPeaks = 0;
while (getline(in,first))
{
if (first[0] == '3')NumberPeaks++;
}
if(NumberPeaks != outWS->getNumberPeaks())
{
g_log.error()<<"Number of peaks in file is " << NumberPeaks << " but only read "
<<outWS->getNumberPeaks() << std::endl;
throw std::length_error("Wrong number of peaks read");
}
}

//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
Expand All @@ -600,6 +621,8 @@ namespace Crystal

// Save it in the output
setProperty("OutputWorkspace", boost::dynamic_pointer_cast<Workspace>(ws));

this->checkNumberPeaks(ws, getPropertyValue("Filename"));
}


Expand Down

0 comments on commit 8b16f3c

Please sign in to comment.