\(\newcommand{\AA}{\text{Å}}\)
CRYSTALpytools.spectra module
Classes and methods for spectra.
- class XRD(theta, spectra)
Bases:
object
The class for X-ray diffraction spectra.
- Parameters:
theta (array) – 2:math:`theta` values in degree.
spectra (array) – Spectra intensities.
- classmethod from_file(output, option='LP')
Read XRD spectra from the standard screen output of properties calculation.
- Parameters:
output (str) – Output filename.
option (str) – ‘NC’ for no correction (The ‘INTENS’ col); ‘LP’ for Lorentz and polarization effects (‘INTENS-LP’) and ‘DW’ for LP with Debye-Waller thermal factors (‘INTENS-LP-DW’).
- Returns:
cls (XRD)
- plot(theta_range=[], normalize=True, title=None, figsize=[6.4, 4.8], fontsize=14, **kwargs)
Plot XRD spectra.
- Parameters:
theta_range (list) – 1*2 list of theta range in degree.
normalize (bool) – Normalize the maximum intensity to 100.
title (str|None) – The title of the plot. ‘None’ for no title.
figsize (list) – Matplotlib figure size.
fontsize (int) – Fontsize of the axis label and title.
**kwargs – Other parameters passed to matplotlib
Axes.plot()
method.
- Returns:
fig (Figure) – Matplotlib figure.
- class IR(freq, absorb, reflec, type, unit='cm-1')
Bases:
object
The class for infrared spectrum. Unit: in principle, should always in ‘cm \(^{-1}\)’.
- Parameters:
freq (array) – Frequencies. Must be commensurate with unit.
absorb (array) – Absorbance spectrum, nType*nFreq array.
reflec (array) – Reflectance spectrum along inequivalent polarization directions (periodic systems only), nDir*nFreq array.
type (str) – ‘molecule’ or ‘crystal’
unit (str) – ‘cm-1’ or ‘THz’.
- classmethod from_file(specfile, output=None)
Generate an
IR
object from output and ‘IRSPEC.DAT’ files of CRYSTAL.- Parameters:
specfile (str) – The ‘IRSPEC.DAT’ file.
- Returns:
cls (IR)
- plot(unit='cm-1', option='LG', normalize=True, REFL_overlap=True, shift=0, label=None, color=None, linestyle=None, linewidth=None, x_range=[], title=None, figsize=[6.4, 4.8], legend='upper left', sharey=True, fontsize=14, fig=None, **kwargs)
Plot IR spectra into the same axis.
- Parameters:
unit (str) – X axis unit. ‘cm \(^{-1}\)’ or ‘nm’.
option (str) – Broadening method. ‘LG’ for Lorentzian-Gaussian, ‘V’ for Voigt, ‘RS’ for Rayleigh spherical particles, ‘RE’ for Rayleigh with elipsoid particles, ‘REFL’ for reflectance spectra with ‘LG’. Periodic systems only.
normalize (bool) – Normalize the maximum intensity to 100.
REFL_overlap (bool) – For ``option=’REFL’`` only If more than 1 inequivalent directions exists, whether to plot REFL data into the same plot or into subplots.
shift (float) – For ``option=’REFL’`` and ``REFL_overlap=False`` only If multiple spectra are plotted, shift them up by the given value. Shift length is the value after normalization if
normalize=True
.label (list|str|None) – For ``option=’REFL’`` only List of plot labels. ‘None’ for the default values (’# <number>’) and string for prefix the string before number. Otherwise should be a 1*nPlot list.
color (list|str|None) – For ``option=’REFL’`` only If str, use the same color for all the plot lines. If 1*nPlot, use the color defined for every plot line. ‘None’ for default values (matplotlib Tableau Palette).
linestyle (list|str|None) – For ``option=’REFL’`` only See explanations of
color
.linewidth (list|float|None) – For ``option=’REFL’`` only See explanations of
color
.x_range (list) – 1*2 list of x axis range.
title (str|None) – The title of the plot. ‘None’ for no title.
figsize (list) – Matplotlib figure size.
legend (str|None) – Location of legend. None for not adding legend.
sharey (bool) – Whether to share the y-axis among subplots. Share x is enforced.
fontsize (int) – Fontsize of the axis label and title.
fig (Figure) – Developer Only Matplotlib figure object.
**kwargs – Other parameters passed to matplotlib
Axes.plot()
method.
- Returns:
fig (Figure) – Matplotlib figure.
- _set_unit(unit)
Set unit of frequency.
- Parameters:
unit (str) – ‘cm-1’ or ‘THz’
- class Raman(freq, poly, single, unit='cm-1')
Bases:
object
The class for Raman spectrum. Unit: in principle, should always in ‘cm \(^{-1}\)’.
- Parameters:
freq (array) – Frequencies. Must be commensurate with unit.
poly (array) – Polycrystalline isotropic spectrum, 3*nFreq array for total, parallel and perpendicular directions.
single (array) – Single crystal spectrum, 6*nFreq array for xx, xy, xz, yy, yz, zz directions.
unit (str) – ‘cm-1’ or ‘THz’.
- classmethod from_file(specfile, output=None)
Generate an
Raman
object from output and ‘RAMSPEC.DAT’ files of CRYSTAL.- Parameters:
specfile (str) – The ‘RAMSPEC.DAT’ file.
- Returns:
cls (IR)
- plot(option='poly', normalize=True, overlap=True, direction=['xx', 'xy', 'xz', 'yy', 'yz', 'zz'], shift=0, label=None, color=None, linestyle=None, linewidth=None, x_range=[], title=None, figsize=[6.4, 4.8], legend='upper left', sharey=True, fontsize=14, fig=None, ax_index=None, **kwargs)
Plot Raman spectra into the same axis.
- Parameters:
option (str) – ‘tot’, ‘poly’ or ‘single’. ‘tot’ plots the total raman spectrum of polycrystalline material. ‘poly’ plots total, parallel and perpendicular spectra. ‘single’ plots spectra along xx, xy, xz, yy, yz, zz directions.
normalize (bool) – Normalize the maximum intensity to 100.
overlap (bool) – If more than 1 inequivalent directions exists, whether to plot spectra into the same plot or into subplots.
direction (list|str) – ``option=’single’`` only Specify the directions of single crystal spectra to plot.
shift (float) – If multiple spectra are plotted, shifting them up by the given value.
label (list|str|None) – List of plot labels. ‘None’ for the default values (‘total’, ‘parallel’ series or ‘xx’ ‘yy’ series) and string for prefix the string before default values. Otherwise should be a 1*nPlot list.
color (list|str|None) – If str, use the same color for all the plot lines. If 1*nPlot, use the color defined for every plot line. ‘None’ for default values (matplotlib Tableau Palette).
linestyle (list|str|None) – See explanations of
color
.linewidth (list|float|None) – See explanations of
color
.x_range (list) – 1*2 list of x axis range.
title (str|None) – The title of the plot. ‘None’ for no title.
figsize (list) – Matplotlib figure size.
legend (str|None) – Location of legend. None for not adding legend.
sharey (bool) – Whether to share the y-axis among subplots. Share x is enforced.
fontsize (int) – Fontsize of the axis label and title.
fig (Figure) – Developer Only Matplotlib figure object.
ax_index (int) – Developer Only Index of the Axes object in fig.
**kwargs – Other parameters passed to matplotlib
Axes.plot()
method.
- Returns:
fig (Figure) – Matplotlib figure.
- _set_unit(unit)
Set unit of frequency.
- Parameters:
unit (str) – ‘cm-1’ or ‘THz’