本文整理汇总了C++中Workspace2D_sptr::setImageYAndE方法的典型用法代码示例。如果您正苦于以下问题:C++ Workspace2D_sptr::setImageYAndE方法的具体用法?C++ Workspace2D_sptr::setImageYAndE怎么用?C++ Workspace2D_sptr::setImageYAndE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workspace2D_sptr
的用法示例。
在下文中一共展示了Workspace2D_sptr::setImageYAndE方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rebinnedY
/**
* Creates and initialises a workspace with instrument definition and fills it
* with data
*
* @param fileInfo information for the current file
*
* @param newFileNumber sequence number for the new file when added
* into ws group
*
* @param buffer pre-allocated buffer to contain data values
* @param imageY Object to set the Y data values in
* @param imageE Object to set the E data values in
*
* @param parent A workspace which can be used to copy initialisation
* information from (size/instrument def etc)
*
* @param loadAsRectImg if true, the new workspace will have one
* spectrum per row and one bin per column, instead of the (default)
* as many spectra as pixels.
*
* @param binSize size to rebin (1 == no re-bin == default)
*
* @param noiseThresh threshold for noise filtering
*
* @returns A newly created Workspace2D, as a shared pointer
*/
Workspace2D_sptr
LoadFITS::makeWorkspace(const FITSInfo &fileInfo, size_t &newFileNumber,
std::vector<char> &buffer, MantidImage &imageY,
MantidImage &imageE, const Workspace2D_sptr parent,
bool loadAsRectImg, int binSize, double noiseThresh) {
// Create workspace (taking into account already here if rebinning is
// going to happen)
Workspace2D_sptr ws;
if (!parent) {
if (!loadAsRectImg) {
size_t finalPixelCount = m_pixelCount / binSize * binSize;
ws = boost::dynamic_pointer_cast<Workspace2D>(
WorkspaceFactory::Instance().create("Workspace2D", finalPixelCount, 2,
1));
} else {
ws = boost::dynamic_pointer_cast<Workspace2D>(
WorkspaceFactory::Instance().create(
"Workspace2D",
fileInfo.axisPixelLengths[1] / binSize, // one bin per column
fileInfo.axisPixelLengths[0] / binSize +
1, // one spectrum per row
fileInfo.axisPixelLengths[0] / binSize));
}
} else {
ws = boost::dynamic_pointer_cast<Workspace2D>(
WorkspaceFactory::Instance().create(parent));
}
// this pixel scale property is used to set the workspace X values
double cm_1 = getProperty("Scale");
// amount of width units (e.g. cm) per pixel
double cmpp = 1; // cm per pixel == bin width
if (0.0 != cm_1)
cmpp /= cm_1;
cmpp *= static_cast<double>(binSize);
if (loadAsRectImg && 1 == binSize) {
// set data directly into workspace
readDataToWorkspace(fileInfo, cmpp, ws, buffer);
} else {
readDataToImgs(fileInfo, imageY, imageE, buffer);
doFilterNoise(noiseThresh, imageY, imageE);
// Note this can change the sizes of the images and the number of pixels
if (1 == binSize) {
ws->setImageYAndE(imageY, imageE, 0, loadAsRectImg, cmpp,
false /* no parallel load */);
} else {
MantidImage rebinnedY(imageY.size() / binSize,
std::vector<double>(imageY[0].size() / binSize));
MantidImage rebinnedE(imageE.size() / binSize,
std::vector<double>(imageE[0].size() / binSize));
doRebin(binSize, imageY, imageE, rebinnedY, rebinnedE);
ws->setImageYAndE(rebinnedY, rebinnedE, 0, loadAsRectImg, cmpp,
false /* no parallel load */);
}
}
try {
ws->setTitle(Poco::Path(fileInfo.filePath).getFileName());
} catch (std::runtime_error &) {
ws->setTitle(padZeros(newFileNumber, g_DIGIT_SIZE_APPEND));
}
++newFileNumber;
addAxesInfoAndLogs(ws, loadAsRectImg, fileInfo, binSize, cmpp);
return ws;
}