diffpy.srreal package

Submodules

diffpy.srreal.atomradiitable module

class AtomRadiiTable – storage of empirical atom radii.

class diffpy.srreal.atomradiitable.AtomRadiiTable

Bases: Boost.Python.instance

Base class for looking up empirical atom radii. This class has virtual methods and cannot be used as is.

A derived class has to overload the following methods:

create(self) clone(self) type(self) _standardLookup(self, smbl)

Derived class can be added to the global registry of AtomRadiiTable types by calling the _registerThisType method with any instance.

clone((AtomRadiiTable)arg1) → AtomRadiiTable :

Return a new instance that is a copy of self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::AtomRadiiTable> clone(diffpy::srreal::AtomRadiiTable {lvalue})
create((AtomRadiiTable)arg1) → AtomRadiiTable :

Return a new instance of the same type as self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::AtomRadiiTable> create(diffpy::srreal::AtomRadiiTable {lvalue})
static createByType((str)tp) → AtomRadiiTable :

Return a new AtomRadiiTable instance of the specified string type.

Parameters:
  • tp (str) – string type identifying a registered AtomRadiiTable class.
  • a new instance of the AtomRadiiTable-derived class. (Returns) –

See also

getRegisteredTypes()
Return set of the recognized type strings.
getAliasedTypes()
Return dictionary of string aliases.
C++ signature :
boost::shared_ptr<diffpy::srreal::AtomRadiiTable> createByType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
fromString((AtomRadiiTable)arg1, (str)arg2) → None :

Define custom radius for one or more atom types from string.

s – string with custom atom radii in ‘A1:r1, A2:r2, …’ format.

No return value. Raise ValueError for an invalid string format.

C++ signature :
void fromString(diffpy::srreal::AtomRadiiTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
static getAliasedTypes() → object :

Get all aliases registered for the AtomRadiiTable string types.

Returns:a map of registered aliases to their corresponding standard names.
Return type:dict
C++ signature :
boost::python::api::object getAliasedTypes()
getAllCustom((AtomRadiiTable)arg1) → object :

Return a dictionary of all custom atom radii defined in this table.

C++ signature :
boost::python::api::object getAllCustom(diffpy::srreal::AtomRadiiTable)
static getRegisteredTypes() → object :

Return a set of string types of the registered AtomRadiiTable classes.

These are the allowed arguments for the createByType factory.

C++ signature :
boost::python::api::object getRegisteredTypes()
static isRegisteredType((str)tp) → bool :

Check if the given string is registered as a AtomRadiiTable type.

Parameters:
  • tp (str) – string name or an alias to be checked.
  • True if tp is known to the registry either as (Return) –
  • standard type or its alias. (a) –
C++ signature :
bool isRegisteredType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
lookup((AtomRadiiTable)arg1, (str)smbl) → float :

Return empirical radius of an atom in Angstroms.

smbl – string symbol for atom, ion or isotope

Return atom radius in Angstroms. This method cannot be overloaded in Python.

C++ signature :
double lookup(diffpy::srreal::AtomRadiiTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
resetAll((AtomRadiiTable)arg1) → None :

Reset all custom radii defined in this table.

C++ signature :
void resetAll(diffpy::srreal::AtomRadiiTable {lvalue})
resetCustom((AtomRadiiTable)arg1, (str)smbl) → None :

Remove custom radius for the specified atom type.

smbl – string symbol for atom, ion or isotope

No return value.

C++ signature :
void resetCustom(diffpy::srreal::AtomRadiiTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
setCustom((AtomRadiiTable)arg1, (str)smbl, (float)radius) → None :

Define custom radius for a specified atom type.

smbl – string symbol for atom, ion or isotope radius – custom radius that will be returned by the lookup method

No return value.

C++ signature :
void setCustom(diffpy::srreal::AtomRadiiTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,double)
toString((AtomRadiiTable)arg1[, (str)separator=’, ]) → str :

Return string of all custom atom radii in ‘A1:r1, A2:r2, …’ format.

separator – string separator between ‘A1:r1’ entries, by default ‘,’

Return string.

C++ signature :
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > toString(diffpy::srreal::AtomRadiiTable {lvalue} [,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >=’,’])
type((AtomRadiiTable)arg1) → str :

Return a unique string type that identifies a AtomRadiiTable-derived class. The string type is used for class registration and in the createByType function.

This method must be overloaded in a derived class.

C++ signature :
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > type(diffpy::srreal::AtomRadiiTable {lvalue})
class diffpy.srreal.atomradiitable.ConstantRadiiTable

Bases: diffpy.srreal.srreal_ext.AtomRadiiTable

Atom radii table with the same radius for all atoms, by default 0.

See setDefault() for changing the default radius or setCustom() and fromString() for setting a special radius for selected atoms.

clone((ConstantRadiiTable)arg1) → AtomRadiiTable :

Return a duplicate of this ConstantRadiiTable object

C++ signature :
boost::shared_ptr<diffpy::srreal::AtomRadiiTable> clone(diffpy::srreal::ConstantRadiiTable {lvalue})
create((ConstantRadiiTable)arg1) → AtomRadiiTable :

Return a new instance of ConstantRadiiTable.

C++ signature :
boost::shared_ptr<diffpy::srreal::AtomRadiiTable> create(diffpy::srreal::ConstantRadiiTable {lvalue})
getDefault((ConstantRadiiTable)arg1) → float :

Return the value of the default atom radius.

C++ signature :
double getDefault(diffpy::srreal::ConstantRadiiTable {lvalue})
setDefault((ConstantRadiiTable)arg1, (float)radius) → None :

Set radius that is by default returned for all atoms.

C++ signature :
void setDefault(diffpy::srreal::ConstantRadiiTable {lvalue},double)
class diffpy.srreal.atomradiitable.CovalentRadiiTable

Bases: diffpy.srreal.srreal_ext.AtomRadiiTable

Covalent radii from Cordero et al., 2008, doi:10.1039/b801115j. Instantiation of this class requires the periodictable module.

clone()

Return a new duplicate instance of self.

create()

Create new instance of the CovalentRadiiTable.

type()

Unique string identifier of the CovalentRadiiTable type. This is used for class registration and as an argument for the createByType function.

Return string.

diffpy.srreal.attributes module

class Attributes – wrapper to C++ class diffpy::Attributes A base to PairQuantity and quite a few other classes.

class diffpy.srreal.attributes.Attributes

Bases: Boost.Python.instance

This class manages named C++ double attributes owned by an instance. The derived objects own double attributes that can be looked up from C++ by name, without having to know a full C++ interface of their classes.

diffpy.srreal.bondcalculator module

class BondCalculator – distances between atoms in the structure.

class diffpy.srreal.bondcalculator.BondCalculator(**kwargs)

Bases: diffpy.srreal.srreal_ext.BasePairQuantity

Calculator of bond distances in a specified structure.

directions

List of bond directions in the evaluated structure.

distances

Array of sorted bond distances in the evaluated structure.

filterCone((BondCalculator)arg1, (object)cartesiandir, (float)degrees) → None :

Setup an additive bond filter in a specified direction cone. Second and further calls create more filters that permit more bonds. Use filterOff to create exclusive filter in a new direction.

cartesiandir – cone axis in Cartesian coordinates,
list, tuple or array.

degrees – cone angle in degrees

No return value.

C++ signature :
void filterCone(diffpy::srreal::BondCalculator {lvalue},boost::python::api::object,double)
filterOff((BondCalculator)arg1) → None :

Turn off bond filtering and destroy all cone filters. Permit all bonds in further calculations. Also used to create exclusive cone filter in a new direction.

C++ signature :
void filterOff(diffpy::srreal::BondCalculator {lvalue})
rmax

Upper bound for the bond distances. [5 A]

rmin

Lower bound for the bond distances. [0 A]

sites0

List of zero-based indices of the first site in the pair.

sites1

List of zero-based indices of the second site in the pair.

types0

List of atom symbols for the first site in all pairs.

types1

List of atom symbols for the second site in all pairs.

diffpy.srreal.bvparameterstable module

class BVParametersTable – storage of bond valence parameters class BVParam – bond valence data associated with specific cation-anion pair

class diffpy.srreal.bvparameterstable.BVParam

Bases: Boost.Python.instance

Storage of bond valence parameters for a given cation-anion pair.

B

Bond valence parameter B in Angstroms.

Ro

Bond valence parameter Ro in Angstroms.

atom0

Bare symbol of the cation atom without charge specification.

atom1

Bare symbol of the anion atom without charge specification.

bondvalence((BVParam)arg1, (float)distance) → float :

Bond valence of the specified distance in Angstroms.

C++ signature :
double bondvalence(diffpy::srreal::BVParam {lvalue},double)
bondvalenceToDistance((BVParam)arg1, (float)valence) → float :

Distance in Angstroms corresponding to specified bond valence.

C++ signature :
double bondvalenceToDistance(diffpy::srreal::BVParam {lvalue},double)
ref_id

code of the reference paper in bvparm2011.cif.

setFromCifLine((BVParam)arg1, (str)arg2) → None :

Update bond valence data from a string formatted as in bvparm2011.cif.

C++ signature :
void setFromCifLine(diffpy::srreal::BVParam {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
valence0

Positive integer valence of the cation.

valence1

Negative integer valence of the anion.

class diffpy.srreal.bvparameterstable.BVParametersTable

Bases: Boost.Python.instance

Lookup table for bond valence parameters of a cation-anion pairs.

getAll((BVParametersTable)arg1) → object :

Return all bond valence parameter values in this table.

Return a set of BVParam objects.

C++ signature :
boost::python::api::object getAll(diffpy::srreal::BVParametersTable)
getAtomValence((BVParametersTable)arg1, (str)smbl) → int :

Return signed valence for the specified atom or ion symbol.

Return valence previously defined by setAtomValence or interpret the charge suffix, for example, use -2 for “S2-“.

C++ signature :
int getAtomValence(diffpy::srreal::BVParametersTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
lookup((BVParametersTable)arg1, (BVParam)bvparam) → BVParam :

Lookup bond valence parameters by a BVParam instance.

bvparam – BVParam object. The only attributes considered for
lookup are atom0, valence0, atom1, valence1.

Return a BVParam object with the looked up data. Return BVParametersTable.none() if bond valence data do not exist.

C++ signature :
diffpy::srreal::BVParam lookup(diffpy::srreal::BVParametersTable {lvalue},diffpy::srreal::BVParam)
lookup( (BVParametersTable)arg1, (str)smbl0, (str)smbl1) -> BVParam :

Lookup bond valence parameters by cation-anion pair. The cation-anion order may be flipped.

smbl0 – symbol of the first ion with charge, e.g., “Na+” smbl1 – symbol of the second ion with charge, e.g., “O2-“

Return a BVParam object with the looked up data. Return BVParametersTable.none() if bond valence data do not exist.

C++ signature :
diffpy::srreal::BVParam lookup(diffpy::srreal::BVParametersTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
lookup( (BVParametersTable)arg1, (str)atom0, (int)valence0, (str)atom1, (int)valence1) -> BVParam :

Lookup bond valence parameters by cation-anion pair. The cation-anion order may be flipped.

atom0 – bare symbol of the cation atom valence0 – positive integer cation valence atom1 – bare symbol of the anion atom valence1 – negative integer anion valence

Return a BVParam object with the looked up data. Return BVParametersTable.none() if bond valence data do not exist.

C++ signature :
diffpy::srreal::BVParam lookup(diffpy::srreal::BVParametersTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,int,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,int)
static none() → object :

Singleton instance of void bond valence parameters. Also returned by ‘lookup’ when valence data do not exist.

C++ signature :
boost::python::api::object none()
resetAll((BVParametersTable)arg1) → None :

Remove all custom bond valence data defined in this table.

C++ signature :
void resetAll(diffpy::srreal::BVParametersTable {lvalue})
resetAtomValences((BVParametersTable)arg1) → None :

Unset any custom valences defined by setAtomValence.

Valences are thereafter obtained from charge suffixes only.

C++ signature :
void resetAtomValences(diffpy::srreal::BVParametersTable {lvalue})
resetCustom((BVParametersTable)arg1, (BVParam)arg2) → None :

Remove custom bond valence data for the specified cation-anion pair.

bvparam – BVParam object. The only attributes considered for
custom entry lookup are atom0, valence0, atom1, valence1.

No return value.

C++ signature :
void resetCustom(diffpy::srreal::BVParametersTable {lvalue},diffpy::srreal::BVParam)
resetCustom( (BVParametersTable)arg1, (str)atom0, (int)valence0, (str)atom1, (int)valence1) -> None :

Remove custom bond valence data for the specified cation-anion pair. The cation-anion order may be flipped.

atom0 – bare symbol of the cation atom valence0 – positive integer cation valence atom1 – bare symbol of the anion atom valence1 – negative integer anion valence

No return value.

C++ signature :
void resetCustom(diffpy::srreal::BVParametersTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,int,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,int)
setAtomValence((BVParametersTable)arg1, (str)smbl, (int)value) → None :

Define custom valence for the specified atom or ion symbol.

smbl – string symbol of atom or ion, for example “F”. value – signed valence to be used for the symbol, e.g., -1.

No return value.

C++ signature :
void setAtomValence(diffpy::srreal::BVParametersTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,int)
setCustom((BVParametersTable)arg1, (BVParam)bvparm) → None :

Insert custom bond valence data to the table.

bvparam – BVParam object with the custom bond valence data.

No return value.

C++ signature :
void setCustom(diffpy::srreal::BVParametersTable {lvalue},diffpy::srreal::BVParam)
setCustom( (BVParametersTable)arg1, (str)atom0, (int)valence0, (str)atom1, (int)valence1, (float)Ro, (float)B [, (str)ref_id=”]) -> None :

Insert custom bond valence data to the table.

atom0 – bare symbol of the cation atom valence0 – positive integer cation valence atom1 – bare symbol of the anion atom valence1 – negative integer anion valence Ro – valence parameter Ro in Angstroms B – valence parameter B in Angstroms ref_id – optional reference code in bvparm2011.cif

No return value.

C++ signature :
void setCustom(diffpy::srreal::BVParametersTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,int,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,int,double,double [,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >=”])

diffpy.srreal.bvscalculator module

class BVSCalculator – bond valence sums calculator

class diffpy.srreal.bvscalculator.BVSCalculator(**kwargs)

Bases: diffpy.srreal.srreal_ext.BasePairQuantity

Calculator of bond valence sums in the specified structure.

bvdiff

Difference between expected and calculated valence magnitudes at each site. Positive for underbonding, negative for overbonding.

bvmsdiff

Mean square difference between expected and calculated valences. Adjusted for multiplicity and occupancy of atom sites in the structure.

bvparamtable

BVParametersTable object used for bond valence parameters lookup.

bvrmsdiff

Root mean square difference between expected and calculated valences. Adjusted for multiplicity and occupancy of atom sites in the structure.

rmax

Upper bound for the summed bond lengths. The calculation is actually cut off much earlier when valence contributions get below valenceprecission. See also rmaxused and valenceprecission. [1e6 A]

rmaxused

Effective bound for bond lengths, where valence contributions become smaller than valenceprecission, read-only. Always smaller or equal to rmax. The value depends on ions present in the structure.

rmin

Lower bound for the summed bond lengths. [0 A]

valenceprecision

Cutoff value for valence contributions at long distances. [1e-5]

valences

Return valences expected at each site of the evaluated structure.

value

Return bond valence sums per each atom site in the structure.

diffpy.srreal.eventticker module

class EventTicker – storage of modification times of dependent objects

class diffpy.srreal.eventticker.EventTicker

Bases: Boost.Python.instance

Class for storing modification ‘times’ of dependent objects The default EventTicker object is initialized to a zero time.

click((EventTicker)arg1) → None :

Increment ticker value to the latest unique time.

C++ signature :
void click(diffpy::eventticker::EventTicker {lvalue})
updateFrom((EventTicker)arg1, (EventTicker)other) → None :

Update ticker time to the value of other, newer ticker. Keep original value if the other ticker is older.

other – instance of another EventTicker object

No return value.

C++ signature :
void updateFrom(diffpy::eventticker::EventTicker {lvalue},diffpy::eventticker::EventTicker)

diffpy.srreal.overlapcalculator module

class OverlapCalculator – calculator of atom overlaps in a structure.

class diffpy.srreal.overlapcalculator.OverlapCalculator(**kwargs)

Bases: diffpy.srreal.srreal_ext.BasePairQuantity

Calculate the overlap of atom radii and coordination numbers at each site.

atomradiitable

AtomRadiiTable object used for radius lookup.

coordinationByTypes((OverlapCalculator)arg1, (int)i) → object :

Evaluate neighbor types and their occupancies at the specified site.

i – zero-based index of the evaluated site

Return a dictionary where the keys are atom type strings and the values their total occupancies.

C++ signature :
boost::python::api::object coordinationByTypes(diffpy::srreal::OverlapCalculator,int)
coordinations

Return coordination numbers per each site in the structure. These may be non-integer if there are sites with partial occupancies.

directions

Directions from the first to the second atom in the overlapping pairs. Returns an Nx3 array.

distances

Distances of all overlapping atom pairs in the structure.

flipDiffMean((OverlapCalculator)arg1, (object)arg2, (object)arg3) → float :

Calculate change of the meansquareoverlap after flipping the atom types at the i and j sites.

i – zero-based index of the first site j – zero-based index of the second site

Return float.

C++ signature :
double flipDiffMean(diffpy::srreal::OverlapCalculator,boost::python::api::object,boost::python::api::object)
flipDiffTotal((OverlapCalculator)arg1, (object)i, (object)j) → float :

Calculate change of the totalsquareoverlap after flipping the atom types at the i and j sites.

i – zero-based index of the first site j – zero-based index of the second site

Return float.

C++ signature :
double flipDiffTotal(diffpy::srreal::OverlapCalculator,boost::python::api::object,boost::python::api::object)
getNeighborSites((OverlapCalculator)arg1, (object)i) → object :

Get indices of all sites that neighbor with the specified site, either directly or as periodic or symmetry images. Atoms are assumed neighbors if they have non-zero overlap.

i – zero-based index of the evaluated site

Return a set of integer indices, this may include i.

C++ signature :
boost::python::api::object getNeighborSites(diffpy::srreal::OverlapCalculator,boost::python::api::object)
gradients

Gradients of the totalsquareoverlap per each site in the structure. Returns an Nx3 array.

meansquareoverlap

Total square overlap per one atom in the structure.

neighborhoods

Return all sets of connected site indices in the structure. Sites are assumed in the same neighborhood if they have overlapping neighbors or can be connected through neighbor links. There are no overlapping pairs between sites from different neighborhoods.

Return a list of site indices sets.

overlaps

Magnitudes of all non-zero atom radii overlaps in the structure.

rmax

Upper bound for the bond distances. [5 A]

rmaxused

Effective upper bound for the bond distances. rmaxused equals either a double of the maximum atom radius in the structure or rmax.

rmin

Lower bound for the bond distances. [0 A]

sites0

Indices of all first sites of the overlapping pairs.

sites1

Indices of all second sites of the overlapping pairs.

sitesquareoverlaps

Sum of squared overlaps per each site in the structure.

totalsquareoverlap

Total sum of squared overlaps in the structure adjusted for site multiplicities and occupancies.

types0

List of atom symbols of all first sites of the overlapping pairs.

types1

List of atom symbols of all second sites of the overlapping pairs.

diffpy.srreal.pairquantity module

class PairQuantity – base class for Python defined calculators.

class diffpy.srreal.pairquantity.PairQuantity

Bases: diffpy.srreal.srreal_ext.BasePairQuantity

Base class for Python defined pair quantity calculators. No action by default. Concrete calculators must override the _addPairContribution method to get some results.

ticker((PairQuantity)arg1) → EventTicker :

Return EventTicker object with the last configuration change time.

The ticker should be clicked on every configuration change that requires reevaluation of the PairQuantity even for an unchanged structure.

This method can be overridden in the derived class.

C++ signature :
diffpy::eventticker::EventTicker {lvalue} ticker(srrealmodule::nswrap_PairQuantity::PairQuantityExposed {lvalue})

ticker( (PairQuantity)arg1) -> EventTicker :

C++ signature :
diffpy::eventticker::EventTicker {lvalue} ticker(srrealmodule::nswrap_PairQuantity::PairQuantityWrap {lvalue})

diffpy.srreal.parallel module

ParallelPairQuantity – proxy class for converting PairQuantity types into parallel calculators.

diffpy.srreal.parallel.createParallelCalculator(pqobj, ncpu, pmap)

Create a proxy parallel calculator to a PairQuantity instance.

pqobj – instance of PairQuantity calculator to be run in parallel ncpu – number of parallel jobs pmap – a parallel map function used to submit job to workers

The pqobj.evaluatortype is reset to ‘BASIC’ because other evaluator types are not supported within parallel calculations.

Return a proxy calculator instance that has the same interface, but executes the calculation in parallel split among ncpu jobs.

diffpy.srreal.pdfbaseline module

Classes for configuring PDF baseline: PDFBaseline, ZeroBaseline, LinearBaseline

class diffpy.srreal.pdfbaseline.PDFBaseline

Bases: diffpy.srreal.srreal_ext.Attributes

Base class and registry for functions that calculate PDF baseline.

clone((PDFBaseline)arg1) → PDFBaseline :

Return a new instance that is a copy of self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::PDFBaseline> clone(diffpy::srreal::PDFBaseline {lvalue})
create((PDFBaseline)arg1) → PDFBaseline :

Return a new instance of the same type as self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::PDFBaseline> create(diffpy::srreal::PDFBaseline {lvalue})
static createByType((str)tp) → PDFBaseline :

Return a new PDFBaseline instance of the specified string type.

Parameters:
  • tp (str) – string type identifying a registered PDFBaseline class.
  • a new instance of the PDFBaseline-derived class. (Returns) –

See also

getRegisteredTypes()
Return set of the recognized type strings.
getAliasedTypes()
Return dictionary of string aliases.
C++ signature :
boost::shared_ptr<diffpy::srreal::PDFBaseline> createByType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
static getAliasedTypes() → object :

Get all aliases registered for the PDFBaseline string types.

Returns:a map of registered aliases to their corresponding standard names.
Return type:dict
C++ signature :
boost::python::api::object getAliasedTypes()
static getRegisteredTypes() → object :

Return a set of string types of the registered PDFBaseline classes.

These are the allowed arguments for the createByType factory.

C++ signature :
boost::python::api::object getRegisteredTypes()
static isRegisteredType((str)tp) → bool :

Check if the given string is registered as a PDFBaseline type.

Parameters:
  • tp (str) – string name or an alias to be checked.
  • True if tp is known to the registry either as (Return) –
  • standard type or its alias. (a) –
C++ signature :
bool isRegisteredType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
type((PDFBaseline)arg1) → str :

Return a unique string type that identifies a PDFBaseline-derived class. The string type is used for class registration and in the createByType function.

This method must be overloaded in a derived class.

C++ signature :
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > type(diffpy::srreal::PDFBaseline {lvalue})
diffpy.srreal.pdfbaseline.makePDFBaseline(name, fnc, replace=False, **dbattrs)

Helper function for registering Python function as a PDFBaseline. This is required for using Python function as PDFCalculator.baseline.

name – unique string name for registering Python function in the
global registry of PDFBaseline types. This will be the string identifier for the createByType factory.
fnc – Python function of a floating point argument and optional
float parameters. The parameters need to be registered as double attributes in the functor class. The function fnc must be picklable and it must return a float.
replace – when set replace any PDFBaseline type already registered
under the name. Otherwise raise RuntimeError when the name is taken.
dbattrs – optional float parameters of the wrapped function.
These will be registered as double attributes in the functor class. The wrapped function must be callable as fnc(x, **dbattrs). Make sure to pick attribute names that do not conflict with other PDFCalculator attributes.

Return an instance of the new PDFBaseline class.

Example

# Python baseline function def fshiftedline(x, aline, bline):

return aline * x + bline

# wrap it as a PDFBaseline and register as a “shiftedline” type makePDFBaseline(“shiftedline”, fshiftedline, aline=-1, bline=0) baseline = PDFBaseline.createByType(“shiftedline”) print map(baseline, range(5)) # use it in PDFCalculator pdfc = PDFCalculator() pdfc.baseline = baseline # or pdfc.baseline = “shiftedline”

class diffpy.srreal.pdfbaseline.ZeroBaseline

Bases: diffpy.srreal.srreal_ext.PDFBaseline

Trivial baseline function that is always zero, no baseline.

class diffpy.srreal.pdfbaseline.LinearBaseline

Bases: diffpy.srreal.srreal_ext.PDFBaseline

Trivial baseline function that is always zero, no baseline.

slope

Slope of an unscaled linear baseline. For crystal structures it is preset to (-4 * pi * rho0).

diffpy.srreal.pdfcalculator module

Top-level classes for PDF calculation: DebyePDFCalculator – simulate PDF by evaluating Debye sum in Q-space PDFCalculator – calculate PDF by peak summation in real space

class diffpy.srreal.pdfcalculator.DebyePDFCalculator(**kwargs)

Bases: diffpy.srreal.srreal_ext.BasePairQuantity, diffpy.srreal.srreal_ext.PeakWidthModelOwner, diffpy.srreal.srreal_ext.ScatteringFactorTableOwner

Calculate PDF using the Debye scattering equation.

addEnvelope((DebyePDFCalculator)arg1, (object)envlp) → None :

Add a PDFEnvelope object as another scaling function. This replaces any existing PDFEnvelope of the same string type.

envlp – instance of PDFEnvelope that defines the scaling function or
a string type for a registered PDFEnvelope class. Use PDFEnvelope.getRegisteredTypes for the available string values.

No return value.

C++ signature :
void addEnvelope(diffpy::srreal::DebyePDFCalculator {lvalue},boost::python::api::object)
clearEnvelopes((DebyePDFCalculator)arg1) → None :

Remove all PDFEnvelope scaling functions from the calculator.

C++ signature :
void clearEnvelopes(diffpy::srreal::DebyePDFCalculator {lvalue})
debyeprecision

Cutoff amplitude for the sine contributions to the F(Q). [1e-6 unitless]

delta1

Coefficient for (1/r) contribution to the peak sharpening. Active for JeongPeakWidth model. [0 A]

delta2

Coefficient for (1/r**2) contribution to the peak sharpening. Active for JeongPeakWidth model. [0 A**2]

envelopes

A tuple of PDFEnvelope instances used for calculating scaling envelope. This property can be assigned an iterable of PDFEnvelope objects.

extendedrmax

Upper boundary of the extended r-range, read-only. [A]

extendedrmin

Low boundary of the extended r-range, read-only. [A]

fq

An array of F values in 1/A that can be Fourier transformed to G(r).

getEnvelope((DebyePDFCalculator)arg1, (str)tp) → PDFEnvelope :

Retrieve an active PDFEnvelope object by its string type.

tp – string type of a PDFEnvelope object that is present in
the calculator. See the ‘usedenvelopetypes’ attribute for the present string types.

Return a PDFEnvelope instance. Raise ValueError it type tp is not present.

C++ signature :
boost::shared_ptr<diffpy::srreal::PDFEnvelope> getEnvelope(diffpy::srreal::DebyePDFCalculator {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
isOptimumQstep((DebyePDFCalculator)arg1) → bool :

Return True if qstep is set to an optimum, rmax-dependent value. Return False if qstep was overridden by the user.

C++ signature :
bool isOptimumQstep(diffpy::srreal::DebyePDFCalculator {lvalue})
maxextension

Maximum extension of the r-range that accounts for contributions from the out of range peaks. [10 A]

pdf

An array of PDF values in the form of G = 4*pi*r(rho - rho0) in A**-2.

popEnvelope((DebyePDFCalculator)arg1, (object)arg2) → None :

Remove PDFEnvelope object from an internal list of scaling functions.

envlp – instance of PDFEnvelope object or a string type of a registered
PDFEnvelope class to be removed. No action if envlp is not present in the calculator. See the ‘envelopes’ attribute for a tuple of active PDFEnvelope instances or the ‘usedenvelopetypes’ attribute for the corresponding string types.

No return value.

C++ signature :
void popEnvelope(diffpy::srreal::DebyePDFCalculator {lvalue},boost::python::api::object)
qbroad

PDF peak broadening from increased intensity noise at high Q. Not applied when equal zero. Active for JeongPeakWidth model. [0 1/A]

qdamp

PDF Gaussian dampening factor due to limited Q-resolution. Not applied when equal to zero. Active for QResolutionEnvelope. [0 1/A]

qgrid

An array of Q-values in 1/A. This is a uniformly spaced array of qstep values that start at 0/A and are smaller than qmax.

qmax

Upper bound of the Q-grid for the calculated F(Q). Affects the termination ripples. [25 1/A]

qmin

Lower bound of the Q-grid for the calculated F(Q). Affects the shape envelope. [0 1/A]

qstep

Spacing in the Q-grid. Q-values are at the multiples of qstep. [PI/extendedrmax A] unless user overridden. See also setOptimumQstep, isOptimumQstep.

rdf

An array of the last RDF values in A**-1.

rgrid

An array of r-values in Angstrom. This is a uniformly spaced array of rstep multiples that are greater or equal to rmin and smaller than rmax.

rmax

Upper bound of the r-grid for PDF calculation. [10 A]

rmin

Lower bound of the r-grid for PDF calculation. [0 A]

rstep

Spacing in the calculated r-grid. r-values are at the multiples of rstep. [0.01 A]

scale

Scale factor of the calculated PDF. Active for ScaleEnvelope. [1.0 unitless]

setOptimumQstep((DebyePDFCalculator)arg1) → None :

Use the optimum qstep value equal to the Nyquist step of pi/rmaxext, where rmaxext is rmax extended for termination ripples and peak tails. The qstep value depends on rmax when active. This is disabled after explicit qstep assignment, which makes qstep independent of rmax.

C++ signature :
void setOptimumQstep(diffpy::srreal::DebyePDFCalculator {lvalue})
usedenvelopetypes

A tuple of string types of the used PDFEnvelope instances, read-only.

class diffpy.srreal.pdfcalculator.PDFCalculator(**kwargs)

Bases: diffpy.srreal.srreal_ext.BasePairQuantity, diffpy.srreal.srreal_ext.PeakWidthModelOwner, diffpy.srreal.srreal_ext.ScatteringFactorTableOwner

Calculate PDF using the real-space summation of PeakProfile functions.

addEnvelope((PDFCalculator)arg1, (object)envlp) → None :

Add a PDFEnvelope object as another scaling function. This replaces any existing PDFEnvelope of the same string type.

envlp – instance of PDFEnvelope that defines the scaling function or
a string type for a registered PDFEnvelope class. Use PDFEnvelope.getRegisteredTypes for the available string values.

No return value.

C++ signature :
void addEnvelope(diffpy::srreal::PDFCalculator {lvalue},boost::python::api::object)
baseline

Instance of PDFBaseline that calculates unscaled baseline at r. The baseline property can be assigned either a PDFBaseline-derived object or a string type of a registered PDFBaseline class. Use PDFBaseline.getRegisteredTypes() for the set of allowed values.

clearEnvelopes((PDFCalculator)arg1) → None :

Remove all PDFEnvelope scaling functions from the calculator.

C++ signature :
void clearEnvelopes(diffpy::srreal::PDFCalculator {lvalue})
delta1

Coefficient for (1/r) contribution to the peak sharpening. Active for JeongPeakWidth model. [0 A]

delta2

Coefficient for (1/r**2) contribution to the peak sharpening. Active for JeongPeakWidth model. [0 A**2]

envelopes

A tuple of PDFEnvelope instances used for calculating scaling envelope. This property can be assigned an iterable of PDFEnvelope objects.

extendedrmax

Upper boundary of the extended r-range, read-only. [A]

extendedrmin

Low boundary of the extended r-range, read-only. [A]

fq

An array of F values in 1/A that can be Fourier transformed to G(r).

getEnvelope((PDFCalculator)arg1, (str)tp) → PDFEnvelope :

Retrieve an active PDFEnvelope object by its string type.

tp – string type of a PDFEnvelope object that is present in
the calculator. See the ‘usedenvelopetypes’ attribute for the present string types.

Return a PDFEnvelope instance. Raise ValueError it type tp is not present.

C++ signature :
boost::shared_ptr<diffpy::srreal::PDFEnvelope> getEnvelope(diffpy::srreal::PDFCalculator {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
maxextension

Maximum extension of the r-range that accounts for contributions from the out of range peaks. [10 A]

pdf

An array of PDF values in the form of G = 4*pi*r(rho - rho0) in A**-2.

peakprecision

Cutoff amplitude of the peak tail relative to the peak maximum. [3.33e-6 unitless]

peakprofile

Instance of PeakProfile that calculates the real-space profile for a single atom-pair contribution. This can be assigned either a PeakProfile-derived object or a string type of a registered PeakProfile class. Use PeakProfile.getRegisteredTypes() for the allowed values.

popEnvelope((PDFCalculator)arg1, (object)arg2) → None :

Remove PDFEnvelope object from an internal list of scaling functions.

envlp – instance of PDFEnvelope object or a string type of a registered
PDFEnvelope class to be removed. No action if envlp is not present in the calculator. See the ‘envelopes’ attribute for a tuple of active PDFEnvelope instances or the ‘usedenvelopetypes’ attribute for the corresponding string types.

No return value.

C++ signature :
void popEnvelope(diffpy::srreal::PDFCalculator {lvalue},boost::python::api::object)
qbroad

PDF peak broadening from increased intensity noise at high Q. Not applied when equal zero. Active for JeongPeakWidth model. [0 1/A]

qdamp

PDF Gaussian dampening factor due to limited Q-resolution. Not applied when equal to zero. Active for QResolutionEnvelope. [0 1/A]

qgrid

An array of Q-values in 1/A. This is a uniformly spaced array of qstep values that start at 0/A and are smaller than qmax.

qmax

Upper bound of the experimental Q-range used. Affects the termination ripples. Not used when zero. [0 1/A]

qmin

Lower bound of the experimental Q-range used. Affects the shape envelope. [0 1/A]

qstep

Spacing in the Q-grid. Q-values are at the multiples of qstep. The value is padded by rsteps so that PI/qstep > extendedrmax and PI/(qstep * rstep) is a power of 2. Read-only. [PI/(padded extendedrmax) A]

rdf

An array of the last RDF values in A**-1.

rgrid

An array of r-values in Angstrom. This is a uniformly spaced array of rstep multiples that are greater or equal to rmin and smaller than rmax.

rmax

Upper bound of the r-grid for PDF calculation. [10 A]

rmin

Lower bound of the r-grid for PDF calculation. [0 A]

rstep

Spacing in the calculated r-grid. r-values are at the multiples of rstep. [0.01 A]

scale

Scale factor of the calculated PDF. Active for ScaleEnvelope. [1.0 unitless]

slope

Slope of the linear PDF background. Assigned according to number density of the evaluated structure at each PDF calculation. Active for LinearBaseline. [-4*pi*numdensity unitless]

spdiameter

Spherical particle diameter for PDF shape damping correction. Not used when zero. Active for SphericalShapeEnvelope. [0 A]

stepcut

r-boundary for a step cutoff of the calculated PDF. Not used when negative or zero. Active for StepCutEnvelope. Not used when zero. Active for StepCutEnvelope. [0 A]

usedenvelopetypes

A tuple of string types of the used PDFEnvelope instances, read-only.

diffpy.srreal.pdfcalculator.fftftog((object)f, (float)qstep[, (float)qmin=0.0]) → tuple :

Perform sine-fast Fourier transform from F(Q) to G(r). The length of the output array is padded to the next power of 2.

f – array of the F values on a regular Q-space grid. qstep – spacing in the Q-space grid, this is used for proper

scaling of the output array.

qmin – optional starting point of the Q-space grid.

Return a tuple of (g, rstep). These can be used with the complementary fftgtof function to recover the original signal f.

C++ signature :
boost::python::tuple fftftog(boost::python::api::object,double [,double=0.0])
diffpy.srreal.pdfcalculator.fftgtof((object)g, (float)rstep[, (float)rmin=0.0]) → tuple :

Perform sine-fast Fourier transform from G(r) to F(Q). The length of the output array is padded to the next power of 2.

g – array of the G values on a regular r-space grid. rstep – spacing in the r-space grid, this is used for proper

scaling of the output array.

rmin – optional starting point of the r-space grid.

Return a tuple of (f, qstep). These can be used with the complementary fftftog function to recover the original signal g.

C++ signature :
boost::python::tuple fftgtof(boost::python::api::object,double [,double=0.0])

diffpy.srreal.pdfenvelope module

Classes for configuring PDF scaling envelope: PDFEnvelope, ScaleEnvelope, QResolutionEnvelope, SphericalShapeEnvelope, StepCutEnvelope

class diffpy.srreal.pdfenvelope.PDFEnvelope

Bases: diffpy.srreal.srreal_ext.Attributes

Base class and registry for functions that return PDF scaling envelopes.

clone((PDFEnvelope)arg1) → PDFEnvelope :

Return a new instance that is a copy of self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::PDFEnvelope> clone(diffpy::srreal::PDFEnvelope {lvalue})
create((PDFEnvelope)arg1) → PDFEnvelope :

Return a new instance of the same type as self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::PDFEnvelope> create(diffpy::srreal::PDFEnvelope {lvalue})
static createByType((str)tp) → PDFEnvelope :

Return a new PDFEnvelope instance of the specified string type.

Parameters:
  • tp (str) – string type identifying a registered PDFEnvelope class.
  • a new instance of the PDFEnvelope-derived class. (Returns) –

See also

getRegisteredTypes()
Return set of the recognized type strings.
getAliasedTypes()
Return dictionary of string aliases.
C++ signature :
boost::shared_ptr<diffpy::srreal::PDFEnvelope> createByType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
static getAliasedTypes() → object :

Get all aliases registered for the PDFEnvelope string types.

Returns:a map of registered aliases to their corresponding standard names.
Return type:dict
C++ signature :
boost::python::api::object getAliasedTypes()
static getRegisteredTypes() → object :

Return a set of string types of the registered PDFEnvelope classes.

These are the allowed arguments for the createByType factory.

C++ signature :
boost::python::api::object getRegisteredTypes()
static isRegisteredType((str)tp) → bool :

Check if the given string is registered as a PDFEnvelope type.

Parameters:
  • tp (str) – string name or an alias to be checked.
  • True if tp is known to the registry either as (Return) –
  • standard type or its alias. (a) –
C++ signature :
bool isRegisteredType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
type((PDFEnvelope)arg1) → str :

Return a unique string type that identifies a PDFEnvelope-derived class. The string type is used for class registration and in the createByType function.

This method must be overloaded in a derived class.

C++ signature :
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > type(diffpy::srreal::PDFEnvelope {lvalue})
diffpy.srreal.pdfenvelope.makePDFEnvelope(name, fnc, replace=False, **dbattrs)

Helper function for registering Python function as a PDFEnvelope. This is required for using Python function as PDFCalculator envelope.

name – unique string name for registering Python function in the
global registry of PDFEnvelope types. This will be the string identifier for the createByType factory.
fnc – Python function of a floating point argument and optional
float parameters. The parameters need to be registered as double attributes in the functor class. The function fnc must be picklable and it must return a float.
replace – when set replace any PDFEnvelope type already registered
under the name. Otherwise raise RuntimeError when the name is taken.
dbattrs – optional float parameters of the wrapped function.
These will be registered as double attributes in the functor class. The wrapped function must be callable as fnc(x, **dbattrs). Make sure to pick attribute names that do not conflict with other PDFCalculator attributes.

Return an instance of the new PDFEnvelope class.

Example

# Python envelope function def fexpdecay(x, expscale, exptail):

from math import exp return expscale * exp(-x / exptail)

# wrap it as a PDFEnvelope and register as a “expdecay” type makePDFEnvelope(“expdecay”, fexpdecay, expscale=5, exptail=4) envelope = PDFEnvelope.createByType(“expdecay”) print map(envelope, range(9)) # use it in PDFCalculator pdfc = PDFCalculator() pdfc.addEnvelope(envelope) # or pdfc.addEnvelope(“expdecay”)

class diffpy.srreal.pdfenvelope.QResolutionEnvelope

Bases: diffpy.srreal.srreal_ext.PDFEnvelope

Gaussian dampening envelope function due to limited Q-resolution.

Returns exp(-qdamp * x**2). Returns 1 when qdamp is zero or negative.

qdamp

Dampening parameter in the Gaussian envelope function.

class diffpy.srreal.pdfenvelope.ScaleEnvelope

Bases: diffpy.srreal.srreal_ext.PDFEnvelope

Uniform scaling envelope function.

Returns scale.

scale

Overall scale for a uniform scaling envelope.

class diffpy.srreal.pdfenvelope.SphericalShapeEnvelope

Bases: diffpy.srreal.srreal_ext.PDFEnvelope

Dampening PDF envelope due to finite spherical particle shape.

Returns (1 - 1.5*tau + 0.5*tau**3), where tau = x/spdiameter. Returns 1 when spdiameter <= 0.

spdiameter

Particle diameter in Angstroms for a spherical shape damping.

class diffpy.srreal.pdfenvelope.StepCutEnvelope

Bases: diffpy.srreal.srreal_ext.PDFEnvelope

Step function damping envelope.

Returns 1 when x <= stepcut or if stepcut <= 0. Returns 0 when x > stepcut.

stepcut

Cutoff for a step-function envelope.

diffpy.srreal.peakprofile module

Class for configuring PDF profile function: PeakProfile GaussianProfile, CroppedGaussianProfile

class diffpy.srreal.peakprofile.PeakProfile

Bases: diffpy.srreal.srreal_ext.Attributes

Base class and registry for PDF peak profile functions. The peak profile functions must be centered at 0 and their integrated area must be 1.

clone((PeakProfile)arg1) → PeakProfile :

Return a new instance that is a copy of self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::PeakProfile> clone(diffpy::srreal::PeakProfile {lvalue})
create((PeakProfile)arg1) → PeakProfile :

Return a new instance of the same type as self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::PeakProfile> create(diffpy::srreal::PeakProfile {lvalue})
static createByType((str)tp) → PeakProfile :

Return a new PeakProfile instance of the specified string type.

Parameters:
  • tp (str) – string type identifying a registered PeakProfile class.
  • a new instance of the PeakProfile-derived class. (Returns) –

See also

getRegisteredTypes()
Return set of the recognized type strings.
getAliasedTypes()
Return dictionary of string aliases.
C++ signature :
boost::shared_ptr<diffpy::srreal::PeakProfile> createByType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
static getAliasedTypes() → object :

Get all aliases registered for the PeakProfile string types.

Returns:a map of registered aliases to their corresponding standard names.
Return type:dict
C++ signature :
boost::python::api::object getAliasedTypes()
static getRegisteredTypes() → object :

Return a set of string types of the registered PeakProfile classes.

These are the allowed arguments for the createByType factory.

C++ signature :
boost::python::api::object getRegisteredTypes()
static isRegisteredType((str)tp) → bool :

Check if the given string is registered as a PeakProfile type.

Parameters:
  • tp (str) – string name or an alias to be checked.
  • True if tp is known to the registry either as (Return) –
  • standard type or its alias. (a) –
C++ signature :
bool isRegisteredType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
peakprecision

Profile amplitude relative to the peak maximum for evaluating peak bounds xboundlo and xboundhi. [3.33e-6 unitless]

ticker((PeakProfile)arg1) → EventTicker :
Return EventTicker that marks last modification time of this object.

This ticker object is used in fast PDF update, to check if PeakProfile has changed since the last calculation. The ticker.click() method needs to be therefore called after every change in PeakProfile configuration.

Return EventTicker object. This method can be overridden in a Python-derived class.

C++ signature :
diffpy::eventticker::EventTicker {lvalue} ticker(diffpy::srreal::PeakProfile {lvalue})

ticker( (PeakProfile)arg1) -> EventTicker :

C++ signature :
diffpy::eventticker::EventTicker {lvalue} ticker(srrealmodule::nswrap_PeakProfile::PeakProfileWrap {lvalue})
type((PeakProfile)arg1) → str :

Return a unique string type that identifies a PeakProfile-derived class. The string type is used for class registration and in the createByType function.

This method must be overloaded in a derived class.

C++ signature :
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > type(diffpy::srreal::PeakProfile {lvalue})
xboundhi((PeakProfile)arg1, (float)fwhm) → float :

Upper x-bound where profile function becomes smaller than precision. The bound is evaluated relative to profile maximum, i.e., for each x above xboundhi the profile function must be smaller than (peakprecision * maximum).

fwhm – Full Width at Half Maximum of the profile function

Return float. See also the peakprecision property.

C++ signature :
double xboundhi(diffpy::srreal::PeakProfile {lvalue},double)
xboundlo((PeakProfile)arg1, (float)fwhm) → float :

Lower x-bound where profile function becomes smaller than precision. The bound is evaluated relative to profile maximum, i.e., for each x below xboundlo the profile function must be smaller than (peakprecision * maximum).

fwhm – Full Width at Half Maximum of the profile function

Return float. See also the peakprecision property.

C++ signature :
double xboundlo(diffpy::srreal::PeakProfile {lvalue},double)
class diffpy.srreal.peakprofile.GaussianProfile

Bases: diffpy.srreal.srreal_ext.PeakProfile

Gaussian profile function.

class diffpy.srreal.peakprofile.CroppedGaussianProfile

Bases: diffpy.srreal.srreal_ext.GaussianProfile

Gaussian function cropped to zero at its crossing with peakprecision.

The profile is also rescaled to keep the integrated area of 1.

diffpy.srreal.peakwidthmodel module

Classes for configuring peak width evaluation in PDF calculations: PeakWidthModel, ConstantPeakWidth, DebyeWallerPeakWidth, JeongPeakWidth

class diffpy.srreal.peakwidthmodel.PeakWidthModel

Bases: diffpy.srreal.srreal_ext.Attributes

Base class for functors that calculate the PDF peak widths. Peak width is defined as full width at half maximum (FWHM).

calculate((PeakWidthModel)arg1, (BaseBondGenerator)bnds) → float :

Calculate the FWHM peak width for the specified bond.

bnds – instance of BaseBondGenerator with the current bond data.

Return float. This method must be overridden in a derived class.

C++ signature :
double calculate(diffpy::srreal::PeakWidthModel {lvalue},diffpy::srreal::BaseBondGenerator)
clone((PeakWidthModel)arg1) → PeakWidthModel :

Return a new instance that is a copy of self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::PeakWidthModel> clone(diffpy::srreal::PeakWidthModel {lvalue})
create((PeakWidthModel)arg1) → PeakWidthModel :

Return a new instance of the same type as self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::PeakWidthModel> create(diffpy::srreal::PeakWidthModel {lvalue})
static createByType((str)tp) → PeakWidthModel :

Return a new PeakWidthModel instance of the specified string type.

Parameters:
  • tp (str) – string type identifying a registered PeakWidthModel class.
  • a new instance of the PeakWidthModel-derived class. (Returns) –

See also

getRegisteredTypes()
Return set of the recognized type strings.
getAliasedTypes()
Return dictionary of string aliases.
C++ signature :
boost::shared_ptr<diffpy::srreal::PeakWidthModel> createByType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
static getAliasedTypes() → object :

Get all aliases registered for the PeakWidthModel string types.

Returns:a map of registered aliases to their corresponding standard names.
Return type:dict
C++ signature :
boost::python::api::object getAliasedTypes()
static getRegisteredTypes() → object :

Return a set of string types of the registered PeakWidthModel classes.

These are the allowed arguments for the createByType factory.

C++ signature :
boost::python::api::object getRegisteredTypes()
static isRegisteredType((str)tp) → bool :

Check if the given string is registered as a PeakWidthModel type.

Parameters:
  • tp (str) – string name or an alias to be checked.
  • True if tp is known to the registry either as (Return) –
  • standard type or its alias. (a) –
C++ signature :
bool isRegisteredType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
maxWidth((PeakWidthModel)arg1, (StructureAdapter)stru, (float)rmin, (float)rmax) → float :

Return maximum peak width for the specified structure and distance range

stru – StructureAdapter object or an object convertible to StructureAdapter. rmin – lower bound for the PDF calculation rmax – upper bound for the PDF calculation

isotropically vibrating atoms this

Return float.

C++ signature :
double maxWidth(diffpy::srreal::PeakWidthModel {lvalue},boost::shared_ptr<diffpy::srreal::StructureAdapter>,double,double)

maxWidth( (PeakWidthModel)arg1, (object)stru, (float)rmin, (float)rmax) -> float :

C++ signature :
double maxWidth(diffpy::srreal::PeakWidthModel,boost::python::api::object,double,double)
maxWidth( (PeakWidthModel)arg1, (StructureAdapter)stru, (float)rmin, (float)rmax) -> float :

Return maximum peak width for the specified structure and distance range

stru – StructureAdapter object or an object convertible to StructureAdapter. rmin – lower bound for the PDF calculation rmax – upper bound for the PDF calculation

isotropically vibrating atoms this

Return float.

C++ signature :
double maxWidth(diffpy::srreal::PeakWidthModel {lvalue},boost::shared_ptr<diffpy::srreal::StructureAdapter>,double,double)
ticker((PeakWidthModel)arg1) → EventTicker :
Return EventTicker that marks last modification time of this object.

This ticker object is used in fast PDF update, to check if PeakWidthModel has changed since the last calculation. The ticker.click() method needs to be therefore called after every change in PeakWidthModel configuration.

Return EventTicker object. This method can be overridden in a Python-derived class.

C++ signature :
diffpy::eventticker::EventTicker {lvalue} ticker(diffpy::srreal::PeakWidthModel {lvalue})

ticker( (PeakWidthModel)arg1) -> EventTicker :

C++ signature :
diffpy::eventticker::EventTicker {lvalue} ticker(srrealmodule::nswrap_PeakWidthModel::PeakWidthModelWrap {lvalue})
type((PeakWidthModel)arg1) → str :

Return a unique string type that identifies a PeakWidthModel-derived class. The string type is used for class registration and in the createByType function.

This method must be overloaded in a derived class.

C++ signature :
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > type(diffpy::srreal::PeakWidthModel {lvalue})
class diffpy.srreal.peakwidthmodel.ConstantPeakWidth

Bases: diffpy.srreal.srreal_ext.PeakWidthModel

Peak width model returning constant width.

width

Constant FWHM value returned by this model.

class diffpy.srreal.peakwidthmodel.DebyeWallerPeakWidth

Bases: diffpy.srreal.srreal_ext.PeakWidthModel

Calculate PDF peak width from a Debye-Waller model of atom vibrations. This returns mean-square displacement of atoms in the pair along their bond scaled as FWHM. The atom displacements are assumed independent.

class diffpy.srreal.peakwidthmodel.JeongPeakWidth

Bases: diffpy.srreal.srreal_ext.DebyeWallerPeakWidth

Calculate PDF peak width assuming I.-K. Jeong model of correlated motion. This returns mean-square displacement of atoms in the pair along their bond corrected for correlated motion and data noise at high-Q by a scaling factor sqrt(1 - delta1/r - delta2/r**2 + (qbroad * r)**2).

delta1

Coefficient for (1/r) contribution to the peak sharpening.

delta2

Coefficient for (1/r**2) contribution to the peak sharpening.

qbroad

PDF peak broadening from increased intensity noise at high Q.

diffpy.srreal.scatteringfactortable module

class ScatteringFactorTable – scattering factors for atoms, ions and isotopes.

class diffpy.srreal.scatteringfactortable.ScatteringFactorTable

Bases: Boost.Python.instance

Base class for looking up scattering factors by atom symbols. This class has virtual methods and cannot be used as is.

A derived class has to override the following methods:

create(self) clone(self) type(self) radiationType(self) _standardLookup(self, smbl, q)

Derived class can be added to the global registry of ScatteringFactorTable types by calling the _registerThisType method with any instance.

clone((ScatteringFactorTable)arg1) → ScatteringFactorTable :

Return a new instance that is a copy of self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::ScatteringFactorTable> clone(diffpy::srreal::ScatteringFactorTable {lvalue})
create((ScatteringFactorTable)arg1) → ScatteringFactorTable :

Return a new instance of the same type as self.

This method must be overloaded in a derived class.

C++ signature :
boost::shared_ptr<diffpy::srreal::ScatteringFactorTable> create(diffpy::srreal::ScatteringFactorTable {lvalue})
static createByType((str)tp) → ScatteringFactorTable :

Return a new ScatteringFactorTable instance of the specified string type.

Parameters:
  • tp (str) – string type identifying a registered ScatteringFactorTable class.
  • a new instance of the ScatteringFactorTable-derived class. (Returns) –

See also

getRegisteredTypes()
Return set of the recognized type strings.
getAliasedTypes()
Return dictionary of string aliases.
C++ signature :
boost::shared_ptr<diffpy::srreal::ScatteringFactorTable> createByType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
static getAliasedTypes() → object :

Get all aliases registered for the ScatteringFactorTable string types.

Returns:a map of registered aliases to their corresponding standard names.
Return type:dict
C++ signature :
boost::python::api::object getAliasedTypes()
getCustomSymbols((ScatteringFactorTable)arg1) → object :

Return a set of all atom symbols with custom scattering factors.

C++ signature :
boost::python::api::object getCustomSymbols(diffpy::srreal::ScatteringFactorTable)
static getRegisteredTypes() → object :

Return a set of string types of the registered ScatteringFactorTable classes.

These are the allowed arguments for the createByType factory.

C++ signature :
boost::python::api::object getRegisteredTypes()
static isRegisteredType((str)tp) → bool :

Check if the given string is registered as a ScatteringFactorTable type.

Parameters:
  • tp (str) – string name or an alias to be checked.
  • True if tp is known to the registry either as (Return) –
  • standard type or its alias. (a) –
C++ signature :
bool isRegisteredType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
lookup((ScatteringFactorTable)arg1, (str)smbl, (object)qarray) → object :
C++ signature :
boost::python::api::object lookup(diffpy::srreal::ScatteringFactorTable,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,boost::python::api::object {lvalue})
lookup( (ScatteringFactorTable)arg1, (str)smbl [, (float)q=0.0]) -> float :

Scattering factor of a specified atom at Q in 1/A. The standard value can be redefined using the setCustomAs method.

smbl – string symbol for atom, ion or isotope. Q – Q value in inverse Angstroms, by default 0.

Q can be either float or NumPy array.

Return float or NumPy array of the same shape as Q. No support for Python override.

C++ signature :
double lookup(diffpy::srreal::ScatteringFactorTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > [,double=0.0])
radiationType((ScatteringFactorTable)arg1) → str :

Return a string identifying the radiation type. ‘X’ for x-rays, ‘N’ for neutrons. This method must be overridden in a derived class.

C++ signature :
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > radiationType(diffpy::srreal::ScatteringFactorTable {lvalue})
resetAll((ScatteringFactorTable)arg1) → None :

Reset all custom scattering factor values.

No return value. No support for Python override.

C++ signature :
void resetAll(diffpy::srreal::ScatteringFactorTable {lvalue})
resetCustom((ScatteringFactorTable)arg1, (str)smbl) → None :

Revert scattering factor for the specified symbol to a standard value.

smbl – string symbol for atom, ion or isotope.

No return value. No support for Python override.

C++ signature :
void resetCustom(diffpy::srreal::ScatteringFactorTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
setCustomAs((ScatteringFactorTable)arg1, (str)smbl, (str)src) → None :
Define custom alias for the specified atom symbol.

Example: setCustomAs(‘12-C’, ‘C’) will declare the same scattering factors for ‘12-C’ as for ‘C’.

smbl – custom string alias for an existing standard symbol. src – standard atom symbol (cannot be another alias).

No return value. No support for Python override.

C++ signature :
void setCustomAs(diffpy::srreal::ScatteringFactorTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
setCustomAs( (ScatteringFactorTable)arg1, (str)smbl, (str)src, (float)sf [, (float)q=0.0]) -> None :

Define custom scattering factor for the specified atom symbol. The custom value is calculated by rescaling standard value from a source atom type.

smbl – string symbol of the atom with custom scattering factor. src – atom symbol for the source standard scattering factor. sf – new scattering factor value, defaults to the standard src factor. q – optional Q value for the new custom scattering factor.

The internal scaling of the standard value is calculated at this Q.

No return value. No support for Python override.

C++ signature :
void setCustomAs(diffpy::srreal::ScatteringFactorTable {lvalue},std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >,double [,double=0.0])
ticker((ScatteringFactorTable)arg1) → EventTicker :
Return EventTicker that marks last modification time of this object.

This ticker object is used in fast PDF update, to check if scattering factors changed since the last calculation. The ticker.click() method thus needs to be used for _standardLookup that returns variable values.

Return EventTicker object. This method can be overridden in a Python-derived class.

C++ signature :
diffpy::eventticker::EventTicker {lvalue} ticker(diffpy::srreal::ScatteringFactorTable {lvalue})

ticker( (ScatteringFactorTable)arg1) -> EventTicker :

C++ signature :
diffpy::eventticker::EventTicker {lvalue} ticker(srrealmodule::nswrap_ScatteringFactorTable::ScatteringFactorTableWrap {lvalue})
type((ScatteringFactorTable)arg1) → str :

Return a unique string type that identifies a ScatteringFactorTable-derived class. The string type is used for class registration and in the createByType function.

This method must be overloaded in a derived class.

C++ signature :
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > type(diffpy::srreal::ScatteringFactorTable {lvalue})
class diffpy.srreal.scatteringfactortable.SFTXray

Bases: diffpy.srreal.srreal_ext.ScatteringFactorTable

X-ray scattering factors table.

Q-dependence of scattering factors is calculated using Waasmaier - Kirfel approximation valid up to Q=75/A.

class diffpy.srreal.scatteringfactortable.SFTElectron

Bases: diffpy.srreal.srreal_ext.ScatteringFactorTable

Electron scattering factors table.

Q-dependence is derived from X-ray scattering factors according to the International Tables Volume C.

class diffpy.srreal.scatteringfactortable.SFTNeutron

Bases: diffpy.srreal.srreal_ext.ScatteringFactorTable

Table of neutron scattering lengths in fm.

class diffpy.srreal.scatteringfactortable.SFTElectronNumber

Bases: diffpy.srreal.srreal_ext.ScatteringFactorTable

Table of electron numbers for elements and ions.

Can be used as Q-indendent scattering factors for X-rays.

diffpy.srreal.sfaverage module

Compositional averaging of atom scattering factors.

Examples

import numpy as np
from diffpy.srreal.scatteringfactortable import SFTXray
xtb = SFTXray()
qa = np.linspace(0, 25)
sfavg1 = SFAverage.fromComposition({'Na' : 1, 'Cl' : 1}, xtb, qa)
sfavg2 = SFAverage.fromComposition([('Mn', 1), ('O', 2)], xtb, qa)

from diffpy.structure import loadStructure
from diffpy.srreal.pdfcalculator import DebyePDFCalculator
dpdfc = DebyePDFCalculator()
dpdfc(loadStructure('rutile.cif'))
sfavg3 = SFAverage.fromStructure(dpdfc.getStructure(),
                                 dpdfc.scatteringfactortable, dpdfc.qgrid)
class diffpy.srreal.sfaverage.SFAverage

Calculate compositional statistics of atom scattering factors.

Compositional averages can be calculated for an array of Q-values. Results are stored in the class attributes.

f1sum

Sum of scattering factors from all atoms. Float or NumPy array.

f2sum

Sum of squared scattering factors from all atoms. Float or NumPy array.

count

Total number of atoms. Can be non-integer in case of fractional occupancies.

f1avg

Compositional average of scattering factors. Float or NumPy array.

f2avg

Compositional average of squared scattering factors. Float or NumPy array.

composition

Dictionary of atom symbols and their total abundancies.

composition = None
count = 0
f1avg = 0
f1sum = 0
f2avg = 0
f2sum = 0
classmethod fromComposition(composition, sftb, q=0)

Calculate average scattering factors from atom concentrations.

Parameters:
  • composition (dictionary or a list of (symbol, amount) pairs.) – The chemical composition for evaluating the average. Atom symbols may repeat when it is a list of (symbol, amount) pairs.
  • sftb (ScatteringFactorTable or str) – The ScatteringFactorTable object for looking up the values. When string use ScatteringFactorTable.createByType to create a new lookup table of the specified type.
  • q (float or NumPy array (optional)) – The Q value in inverse Angstroms for which to lookup the scattering factor values.
Returns:

The calculated scattering factor averages.

Return type:

SFAverage

classmethod fromStructure(stru, sftb, q=0)

Calculate average scattering factors from a structure object.

Parameters:
  • stru (diffpy Structure or pyobjcryst Crystal or StructureAdapter) – The structure object that stores the atom species and their occupancies. Can be any type with a registered conversion to the StructureAdapter class.
  • sftb (ScatteringFactorTable or str) – The ScatteringFactorTable object for looking up the values. When string use ScatteringFactorTable.createByType to create a new lookup table of the specified type.
  • q (float or NumPy array (optional)) – The Q value in inverse Angstroms for which to lookup the scattering factor values.

See also

RegisterStructureAdapter()
to add support for more structure types.
Returns:The calculated scattering factor averages.
Return type:SFAverage

diffpy.srreal.structureadapter module

class StructureAdapter – adapter of any structure object to the interface
expected by srreal PairQuantity calculators

Routines:

createStructureAdapter – create StructureAdapter from a Python object nometa – create StructureAdapter with disabled _customPQConfig method

this prevents copying of diffpy.structure pdffit metadata to PDFCalculator object

nosymmetry – create StructureAdapter with disabled symmetry expansion.

Constants:

EMPTY – singleton instance of an empty structure.

diffpy.srreal.structureadapter.RegisterStructureAdapter(fqname, fnc=None)

Function decorator that marks it as a converter of specified object type to StructureAdapter class in diffpy.srreal. The registered structure object types can be afterwards directly used with calculators in diffpy.srreal as they would be implicitly converted to the internal diffpy.srreal structure type.

fqname – fully qualified class name for the convertible objects.
This is the quoted string included in “str(type(obj))”. The converter function would be called for object of the same or derived types.

fnc – function that converts the fqname type to StructureAdapter.

Note: When fnc is None RegisterStructureAdapter works as a decorator and the conversion function can be specified below, i.e.,

@RegisterStructureAdapter(‘my.structure.Type’) def convertMyStructure(stru):

See diffpy.srreal.structureconverters module for usage example.

diffpy.srreal.structureadapter.createStructureAdapter(stru)

Create StructureAdapter from a Python object.

stru – an object that is convertible to StructureAdapter, i.e., it has
a registered factory that converts Python structure object to StructureAdapter. Return stru if already a StructureAdapter.

Return a StructureAdapter instance. Raise TypeError if stru cannot be converted to StructureAdapter.

diffpy.srreal.structureconverters module

Converters from other structure representations in Python to diffpy.srreal StructureAdapter classes.

class diffpy.srreal.structureconverters.DiffPyStructureAtomicAdapter

Bases: diffpy.srreal.structureconverters._DiffPyStructureMetadata, diffpy.srreal.srreal_ext.AtomicStructureAdapter

class diffpy.srreal.structureconverters.DiffPyStructurePeriodicAdapter

Bases: diffpy.srreal.structureconverters._DiffPyStructureMetadata, diffpy.srreal.srreal_ext.PeriodicStructureAdapter

diffpy.srreal.structureconverters.convertDiffPyStructure(stru)

Adapt Structure class from diffpy.structure package.

diffpy.srreal.version module

Definitions of version-related constants and of libdiffpy_version_info.

diffpy.srreal.version.get_libdiffpy_version_info()

Get version data for the active libdiffpy shared library.

Returns:a namedtuple which contains libdiffpy version data.
Return type:libdiffpy_version_info

Note

Deprecated in diffpy.srreal 1.1 libdiffpy_version_info will be removed in diffpy.srreal 1.2.

diffpy.srreal.wraputils module

Local utilities helpful for tweaking interfaces to boost python classes.

diffpy.srreal.wraputils.propertyFromExtDoubleAttr(attrname, doc)

Create property wrapper to a DoubleAttr in C++ extension object.

attrname – string name of the double attribute doc – docstring for the Python class property

Return a property object.

diffpy.srreal.wraputils.setattrFromKeywordArguments(obj, **kwargs)

Set attributes of the obj according to keyword arguments. For example: setattrFromKeywordArguments(obj, qmax=24, scale=2) This is a shared helper function used by __init__ and __call__.

kwargs – one or more keyword arguments

No return value. Raise TypeError for invalid keyword argument.

Module contents

Tools for real space structure analysis.