hexrd.wppf.WPPF module
- class hexrd.wppf.WPPF.LeBail(expt_spectrum=None, params=None, phases=None, wavelength={'kalpha1': [valWUnit('lp', 'LENGTH', 0.15406, 'nm'), 1.0], 'kalpha2': [valWUnit('lp', 'LENGTH', 0.154443, 'nm'), 1.0]}, bkgmethod={'spline': None}, intensity_init=None, peakshape='pvfcj')[source]
Bases:
object
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
- >> @DATE: 05/19/2020 SS 1.0 original
09/11/2020 SS 1.1 expt_spectrum, params and phases now have multiple input option for easy integration with hexrdgui 09/14/2020 SS 1.2 bkgmethod is now a dictionary. if method is ‘chebyshev’, the the value specifies the degree of the polynomial to use for background estimation 01/22/2021 SS 1.3 added intensity_init option to initialize intensity with structure factors if the user so chooses 01/22/2021 SS 1.4 added option to specify background via a filename or numpy array 03/12/2021 SS 1.5 added _generate_default_parameter function
- >> @DETAILS: this is the main LeBail class and contains all the refinable
parameters for the analysis. Since the LeBail method has no structural information during refinement, the refinable parameters for this model will be:
a, b, c, alpha, beta, gamma : unit cell parameters
U, V, W : cagliotti paramaters
2theta_0 : Instrumental zero shift error
eta1, eta2, eta3 : weight factor for gaussian vs lorentzian
@NOTE: All angles are always going to be in degrees
- >> @PARAMETERS:
- expt_spectrum: name of file or numpy array or Spectrum
class of experimental intensity
params: yaml file or dictionary or Parameter class phases: yaml file or dictionary or Phases_Lebail class wavelength: dictionary of wavelengths bkgmethod: method to estimate background. either spline or chebyshev
fit or filename or numpy array (last two options added 01/22/2021 SS)
- Intensity_init: if set to none, then some power of 10 is used.
User has option to pass in dictionary of structure factors. must ensure that the size of structure factor matches the possible reflections (added 01/22/2021 SS)
- CalcIobs()[source]
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
>> @DATE: 06/08/2020 SS 1.0 original >> @DETAILS: this is one of the main functions to partition the expt
intensities to overlapping peaks in the calculated pattern
- property HL
- property Hcag
- Refine()[source]
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
>> @DATE: 05/19/2020 SS 1.0 original >> @DETAILS: this routine performs the least squares refinement for all
variables which are allowed to be varied.
- RefineCycle(print_to_screen=True)[source]
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
- >> @DATE: 06/08/2020 SS 1.0 original
01/28/2021 SS 1.1 added optional print_to_screen argument
- >> @DETAILS: this is one refinement cycle for the least squares,
typically few 10s to 100s of cycles may be required for convergence
- property SL
- property U
- property V
- property W
- property X
- property Y
- property alpha0
- property alpha1
- property background
- property beta0
- property beta1
- property bkgmethod
- calcRwp(params)[source]
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
>> @DATE: 05/19/2020 SS 1.0 original >> @DETAILS: this routine computes the rwp for a set of parameters.
the parameters are used to set the values in the LeBail class too
- property calc_Iobs_fcn
- property cheb_coef
- property cheb_init_coef
- property cheb_polynomial
- computespectrum()[source]
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
>> @DATE: 06/08/2020 SS 1.0 original >> @DETAILS: compute the simulated spectrum
- property computespectrum_fcn
- dump_hdf5(file)[source]
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
>> @DATE: 01/19/2021 SS 1.0 original >> @DETAILS: write out the hdf5 file with all the spectrum, parameters
and phases pecified by filename or h5py.File object
- property eta_fwhm
- property gamma
- property init_bkg
- initialize_Icalc()[source]
@DATE 01/22/2021 SS modified the function so Icalc can be initialized with a dictionary of structure factors
- initialize_bkg()[source]
the cubic spline seems to be the ideal route in terms of determining the background intensity. this involves selecting a small (~5) number of points from the spectrum, usually called the anchor points. a cubic spline interpolation is performed on this subset to estimate the overall background. scipy provides some useful routines for this
the other option implemented is the chebyshev polynomials. this basically automates the background determination and removes the user from the loop which is required for the spline type background.
- property params
- property peakshape
- property phases
- property shft
- property spectrum_expt
- property spectrum_sim
- splinefit(x, y, tth)[source]
03/08/2021 SS adding tth as input. this is the list of points for which background is estimated
- property trns
- property tth_list
- updatespectrum()[source]
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
- >> @DATE: 11/23/2020 SS 1.0 original
03/05/2021 SS 1.1 added computation and update of Rwp
- >> @DETAILS: this routine computes the spectrum for an updated list of
parameters intended to be used for sensitivity and identifiability analysis
- property weights
- property zero_error
- class hexrd.wppf.WPPF.Rietveld(expt_spectrum=None, params=None, phases=None, wavelength={'kalpha1': [valWUnit('lp', 'LENGTH', 0.15406, 'nm'), 1.0], 'kalpha2': [valWUnit('lp', 'LENGTH', 0.154443, 'nm'), 0.52]}, bkgmethod={'spline': None}, peakshape='pvfcj', shape_factor=1.0, particle_size=1.0, phi=0.0)[source]
Bases:
object
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
- >> @DATE: 01/08/2020 SS 1.0 original
- 07/13/2020 SS 2.0 complete rewrite to include new
parameter/material/pattern class
- 02/01/2021 SS 2.1 peak shapes from Thompson,Cox and Hastings
formula using X anf Y parameters for the lorentzian peak widths
- >> @DETAILS: this is the main rietveld class and contains all the refinable
parameters for the analysis. the member classes are as follows (in order of initialization):
Spectrum contains the experimental spectrum
- Background contains the background extracted from
spectrum
Refine contains all the machinery for refinement
- property Hcag
- property P
- property Ph
- Refine()[source]
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
>> @DATE: 05/19/2020 SS 1.0 original >> @DETAILS: this routine performs the least squares refinement for all
variables that are allowed to be varied.
- property U
- property V
- property W
- property X
- property Xe
- property Xs
- property Y
- property Ye
- property background
- property bkgmethod
- calcRwp(params)[source]
- >> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab,
>> @DATE: 05/19/2020 SS 1.0 original >> @DETAILS: this routine computes the weighted error between
calculated and experimental spectra. goodness of fit is also calculated. the weights are the inverse squareroot of the experimental intensities
- property calc_Iobs_fcn
- property cheb_coef
- property cheb_init_coef
- property cheb_polynomial
- computespectrum()[source]
>> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab >> @EMAIL: saransh1@llnl.gov >> @DATE: 06/08/2020 SS 1.0 original >> @DETAILS: compute the simulated spectrum
- property computespectrum_fcn
- property eta_fwhm
- property gamma
- property init_bkg
- initialize_bkg()[source]
the cubic spline seems to be the ideal route in terms of determining the background intensity. this involves selecting a small (~5) number of points from the spectrum, usually called the anchor points. a cubic spline interpolation is performed on this subset to estimate the overall background. scipy provides some useful routines for this
the other option implemented is the chebyshev polynomials. this basically automates the background determination and removes the user from the loop which is required for the spline type background.
- property params
- property peakshape
- property phases
- property scale
- property spectrum_expt
- property spectrum_sim
- splinefit(x, y, tth)[source]
03/08/2021 SS adding tth as input. this is the list of points for which background is estimated
- property tth_list
- property weights
- property zero_error
- hexrd.wppf.WPPF.extract_intensities(polar_view, tth_array, params=None, phases=None, wavelength={'kalpha1': valWUnit('lp', 'LENGTH', 0.15406, 'nm'), 'kalpha2': valWUnit('lp', 'LENGTH', 0.154443, 'nm')}, bkgmethod={'chebyshev': 10}, intensity_init=None, termination_condition={'max_iter': 100, 'rwp_perct_change': 0.05}, peakshape='pvtch')[source]
- >> @AUTHOR: Saransh Singh, Lanwrence Livermore National Lab,
- >> @DATE: 01/28/2021 SS 1.0 original
03/03/2021 SS 1.1 removed detector_mask since polar_view is now a masked array
- >> @DETAILS: this function is used for extracting the experimental pole
figure intensities from the polar 2theta-eta map. The workflow is to simply run the LeBail class, in parallel, over the different azimuthal profiles and return the Icalc values for the different wavelengths in the calculation. For now, the multiprocessing is done using the multiprocessing module which comes natively with python. Extension to MPI will be done later if necessary.
- >> @PARAMS polar_view: mxn array with the polar view. the parallelization
is done !!! this is now a masked numpy array !!! over “m” i.e. the eta dimension
- tth_array: nx1 array with two theta values at each sampling
point
- params: parameter values for the LeBail class. Could be in
the form of yaml file, dictionary or Parameter class
- phases: materials to use in intensity extraction. could be
a list of material objects, or file or dictionary
- wavelength: dictionary of wavelengths to be used in the
computation
- bkgmethod: “spline” or “chebyshev” or “snip”
default is chebyshev
- intensity_init: initial intensities for each reflection.
If none, then it is specified to some power of 10 depending on maximum intensity in spectrum (only used for powder simulator)
- hexrd.wppf.WPPF.join_regions(vector_list, global_index, global_shape)[source]
@author Saransh Singh Lawrence Livermore National Lab @date 03/08/2021 SS 1.0 original @details utility function for joining different pieces of masked array into one masked array
- hexrd.wppf.WPPF.separate_regions(masked_spec_array)[source]
utility function for separating array into separate islands as dictated by mask. this function was taken from stackoverflow https://stackoverflow.com/questions/43385877/ efficient-numpy-subarrays-extraction-from-a-mask
- hexrd.wppf.WPPF.single_azimuthal_extraction(expt_spectrum, params=None, phases=None, wavelength={'kalpha1': valWUnit('lp', 'LENGTH', 0.15406, 'nm'), 'kalpha2': valWUnit('lp', 'LENGTH', 0.154443, 'nm')}, bkgmethod={'chebyshev': 10}, intensity_init=None, termination_condition=None, peakshape='pvtch')[source]