/// Converts the given tolerance (interpreted as standard deviation of a normal
/// probability distribution) to FWHM and assigns that to all peaks of the
/// supplied collection.
void PoldiIndexKnownCompounds::assignFwhmEstimates(
    const PoldiPeakCollection_sptr &peakCollection, double tolerance) const {
    if (!peakCollection) {
        throw std::invalid_argument(
            "Cannot assign intensities to invalid PoldiPeakCollection.");
    }

    size_t peakCount = peakCollection->peakCount();
    double fwhm = sigmaToFwhm(tolerance);

    for (size_t i = 0; i < peakCount; ++i) {
        PoldiPeak_sptr peak = peakCollection->peak(i);
        peak->setFwhm(UncertainValue(fwhm), PoldiPeak::Relative);
    }
}
void PoldiFitPeaks1D2::setValuesFromProfileFunction(
    PoldiPeak_sptr poldiPeak, const IFunction_sptr &fittedFunction) const {
  IPeakFunction_sptr peakFunction =
      boost::dynamic_pointer_cast<IPeakFunction>(fittedFunction);

  if (peakFunction) {
    poldiPeak->setIntensity(
        UncertainValue(peakFunction->height(), peakFunction->getError(0)));
    poldiPeak->setQ(
        UncertainValue(peakFunction->centre(), peakFunction->getError(1)));
    poldiPeak->setFwhm(UncertainValue(peakFunction->fwhm(),
                                      getFwhmWidthRelation(peakFunction) *
                                          peakFunction->getError(2)));
  }
}
Exemple #3
0
/** Creates PoldiPeak-objects from peak position iterators
  *
  * In this method, PoldiPeak objects are created from the raw peak position data and the original x-data. Estimates for peak height and FWHM
  * provided along with the position.
  *
  * @param baseListStart :: Starting iterator of the vector which the peak positions refer to.
  * @param peakPositions :: List with peakPositions.
  * @param xData :: Vector with x-values of the correlation spectrum.
  * @return Vector with PoldiPeak objects constructed from the raw peak position data.
  */
std::vector<PoldiPeak_sptr> PoldiPeakSearch::getPeaks(MantidVec::const_iterator baseListStart, std::list<MantidVec::const_iterator> peakPositions, const MantidVec &xData) const
{
    std::vector<PoldiPeak_sptr> peakData;
    peakData.reserve(peakPositions.size());

    for(std::list<MantidVec::const_iterator>::const_iterator peak = peakPositions.begin();
        peak != peakPositions.end();
        ++peak)
    {
        size_t index = std::distance(baseListStart, *peak);

        PoldiPeak_sptr newPeak = PoldiPeak::create(UncertainValue(xData[index]), UncertainValue(**peak));
        double fwhmEstimate = getFWHMEstimate(baseListStart, *peak, xData);
        newPeak->setFwhm(UncertainValue(fwhmEstimate));
        peakData.push_back(newPeak);
    }

    return peakData;
}
Exemple #4
0
/// Creates a PoldiPeak from the given profile function/hkl pair.
PoldiPeak_sptr
PoldiFitPeaks2D::getPeakFromPeakFunction(IPeakFunction_sptr profileFunction,
                                         const V3D &hkl) {

  // Use EstimatePeakErrors to calculate errors of FWHM and so on
  IAlgorithm_sptr errorAlg = createChildAlgorithm("EstimatePeakErrors");
  errorAlg->setProperty(
      "Function", boost::dynamic_pointer_cast<IFunction>(profileFunction));
  errorAlg->setPropertyValue("OutputWorkspace", "Errors");
  errorAlg->execute();

  double centre = profileFunction->centre();
  double fwhmValue = profileFunction->fwhm();

  ITableWorkspace_sptr errorTable = errorAlg->getProperty("OutputWorkspace");
  double centreError = errorTable->cell<double>(0, 2);
  double fwhmError = errorTable->cell<double>(2, 2);

  UncertainValue d(centre, centreError);
  UncertainValue fwhm(fwhmValue, fwhmError);

  UncertainValue intensity;

  bool useIntegratedIntensities = getProperty("OutputIntegratedIntensities");
  if (useIntegratedIntensities) {
    double integratedIntensity = profileFunction->intensity();
    double integratedIntensityError = errorTable->cell<double>(3, 2);
    intensity = UncertainValue(integratedIntensity, integratedIntensityError);
  } else {
    double height = profileFunction->height();
    double heightError = errorTable->cell<double>(1, 2);
    intensity = UncertainValue(height, heightError);
  }

  // Create peak with extracted parameters and supplied hkl
  PoldiPeak_sptr peak =
      PoldiPeak::create(MillerIndices(hkl), d, intensity, UncertainValue(1.0));
  peak->setFwhm(fwhm, PoldiPeak::FwhmRelation::AbsoluteD);

  return peak;
}