Esempio n. 1
0
void PoldiFitPeaks1D::exec() {
  setPeakFunction(getProperty("PeakFunction"));

  // Number of points around the peak center to use for the fit
  m_fwhmMultiples = getProperty("FwhmMultiples");

  // try to construct PoldiPeakCollection from provided TableWorkspace
  TableWorkspace_sptr poldiPeakTable = getProperty("PoldiPeakTable");
  m_peaks = getInitializedPeakCollection(poldiPeakTable);

  g_log.information() << "Peaks to fit: " << m_peaks->peakCount() << '\n';

  Workspace2D_sptr dataWorkspace = getProperty("InputWorkspace");

  auto fitPlotGroup = boost::make_shared<WorkspaceGroup>();

  for (size_t i = 0; i < m_peaks->peakCount(); ++i) {
    PoldiPeak_sptr currentPeak = m_peaks->peak(i);
    IFunction_sptr currentProfile = getPeakProfile(currentPeak);

    IAlgorithm_sptr fit =
        getFitAlgorithm(dataWorkspace, currentPeak, currentProfile);

    bool fitSuccess = fit->execute();

    if (fitSuccess) {
      setValuesFromProfileFunction(currentPeak, fit->getProperty("Function"));

      MatrixWorkspace_sptr fpg = fit->getProperty("OutputWorkspace");
      fitPlotGroup->addWorkspace(fpg);
    }
  }

  setProperty("OutputWorkspace", m_peaks->asTableWorkspace());
  setProperty("FitPlotsWorkspace", fitPlotGroup);
}
Esempio n. 2
0
void PoldiFitPeaks1D2::exec() {
  setPeakFunction(getProperty("PeakFunction"));

  // Number of points around the peak center to use for the fit
  m_fwhmMultiples = getProperty("FwhmMultiples");
  m_maxRelativeFwhm = getProperty("MaximumRelativeFwhm");

  // try to construct PoldiPeakCollection from provided TableWorkspace
  TableWorkspace_sptr poldiPeakTable = getProperty("PoldiPeakTable");
  m_peaks = getInitializedPeakCollection(poldiPeakTable);

  PoldiPeakCollection_sptr fittedPeaksNew = fitPeaks(m_peaks);
  PoldiPeakCollection_sptr fittedPeaksOld = m_peaks;

  int i = 0;
  while (fittedPeaksNew->peakCount() < fittedPeaksOld->peakCount() || i < 1) {
    fittedPeaksOld = fittedPeaksNew;
    fittedPeaksNew = fitPeaks(fittedPeaksOld);
    ++i;
  }

  setProperty("OutputWorkspace", fittedPeaksNew->asTableWorkspace());
  setProperty("FitPlotsWorkspace", m_fitplots);
}