void PoldiIndexKnownCompounds::assignCrystalStructureParameters( PoldiPeakCollection_sptr &indexedPeaks, const PoldiPeakCollection_sptr &phasePeaks) const { indexedPeaks->setPointGroup(phasePeaks->pointGroup()); indexedPeaks->setUnitCell(phasePeaks->unitCell()); }
/** * Returns a Poldi2DFunction that encapsulates a PawleyFunction * * This function creates a PawleyFunction using the supplied profile function * name and the crystal system as well as initial cell from the input * properties of the algorithm and wraps it in a Poldi2DFunction. * * The cell is refined using LatticeFunction to get better starting values. * * Because the peak intensities are integral at this step but PawleyFunction * expects peak heights, a profile function is created and * setIntensity/height-methods are used to convert. * * @param profileFunctionName :: Profile function name for PawleyFunction. * @param peakCollection :: Peak collection with peaks to be used in the fit. * @return :: A Poldi2DFunction with a PawleyFunction. */ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionPawley( std::string profileFunctionName, const PoldiPeakCollection_sptr &peakCollection) { auto mdFunction = boost::make_shared<Poldi2DFunction>(); boost::shared_ptr<PoldiSpectrumPawleyFunction> poldiPawleyFunction = boost::dynamic_pointer_cast<PoldiSpectrumPawleyFunction>( FunctionFactory::Instance().createFunction( "PoldiSpectrumPawleyFunction")); if (!poldiPawleyFunction) { throw std::invalid_argument("Could not create pawley function."); } poldiPawleyFunction->setDecoratedFunction("PawleyFunction"); IPawleyFunction_sptr pawleyFunction = poldiPawleyFunction->getPawleyFunction(); pawleyFunction->setProfileFunction(profileFunctionName); // Extract crystal system from peak collection PointGroup_sptr pointGroup = peakCollection->pointGroup(); if (!pointGroup) { throw std::invalid_argument("Can not initialize pawley function properly - " "peaks do not have point group."); } std::string latticeSystem = getLatticeSystemFromPointGroup(pointGroup); pawleyFunction->setLatticeSystem(latticeSystem); UnitCell cell = peakCollection->unitCell(); // Extract unit cell from peak collection pawleyFunction->setUnitCell(getRefinedStartingCell( unitCellToStr(cell), latticeSystem, peakCollection)); IPeakFunction_sptr pFun = boost::dynamic_pointer_cast<IPeakFunction>( FunctionFactory::Instance().createFunction(profileFunctionName)); for (size_t i = 0; i < peakCollection->peakCount(); ++i) { PoldiPeak_sptr peak = peakCollection->peak(i); pFun->setCentre(peak->d()); pFun->setFwhm(peak->fwhm(PoldiPeak::AbsoluteD)); pFun->setIntensity(peak->intensity()); pawleyFunction->addPeak(peak->hkl().asV3D(), peak->fwhm(PoldiPeak::AbsoluteD), pFun->height()); } pawleyFunction->fix(pawleyFunction->parameterIndex("f0.ZeroShift")); mdFunction->addFunction(poldiPawleyFunction); return mdFunction; }
/// Copy crystal data from source to target collection to preserve during /// integration etc. void PoldiFitPeaks2D::assignCrystalData( PoldiPeakCollection_sptr &targetCollection, const PoldiPeakCollection_sptr &sourceCollection) const { targetCollection->setUnitCell(sourceCollection->unitCell()); targetCollection->setPointGroup(sourceCollection->pointGroup()); }