soprano.calculate.xrd.xrd#
Classes and functions for simulating X-ray diffraction spectroscopic results from structures.
Classes
|
A class implementing methods for XRD simulations, comparisons and fittings. |
|
Create new instance of XraySpectrum(theta2, hkl, hkl_unique, invd, intensity, lambdax) |
|
Create new instance of XraySpectrumData(theta2, intensity) |
- class soprano.calculate.xrd.xrd.XRDCalculator(lambdax=1.54056, theta2_digits=6, baseline=0.0, peak_func=None, peak_f_args=None)[source]#
Bases:
object
A class implementing methods for XRD simulations, comparisons and fittings.
Initialize the XDRCalculator object’s main parameters
Args:lambdax (Optional[float]): X-ray wavelength in Angstroms(default is 1.54056 Ang)theta2_digits (Optional[int]): Rounding within whichtwo theta angles (in degrees)are considered to be equivalent(default is 6 digits) whencalculating theoretical peaksbaseline (Optional[float]): baseline to use as starting point forsimulated spectrapeak_func (Optional[function<float, float, *kargs>=> <np.ndarray>]): the function used tosimulate peaks. Should taketh2 as its first argument,peak centre as its second,and any number of optionalarguments. Returns a numpyarray containing the peakshape. Should be able towork with numpy arrays asinputpeak_f_args (Optional[list<float>]): optional arguments forpeak_func. If no peak_funchas been supplied by theuser, the first value willbe used as the Gaussian width- dataset_range(xpeaks, theta2_range=(None, None))[source]#
- Restrict the given dataset (XraySpectrum or XraySpectrumData) to
only the values that lie within a certain theta2 range.
Args:xpeaks (XraySpectrum or XraySpectrumData): the dataset to modifytheta2_range (tuple<int>): a tuple indicating minimum and maximumof the desired theta2 range (degrees).A value of None means no boundaryReturns:xpeaks_restrict (XraySpectrum or XraySpectrumData): the restricteddatasetRaises:ValueError: if some of the values passed are invalid
- exp_dataset(th2_axis, int_axis)[source]#
Build an experimental dataset as an XraySpectrumData object.
Args:th2_axis (np.ndarray): array containing the values for 2*thetaint_axis (np.ndarray): array containing the values for intensityReturns:exp_spec (XraySpectrumData): named tuple containing theexperimental datasetRaises:ValueError: if some of the values passed are invalid
- lebail_fit(xpeaks, exp_spec, rwp_tol=0.01, max_iter=100)[source]#
Perform a refining on an XraySpectrum object’s intensities based on experimental data with leBail’s method.
Args:xpeaks (XraySpectrum): object containing the details of the XRDpeaksexp_spec (XraySpectrumData): experimental data, dataset builtusing xrd_exp_datasetrwp_tol (Optional[float]): tolerance on the Rwp error valuebetween two iterations that stops thecalculation. Default is 1e-2max_iter (Optional[int]): maximum number of iterations to performReturns:xpeaks_scaled (XraySpectrum): a new XraySpectrum object, withintensities properly scaled to matchthe experimental datasimul_spec (np.ndarray): final simulated XRD spectrumsimul_peaks (np.ndarray): final simulated spectrum broken by peakcontribution along axis 1rwp (float): the final value of Rwp (fitness of simulated toexperimental data)Raises:ValueError: if some of the arguments are invalid
- property peak_f_args#
Additional arguments to be passed to peak_func
- property peak_func#
The function used to build peaks in simulated spectra
Should be of form peak_func(theta2, peak_position, *peak_f_args)
- powder_peaks(atoms=None, latt_abc=None, n=1, o='all')[source]#
Calculate the peaks (without intensities) of a powder XRD spectrum given either an Atoms object or the lattice in ABC form and the spacegroup indices to apply the selection rules
Args:atoms (Optional[soprano.Atoms]): atoms object to gather latticeand spacegroup information fromlatt_abc (Optional[np.ndarray]): periodic lattice in ABC form,Angstroms and radiansn (Optional[int]): International number of the required spacegroupo (Optional[int]): Sub-option of the required spacegroupReturns:xpeaks (XraySpectrum): a named tuple containing the peakswith theta2, corresponding hkl indices,a unique hkl tuple for each peak,inverse reciprocal lattice distances,intensities and wavelengthRaises:ValueError: if some of the arguments are invalid
- set_peak_func(peak_func=None, peak_f_args=None)[source]#
Set a new peak_func for this XDRCalculator. If no new function is passed, reset the default Gaussian function.
Args:peak_func (Optional[function<float, float, *kargs>=> <np.ndarray>]): the function used tosimulate peaks. Shouldtake th2 as its firstargument, peak centre asits second, and anynumber of optionalarguments. Returns anumpy array containingthe peak shape. Shouldbe able to work withnumpy arrays as inputpeak_f_args (Optional[list<float>]): optional arguments forpeak_func. If no peak_funchas been supplied by theuser, the first value willbe used as the Gaussianwidth
- spec_simul(xpeaks, th2_axis)[source]#
Simulate an XRD spectrum given positions of peaks, intensities, baseline, and a peak function (a Gaussian by default).
Args:xpeaks (XraySpectrum): object containing the details of the XRDpeaksth2_axis (np.ndarray): theta2 axis points on which thespectrum should be simulatedReturns:simul_spec (XraySpectrumData): simulated XRD spectrumsimul_peaks (np.ndarray): simulated spectrum intensities broken bypeak contribution along axis 1Raises:ValueError: if some of the arguments are invalid
- class soprano.calculate.xrd.xrd.XraySpectrum(theta2, hkl, hkl_unique, invd, intensity, lambdax)#
Bases:
tuple
Create new instance of XraySpectrum(theta2, hkl, hkl_unique, invd, intensity, lambdax)
- _asdict()#
Return a new dict which maps field names to their values.
- classmethod _make(iterable)#
Make a new XraySpectrum object from a sequence or iterable
- _replace(**kwds)#
Return a new XraySpectrum object replacing specified fields with new values
- count(value, /)#
Return number of occurrences of value.
- hkl#
Alias for field number 1
- hkl_unique#
Alias for field number 2
- index(value, start=0, stop=9223372036854775807, /)#
Return first index of value.
Raises ValueError if the value is not present.
- intensity#
Alias for field number 4
- invd#
Alias for field number 3
- lambdax#
Alias for field number 5
- theta2#
Alias for field number 0
- class soprano.calculate.xrd.xrd.XraySpectrumData(theta2, intensity)#
Bases:
tuple
Create new instance of XraySpectrumData(theta2, intensity)
- _asdict()#
Return a new dict which maps field names to their values.
- classmethod _make(iterable)#
Make a new XraySpectrumData object from a sequence or iterable
- _replace(**kwds)#
Return a new XraySpectrumData object replacing specified fields with new values
- count(value, /)#
Return number of occurrences of value.
- index(value, start=0, stop=9223372036854775807, /)#
Return first index of value.
Raises ValueError if the value is not present.
- intensity#
Alias for field number 1
- theta2#
Alias for field number 0
- soprano.calculate.xrd.xrd._Rwp_eval(simul_int, exp_int)[source]#
Evaluate Rwp for use in LeBail fitting