本文整理汇总了C++中api::MatrixWorkspace_const_sptr::id方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixWorkspace_const_sptr::id方法的具体用法?C++ MatrixWorkspace_const_sptr::id怎么用?C++ MatrixWorkspace_const_sptr::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::MatrixWorkspace_const_sptr
的用法示例。
在下文中一共展示了MatrixWorkspace_const_sptr::id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
/** Write out a MatrixWorkspace's data as a 2D matrix.
* Use writeNexusProcessedDataEvent if writing an EventWorkspace.
*/
int NexusFileIO::writeNexusProcessedData2D( const API::MatrixWorkspace_const_sptr& localworkspace,
const bool& uniformSpectra, const std::vector<int>& spec,
const char * group_name, bool write2Ddata) const
{
NXstatus status;
//write data entry
status=NXmakegroup(fileID,group_name,"NXdata");
if(status==NX_ERROR)
return(2);
NXopengroup(fileID,group_name,"NXdata");
// write workspace data
const size_t nHist=localworkspace->getNumberHistograms();
if(nHist<1)
return(2);
const size_t nSpectBins=localworkspace->readY(0).size();
const size_t nSpect=spec.size();
int dims_array[2] = { static_cast<int>(nSpect),static_cast<int>(nSpectBins) };
// Set the axis labels and values
Mantid::API::Axis *xAxis=localworkspace->getAxis(0);
Mantid::API::Axis *sAxis=localworkspace->getAxis(1);
std::string xLabel,sLabel;
if ( xAxis->isSpectra() ) xLabel = "spectraNumber";
else
{
if ( xAxis->unit() ) xLabel = xAxis->unit()->unitID();
else xLabel = "unknown";
}
if ( sAxis->isSpectra() ) sLabel = "spectraNumber";
else
{
if ( sAxis->unit() ) sLabel = sAxis->unit()->unitID();
else sLabel = "unknown";
}
// Get the values on the vertical axis
std::vector<double> axis2;
if (nSpect < nHist)
for (size_t i=0;i<nSpect;i++)
axis2.push_back((*sAxis)(spec[i]));
else
for (size_t i=0;i<sAxis->length();i++)
axis2.push_back((*sAxis)(i));
int start[2]={0,0};
int asize[2]={1,dims_array[1]};
// -------------- Actually write the 2D data ----------------------------
if (write2Ddata)
{
std::string name="values";
NXcompmakedata(fileID, name.c_str(), NX_FLOAT64, 2, dims_array,m_nexuscompression,asize);
NXopendata(fileID, name.c_str());
for(size_t i=0;i<nSpect;i++)
{
int s = spec[i];
NXputslab(fileID, reinterpret_cast<void*>(const_cast<double*>(&(localworkspace->readY(s)[0]))),start,asize);
start[0]++;
}
if(m_progress != 0) m_progress->reportIncrement(1, "Writing data");
int signal=1;
NXputattr (fileID, "signal", &signal, 1, NX_INT32);
// More properties
const std::string axesNames="axis2,axis1";
NXputattr (fileID, "axes", reinterpret_cast<void*>(const_cast<char*>(axesNames.c_str())), static_cast<int>(axesNames.size()), NX_CHAR);
std::string yUnits=localworkspace->YUnit();
std::string yUnitLabel=localworkspace->YUnitLabel();
NXputattr (fileID, "units", reinterpret_cast<void*>(const_cast<char*>(yUnits.c_str())), static_cast<int>(yUnits.size()), NX_CHAR);
NXputattr (fileID, "unit_label", reinterpret_cast<void*>(const_cast<char*>(yUnitLabel.c_str())), static_cast<int>(yUnitLabel.size()), NX_CHAR);
NXclosedata(fileID);
// error
name="errors";
NXcompmakedata(fileID, name.c_str(), NX_FLOAT64, 2, dims_array,m_nexuscompression,asize);
NXopendata(fileID, name.c_str());
start[0]=0;
for(size_t i=0;i<nSpect;i++)
{
int s = spec[i];
NXputslab(fileID, reinterpret_cast<void*>(const_cast<double*>(&(localworkspace->readE(s)[0]))),start,asize);
start[0]++;
}
if(m_progress != 0) m_progress->reportIncrement(1, "Writing data");
// Fractional area for RebinnedOutput
if (localworkspace->id() == "RebinnedOutput")
{
RebinnedOutput_const_sptr rebin_workspace = boost::dynamic_pointer_cast<const RebinnedOutput>(localworkspace);
name="frac_area";
NXcompmakedata(fileID, name.c_str(), NX_FLOAT64, 2,
dims_array,m_nexuscompression,asize);
NXopendata(fileID, name.c_str());
start[0]=0;
for(size_t i=0;i<nSpect;i++)
{
//.........这里部分代码省略.........