diffpy.utils.parsers package¶
Various utilities related to data parsing and manipulation.
diffpy.utils.parsers.loaddata module¶

class
diffpy.utils.parsers.loaddata.
TextDataLoader
(minrows=None, usecols=None, skiprows=None)[source]¶ Bases:
object
Smart loading of a text data with possibly multiple datasets.

minrows
= 10¶

skiprows
= None¶

usecols
= None¶


diffpy.utils.parsers.loaddata.
loadData
(filename, minrows=10, **kwargs)[source]¶ Find and load data from a text file.
The data reading starts at the first matrix block of at least minrows rows and constant number of columns. This seems to work for most of the datafiles including those generated by PDFGetX2.
filename – name of the file we want to load data from. minrows – minimum number of rows in the first data block.
All rows must have the same number of floating point values. usecols – zerobased index of columns to be loaded, by default use
 all detected columns. The reading skips data blocks that do not have the usecolsspecified columns.
 unpack – return data as a sequence of columns that allows tuple
 unpacking such as x, y = loadData(FILENAME, unpack=True). Note transposing the loaded array as loadData(FILENAME).T has the same effect.
kwargs – keyword arguments that are passed to numpy.loadtxt
Return a numpy array of the data. See also numpy.loadtxt for more details.
diffpy.utils.parsers.resample module¶
Various utilities related to data parsing and manipulation.

diffpy.utils.parsers.resample.
resample
(r, s, dr)[source]¶ Resample a PDF on a new grid.
This uses the WhittakerShannon interpolation formula to put s1 on a new grid if dr is less than the sampling interval of r1, or linear interpolation if dr is greater than the sampling interval of r1.
r – The rgrid used for s1 s – The signal to be resampled dr – The new sampling interval
Returns resampled (r, s)

diffpy.utils.parsers.resample.
wsinterp
(x, xp, fp, left=None, right=None)[source]¶ Onedimensional WhittakerShannon interpolation.
This uses the WhittakerShannon interpolation formula to interpolate the value of fp (array), which is defined over xp (array), at x (array or float).
Returns the interpolated array with dimensions of x.