pymatgen.core.spectrum module

class Spectrum(x, y, *args, **kwargs)[source]

Bases: monty.json.MSONable

Base class for any type of xas, essentially just x, y values. Examples include XRD patterns, XANES, EXAFS, NMR, DOS, etc.

Implements basic tools like application of smearing, normalization, addition multiplication, etc.

Subclasses should extend this object and ensure that super is called with ALL args and kwargs. That ensures subsequent things like add and mult work properly.

  • x (ndarray) – A ndarray of N values.
  • y (ndarray) – A ndarray of N x k values. The first dimension must be the same as that of x. Each of the k values are interpreted as
  • *args – All subclasses should provide args other than x and y when calling super, e.g., super(Subclass, self).__init__( x, y, arg1, arg2, kwarg1=val1, ..). This guarantees the +, -, *, etc. operators work properly.
  • **kwargs – Same as that for *args.
XLABEL = 'x'
YLABEL = 'y'
Returns:Copy of Spectrum object.

Returns an interpolated y value for a particular x value.

Parameters:x – x value to return the y value for
Returns:Value of y at x
normalize(mode='max', value=1)[source]

Normalize the spectrum with respect to the sum of intensity

  • mode (str) – Normalization mode. Supported modes are “max” (set the max y value to value, e.g., in XRD patterns), “sum” (set the sum of y to a value, i.e., like a probability density).
  • value (float) – Value to normalize to. Defaults to 1.

Apply Gaussian smearing to spectrum y value.

Parameters:sigma – Std dev for Gaussian smear function