本文整理汇总了C++中api::MatrixWorkspace_const_sptr::hasMaskedBins方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixWorkspace_const_sptr::hasMaskedBins方法的具体用法?C++ MatrixWorkspace_const_sptr::hasMaskedBins怎么用?C++ MatrixWorkspace_const_sptr::hasMaskedBins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::MatrixWorkspace_const_sptr
的用法示例。
在下文中一共展示了MatrixWorkspace_const_sptr::hasMaskedBins方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_masks
/** Checks whether the two input workspaces have the same bin masking.
* Prints a warning if not.
* @param w1 :: The first (sample) input workspace
* @param w2 :: The second (vanadium) input workspace
* @param index :: The workspace index to check
*/
void PointByPointVCorrection::check_masks(
const API::MatrixWorkspace_const_sptr &w1,
const API::MatrixWorkspace_const_sptr &w2, const int &index) const {
static bool warned = false;
if (!warned) {
const bool w1masked = w1->hasMaskedBins(index);
const bool w2masked = w2->hasMaskedBins(index);
if ((w1masked && w2masked &&
(w1->maskedBins(index) != w2->maskedBins(index))) ||
(w1masked && !w2masked) || (!w1masked && w2masked)) {
g_log.warning("The input workspaces do not have matching bin masking");
warned = true;
}
}
}
示例2: writeNexusBinMasking
/**
* Write bin masking information
* @param ws :: The workspace
* @return true for OK, false for error
*/
bool NexusFileIO::writeNexusBinMasking(API::MatrixWorkspace_const_sptr ws) const
{
std::vector< int > spectra;
std::vector< std::size_t > bins;
std::vector< double > weights;
int spectra_count = 0;
int offset = 0;
for(std::size_t i=0;i<ws->getNumberHistograms(); ++i)
{
if (ws->hasMaskedBins(i))
{
const API::MatrixWorkspace::MaskList& mList = ws->maskedBins(i);
spectra.push_back(spectra_count);
spectra.push_back(offset);
API::MatrixWorkspace::MaskList::const_iterator it = mList.begin();
for(;it != mList.end(); ++it)
{
bins.push_back(it->first);
weights.push_back(it->second);
}
++spectra_count;
offset += static_cast<int>(mList.size());
}
}
if (spectra_count == 0) return false;
NXstatus status;
// save spectra offsets as a 2d array of ints
int dimensions[2];
dimensions[0]=spectra_count;
dimensions[1]=2;
status=NXmakedata(fileID, "masked_spectra", NX_INT32, 2, dimensions);
if(status==NX_ERROR) return false;
NXopendata(fileID, "masked_spectra");
const std::string description = "spectra index,offset in masked_bins and mask_weights";
NXputattr(fileID, "description", reinterpret_cast<void*>(const_cast<char*>(description.c_str())), static_cast<int>(description.size()+1), NX_CHAR);
NXputdata(fileID, (void*)&spectra[0]);
NXclosedata(fileID);
// save masked bin indices
dimensions[0]=static_cast<int>(bins.size());
status=NXmakedata(fileID, "masked_bins", NX_INT32, 1, dimensions);
if(status==NX_ERROR) return false;
NXopendata(fileID, "masked_bins");
NXputdata(fileID, (void*)&bins[0]);
NXclosedata(fileID);
// save masked bin weights
dimensions[0]=static_cast<int>(bins.size());
status=NXmakedata(fileID, "mask_weights", NX_FLOAT64, 1, dimensions);
if(status==NX_ERROR) return false;
NXopendata(fileID, "mask_weights");
NXputdata(fileID, (void*)&weights[0]);
NXclosedata(fileID);
return true;
}