Skip to content

Commit

Permalink
refs #10384 fixing SimpleAPITest
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Oct 28, 2014
1 parent 9e6708c commit db08fcb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
36 changes: 31 additions & 5 deletions Code/Mantid/Framework/Algorithms/src/Rebin.cpp
Expand Up @@ -104,7 +104,7 @@ namespace Mantid
vsValidator->add<WorkspaceUnitValidator>("TOF");
vsValidator->add<HistogramValidator>();
declareProperty(new WorkspaceProperty<>("FlatBkgWorkspace","",Direction::Input,API::PropertyMode::Optional,vsValidator),
"An optional histogram workspace in the units of TOF defined background for removal during rebinning."
"An optional histogram workspace in the units of TOF defining background for removal during rebinning."
"The workspace has to have single value or contain the same number of spectra as the \"InputWorkspace\" and single Y value per each spectra,"
"representing flat background in the background time region. "
"If such workspace is present, the value of the flat background provided by this workspace is removed "
Expand All @@ -113,7 +113,7 @@ namespace Mantid

std::vector<std::string> dE_modes = Kernel::DeltaEMode().availableTypes();
declareProperty("EMode",dE_modes[Kernel::DeltaEMode::Direct],boost::make_shared<Kernel::StringListValidator>(dE_modes),
"If FlatBkgWorkspace, this property is used to define the units conversion from TOF to the units of the InputWorkspace",Direction::Input);
"If FlatBkgWorkspace is present, this property used to define the units conversion from TOF to the units of the InputWorkspace",Direction::Input);
setPropertySettings("EMode",
new Kernel::VisibleWhenProperty("FlatBkgWorkspace", IS_NOT_EQUAL_TO, ""));

Expand Down Expand Up @@ -239,6 +239,7 @@ namespace Mantid
}
PARALLEL_CHECK_INTERUPT_REGION


//Copy all the axes
for (int i=1; i<inputWS->axes(); i++)
{
Expand Down Expand Up @@ -288,7 +289,7 @@ namespace Mantid
{
PARALLEL_START_INTERUPT_REGION
// get const references to input Workspace arrays (no copying)
const MantidVec& XValues = inputWS->readX(hist);
const MantidVec& XValues = inputWS->readX(hist);
const MantidVec& YValues = inputWS->readY(hist);
const MantidVec& YErrors = inputWS->readE(hist);

Expand Down Expand Up @@ -344,6 +345,31 @@ namespace Mantid
outputWS = ChildAlg->getProperty("OutputWorkspace");
}

if(remove_background)
{
const std::list<int> &failedBkgRemoalList= m_BackgroundHelper.getFailingSpectrsList();
if(!failedBkgRemoalList.empty())
{
size_t nFailed = failedBkgRemoalList.size();
if(nFailed == histnumber)
{
g_log.warning()<<" has not been able to remove any background while rebinning workspace "<<inputWS->getName()<<
"\n possible reasons: wrong instrument or units conversion mode\n";
}
else
{
g_log.debug()<<" has not removed background from "<<nFailed<<" spectra\n";
if(nFailed<20)
{
g_log.debug()<<" Spectra numbers are: ";
for(auto it=failedBkgRemoalList.begin(); it !=failedBkgRemoalList.end();it++) g_log.debug()<<(*it);
g_log.debug()<<"\n";
}
}
}
}


// Assign it to the output workspace property
setProperty("OutputWorkspace",outputWS);

Expand Down Expand Up @@ -390,8 +416,8 @@ namespace Mantid

if(!(bkgWksp->getNumberHistograms() == 1 || inputWS->getNumberHistograms()==bkgWksp->getNumberHistograms()))
{
g_log.warning()<<" Background Workspace: "<< bkgWksp->getName()<< " should have the same number of spectra as source workspace or be a single histogram workspace\n";
return API::MatrixWorkspace_const_sptr();
g_log.warning()<<" Background Workspace: "<< bkgWksp->getName()<< " should have the same number of spectra as source workspace or be a single histogram workspace\n";
return API::MatrixWorkspace_const_sptr();
}


Expand Down
Expand Up @@ -67,6 +67,10 @@ def test_alg_has_expected_doc_string(self):
PreserveEvents(Input) *boolean* Keep the output workspace as an EventWorkspace, if the input has events. If the input and output EventWorkspace names are the same, only the X bins are set, which is very quick. If false, then the workspace gets converted to a Workspace2D histogram.
FullBinsOnly(Input) *boolean* Omit the final bin if it's width is smaller than the step size
FlatBkgWorkspace(Input) *MatrixWorkspace* An optional histogram workspace in the units of TOF defining background for removal during rebinning.The workspace has to have single value or contain the same number of spectra as the "InputWorkspace" and single Y value per each spectra,representing flat background in the background time region. If such workspace is present, the value of the flat background provided by this workspace is removed from each spectra of the rebinned workspace. This works for histogram and event workspace when events are not retained but actually useful mainly for removing background while rebinning an event workspace in the units different from TOF.[]
EMode(Input) *string* If FlatBkgWorkspace is present, this property used to define the units conversion from TOF to the units of the InputWorkspace[Elastic, Direct, Indirect]
"""
doc = simpleapi.rebin.__doc__
self.assertTrue(len(doc) > 0 )
Expand Down

0 comments on commit db08fcb

Please sign in to comment.