本文整理汇总了C++中mantid::api::MatrixWorkspace_sptr类的典型用法代码示例。如果您正苦于以下问题:C++ MatrixWorkspace_sptr类的具体用法?C++ MatrixWorkspace_sptr怎么用?C++ MatrixWorkspace_sptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MatrixWorkspace_sptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: set2DValues
void set2DValues(Mantid::API::MatrixWorkspace_sptr ws) {
const auto numberOfHistograms = ws->getNumberHistograms();
for (size_t index = 0; index < numberOfHistograms; ++index) {
auto &data = ws->dataY(index);
data = Mantid::MantidVec(data.size(), static_cast<double>(index));
}
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:8,代码来源:NXcanSASTestHelper.cpp
示例2: slicePlotRaw
/**
* Redraw the raw input plot
*/
void IndirectDiagnostics::slicePlotRaw()
{
QString filename = m_uiForm.dsInputFiles->getFirstFilename();
// Only update if we have a different file
if(filename == m_lastDiagFilename)
return;
m_lastDiagFilename = filename;
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updatePreviewPlot()));
disconnect(m_blnManager, SIGNAL(valueChanged(QtProperty*, bool)), this, SLOT(updatePreviewPlot()));
setDefaultInstDetails();
if ( m_uiForm.dsInputFiles->isValid() )
{
QFileInfo fi(filename);
QString wsname = fi.baseName();
int specMin = static_cast<int>(m_dblManager->value(m_properties["SpecMin"]));
int specMax = static_cast<int>(m_dblManager->value(m_properties["SpecMax"]));
if(!loadFile(filename, wsname, specMin, specMax))
{
emit showMessageBox("Unable to load file.\nCheck whether your file exists and matches the selected instrument in the EnergyTransfer tab.");
return;
}
Mantid::API::MatrixWorkspace_sptr input = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
Mantid::API::AnalysisDataService::Instance().retrieve(wsname.toStdString()));
const Mantid::MantidVec & dataX = input->readX(0);
std::pair<double, double> range(dataX.front(), dataX.back());
plotMiniPlot(input, 0, "SlicePlot");
setXAxisToCurve("SlicePlot", "SlicePlot");
setPlotRange("SlicePeak", m_properties["PeakStart"], m_properties["PeakEnd"], range);
setPlotRange("SliceBackground", m_properties["BackgroundStart"], m_properties["BackgroundEnd"], range);
replot("SlicePlot");
}
else
{
emit showMessageBox("Selected input files are invalid.");
}
connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updatePreviewPlot()));
connect(m_blnManager, SIGNAL(valueChanged(QtProperty*, bool)), this, SLOT(updatePreviewPlot()));
updatePreviewPlot();
}
开发者ID:mkoennecke,项目名称:mantid,代码行数:56,代码来源:IndirectDiagnostics.cpp
示例3: setGoniometer
/*
* Set the goniometer values for the workspace
*
* @param workspace :: the workspace to set the goniometer values in
*/
void CreateMD::setGoniometer(Mantid::API::MatrixWorkspace_sptr workspace) {
Algorithm_sptr log_alg = createChildAlgorithm("SetGoniometer");
if (!workspace->run().getProperty("gl")) {
std::ostringstream temp_ss;
temp_ss << "Value of gl in log is: "
<< workspace->run().getPropertyAsSingleValue("gl");
throw std::invalid_argument(temp_ss.str());
}
log_alg->setProperty("Workspace", workspace);
log_alg->setProperty("Axis0", "gl,0,0,1,1");
log_alg->setProperty("Axis1", "gs,1,0,0,1");
log_alg->setProperty("Axis2", "psi,0,1,0,1");
log_alg->executeAsChildAlg();
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:20,代码来源:CreateMD.cpp
示例4: invalid_argument
/*
* Add parameter logs and convert to MD for a single run
*
* @param input_workspace :: datasource workspace
* @param emode :: analysis mode "Elastic", "Direct" or "Indirect"
* @param efix :: datasource energy values in meV
* @param psi :: goniometer rotation in degrees
* @param gl :: goniometer rotation in degrees
* @param gs :: goniometer rotation in degrees
* @param in_place :: do merge step at the same time as converting to
*MDWorkspace
* @param alatt :: length of crystal lattice parameter in angstroms
* @param angdeg :: lattice angle
* @param u :: lattice vector parallel to incident neutron beam
* @param v :: lattice vector perpendicular to u in the horizontal plane
* @param out_mdws :output workspace to use if merge step is carried out
*/
Mantid::API::IMDEventWorkspace_sptr CreateMD::single_run(
Mantid::API::MatrixWorkspace_sptr input_workspace, const std::string &emode,
double efix, double psi, double gl, double gs, bool in_place,
const std::vector<double> &alatt, const std::vector<double> &angdeg,
const std::vector<double> &u, const std::vector<double> &v,
const std::string &filebackend_filename, const bool filebackend,
Mantid::API::IMDEventWorkspace_sptr out_mdws) {
std::vector<std::vector<double>> ub_params{alatt, angdeg, u, v};
if (any_given(ub_params) && !all_given(ub_params)) {
throw std::invalid_argument(
"Either specify all of alatt, angledeg, u, v or none of them");
} else {
if (input_workspace->sample().hasOrientedLattice()) {
g_log.warning() << "Sample already has a UB. This will not be "
"overwritten. Use ClearUB and re-run.\n";
} else {
setUB(input_workspace, alatt[0], alatt[1], alatt[2], angdeg[0], angdeg[1],
angdeg[2], u, v);
}
if (efix > 0.0) {
addSampleLog(input_workspace, "Ei", efix);
}
addSampleLog(input_workspace, "gl", gl);
addSampleLog(input_workspace, "gs", gs);
addSampleLog(input_workspace, "psi", psi);
setGoniometer(input_workspace);
return convertToMD(input_workspace, emode, in_place, filebackend_filename,
filebackend, out_mdws);
}
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:52,代码来源:CreateMD.cpp
示例5: InstrumentDefinitionError
/// calculate distance from source to sample or detector
double ModeratorTzero::CalculateL1(Mantid::API::MatrixWorkspace_sptr inputWS, size_t i){
double L1(0);
// Get detector position
IDetector_const_sptr det;
try
{
det = inputWS->getDetector(i);
}
catch (Exception::NotFoundError&)
{
return 0;
}
if( det->isMonitor() )
{
L1=m_instrument->getSource()->getDistance(*det);
}
else
{
IComponent_const_sptr sample = m_instrument->getSample();
try
{
L1 = m_instrument->getSource()->getDistance(*sample);
}
catch (Exception::NotFoundError &)
{
g_log.error("Unable to calculate source-sample distance");
throw Exception::InstrumentDefinitionError("Unable to calculate source-sample distance", inputWS->getTitle());
}
}
return L1;
}
开发者ID:AlistairMills,项目名称:mantid,代码行数:33,代码来源:ModeratorTzero.cpp
示例6: provideCollimationLength
/**
* Provide the collimation length which is associated with the instrument
* @param workspace: the input workspace
* @returns the collimation length
*/
double SANSCollimationLengthEstimator::provideCollimationLength(
Mantid::API::MatrixWorkspace_sptr workspace) {
// If the instrument does not have a correction specified then set the length
// to 4
const double defaultLColim = 4.0;
auto collimationLengthID = "collimation-length-correction";
if (!workspace->getInstrument()->hasParameter(collimationLengthID)) {
g_log.error("Error in SANSCollimtionLengthEstimator: The instrument "
"parameter file does not contain a collimation length "
"correction,"
"a default of 4 is provided. Please update the instrument "
"parameter file.");
return defaultLColim;
}
// Get the L1 length
const V3D samplePos = workspace->getInstrument()->getSample()->getPos();
const V3D sourcePos = workspace->getInstrument()->getSource()->getPos();
const V3D SSD = samplePos - sourcePos;
const double L1 = SSD.norm();
auto collimationLengthCorrection =
workspace->getInstrument()->getNumberParameter(collimationLengthID);
if (workspace->getInstrument()->hasParameter(
"special-default-collimation-length-method")) {
auto specialCollimationMethod =
workspace->getInstrument()->getStringParameter(
"special-default-collimation-length-method");
if (specialCollimationMethod[0] == "guide") {
try {
return getCollimationLengthWithGuides(workspace, L1,
collimationLengthCorrection[0]);
} catch (std::invalid_argument &ex) {
g_log.notice() << ex.what();
g_log.notice()
<< "SANSCollimationLengthEstimator: Not using any guides";
return L1 - collimationLengthCorrection[0];
}
} else {
throw std::invalid_argument("Error in SANSCollimationLengthEstimator: "
"Unknown special collimation method.");
}
}
return L1 - collimationLengthCorrection[0];
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:52,代码来源:SANSCollimationLengthEstimator.cpp
示例7: addFocusedRun
void EnggDiffMultiRunFittingWidgetPresenter::addFocusedRun(
const Mantid::API::MatrixWorkspace_sptr ws) {
const auto runNumber = ws->getRunNumber();
const auto bankID = guessBankID(ws);
m_model->addFocusedRun(RunLabel(runNumber, bankID), ws);
m_view->updateRunList(m_model->getAllWorkspaceLabels());
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:8,代码来源:EnggDiffMultiRunFittingWidgetPresenter.cpp
示例8: runtime_error
/// Constructor.
/// @param wsName :: Name of a MatrixWorkspace with the data for fitting.
/// @param wsIndex :: Workspace index of a spectrum in wsName to plot.
/// @param outputWSName :: Name of the Fit's output workspace containing at
/// least 3 spectra:
/// #0 - original data (the same as in wsName[wsIndex]), #1 - calculated
/// data, #3 - difference.
/// If empty - ignore this workspace.
DatasetPlotData::DatasetPlotData(const QString &wsName, int wsIndex,
const QString &outputWSName)
: m_dataCurve(new QwtPlotCurve(wsName + QString(" (%1)").arg(wsIndex))),
m_dataErrorCurve(NULL), m_calcCurve(NULL), m_diffCurve(NULL),
m_showDataErrorBars(false) {
// get the data workspace
auto ws = Mantid::API::AnalysisDataService::Instance()
.retrieveWS<Mantid::API::MatrixWorkspace>(wsName.toStdString());
if (!ws) {
QString mess =
QString("Workspace %1 either doesn't exist or isn't a MatrixWorkspace")
.arg(wsName);
throw std::runtime_error(mess.toStdString());
}
// check that the index is in range
if (static_cast<size_t>(wsIndex) >= ws->getNumberHistograms()) {
QString mess = QString("Spectrum %1 doesn't exist in workspace %2")
.arg(wsIndex)
.arg(wsName);
throw std::runtime_error(mess.toStdString());
}
// get the data workspace
Mantid::API::MatrixWorkspace_sptr outputWS;
if (!outputWSName.isEmpty()) {
std::string stdOutputWSName = outputWSName.toStdString();
if (Mantid::API::AnalysisDataService::Instance().doesExist(
stdOutputWSName)) {
try {
outputWS =
Mantid::API::AnalysisDataService::Instance()
.retrieveWS<Mantid::API::MatrixWorkspace>(stdOutputWSName);
} catch (Mantid::Kernel::Exception::NotFoundError &) {
QString mess =
QString(
"Workspace %1 either doesn't exist or isn't a MatrixWorkspace")
.arg(outputWSName);
throw std::runtime_error(mess.toStdString());
}
}
}
// create the curves
setData(ws.get(), wsIndex, outputWS.get());
}
开发者ID:liyulun,项目名称:mantid,代码行数:53,代码来源:MDFDatasetPlotData.cpp
示例9: shiftTimeInLogForTimeSeries
/**
* Shift the time in a time series. This is similar to the implementation in
* @param ws :: a matrix workspace
* @param prop :: a time series log
* @param timeShift :: the time shift in seconds
*/
void ChangeTimeZero::shiftTimeInLogForTimeSeries(
Mantid::API::MatrixWorkspace_sptr ws, Mantid::Kernel::Property *prop,
double timeShift) const {
if (auto timeSeries =
dynamic_cast<Mantid::Kernel::ITimeSeriesProperty *>(prop)) {
auto newlog = timeSeries->cloneWithTimeShift(timeShift);
ws->mutableRun().addProperty(newlog, true);
}
}
开发者ID:DiegoMonserrat,项目名称:mantid,代码行数:15,代码来源:ChangeTimeZero.cpp
示例10: runtime_error
/**
* @brief Gets the X range of the first curve whose data is stored in the query
* workspace.
* @param workspace pointer to query workspace
* @return the range of the first curve associated to the workspace
* @exception std::runtime_error no stored curves are associated to the query
* workspace
*/
QPair<double, double> DisplayCurveFit::getCurveRange(
const Mantid::API::MatrixWorkspace_sptr workspace) {
curveTypes typesFound = this->getCurvesForWorkspace(workspace);
if (typesFound.size() == 0) {
throw std::runtime_error("No fitting curves associated to workspace" +
workspace->name());
}
return getCurveRange(typesFound[0]);
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:17,代码来源:DisplayCurveFit.cpp
示例11: convertFromDistribution
void EnggDiffFittingModel::convertFromDistribution(
Mantid::API::MatrixWorkspace_sptr inputWS) {
const auto name = inputWS->getName();
auto convertFromDistAlg = Mantid::API::AlgorithmManager::Instance().create(
"ConvertFromDistribution");
convertFromDistAlg->initialize();
convertFromDistAlg->setProperty("Workspace", inputWS);
convertFromDistAlg->execute();
}
开发者ID:DanNixon,项目名称:mantid,代码行数:9,代码来源:EnggDiffFittingModel.cpp
示例12: checkInput
/**
* Check the input workspace
* @param inWS: the input workspace
*/
void TOFSANSResolutionByPixel::checkInput(
Mantid::API::MatrixWorkspace_sptr inWS) {
// Make sure that input workspace has an instrument as we rely heavily on
// thisa
auto inst = inWS->getInstrument();
if (inst->getName().empty()) {
throw std::invalid_argument("TOFSANSResolutionByPixel: The input workspace "
"does not contain an instrument");
}
}
开发者ID:DanNixon,项目名称:mantid,代码行数:14,代码来源:TOFSANSResolutionByPixel.cpp
示例13: setXValuesOn1DWorkspaceWithPointData
void setXValuesOn1DWorkspaceWithPointData(
Mantid::API::MatrixWorkspace_sptr workspace, double xmin, double xmax) {
auto &xValues = workspace->dataX(0);
auto size = xValues.size();
double binWidth = (xmax - xmin) / static_cast<double>(size - 1);
for (size_t index = 0; index < size; ++index) {
xValues[index] = xmin;
xmin += binWidth;
}
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:10,代码来源:NXcanSASTestHelper.cpp
示例14: plotAll
void IndirectFitAnalysisTab::plotAll(
Mantid::API::MatrixWorkspace_sptr workspace) {
auto const numberOfDataPoints = workspace->blocksize();
if (numberOfDataPoints > 1)
plotSpectrum(workspace);
else
showMessageBox(
"The plotting of data in one of the result workspaces failed:\n\n "
"Workspace has only one data point");
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:10,代码来源:IndirectFitAnalysisTab.cpp
示例15: handleNewFile
void ISISDiagnostics::handleNewFile() {
if (!m_uiForm.dsInputFiles->isValid())
return;
QString filename = m_uiForm.dsInputFiles->getFirstFilename();
QFileInfo fi(filename);
QString wsname = fi.baseName();
int specMin = static_cast<int>(m_dblManager->value(m_properties["SpecMin"]));
int specMax = static_cast<int>(m_dblManager->value(m_properties["SpecMax"]));
if (!loadFile(filename, wsname, specMin, specMax)) {
emit showMessageBox("Unable to load file.\nCheck whether your file exists "
"and matches the selected instrument in the "
"EnergyTransfer tab.");
return;
}
Mantid::API::MatrixWorkspace_sptr input =
boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
Mantid::API::AnalysisDataService::Instance().retrieve(
wsname.toStdString()));
const Mantid::MantidVec &dataX = input->readX(0);
QPair<double, double> range(dataX.front(), dataX.back());
int previewSpec =
static_cast<int>(m_dblManager->value(m_properties["PreviewSpec"])) -
specMin;
m_uiForm.ppRawPlot->clear();
m_uiForm.ppRawPlot->addSpectrum("Raw", input, previewSpec);
setPlotPropertyRange(m_uiForm.ppRawPlot->getRangeSelector("SlicePeak"),
m_properties["PeakStart"], m_properties["PeakEnd"],
range);
setPlotPropertyRange(m_uiForm.ppRawPlot->getRangeSelector("SliceBackground"),
m_properties["BackgroundStart"],
m_properties["BackgroundEnd"], range);
m_uiForm.ppRawPlot->resizeX();
}
开发者ID:mducle,项目名称:mantid,代码行数:42,代码来源:ISISDiagnostics.cpp
示例16: getEMode
/**
* Gets the energy mode from a workspace based on the X unit.
*
* Units of dSpacing typically denote diffraction, hence Elastic.
* All other units default to spectroscopy, therefore Indirect.
*
* @param ws Pointer to the workspace
* @return Energy mode
*/
std::string IndirectTab::getEMode(Mantid::API::MatrixWorkspace_sptr ws) {
Mantid::Kernel::Unit_sptr xUnit = ws->getAxis(0)->unit();
std::string xUnitName = xUnit->caption();
g_log.debug() << "X unit name is: " << xUnitName << '\n';
if (boost::algorithm::find_first(xUnitName, "d-Spacing"))
return "Elastic";
return "Indirect";
}
开发者ID:mducle,项目名称:mantid,代码行数:20,代码来源:IndirectTab.cpp
示例17: plotSpectrum
void IndirectFitAnalysisTab::plotSpectrum(
Mantid::API::MatrixWorkspace_sptr workspace,
const std::string ¶meterToPlot) {
const auto name = QString::fromStdString(workspace->getName());
const auto labels = IndirectTab::extractAxisLabels(workspace, 1);
for (const auto ¶meter : m_fittingModel->getFitParameterNames()) {
if (boost::contains(parameter, parameterToPlot)) {
auto it = labels.find(parameter);
if (it != labels.end())
IndirectTab::plotSpectrum(name, static_cast<int>(it->second));
}
}
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:13,代码来源:IndirectFitAnalysisTab.cpp
示例18:
/**
Check for a set of synthetic logs associated with multi-period log data. Raise
warnings where necessary.
*/
void
LoadISISNexus2::validateMultiPeriodLogs(Mantid::API::MatrixWorkspace_sptr ws) {
const Run &run = ws->run();
if (!run.hasProperty("current_period")) {
g_log.warning("Workspace has no current_period log.");
}
if (!run.hasProperty("nperiods")) {
g_log.warning("Workspace has no nperiods log");
}
if (!run.hasProperty("proton_charge_by_period")) {
g_log.warning("Workspace has not proton_charge_by_period log");
}
}
开发者ID:stothe2,项目名称:mantid,代码行数:17,代码来源:LoadISISNexus2.cpp
示例19: updateMiniPlots
/**
* Updates the mini plots.
*/
void IndirectSymmetrise::updateMiniPlots() {
if (!m_uiForm.dsInput->isValid())
return;
QString workspaceName = m_uiForm.dsInput->getCurrentDataName();
int spectrumNumber =
static_cast<int>(m_dblManager->value(m_properties["PreviewSpec"]));
Mantid::API::MatrixWorkspace_sptr input =
boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
Mantid::API::AnalysisDataService::Instance().retrieve(
workspaceName.toStdString()));
// Plot the spectrum chosen by the user
size_t spectrumIndex = input->getIndexFromSpectrumNumber(spectrumNumber);
m_uiForm.ppRawPlot->clear();
m_uiForm.ppRawPlot->addSpectrum("Raw", input, spectrumIndex);
// Match X axis range on preview plot
m_uiForm.ppPreviewPlot->setAxisRange(m_uiForm.ppRawPlot->getCurveRange("Raw"),
QwtPlot::xBottom);
m_uiForm.ppPreviewPlot->replot();
}
开发者ID:liyulun,项目名称:mantid,代码行数:26,代码来源:IndirectSymmetrise.cpp
示例20: exec
/** Executes the algorithm
*
*/
void SumNeighbours::exec()
{
// Try and retrieve the optional properties
SumX = getProperty("SumX");
SumY = getProperty("SumY");
// Get the input workspace
Mantid::API::MatrixWorkspace_sptr inWS = getProperty("InputWorkspace");
Mantid::Geometry::IDetector_const_sptr det = inWS->getDetector(0);
// Check if grandparent is rectangular detector
boost::shared_ptr<const Geometry::IComponent> parent = det->getParent()->getParent();
boost::shared_ptr<const RectangularDetector> rect = boost::dynamic_pointer_cast<const RectangularDetector>(parent);
Mantid::API::MatrixWorkspace_sptr outWS;
IAlgorithm_sptr smooth = createChildAlgorithm("SmoothNeighbours");
smooth->setProperty("InputWorkspace", inWS);
if (rect)
{
smooth->setProperty("SumPixelsX",SumX);
smooth->setProperty("SumPixelsY",SumY);
}
else
{
smooth->setProperty<std::string>("RadiusUnits","NumberOfPixels");
smooth->setProperty("Radius",static_cast<double>(SumX*SumY*SumX*SumY));
smooth->setProperty("NumberOfNeighbours",SumX*SumY*SumX*SumY*4);
smooth->setProperty("SumNumberOfNeighbours",SumX*SumY);
}
smooth->executeAsChildAlg();
// Get back the result
outWS = smooth->getProperty("OutputWorkspace");
//Cast to the matrixOutputWS and save it
this->setProperty("OutputWorkspace", outWS);
}
开发者ID:AlistairMills,项目名称:mantid,代码行数:40,代码来源:SumNeighbours.cpp
注:本文中的mantid::api::MatrixWorkspace_sptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论