Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mantidproject/mantid
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Nov 3, 2011
2 parents d07ca53 + ea907f7 commit f301e16
Show file tree
Hide file tree
Showing 26 changed files with 765 additions and 80 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace Mantid
/// Query the NearestNeighbours object for a given spectrum index using a search radius
std::map<specid_t, double> getNeighbours(specid_t spec, const double radius) const;
/// Query the NearestNeighbours object for a given spectrum index using the direct number of nearest neighbours
std::map<specid_t, double> getNeighbours(specid_t spec, const unsigned int nNeighbours) const;
std::map<specid_t, double> getNeighboursExact(specid_t spec, const int nNeighbours) const;
//@}

/// Const access to the spectra-detector map
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ namespace Mantid
* @param nNeighbours :: unsigned int, number of neighbours to include.
* @return map of DetectorID to distance for the nearest neighbours
*/
std::map<specid_t, double> MatrixWorkspace::getNeighbours(specid_t spec, const unsigned int nNeighbours) const
std::map<specid_t, double> MatrixWorkspace::getNeighboursExact(specid_t spec, const int nNeighbours) const
{
if ( !m_nearestNeighbours )
{
Expand Down
21 changes: 13 additions & 8 deletions Code/Mantid/Framework/Algorithms/src/NormaliseByVanadium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include "MantidAPI/WorkspaceOpOverloads.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidKernel/Exception.h"
#include "MantidKernel/CPUTimer.h"

using namespace Mantid::Kernel;
using namespace Mantid::API;
using Mantid::Kernel::CPUTimer;

namespace Mantid
{
Expand Down Expand Up @@ -45,21 +47,19 @@ namespace Algorithms
"The name of the vanadium Workspace2D to take as input");
declareProperty(new WorkspaceProperty<>("OutputWorkspace","",Direction::Output),
"The name of the workspace in which to store the result");
declareProperty(new PropertyWithValue<int>("NumberOfNeighbours", 8, new BoundedValidator<int>(), Direction::Input), "The number of neighbours to utilise. Defaults to 8.");
}

/// Run the algorithm
void NormaliseByVanadium::exec()
{
MatrixWorkspace_sptr sampleWS = getProperty("SampleInputWorkspace");
MatrixWorkspace_sptr vanadiumWS = getProperty("VanadiumInputWorkspace");
int neighbours = getProperty("NumberOfNeighbours");
if(sampleWS->getXDimension()->getNBins() != vanadiumWS->getXDimension()->getNBins())
{
throw std::runtime_error("Sample and Vanadium workspaces do not have the same number of bins.");
}
//if(sampleWS->getNumberHistograms() != vanadiumWS->getNumberHistograms())
//{
// throw std::runtime_error("Sample and Vanadium workspaces do not have the same number of historams");
//}

spec2index_map* specToWSIndexMap = vanadiumWS->getSpectrumToWorkspaceIndexMap();

Expand All @@ -73,7 +73,7 @@ namespace Algorithms

// Calculate the average TOF accross all spectra
size_t nHistograms = vanSumTOF_WS->getNumberHistograms();
Progress progress(this,0.01,0.99,nHistograms);
Progress progress(this, 0.01, 0.80,nHistograms);

/// Create an empty workspace with the same dimensions as the integrated vanadium.
MatrixWorkspace_sptr yAvgWS = Mantid::API::WorkspaceFactory::Instance().create(vanSumTOF_WS);
Expand All @@ -91,7 +91,9 @@ namespace Algorithms
std::map<specid_t, double> specIdMap;
PARALLEL_CRITICAL(NearestNeighboursSearch)
{
specIdMap = vanadiumWS->getNeighbours(inSpec, 0.0); //This is not threadsafe!
//CPUTimer tim;
specIdMap = vanadiumWS->getNeighboursExact(inSpec, neighbours); //This is not threadsafe!
// std::cout << tim << " to get nearest neighbours." << std::endl;
}
std::map<specid_t, double>::iterator it = specIdMap.begin();
double spectraSum = 0;
Expand All @@ -116,7 +118,7 @@ namespace Algorithms
vanSumTOF_WS = vanSumTOF_WS/yAvgWS;

//Mask detectors outside of limits
IAlgorithm_sptr constrainAlg = this->createSubAlgorithm("FindDetectorsOutsideLimits", 0.99, 0.991, true, 1);
IAlgorithm_sptr constrainAlg = this->createSubAlgorithm("FindDetectorsOutsideLimits", 0.80, 0.85, true, 1);
constrainAlg->setProperty("InputWorkspace", vanSumTOF_WS);
constrainAlg->setPropertyValue("OutputWorkspace", "ConstrainedWS");
constrainAlg->setProperty("HighThreshold", pow((double)10, (double)300));
Expand All @@ -125,13 +127,16 @@ namespace Algorithms
MatrixWorkspace_sptr constrainedWS = constrainAlg->getProperty("OutputWorkspace");

//Mask detectors outside of limits
IAlgorithm_sptr maskdetectorsAlg = this->createSubAlgorithm("MaskDetectors", 0.991, 1, true, 1);
IAlgorithm_sptr maskdetectorsAlg = this->createSubAlgorithm("MaskDetectors", 0.85, 0.90, true, 1);
maskdetectorsAlg->setProperty("Workspace", vanSumTOF_WS);
maskdetectorsAlg->setProperty("MaskedWorkspace", constrainedWS);
maskdetectorsAlg->executeAsSubAlg();

//Divide the sample workspace by the smoothed vanadium workspace.
sampleWS = sampleWS / vanSumTOF_WS;

progress.report(1, "Complete");
//Finally set the output workspace.
setProperty("OutputWorkspace", sampleWS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class NormaliseByVanadiumTest : public CxxTest::TestSuite
{
using Mantid::API::AnalysisDataService;

MatrixWorkspace_sptr sampleWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(50, 10);
MatrixWorkspace_sptr vanadiumWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(50, 10); //Effectively normalisation by itself.
MatrixWorkspace_sptr sampleWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(5000, 10);
MatrixWorkspace_sptr vanadiumWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(5000, 10); //Effectively normalisation by itself.

NormaliseByVanadium alg;
alg.initialize();
Expand Down Expand Up @@ -132,8 +132,8 @@ class NormaliseByVanadiumTestPeformance : public CxxTest::TestSuite
{
using Mantid::API::AnalysisDataService;

MatrixWorkspace_sptr sampleWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(200, 10);
MatrixWorkspace_sptr vanadiumWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(200, 10); //Effectively normalisation by itself.
MatrixWorkspace_sptr sampleWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(2000, 10);
MatrixWorkspace_sptr vanadiumWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(2000, 10); //Effectively normalisation by itself.

NormaliseByVanadium alg;
alg.initialize();
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/DataHandling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ set ( TEST_FILES
test/LoadNXSPETest.h
test/LoadParameterFileTest.h
test/LoadPreNexusMonitorsTest.h
test/LoadQKKTest.h
test/LoadRKHTest.h
test/LoadRSaveNLoadNcspTest.h
test/LoadRaw2Test.h
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/DataHandling/src/LoadQKK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ namespace Mantid
Geometry::Object_sptr shape = Geometry::ShapeFactory().createShape(detXML);
// Initialise the detector specifying the sizes.
bank->initialize(shape,int(nx),0,pixel_width,int(ny),0,pixel_height,1,true,int(nx));
for (size_t i = 0; i < ny; ++i)
for (size_t j = 0; j < nx; ++j)
{
instrument->markAsDetector(bank->getAtXY(j,i).get());
}
// Position the detector so the z axis goes through its centre
bank->setPos(-width / 2, -height / 2, 0);

Expand Down
60 changes: 60 additions & 0 deletions Code/Mantid/Framework/DataHandling/test/LoadQKKTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef LOADRKHTEST_H_
#define LOADRKHTEST_H_

//-----------------
// Includes
//-----------------
#include "MantidDataHandling/LoadQKK.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidKernel/ConfigService.h"
#include <cxxtest/TestSuite.h>
#include <Poco/Path.h>

using Mantid::Kernel::ConfigServiceImpl;
using namespace Mantid::API;
using namespace Mantid::DataObjects;

class LoadQKKTest : public CxxTest::TestSuite
{
public:

static LoadQKKTest *createSuite() { return new LoadQKKTest(); }
static void destroySuite(LoadQKKTest *suite) { delete suite; }

// A sample file is in the repository
LoadQKKTest()
{
}

void testInit()
{
Mantid::DataHandling::LoadQKK load;
TS_ASSERT_THROWS_NOTHING( load.initialize());
TS_ASSERT( load.isInitialized() );
}

void testLoad()
{
std::string wsName = "QKK0029775";
Mantid::DataHandling::LoadQKK load;
TS_ASSERT_THROWS_NOTHING( load.initialize());
load.setPropertyValue("Filename","QKK0029775.nx.hdf");
load.setPropertyValue("OutputWorkspace",wsName);
load.execute();
TS_ASSERT( load.isExecuted() );

Workspace_sptr ws;
TS_ASSERT_THROWS_NOTHING( ws = AnalysisDataService::Instance().retrieve(wsName) );
Workspace2D_sptr data = boost::dynamic_pointer_cast<Workspace2D>(ws);
TS_ASSERT(data);
TS_ASSERT_EQUALS( data->getNumberHistograms(), 192 * 192 );
Mantid::Geometry::IDetector_const_sptr det;
for(size_t i = 0; i < data->getNumberHistograms(); ++i)
{
TS_ASSERT_THROWS_NOTHING( det = data->getDetector(i) );
}
}
};


#endif //LOADRKHTEST_H_
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace Mantid
std::map<specid_t, double> neighbours(const specid_t spectrum, const double radius=0.0) const;

// Neighbouring spectra by
std::map<specid_t, double> neighbours(const specid_t spectrum, bool force, const unsigned int numberofneighbours=8) const;
std::map<specid_t, double> neighbours(const specid_t spectrum, bool force, const int numberofneighbours=8) const;

private:
/// typedef for Graph object used to hold the calculated information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Mantid
* @return map of Detector ID's to distance
* @throw NotFoundError if component is not recognised as a detector
*/
std::map<specid_t, double> NearestNeighbours::neighbours(const specid_t spectrum, bool force, const unsigned int noNeighbours) const
std::map<specid_t, double> NearestNeighbours::neighbours(const specid_t spectrum, bool force, const int noNeighbours) const
{
if(force || m_noNeighbours != int(noNeighbours))
{
Expand Down
65 changes: 65 additions & 0 deletions Code/Mantid/Framework/Geometry/test/NearestNeighboursTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ using Mantid::Kernel::V3D;
* Everything must be in one test or the instrument/detector list goes AWOL.
*/

//=====================================================================================
// Functional tests
//=====================================================================================
class NearestNeighboursTest : public CxxTest::TestSuite
{
public:
Expand Down Expand Up @@ -148,4 +151,66 @@ class NearestNeighboursTest : public CxxTest::TestSuite

};

//=====================================================================================
// Performance tests
//=====================================================================================
class NearestNeighboursTestPerformance : public CxxTest::TestSuite
{

public:

void testUsingRadius()
{
Instrument_sptr instrument = boost::dynamic_pointer_cast<Instrument>(ComponentCreationHelper::createTestInstrumentCylindrical(2));
boost::scoped_ptr<ISpectraDetectorMap> spectramap(new OneToOneSpectraDetectorMap(1, 18));
// Default parameter map.
ParameterMap_sptr pmap(new ParameterMap());
// Parameterized instrument
Instrument_sptr m_instrument(new Instrument(instrument, pmap));

// Create the NearestNeighbours object directly.
NearestNeighbours nn(m_instrument, *spectramap);
for(size_t i = 0; i < 2000; i++)
{
nn.neighbours(1, 5.0);
}
}

void testUsingDefault()
{
Instrument_sptr instrument = boost::dynamic_pointer_cast<Instrument>(ComponentCreationHelper::createTestInstrumentCylindrical(2));
boost::scoped_ptr<ISpectraDetectorMap> spectramap(new OneToOneSpectraDetectorMap(1, 18));
// Default parameter map.
ParameterMap_sptr pmap(new ParameterMap());
// Parameterized instrument
Instrument_sptr m_instrument(new Instrument(instrument, pmap));

// Create the NearestNeighbours object directly.
NearestNeighbours nn(m_instrument, *spectramap);
for(size_t i = 0; i < 2000; i++)
{
nn.neighbours(1, 0.0);
}
}

void testUsingNumberOfNeighbours()
{
Instrument_sptr instrument = boost::dynamic_pointer_cast<Instrument>(ComponentCreationHelper::createTestInstrumentCylindrical(2));
boost::scoped_ptr<ISpectraDetectorMap> spectramap(new OneToOneSpectraDetectorMap(1, 18));
// Default parameter map.
ParameterMap_sptr pmap(new ParameterMap());
// Parameterized instrument
Instrument_sptr m_instrument(new Instrument(instrument, pmap));

// Create the NearestNeighbours object directly.
NearestNeighbours nn(m_instrument, *spectramap);
for(size_t i = 0; i < 2000; i++)
{
nn.neighbours(1, true, 8.0);
}
}

};


#endif /* MANTID_TEST_GEOMETRY_NEARESTNEIGHBOURS */
6 changes: 6 additions & 0 deletions Code/Mantid/Installers/WinInstaller/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ipch
*.sdf
*.opensdf
*.suo
Mantid.properties
mantid_version.txt
2 changes: 2 additions & 0 deletions Code/Mantid/Installers/WinInstaller/MantidMSI/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin
obj
20 changes: 20 additions & 0 deletions Code/Mantid/Installers/WinInstaller/MantidMSI/MantidMSI.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MantidMSI", "MantidMSI\MantidMSI.vcxproj", "{5092A8BC-F5E5-4FAA-88B4-DC16DB5C7DE8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5092A8BC-F5E5-4FAA-88B4-DC16DB5C7DE8}.Debug|Win32.ActiveCfg = Debug|Win32
{5092A8BC-F5E5-4FAA-88B4-DC16DB5C7DE8}.Debug|Win32.Build.0 = Debug|Win32
{5092A8BC-F5E5-4FAA-88B4-DC16DB5C7DE8}.Release|Win32.ActiveCfg = Release|Win32
{5092A8BC-F5E5-4FAA-88B4-DC16DB5C7DE8}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
This custom action searches for previous installed products and returns all that match
regardless off their install context, i.e. per-machine and per-user.
Copyright &copy; 2011 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://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
#include "stdafx.h"

// DllMain - Initialize and cleanup WiX custom action utils.
extern "C" BOOL WINAPI DllMain(
__in HINSTANCE hInst,
__in ULONG ulReason,
__in LPVOID
)
{
switch(ulReason)
{
case DLL_PROCESS_ATTACH:
WcaGlobalInitialize(hInst);
break;

case DLL_PROCESS_DETACH:
WcaGlobalFinalize();
break;
}

return TRUE;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LIBRARY "MantidMSI"

EXPORTS

FindOldMachineContextInstall

0 comments on commit f301e16

Please sign in to comment.