当前位置: 首页>>代码示例>>C++>>正文


C++ IAlgorithm_sptr::initialize方法代码示例

本文整理汇总了C++中IAlgorithm_sptr::initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::initialize方法的具体用法?C++ IAlgorithm_sptr::initialize怎么用?C++ IAlgorithm_sptr::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAlgorithm_sptr的用法示例。


在下文中一共展示了IAlgorithm_sptr::initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/**
 * Loads an empty instrument and returns a pointer to the workspace.
 *
 * Optionally loads an IPF if a reflection was provided.
 *
 * @param instrumentName Name of an inelastic indiretc instrument (IRIS, OSIRIN,
 *TOSCA, VESUVIO)
 * @param reflection Reflection mode to load parameters for (diffspec or
 *diffonly)
 */
MatrixWorkspace_sptr
IndirectDiffractionReduction::loadInstrument(std::string instrumentName,
                                             std::string reflection) {
  std::string idfPath = Mantid::Kernel::ConfigService::Instance().getString(
      "instrumentDefinition.directory");

  std::string parameterFilename = idfPath + instrumentName + "_Definition.xml";
  IAlgorithm_sptr loadAlg =
      AlgorithmManager::Instance().create("LoadEmptyInstrument");
  loadAlg->setChild(true);
  loadAlg->initialize();
  loadAlg->setProperty("Filename", parameterFilename);
  loadAlg->setProperty("OutputWorkspace", "__InDiff_Inst");
  loadAlg->execute();
  MatrixWorkspace_sptr instWorkspace = loadAlg->getProperty("OutputWorkspace");

  // Load parameter file if a reflection was given
  if (!reflection.empty()) {
    std::string ipfFilename = idfPath + instrumentName + "_diffraction_" +
                              reflection + "_Parameters.xml";
    IAlgorithm_sptr loadParamAlg =
        AlgorithmManager::Instance().create("LoadParameterFile");
    loadParamAlg->setChild(true);
    loadParamAlg->initialize();
    loadParamAlg->setProperty("Filename", ipfFilename);
    loadParamAlg->setProperty("Workspace", instWorkspace);
    loadParamAlg->execute();
  }

  return instWorkspace;
}
开发者ID:liyulun,项目名称:mantid,代码行数:41,代码来源:IndirectDiffractionReduction.cpp

示例2: updateContainer

void ApplyPaalmanPings::updateContainer() {
  const auto canName = m_uiForm.dsContainer->getCurrentDataName();
  const auto canValid = m_uiForm.dsContainer->isValid();
  const auto useCan = m_uiForm.ckUseCan->isChecked();
  if (canValid && useCan) {
    auto shift = m_uiForm.spCanShift->value();
    if (!m_uiForm.ckShiftCan->isChecked())
      shift = 0.0;

    auto scale = m_uiForm.spCanScale->value();
    if (!m_uiForm.ckScaleCan->isChecked())
      scale = 1.0;

    IAlgorithm_sptr scaleXAlg = AlgorithmManager::Instance().create("ScaleX");
    scaleXAlg->initialize();
    scaleXAlg->setLogging(false);
    scaleXAlg->setProperty("InputWorkspace", canName.toStdString());
    scaleXAlg->setProperty("OutputWorkspace", m_containerWorkspaceName);
    scaleXAlg->setProperty("Factor", shift);
    scaleXAlg->setProperty("Operation", "Add");
    scaleXAlg->execute();

    IAlgorithm_sptr scaleAlg = AlgorithmManager::Instance().create("Scale");
    scaleAlg->initialize();
    scaleAlg->setLogging(false);
    scaleAlg->setProperty("InputWorkspace", m_containerWorkspaceName);
    scaleAlg->setProperty("OutputWorkspace", m_containerWorkspaceName);
    scaleAlg->setProperty("Factor", scale);
    scaleAlg->setProperty("Operation", "Multiply");
    scaleAlg->execute();

    const auto sampleValid = m_uiForm.dsSample->isValid();
    if (sampleValid) {
      IAlgorithm_sptr rebin =
          AlgorithmManager::Instance().create("RebinToWorkspace");
      rebin->initialize();
      rebin->setLogging(false);
      rebin->setProperty("WorkspaceToRebin", m_containerWorkspaceName);
      rebin->setProperty("WorkspaceToMatch", m_sampleWorkspaceName);
      rebin->setProperty("OutputWorkspace", m_containerWorkspaceName);
      rebin->execute();
    } else {
      // Sample was not valid so do not rebin
      m_uiForm.ppPreview->removeSpectrum("Container");
      return;
    }
  } else {
    // Can was not valid so do not replot
    m_uiForm.ppPreview->removeSpectrum("Container");
    return;
  }
  plotPreview(m_uiForm.spPreviewSpec->value());
}
开发者ID:liyulun,项目名称:mantid,代码行数:53,代码来源:ApplyPaalmanPings.cpp

示例3: saveGenericReductions

/**
 * Handles saving the reductions from the generic algorithm.
 */
void IndirectDiffractionReduction::saveGenericReductions() {
  for (auto it = m_plotWorkspaces.begin(); it != m_plotWorkspaces.end(); ++it) {
    std::string wsName = *it;

    if (m_uiForm.ckGSS->isChecked()) {
      std::string tofWsName = wsName + "_tof";

      // Convert to TOF for GSS
      IAlgorithm_sptr convertUnits =
          AlgorithmManager::Instance().create("ConvertUnits");
      convertUnits->initialize();
      convertUnits->setProperty("InputWorkspace", wsName);
      convertUnits->setProperty("OutputWorkspace", tofWsName);
      convertUnits->setProperty("Target", "TOF");
      m_batchAlgoRunner->addAlgorithm(convertUnits);

      BatchAlgorithmRunner::AlgorithmRuntimeProps inputFromConvUnitsProps;
      inputFromConvUnitsProps["InputWorkspace"] = tofWsName;

      // Save GSS
      std::string gssFilename = wsName + ".gss";
      IAlgorithm_sptr saveGSS = AlgorithmManager::Instance().create("SaveGSS");
      saveGSS->initialize();
      saveGSS->setProperty("Filename", gssFilename);
      m_batchAlgoRunner->addAlgorithm(saveGSS, inputFromConvUnitsProps);
    }

    if (m_uiForm.ckNexus->isChecked()) {
      // Save NEXus using SaveNexusProcessed
      std::string nexusFilename = wsName + ".nxs";
      IAlgorithm_sptr saveNexus =
          AlgorithmManager::Instance().create("SaveNexusProcessed");
      saveNexus->initialize();
      saveNexus->setProperty("InputWorkspace", wsName);
      saveNexus->setProperty("Filename", nexusFilename);
      m_batchAlgoRunner->addAlgorithm(saveNexus);
    }

    if (m_uiForm.ckAscii->isChecked()) {
      // Save ASCII using SaveAscii version 1
      std::string asciiFilename = wsName + ".dat";
      IAlgorithm_sptr saveASCII =
          AlgorithmManager::Instance().create("SaveAscii", 1);
      saveASCII->initialize();
      saveASCII->setProperty("InputWorkspace", wsName);
      saveASCII->setProperty("Filename", asciiFilename);
      m_batchAlgoRunner->addAlgorithm(saveASCII);
    }
  }

  m_batchAlgoRunner->executeBatchAsync();
}
开发者ID:liyulun,项目名称:mantid,代码行数:55,代码来源:IndirectDiffractionReduction.cpp

示例4: createChildAlgorithm

/** Load SPICE data to Matrix workspace
 * @brief ConvertCWSDExpToMomentum::loadSpiceData
 * @param filename
 * @param loaded
 * @param errmsg
 * @return
 */
API::MatrixWorkspace_sptr
ConvertCWSDExpToMomentum::loadSpiceData(const std::string &filename,
                                        bool &loaded, std::string &errmsg) {
  // Init output
  API::MatrixWorkspace_sptr dataws;
  errmsg = "";

  // Load SPICE file
  try {
    IAlgorithm_sptr loader = createChildAlgorithm("LoadSpiceXML2DDet");
    loader->initialize();
    loader->setProperty("Filename", filename);
    std::vector<size_t> sizelist(2);
    sizelist[0] = 256;
    sizelist[1] = 256;
    loader->setProperty("DetectorGeometry", sizelist);
    loader->setProperty("LoadInstrument", true);

    loader->execute();

    dataws = loader->getProperty("OutputWorkspace");
    loaded = static_cast<bool>(dataws);
  } catch (std::runtime_error &runerror) {
    loaded = false;
    errmsg = runerror.what();
  }

  return dataws;
}
开发者ID:liyulun,项目名称:mantid,代码行数:36,代码来源:ConvertCWSDExpToMomentum.cpp

示例5: setupTransferMatrix

/** Set goniometer to matrix workspace and get its rotation matrix R (from
 * Q-sample to Q-lab
 * and output 1/R
 * @brief ConvertCWSDExpToMomentum::setupTransferMatrix
 * @param dataws :: matrix workspace containing sample rotation angles
 * @param rotationMatrix :: output as matrix 1/R to convert from Q-lab to
 * Q-sample
 */
void ConvertCWSDExpToMomentum::setupTransferMatrix(
    API::MatrixWorkspace_sptr dataws, Kernel::DblMatrix &rotationMatrix) {
  // Check sample logs
  if (!dataws->run().hasProperty("_omega") ||
      !dataws->run().hasProperty("_chi") || !dataws->run().hasProperty("_phi"))
    throw std::runtime_error(
        "Data workspace does not have sample log _phi, _chi or _omega. "
        "Unable to set goniometer and calcualte roation matrix R.");

  // Call algorithm SetGoniometer
  IAlgorithm_sptr setalg = createChildAlgorithm("SetGoniometer");
  setalg->initialize();
  setalg->setProperty("Workspace", dataws);
  setalg->setProperty("Axis0", "_omega,0,1,0,-1");
  setalg->setProperty("Axis1", "_chi,0,0,1,-1");
  setalg->setProperty("Axis2", "_phi,0,1,0,-1");
  setalg->execute();

  if (setalg->isExecuted()) {
    rotationMatrix = dataws->run().getGoniometer().getR();
    g_log.debug() << "Ratation matrix: " << rotationMatrix.str() << "\n";
    rotationMatrix.Invert();
    g_log.debug() << "Ratation matrix: " << rotationMatrix.str() << "\n";
  } else
    throw std::runtime_error("Unable to set Goniometer.");

  return;
}
开发者ID:liyulun,项目名称:mantid,代码行数:36,代码来源:ConvertCWSDExpToMomentum.cpp

示例6: execute

    /*
    Executes the underlying algorithm to create the MVP model.
    @param factory : visualisation factory to use.
    @param loadingProgressUpdate : Handler for GUI updates while algorithm progresses.
    @param drawingProgressUpdate : Handler for GUI updates while vtkDataSetFactory::create occurs.
    */
    vtkDataSet* MDEWEventNexusLoadingPresenter::execute(vtkDataSetFactory* factory, ProgressAction& loadingProgressUpdate, ProgressAction& drawingProgressUpdate)
    {
      using namespace Mantid::API;
      using namespace Mantid::Geometry;

      if(this->shouldLoad())
      {
        Poco::NObserver<ProgressAction, Mantid::API::Algorithm::ProgressNotification> observer(loadingProgressUpdate, &ProgressAction::handler);
        AnalysisDataService::Instance().remove("MD_EVENT_WS_ID");

        IAlgorithm_sptr alg = AlgorithmManager::Instance().create("LoadMD");
        alg->initialize();
        alg->setPropertyValue("Filename", this->m_filename);
        alg->setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
        alg->setProperty("FileBackEnd", !this->m_view->getLoadInMemory()); //Load from file by default.
        alg->addObserver(observer);
        alg->execute();
        alg->removeObserver(observer);
      }

      Workspace_sptr result=AnalysisDataService::Instance().retrieve("MD_EVENT_WS_ID");
      Mantid::API::IMDEventWorkspace_sptr eventWs = boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(result);

      factory->setRecursionDepth(this->m_view->getRecursionDepth());
      //Create visualisation in one-shot.
      vtkDataSet* visualDataSet = factory->oneStepCreate(eventWs, drawingProgressUpdate);
      
      /*extractMetaData needs to be re-run here because the first execution of this from ::executeLoadMetadata will not have ensured that all dimensions
        have proper range extents set.
      */
      this->extractMetadata(eventWs);

      this->appendMetadata(visualDataSet, eventWs->getName());
      return visualDataSet;
    }
开发者ID:mkoennecke,项目名称:mantid,代码行数:41,代码来源:MDEWEventNexusLoadingPresenter.cpp

示例7: maskBins

/** Call MaskBins
  * @param dataws :: MatrixWorkspace to mask bins for
  */
void MaskBinsFromTable::maskBins(API::MatrixWorkspace_sptr dataws) {
  bool firstloop = true;
  API::MatrixWorkspace_sptr outputws;

  size_t numcalls = m_xminVec.size();

  g_log.debug() << "There will be " << numcalls << " calls to MaskBins"
                << "\n";
  for (size_t ib = 0; ib < numcalls; ++ib) {
    // Construct algorithm
    IAlgorithm_sptr maskbins =
        this->createChildAlgorithm("MaskBins", 0, 0.3, true);
    maskbins->initialize();

    // Set properties
    g_log.debug() << "Input to MaskBins: SpetraList = '" << m_spectraVec[ib]
                  << "'; Xmin = " << m_xminVec[ib]
                  << ", Xmax = " << m_xmaxVec[ib] << ".\n";

    if (firstloop) {
      maskbins->setProperty("InputWorkspace", dataws);
      firstloop = false;
    } else {
      if (!outputws)
        throw runtime_error("Programming logic error.");
      maskbins->setProperty("InputWorkspace", outputws);
    }
    maskbins->setProperty("OutputWorkspace",
                          this->getPropertyValue("OutputWorkspace"));
    maskbins->setPropertyValue("SpectraList", m_spectraVec[ib]);
    maskbins->setProperty("XMin", m_xminVec[ib]);
    maskbins->setProperty("XMax", m_xmaxVec[ib]);

    bool isexec = maskbins->execute();
    if (!isexec) {
      stringstream errmsg;
      errmsg << "MaskBins() is not executed for row " << ib << "\n";
      g_log.error(errmsg.str());
      throw std::runtime_error(errmsg.str());
    } else {
      g_log.debug("MaskBins() is executed successfully.");
    }

    outputws = maskbins->getProperty("OutputWorkspace");
    if (!outputws) {
      stringstream errmsg;
      errmsg << "OutputWorkspace cannot be obtained from algorithm row " << ib
             << ". ";
      g_log.error(errmsg.str());
      throw std::runtime_error(errmsg.str());
    }
  }

  //
  g_log.debug() << "About to set to output."
                << "\n";
  setProperty("OutputWorkspace", outputws);

  return;
}
开发者ID:liyulun,项目名称:mantid,代码行数:63,代码来源:MaskBinsFromTable.cpp

示例8: createMapFile

  /**
   * This function creates the mapping/grouping file for the data analysis.
   * @param groupType :: Type of grouping (All, Group, Indiviual)
   * @return path to mapping file, or an empty string if file could not be created.
   */
  QString IndirectConvertToEnergy::createMapFile(const QString& groupType)
  {
    QString specRange = m_uiForm.spSpectraMin->text() + "," + m_uiForm.spSpectraMax->text();

    if(groupType == "File")
    {
      QString groupFile = m_uiForm.dsMapFile->getFirstFilename();
      if(groupFile == "")
      {
        emit showMessageBox("You must enter a path to the .map file.");
      }
      return groupFile;
    }
    else if(groupType == "Groups")
    {
      QString groupWS = "__Grouping";

      IAlgorithm_sptr groupingAlg = AlgorithmManager::Instance().create("CreateGroupingWorkspace");
      groupingAlg->initialize();

      groupingAlg->setProperty("FixedGroupCount", m_uiForm.spNumberGroups->value());
      groupingAlg->setProperty("InstrumentName", getInstrumentConfiguration()->getInstrumentName().toStdString());
      groupingAlg->setProperty("ComponentName", getInstrumentConfiguration()->getAnalyserName().toStdString());
      groupingAlg->setProperty("OutputWorkspace", groupWS.toStdString());

      m_batchAlgoRunner->addAlgorithm(groupingAlg);

      return groupWS;
    }
    else
    {
      // Catch All and Individual
      return groupType;
    }
  }
开发者ID:mkoennecke,项目名称:mantid,代码行数:40,代码来源:IndirectConvertToEnergy.cpp

示例9: updatePreviewPlot

/**
 * Runs the moments algorithm with preview properties.
 */
void IndirectMoments::updatePreviewPlot(QString workspaceName)
{
    if(workspaceName.isEmpty())
        workspaceName = m_uiForm.dsInput->getCurrentDataName();

    QString outputName = workspaceName.left(workspaceName.length() - 4);
    double scale = m_uiForm.spScale->value();
    double eMin = m_dblManager->value(m_properties["EMin"]);
    double eMax = m_dblManager->value(m_properties["EMax"]);

    std::string outputWorkspaceName = outputName.toStdString() + "_Moments";

    IAlgorithm_sptr momentsAlg = AlgorithmManager::Instance().create("SofQWMoments");
    momentsAlg->initialize();
    momentsAlg->setProperty("Sample", workspaceName.toStdString());
    momentsAlg->setProperty("EnergyMin", eMin);
    momentsAlg->setProperty("EnergyMax", eMax);
    momentsAlg->setProperty("Plot", false);
    momentsAlg->setProperty("Save", false);
    momentsAlg->setProperty("OutputWorkspace", outputWorkspaceName);

    if(m_uiForm.ckScale->isChecked())
        momentsAlg->setProperty("Scale", scale);

    // Make sure there are no other algorithms in the queue.
    // It seems to be possible to have the selctionChangedLazy signal fire multiple times
    // if the renage selector is moved in a certain way.
    if(m_batchAlgoRunner->queueLength() == 0)
        runAlgorithm(momentsAlg);
}
开发者ID:nimgould,项目名称:mantid,代码行数:33,代码来源:IndirectMoments.cpp

示例10: correctAndGroup

/**
 * Correct loaded data for dead times (if present) and group
 * @param loadedData :: [input] Load result
 * @param grouping :: [input] Grouping to use
 * @returns :: Workspace containing processed data
 */
Workspace_sptr MuonAnalysisDataLoader::correctAndGroup(
    const Muon::LoadResult &loadedData,
    const Mantid::API::Grouping &grouping) const {
  ITableWorkspace_sptr deadTimes;
  try { // to get the dead time correction
    deadTimes = getDeadTimesTable(loadedData);
  } catch (const std::exception &e) {
    // If dead correction wasn't applied we can still continue, though should
    // make user aware of that
    g_log.warning() << "No dead time correction applied: " << e.what() << "\n";
  }

  // Now apply DTC, if used, and grouping
  Workspace_sptr correctedGroupedWS;
  IAlgorithm_sptr alg =
      AlgorithmManager::Instance().createUnmanaged("MuonProcess");
  alg->initialize();
  alg->setProperty("InputWorkspace", loadedData.loadedWorkspace);
  alg->setProperty("Mode", "CorrectAndGroup");
  if (deadTimes) {
    alg->setProperty("ApplyDeadTimeCorrection", true);
    alg->setProperty("DeadTimeTable", deadTimes);
  }
  alg->setProperty("LoadedTimeZero", loadedData.timeZero);
  alg->setProperty("DetectorGroupingTable", grouping.toTable());
  alg->setChild(true);
  alg->setPropertyValue("OutputWorkspace", "__NotUsed");
  alg->execute();
  correctedGroupedWS = alg->getProperty("OutputWorkspace");
  return correctedGroupedWS;
}
开发者ID:DanNixon,项目名称:mantid,代码行数:37,代码来源:MuonAnalysisDataLoader.cpp

示例11: handleFileChange

/**
 * Handles a new file being selected by the browser.
 */
void DensityOfStates::handleFileChange() {
  QString filename = m_uiForm.mwInputFile->getFirstFilename();

  // Check if we have a .phonon file
  QFileInfo fileInfo(filename);
  bool isPhononFile = fileInfo.suffix() == "phonon";

  std::string filePropName("CASTEPFile");
  if (isPhononFile)
    filePropName = "PHONONFile";

  // Need a .phonon file for ion contributions
  if (isPhononFile) {
    // Load the ion table to populate the list of ions
    IAlgorithm_sptr ionTableAlgo =
        AlgorithmManager::Instance().create("SimulatedDensityOfStates");
    ionTableAlgo->initialize();
    ionTableAlgo->setProperty(filePropName, filename.toStdString());
    ionTableAlgo->setProperty("SpectrumType", "IonTable");
    ionTableAlgo->setProperty("OutputWorkspace", "__dos_ions");

    m_batchAlgoRunner->addAlgorithm(ionTableAlgo);

    connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this,
            SLOT(ionLoadComplete(bool)));
    m_batchAlgoRunner->executeBatchAsync();
  } else {
开发者ID:mducle,项目名称:mantid,代码行数:30,代码来源:DensityOfStates.cpp

示例12: writeToScriptFile

void AlgorithmHistoryWindow::writeToScriptFile()
{
  QString prevDir = MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory();
  QString scriptDir("");
  // Default script directory
  if(prevDir.isEmpty())
  {
    scriptDir = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("pythonscripts.directory"));
  }
  else
  {
    scriptDir = prevDir;
  }
  QString filePath = QFileDialog::getSaveFileName(this,tr("Save Script As "),scriptDir,tr("Script files (*.py)"));
  // An empty string indicates they clicked cancel
  if( filePath.isEmpty() ) return;
  
  IAlgorithm_sptr genPyScript = AlgorithmManager::Instance().createUnmanaged("GeneratePythonScript");
  genPyScript->initialize();
  genPyScript->setChild(true); // Use as utility
  genPyScript->setRethrows(true); // Make it throw to catch errors messages and display them in a more obvious place for this window
  genPyScript->setPropertyValue("InputWorkspace",m_wsName.toStdString());
  genPyScript->setPropertyValue("Filename",filePath.toStdString());
  try
  {
    genPyScript->execute();
  }
  catch(std::exception &)
  {
    QMessageBox::information(this, "Generate Python Script", "Unable to generate script, see log window for details.");
  }

  MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory(QFileInfo(filePath).absoluteDir().path());
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例13: exec

/** Run any algorithm with a variable number of parameters
 *
 * @param algorithmName
 * @param count :: number of arguments given.
 * @return the algorithm created
 */
IAlgorithm_sptr FrameworkManagerImpl::exec(const std::string &algorithmName,
                                           int count, ...) {
  if (count % 2 == 1) {
    throw std::runtime_error(
        "Must have an even number of parameter/value string arguments");
  }

  // Create the algorithm
  IAlgorithm_sptr alg =
      AlgorithmManager::Instance().createUnmanaged(algorithmName, -1);
  alg->initialize();
  if (!alg->isInitialized())
    throw std::runtime_error(algorithmName + " was not initialized.");

  va_list Params;
  va_start(Params, count);
  for (int i = 0; i < count; i += 2) {
    std::string paramName = va_arg(Params, const char *);
    std::string paramValue = va_arg(Params, const char *);
    alg->setPropertyValue(paramName, paramValue);
  }
  va_end(Params);

  alg->execute();
  return alg;
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:32,代码来源:FrameworkManager.cpp

示例14: postProcessComplete

/**
* Handles completion of the unit conversion and saving algorithm.
*
* @param error True if algorithm failed.
*/
void ApplyPaalmanPings::postProcessComplete(bool error) {
  disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this,
             SLOT(postProcessComplete(bool)));

  if (error) {
    emit showMessageBox("Unable to process corrected workspace.\nSee Results "
                        "Log for more details.");
    return;
  }

  // Handle preview plot
  plotPreview(m_uiForm.spPreviewSpec->value());

  // Handle Mantid plotting
  QString plotType = m_uiForm.cbPlotOutput->currentText();

  if (plotType == "Spectra" || plotType == "Both")
    plotSpectrum(QString::fromStdString(m_pythonExportWsName));

  if (plotType == "Contour" || plotType == "Both")
    plot2D(QString::fromStdString(m_pythonExportWsName));

  // Clean up unwanted workspaces
  IAlgorithm_sptr deleteAlg =
      AlgorithmManager::Instance().create("DeleteWorkspace");
  deleteAlg->initialize();
  deleteAlg->setProperty("Workspace", "__algorithm_can");
  deleteAlg->execute();
  const auto conv =
      AnalysisDataService::Instance().doesExist("__algorithm_can_Wavelength");
  if (conv) {
    deleteAlg->setProperty("Workspace", "__algorithm_can_Wavelength");
    deleteAlg->execute();
  }
}
开发者ID:liyulun,项目名称:mantid,代码行数:40,代码来源:ApplyPaalmanPings.cpp

示例15: plotContour

  /**
   * Handles the Plot Input button
   *
   * Creates a colour 2D plot of the data
   */
  void IndirectSqw::plotContour()
  {
    if(m_uiForm.dsSampleInput->isValid())
    {
      QString sampleWsName = m_uiForm.dsSampleInput->getCurrentDataName();

      QString convertedWsName = sampleWsName.left(sampleWsName.length() - 4) + "_rqw";

      IAlgorithm_sptr convertSpecAlg = AlgorithmManager::Instance().create("ConvertSpectrumAxis");
      convertSpecAlg->initialize();

      convertSpecAlg->setProperty("InputWorkspace", sampleWsName.toStdString());
      convertSpecAlg->setProperty("OutputWorkspace", convertedWsName.toStdString());
      convertSpecAlg->setProperty("Target", "ElasticQ");
      convertSpecAlg->setProperty("EMode", "Indirect");

      convertSpecAlg->execute();

      QString pyInput = "plot2D('" + convertedWsName + "')\n";
      m_pythonRunner.runPythonCode(pyInput);
    }
    else
    {
      emit showMessageBox("Invalid filename.");
    }
  }
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:31,代码来源:IndirectSqw.cpp


注:本文中的IAlgorithm_sptr::initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。