pymatgen.core.spectrum module¶

This module defines classes to represent any type of spectrum, essentially any x y value pairs.

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.

Parameters
• 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().__init__( x, y, arg1, arg2, kwarg1=val1, ..). This guarantees the +, -, *, etc. operators work properly.

• **kwargs – Same as that for *args.

XLABEL = 'x'[source]
YLABEL = 'y'[source]
copy()[source]
Returns

Copy of Spectrum object.

get_interpolated_value(x)[source]

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

Parameters
• 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.

smear(sigma)[source]

Apply Gaussian smearing to spectrum y value.

Parameters

sigma – Std dev for Gaussian smear function