本文整理汇总了C++中dataobjects::Workspace2D_sptr::maskBin方法的典型用法代码示例。如果您正苦于以下问题:C++ Workspace2D_sptr::maskBin方法的具体用法?C++ Workspace2D_sptr::maskBin怎么用?C++ Workspace2D_sptr::maskBin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataobjects::Workspace2D_sptr
的用法示例。
在下文中一共展示了Workspace2D_sptr::maskBin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setProperty
/**
Read from the instrument file the dead wires and store the information in a TableWorkspace.
If asked, the dead wires are removed from the data set.
@param localWorkspace :: input raw data workspace, containing the information about the instrument
@param outputws :: input dead wire liste workspace
*/
void PoldiRemoveDeadWires::runExcludWires3
(
DataObjects::Workspace2D_sptr &localWorkspace,
API::ITableWorkspace_sptr &outputws
)
{
outputws->addColumn("int","DeadWires");
boost::shared_ptr<const Mantid::Geometry::IComponent> comp = localWorkspace->getInstrument()->getComponentByName("holder");
boost::shared_ptr<const Mantid::Geometry::ICompAssembly> bank = boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>(comp);
if (bank)
{
// Get a vector of children (recursively)
std::vector<boost::shared_ptr<const Mantid::Geometry::IComponent> > children;
bank->getChildren(children, true);
std::vector<double> defaultDeadWires;
int ewLine = 0;
for (unsigned int it = 0; it < children.size(); ++it)
{
string wireName = children.at(it)->getName();
std::vector<boost::shared_ptr<const Mantid::Geometry::IComponent> > tyty =
localWorkspace.get()->getInstrument().get()->getAllComponentsWithName(wireName);
std::vector<double> tempWire = tyty[0]->getNumberParameter("excluded");
if(tempWire.size()>0) {
int val = (int)tempWire[0];
g_log.debug() << "_poldi : dead wires :" << val << std::endl;
defaultDeadWires.push_back(val);
for(unsigned int j=0; j<m_channelsPerSpectrum; j++) {
localWorkspace->maskBin(val-1,j,1);
}
ewLine++;
TableRow t = outputws->appendRow();
t << val ;
}
}
g_log.information() << "_poldi : dead wires set to 0 (nb:" << ewLine << ")" << std::endl;
setProperty("nbExcludedWires",ewLine);
} else {
g_log.information() << "_poldi : no dead wire removed" << std::endl;
}
}
示例2: getProperty
/**
Auto detecte the dead wires and store the information in the TableWorkspace.
If asked, the dead wires are removed from the data set.
@param localWorkspace :: input raw data workspace, containing the information about the instrument
@param outputws :: input dead wire liste workspace
*/
void PoldiRemoveDeadWires::autoRemoveDeadWires
(
DataObjects::Workspace2D_sptr &localWorkspace,
API::ITableWorkspace_sptr &outputws
)
{
double autoDeadWiresThreshold = 0;
autoDeadWiresThreshold = getProperty("BadWiresThreshold");
if(!autoDeadWiresThreshold) autoDeadWiresThreshold = m_defautDWThreshold;
autoDeadWiresThreshold = 1.-autoDeadWiresThreshold;
// double autoDeadWiresThreshold = 1-0.4;
g_log.information() << "_poldi : auto removed wires : BadWiresThreshold:" << autoDeadWiresThreshold << std::endl;
int count = 0;
double minValue=INFINITY;
unsigned int minPos = 0;
bool checkContinue = true;
std::vector<double> average(this->m_numberOfSpectra);
double globalAverage = 0;
//compute the average intensity per spectrum
for(unsigned int i=0; i<this->m_numberOfSpectra; i++) {
if(!localWorkspace.get()->hasMaskedBins(i)) {
average.at(i) = 0;
MantidVec& tempY = localWorkspace.get()->dataY(i);
for(unsigned int j=0; j<this->m_channelsPerSpectrum; j++) {
average.at(i) += tempY[j];
}
average.at(i) /= static_cast<double>(this->m_channelsPerSpectrum);
if(average[i]<minValue) {
minValue = average[i];
minPos = i;
}
}
}
g_log.debug() << "_poldi : auto removed wires : average done" << std::endl;
while(checkContinue) {
checkContinue = false;
minValue=INFINITY;
minPos = 0;
int n = 0;
// find the minimum average position, the most probably wrong spectra
for(unsigned int i=0; i<this->m_numberOfSpectra; i++) {
if(!localWorkspace.get()->hasMaskedBins(i)) {
globalAverage += average[i];
n++;
if(average[i]<minValue) {
minValue = average[i];
minPos = i;
}
}
}
globalAverage /=n;
//applied the threshold to determine if a wires should be excluded
//check if the wire is not already excluded
if(!localWorkspace.get()->hasMaskedBins(minPos)) {
if(average[minPos]<globalAverage*autoDeadWiresThreshold) {
//mask the wires
for(unsigned int j=0; j<this->m_channelsPerSpectrum; j++) {
localWorkspace->maskBin(minPos,j,1);
}
count++;
checkContinue = true;
TableRow t = outputws->appendRow();
t << int(minPos) ;
}
}
//applied the threshold to determine if a wires should be excluded
//check if the wire is not already excluded
if(!localWorkspace.get()->hasMaskedBins(minPos)) {
//check the threshold on the left
unsigned int left = minPos-1;
//find the first used wires on the left
while(localWorkspace.get()->hasMaskedBins(left) && left>0) {
left--;
}
if(left>0 && average[minPos]<average[left]*autoDeadWiresThreshold) {
//mask the wires
for(unsigned int j=0; j<this->m_channelsPerSpectrum; j++) {
localWorkspace->maskBin(minPos,j,1);
}
//.........这里部分代码省略.........