Пример #1
0
/*
 * 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();
}
Пример #2
0
/**
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");
  }
}
Пример #3
0
/**
 * Fill m_uiForm.logBox with names of the log values read from one of the input files
 */
void PlotAsymmetryByLogValueDialog::fillLogBox(const QString&)
{
  QString nexusFileName = m_uiForm.firstRunBox->text();
  QFileInfo file(nexusFileName);
  if (!file.exists())
  {
    return;
  }

  m_uiForm.logBox->clear();

  Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmFactory::Instance().create("LoadNexus",-1);
  alg->initialize();
  try
  {
    alg->setPropertyValue("Filename",nexusFileName.toStdString());
    alg->setPropertyValue("OutputWorkspace","PlotAsymmetryByLogValueDialog_tmp");
    alg->setPropertyValue("SpectrumMin","0");
    alg->setPropertyValue("SpectrumMax","0");
    alg->execute();
    if (alg->isExecuted())
    {
      std::string wsName = alg->getPropertyValue("OutputWorkspace");
      Mantid::API::Workspace_sptr ws = Mantid::API::AnalysisDataService::Instance().retrieve(wsName);
      if ( !ws )
      {
        return;
      }
      Mantid::API::MatrixWorkspace_sptr mws = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(ws);
      Mantid::API::WorkspaceGroup_sptr gws = boost::dynamic_pointer_cast<Mantid::API::WorkspaceGroup>(ws);
      if (gws)
      {
        if (gws->getNumberOfEntries() < 2) return;
        mws = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
          Mantid::API::AnalysisDataService::Instance().retrieve(gws->getNames()[1])
        );
      }
      const std::vector< Mantid::Kernel::Property* >& props = mws->run().getLogData();
      if (gws)
      {
        std::vector<std::string> wsNames = gws->getNames();
        for(std::vector<std::string>::iterator it=wsNames.begin();it!=wsNames.end();++it)
        {
          Mantid::API::AnalysisDataService::Instance().remove(*it);
        }
      }
      else
      {
        Mantid::API::AnalysisDataService::Instance().remove("PlotAsymmetryByLogValueDialog_tmp");
      }
      for(size_t i=0;i<props.size();i++)
      {
        m_uiForm.logBox->addItem(QString::fromStdString(props[i]->name()));
      }
      // Display the appropriate value
      QString displayed("");
      if( !isForScript() )
      {
        displayed = MantidQt::API::AlgorithmInputHistory::Instance().previousInput("PlotAsymmetryByLogValue", "LogValue");
      }
      if( !displayed.isEmpty() )
      {
        int index = m_uiForm.logBox->findText(displayed);
        if( index >= 0 )
        {
          m_uiForm.logBox->setCurrentIndex(index);
        }
      }
    }
    
  }
  catch(std::exception& )
  {
  }
}