本文整理汇总了C++中dataobjects::Workspace2D_sptr::setX方法的典型用法代码示例。如果您正苦于以下问题:C++ Workspace2D_sptr::setX方法的具体用法?C++ Workspace2D_sptr::setX怎么用?C++ Workspace2D_sptr::setX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataobjects::Workspace2D_sptr
的用法示例。
在下文中一共展示了Workspace2D_sptr::setX方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: final
/**
* Perform a call to nxgetslab, via the NexusClasses wrapped methods for a given
* block-size
* @param data :: The NXDataSet object
* @param blocksize :: The block-size to use
* @param period :: The period number
* @param start :: The index within the file to start reading from (zero based)
* @param hist :: The workspace index to start reading into
* @param spec_num :: The spectrum number that matches the hist variable
* @param local_workspace :: The workspace to fill the data with
*/
void LoadISISNexus2::loadBlock(NXDataSetTyped<int> &data, int64_t blocksize,
int64_t period, int64_t start, int64_t &hist,
int64_t &spec_num,
DataObjects::Workspace2D_sptr &local_workspace) {
data.load(static_cast<int>(blocksize), static_cast<int>(period),
static_cast<int>(start)); // TODO this is just wrong
int *data_start = data();
int *data_end = data_start + m_loadBlockInfo.numberOfChannels;
int64_t final(hist + blocksize);
while (hist < final) {
m_progress->report("Loading data");
MantidVec &Y = local_workspace->dataY(hist);
Y.assign(data_start, data_end);
data_start += m_detBlockInfo.numberOfChannels;
data_end += m_detBlockInfo.numberOfChannels;
MantidVec &E = local_workspace->dataE(hist);
std::transform(Y.begin(), Y.end(), E.begin(), dblSqrt);
// Populate the workspace. Loop starts from 1, hence i-1
local_workspace->setX(hist, m_tof_data);
if (m_load_selected_spectra) {
// local_workspace->getAxis(1)->setValue(hist,
// static_cast<specid_t>(spec_num));
auto spec = local_workspace->getSpectrum(hist);
specid_t specID = m_specInd2specNum_map.at(hist);
// set detectors corresponding to spectra Number
spec->setDetectorIDs(m_spec2det_map.getDetectorIDsForSpectrumNo(specID));
// set correct spectra Number
spec->setSpectrumNo(specID);
}
++hist;
++spec_num;
}
}
示例2: qValues
/** Finalizes the calculation of the correlation spectrum
*
* This method offers a variable way of using the correlation spectrum
*calculated previously.
* The base version converts to Q and creates an appropriate output workspace.
*
* @param correctedCorrelatedIntensities :: Intensities of correlation
*spectrum.
* @param dValues :: d-spacings at which the spectrum was calculated.
* @return A workspace containing the correlation spectrum.
*/
DataObjects::Workspace2D_sptr PoldiAutoCorrelationCore::finalizeCalculation(
const std::vector<double> &correctedCorrelatedIntensities,
const std::vector<double> &dValues) const {
/* Finally, the d-Values are converted to q-Values for plotting etc. and
* inserted into the output workspace. */
size_t dCount = dValues.size();
std::vector<double> qValues(dCount);
PARALLEL_FOR_NO_WSP_CHECK()
for (int i = 0; i < static_cast<int>(dCount); ++i) {
qValues[dCount - i - 1] = Conversions::dToQ(dValues[i]);
}
m_logger.information() << " Setting result..." << std::endl;
DataObjects::Workspace2D_sptr outputWorkspace =
boost::dynamic_pointer_cast<Mantid::DataObjects::Workspace2D>(
WorkspaceFactory::Instance().create("Workspace2D", 1, dValues.size(),
dValues.size()));
outputWorkspace->getAxis(0)->setUnit("MomentumTransfer");
outputWorkspace->dataY(0) = correctedCorrelatedIntensities;
outputWorkspace->setX(0, qValues);
return outputWorkspace;
}
示例3: double
/** Load in a single spectrum taken from a NeXus file
* @param hist :: The workspace index
* @param i :: The spectrum index
* @param specNo :: The spectrum number
* @param nxload :: A reference to the MuonNeXusReader object
* @param lengthIn :: The number of elements in a spectrum
* @param localWorkspace :: A pointer to the workspace in which the data will be
* stored
*/
void LoadMuonNexus1::loadData(size_t hist, specid_t &i, specid_t specNo, MuonNexusReader &nxload,
const int64_t lengthIn,
DataObjects::Workspace2D_sptr localWorkspace) {
// Read in a spectrum
// Put it into a vector, discarding the 1st entry, which is rubbish
// But note that the last (overflow) bin is kept
// For Nexus, not sure if above is the case, hence give all data for now
MantidVec &Y = localWorkspace->dataY(hist);
Y.assign(nxload.counts + i * lengthIn,
nxload.counts + i * lengthIn + lengthIn);
// Create and fill another vector for the errors, containing sqrt(count)
MantidVec &E = localWorkspace->dataE(hist);
typedef double (*uf)(double);
uf dblSqrt = std::sqrt;
std::transform(Y.begin(), Y.end(), E.begin(), dblSqrt);
// Populate the workspace. Loop starts from 1, hence i-1
// Create and fill another vector for the X axis
float *timeChannels = new float[lengthIn+1]();
nxload.getTimeChannels(timeChannels, static_cast<const int>(lengthIn+1));
// Put the read in array into a vector (inside a shared pointer)
boost::shared_ptr<MantidVec> timeChannelsVec(
new MantidVec(timeChannels, timeChannels + lengthIn+1));
localWorkspace->setX(hist, timeChannelsVec);
localWorkspace->getSpectrum(hist)->setSpectrumNo(specNo);
// Clean up
delete[] timeChannels;
}
示例4: loadData
/** Read in a single spectrum from the raw file
* @param tcbs :: The vector containing the time bin boundaries
* @param hist :: The workspace index
* @param i :: The spectrum number
* @param iraw :: A reference to the ISISRAW object
* @param lengthIn :: The number of elements in a spectrum
* @param spectrum :: Pointer to the array into which the spectrum will be read
* @param localWorkspace :: A pointer to the workspace in which the data will be stored
*/
void LoadRaw::loadData(const MantidVecPtr::ptr_type& tcbs, int32_t hist, specid_t& i, ISISRAW& iraw, const int& lengthIn, int* spectrum, DataObjects::Workspace2D_sptr localWorkspace)
{
// Read in a spectrum
memcpy(spectrum, iraw.dat1 + i * lengthIn, lengthIn * sizeof(int));
// Put it into a vector, discarding the 1st entry, which is rubbish
// But note that the last (overflow) bin is kept
MantidVec& Y = localWorkspace->dataY(hist);
Y.assign(spectrum + 1, spectrum + lengthIn);
// Create and fill another vector for the errors, containing sqrt(count)
MantidVec& E = localWorkspace->dataE(hist);
std::transform(Y.begin(), Y.end(), E.begin(), dblSqrt);
// Populate the workspace. Loop starts from 1, hence i-1
localWorkspace->setX(hist, tcbs);
localWorkspace->getAxis(1)->setValue(hist, i);
// NOTE: Raw numbers go straight into the workspace
// - no account taken of bin widths/units etc.
}
示例5: final
/**
* Perform a call to nxgetslab, via the NexusClasses wrapped methods for a given blocksize
* @param data :: The NXDataSet object
* @param blocksize :: The blocksize to use
* @param period :: The period number
* @param start :: The index within the file to start reading from (zero based)
* @param hist :: The workspace index to start reading into
* @param spec_num :: The spectrum number that matches the hist variable
* @param local_workspace :: The workspace to fill the data with
*/
void LoadISISNexus2::loadBlock(NXDataSetTyped<int> & data, int64_t blocksize, int64_t period, int64_t start,
int64_t &hist, int64_t& spec_num,
DataObjects::Workspace2D_sptr local_workspace)
{
data.load(static_cast<int>(blocksize), static_cast<int>(period), static_cast<int>(start)); // TODO this is just wrong
int *data_start = data();
int *data_end = data_start + m_numberOfChannels;
int64_t final(hist + blocksize);
while( hist < final )
{
m_progress->report("Loading data");
MantidVec& Y = local_workspace->dataY(hist);
Y.assign(data_start, data_end);
data_start += m_numberOfChannels; data_end += m_numberOfChannels;
MantidVec& E = local_workspace->dataE(hist);
std::transform(Y.begin(), Y.end(), E.begin(), dblSqrt);
// Populate the workspace. Loop starts from 1, hence i-1
local_workspace->setX(hist, m_tof_data);
local_workspace->getAxis(1)->spectraNo(hist)= static_cast<specid_t>(spec_num);
++hist;
++spec_num;
}
}
示例6: title
//.........这里部分代码省略.........
localWorkspace->setTitle(title);
localWorkspace->getAxis(0)->unit() = UnitFactory::Instance().create("TOF");
// Run parameters
helper->loadRunParameters(localWorkspace, isisRaw.get());
delete helper;
helper = NULL;
// Loop over the number of periods in the raw file, putting each period in a separate workspace
for (int period = 0; period < m_numberOfPeriods; ++period) {
if ( period > 0 )
{
localWorkspace = boost::dynamic_pointer_cast<DataObjects::Workspace2D>
(WorkspaceFactory::Instance().create(localWorkspace));
}
isisRaw->skipData(file,period*(m_numberOfSpectra+1));
int counter = 0;
for (int i = 1; i <= m_numberOfSpectra; ++i)
{
int histToRead = i + period*(m_numberOfSpectra+1);
if ((i >= m_spec_min && i < m_spec_max) ||
(m_list && find(m_spec_list.begin(),m_spec_list.end(),i) != m_spec_list.end()))
{
isisRaw->readData(file,histToRead);
// Copy the data into the workspace vector, discarding the 1st entry, which is rubbish
// But note that the last (overflow) bin is kept
MantidVec& Y = localWorkspace->dataY(counter);
Y.assign(isisRaw->dat1 + 1, isisRaw->dat1 + lengthIn);
// Fill the vector for the errors, containing sqrt(count)
MantidVec& E = localWorkspace->dataE(counter);
std::transform(Y.begin(), Y.end(), E.begin(), dblSqrt);
// Set the X vector pointer and spectrum number
localWorkspace->setX(counter, timeChannelsVec);
localWorkspace->getAxis(1)->setValue(counter, i);
// NOTE: Raw numbers go straight into the workspace
// - no account taken of bin widths/units etc.
++counter;
pr.report();
}
else
{
isisRaw->skipData(file,histToRead);
}
}
// Just a sanity check
assert(counter == total_specs);
std::string outputWorkspace = "OutputWorkspace";
if (period == 0)
{
// Only run the Child Algorithms once
runLoadInstrument(localWorkspace );
runLoadMappingTable(localWorkspace );
runLoadLog(localWorkspace );
const int period_number = period + 1;
Property* log=createPeriodLog(period_number);
if(log)
{
localWorkspace->mutableRun().addLogData(log);
localWorkspace->mutableRun().addLogData(createCurrentPeriodLog(period_number));
}
// Set the total proton charge for this run
// (not sure how this works for multi_period files)
localWorkspace->mutableRun().setProtonCharge(isisRaw->rpb.r_gd_prtn_chrg);