Skip to content

Commit

Permalink
Merge branch 'master' into feature/10246_Fix_os10.9_clang_failed_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumsteve committed Oct 3, 2014
2 parents 91f5ad1 + 011e474 commit 8067903
Show file tree
Hide file tree
Showing 52 changed files with 2,477 additions and 793 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Build/Jenkins/buildscript.bat
Expand Up @@ -8,6 +8,7 @@
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

"C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" --version
echo %sha1%

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Check the required build configuration
Expand Down
Expand Up @@ -203,6 +203,8 @@ class DLLExport FindPeaks : public API::Algorithm

/// Minimum peak height
double m_minHeight;
/// Minimum value of peak's observed maximum Y value
double m_leastMaxObsY;

/// Start values
bool m_useObsCentre;
Expand Down
Expand Up @@ -150,9 +150,10 @@ class DLLExport GetDetOffsetsMultiPeaks: public API::Algorithm
std::string m_backType;
/// Peak profile type
std::string m_peakType;
/// Criterias for fitting peak
double m_maxChiSq;
double m_minPeakHeight;

double m_leastMaxObsY;
double m_maxOffset;

std::vector<double> m_peakPositions;
Expand Down
23 changes: 23 additions & 0 deletions Code/Mantid/Framework/Algorithms/src/FindPeaks.cpp
Expand Up @@ -123,6 +123,10 @@ namespace Algorithms

declareProperty("MinimumPeakHeight", DBL_MIN, "Minimum allowed peak height. ");

declareProperty("MinimumPeakHeightObs", 0.0, "Least value of the maximum observed Y value of a peak within "
"specified region. If any peak's maximum observed Y value is smaller, then "
"this peak will not be fit. It is designed for EventWorkspace with integer counts.");

std::vector<std::string> costFuncOptions;
costFuncOptions.push_back("Chi-Square");
costFuncOptions.push_back("Rwp");
Expand Down Expand Up @@ -255,6 +259,8 @@ namespace Algorithms

m_useObsCentre = getProperty("StartFromObservedPeakCentre");

m_leastMaxObsY = getProperty("MinimumPeakHeightObs");

return;
}

Expand Down Expand Up @@ -890,6 +896,23 @@ namespace Algorithms
const MantidVec& vecX = input->readX(spectrum);
const MantidVec& vecY = input->readY(spectrum);

// Exclude peak with peak counts
bool hasHighCounts = false;
for (int i = i_min; i <= i_max; ++i)
if (vecY[i] > m_leastMaxObsY)
{
hasHighCounts = true;
break;
}
if (!hasHighCounts)
{
std::stringstream ess;
ess << "Peak supposed at " << vecY[i_centre] << " does not have enough counts as " << m_leastMaxObsY;
g_log.debug(ess.str());
addNonFitRecord(spectrum);
return;
}

//-------------------------------------------------------------------------
// Estimate peak and background parameters for better fitting
//-------------------------------------------------------------------------
Expand Down
Expand Up @@ -186,6 +186,11 @@ namespace Algorithms
declareProperty("MaxChiSq", 100., "Maximum chisq value for individual peak fit allowed. (Default: 100)");

declareProperty("MinimumPeakHeight", 2.0, "Minimum value allowed for peak height.");

declareProperty("MinimumPeakHeightObs", 0.0, "Least value of the maximum observed Y value of a peak within "
"specified region. If any peak's maximum observed Y value is smaller, then "
"this peak will not be fit. It is designed for EventWorkspace with integer counts.");

//Disable default gsl error handler (which is to call abort!)
gsl_set_error_handler_off();

Expand Down Expand Up @@ -314,6 +319,7 @@ namespace Algorithms
m_maxChiSq = this->getProperty("MaxChiSq");
m_minPeakHeight = this->getProperty("MinimumPeakHeight");
m_maxOffset=getProperty("MaxOffset");
m_leastMaxObsY = getProperty("MinimumPeakHeightObs");

// Create output workspaces
outputW = boost::make_shared<OffsetsWorkspace>(m_inputWS->getInstrument());
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/Algorithms/src/MaskBinsFromTable.cpp
Expand Up @@ -48,7 +48,7 @@ namespace Algorithms
this->declareProperty(new WorkspaceProperty<>("OutputWorkspace","",Direction::Output),
"Output Workspace with bins masked.");
this->declareProperty(new WorkspaceProperty<DataObjects::TableWorkspace>("MaskingInformation", "", Direction::Input),
"Input TableWorkspace containing parameters, SpectraList, XMin and XMax.");
"Input TableWorkspace containing parameters, XMin and XMax and either SprectaList or DetectorIDsList");

return;
}
Expand Down Expand Up @@ -188,7 +188,7 @@ namespace Algorithms
if (id_xmin < 0 || id_xmax < 0 || id_xmin == id_xmax)
throw runtime_error("Either Xmin nor Xmax is not given. ");
if (id_spec == id_dets)
throw runtime_error("Neither SpectraList nor DetectorIDList is not given.");
throw runtime_error("Neither SpectraList nor DetectorIDList is given.");
else if (id_dets >= 0)
m_useDetectorID = true;
else
Expand Down
Expand Up @@ -94,8 +94,6 @@ namespace Mantid
/// Algorithm's category for identification overriding a virtual method
virtual const std::string category() const { return "DataHandling\\Instrument";}

void execManually();

private:
void init();
void exec();
Expand Down
Expand Up @@ -87,8 +87,6 @@ namespace Mantid
/// Algorithm's category for identification overriding a virtual method
virtual const std::string category() const { return "DataHandling\\Instrument";}

static void execManually(bool useString, std::string filename, std::string parameterString, Mantid::API::ExperimentInfo_sptr localWorkspace);

private:

void init();
Expand Down
Expand Up @@ -6,7 +6,6 @@
#include "MantidGeometry/Instrument.h"
#include "MantidAPI/InstrumentDataService.h"
#include "MantidGeometry/Instrument/InstrumentDefinitionParser.h"
#include "MantidDataHandling/LoadParameterFile.h"

#include <Poco/DOM/DOMWriter.h>
#include <Poco/DOM/Element.h>
Expand Down Expand Up @@ -892,8 +891,10 @@ namespace DataHandling


// Load the string into the workspace
LoadParameterFile::execManually(true, "", parameterXMLString, ws);

Algorithm_sptr loadParamAlg = createChildAlgorithm("LoadParameterFile");
loadParamAlg->setProperty("ParameterXML", parameterXMLString);
loadParamAlg->setProperty("Workspace", ws);
loadParamAlg->execute();
}

/* Add an Ikeda Carpenter PV ALFBE parameter to the XML document according to the table workspace
Expand Down
6 changes: 4 additions & 2 deletions Code/Mantid/Framework/DataHandling/src/LoadIDFFromNexus.cpp
Expand Up @@ -2,7 +2,6 @@
// Includes
//----------------------------------------------------------------------
#include "MantidDataHandling/LoadIDFFromNexus.h"
#include "MantidDataHandling/LoadParameterFile.h"
#include "MantidKernel/ConfigService.h"
#include "MantidAPI/FileProperty.h"

Expand Down Expand Up @@ -86,7 +85,10 @@ void LoadIDFFromNexus::exec()

try {
// load and also populate instrument parameters from this 'fallback' parameter file
LoadParameterFile::execManually(false, paramFile,"", localWorkspace);
Algorithm_sptr loadParamAlg = createChildAlgorithm("LoadParameterFile");
loadParamAlg->setProperty("Filename", paramFile);
loadParamAlg->setProperty("Workspace", localWorkspace);
loadParamAlg->execute();
g_log.notice() << "Instrument parameter file: " << paramFile << " has been loaded" << std::endl;
} catch ( std::runtime_error& ) {
g_log.debug() << "Instrument parameter file: " << paramFile << " not found or un-parsable. ";
Expand Down
6 changes: 4 additions & 2 deletions Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp
Expand Up @@ -5,7 +5,6 @@
#include "MantidAPI/InstrumentDataService.h"
#include "MantidAPI/Progress.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/LoadParameterFile.h"
#include "MantidGeometry/Instrument.h"
#include "MantidGeometry/Instrument/Component.h"
#include "MantidGeometry/Instrument/Detector.h"
Expand Down Expand Up @@ -220,7 +219,10 @@ namespace Mantid
try
{
// To allow the use of ExperimentInfo instead of workspace, we call it manually
LoadParameterFile::execManually(false, fullPathParamIDF, "", m_workspace);
Algorithm_sptr loadParamAlg = createChildAlgorithm("LoadParameterFile");
loadParamAlg->setProperty("Filename", fullPathParamIDF);
loadParamAlg->setProperty("Workspace", m_workspace);
loadParamAlg->execute();
g_log.debug("Parameters loaded successfully.");
} catch (std::invalid_argument& e)
{
Expand Down
21 changes: 12 additions & 9 deletions Code/Mantid/Framework/DataHandling/src/LoadParameterFile.cpp
Expand Up @@ -71,11 +71,11 @@ void LoadParameterFile::init()
void LoadParameterFile::exec()
{
// Retrieve the filename from the properties
std::string filename = getPropertyValue("Filename");
const std::string filename = getPropertyValue("Filename");

// Retrieve the parameter XML string from the properties
const Property * const parameterXMLProperty = getProperty("ParameterXML"); // to check whether it is default
std::string parameterXML = getPropertyValue("ParameterXML");
const std::string parameterXML = getPropertyValue("ParameterXML");

// Check the two properties (at least one must be set)
if( filename.empty() && parameterXMLProperty->isDefault()){
Expand All @@ -85,19 +85,20 @@ void LoadParameterFile::exec()
// Get the input workspace
const MatrixWorkspace_sptr localWorkspace = getProperty("Workspace");

execManually(!parameterXMLProperty->isDefault(), filename, parameterXML, localWorkspace);
}

void LoadParameterFile::execManually(bool useString, std::string filename, std::string parameterXML, Mantid::API::ExperimentInfo_sptr localWorkspace)
{
// TODO: Refactor to remove the need for the const cast (ticket #8521)
Instrument_sptr instrument = boost::const_pointer_cast<Instrument>(localWorkspace->getInstrument()->baseInstrument());

// Set up the DOM parser and parse xml file
DOMParser pParser;
AutoPtr<Document> pDoc;

if(useString){
//Progress reporting object
Progress prog(this, 0.0, 1.0, 100);

prog.report("Parsing XML");
//If we've been given an XML string parse that instead
if(!parameterXMLProperty->isDefault())
{
try
{
pDoc = pParser.parseString(parameterXML);
Expand Down Expand Up @@ -136,11 +137,13 @@ void LoadParameterFile::execManually(bool useString, std::string filename, std::

// Set all parameters that specified in all component-link elements of pRootElem
InstrumentDefinitionParser loadInstr;
loadInstr.setComponentLinks(instrument, pRootElem);
loadInstr.setComponentLinks(instrument, pRootElem, &prog);

// populate parameter map of workspace
localWorkspace->populateInstrumentParameters();

prog.resetNumSteps(1, 0.0, 1.0);
prog.report("Done");
}

} // namespace DataHandling
Expand Down
Expand Up @@ -78,7 +78,7 @@ namespace Geometry
boost::shared_ptr<Instrument> parseXML(Kernel::ProgressBase * prog);

/// Add/overwrite any parameters specified in instrument with param values specified in <component-link> XML elements
void setComponentLinks(boost::shared_ptr<Geometry::Instrument>& instrument, Poco::XML::Element* pElem);
void setComponentLinks(boost::shared_ptr<Geometry::Instrument>& instrument, Poco::XML::Element* pElem, Kernel::ProgressBase* progress = NULL);

std::string getMangledName();

Expand Down

0 comments on commit 8067903

Please sign in to comment.