schrodinger.application.matsci.spectra module

Copyright Schrodinger, LLC. All rights reserved.

exception schrodinger.application.matsci.spectra.SpectrumDataException

Bases: Exception

schrodinger.application.matsci.spectra.read_xy_spectrum_data_file(filename: str) Tuple[List[float], List[float]]

Return the frequencies and intensities from the given experimental spectrum file.

Parameters

filename – the name of the file to read, can be [.csv, .txt, .prn, .convolution]

Returns

the frequencies and intensities lists

Raises
schrodinger.application.matsci.spectra.rubberband_method(x_data, y_data, parameters)

Apply a rubberband to the data

Parameters
  • x_data (list) – list of 2 theta values

  • y_data (list) – list of intensity values

  • parameters (SimpleNamespace) – all the tunable parameters for the method

Return type

list

Returns

list of intensity values

schrodinger.application.matsci.spectra.least_square_method(x_data, y_data, parameters)

Smooth data using least sqaure method

Parameters
  • x_data (list) – list of 2 theta values

  • y_data (list) – list of intensity values

  • parameters (SimpleNamespace) – all the tunable parameters for the method

Return type

list

Returns

list of intensity values

schrodinger.application.matsci.spectra.savgol_method(x_data, y_data, parameters)

Apply a Savitzky-Golay filter to the data

Parameters
  • x_data (list) – list of 2 theta values

  • y_data (list) – list of intensity values

  • parameters (SimpleNamespace) – all the tunable parameters for the method

Return type

list

Returns

list of intensity values

schrodinger.application.matsci.spectra.convert_nm_and_wavenumber(value)

Convert value in wavenumbers to nanometers or vice versa, the conversion is the same.

Parameters

value (int or float) – Number to convert

Return type

float

Returns

value converted from wavenumbers to nanometers or vice versa

schrodinger.application.matsci.spectra.get_file_data(filename)

Read the data from the file

Parameters

name (str) – The name for the spectrum. If none, it will be derived from the file name.

Return type

tuple of (str, str, schrodinger.infra.table.Table)

Returns

First two members of the tuple are the s_j_x_lable and s_j_y_label properties. The third member of the tuple is a Table object from the schrodinger.infra.table module. This object holds the actual data.

schrodinger.application.matsci.spectra.gen_xvals(smin, smax, stride, stride_nm)

Generates a set of x-values (in wavenumbers) for use in generating a curve from stick spectra. Can specify constant intervals in either wavenumber or nm space via stride_nm arg.

Parameters
  • smin (int) – The minimum x-value in wavenumbers.

  • smax (int) – The maximum x-value in wavenumbers.

  • stride (float) – Compute the intensity every stride values of x. Can be in wavenumbers or nm. See stride_nm arg.

  • stride_nm (bool) – if True, “stride” is given in nm. Default is wavenumbers. Results in a series of x-values that have non-constant intervals in wavenumber space, but constant in nm space.

Rtype xvals

Numpy ndarray, type float

Return xvals

Specifies wavenumbers at which to calculate y-values

schrodinger.application.matsci.spectra.find_closest_xval(pos, xvals, stride, stride_nm)

Finds index of xvals array corresponding to the x-value closest to peak position.

Parameters
  • pos (float) – Position of peak in wavenumbers

  • xvals (Numpy ndarray, type float) – Array of x-value in units of wavenumbers

  • stride (float) – Distance between each x-value in xvals. Given in either wavenumber or nm, see stride_nm arg.

  • stride_nm (bool) – if True, “stride” is given in nm. Default is wavenumbers. Results in a series of x-values that have non-constant intervals in wavenumber space, but constant in nm space.

Rtype spot

int

Return spot

index of xvals array corresponding to the x-value closest to peak position

schrodinger.application.matsci.spectra.generate_curve(mytable, line_width, xprop, intensity, x_scale=1.0, uvvis=False, smin=None, smax=None, stride=None, stride_nm=False, function='Lorentzian', line_width_nm=False, offsets=None)

Generate a full curve for a series of frequency/intensity lines. The curve is generated by broadening the lines with Gaussian or Lorentzian curves centered on each line, and summing the curves together.

Broadening is done in wavenumber space and so returns xvalues in wavenumber space. Assumes input data’s x-values are in wavenumbers UNLESS uvvis=True. If uvvis=True, assumes input x-values are in eV and converts them to wavenumbers for curve generation.

Parameters
  • mytable (table.Table object) – table of raw data

  • line_width (float) – the half-bandwidth to use when generating spectrum

  • x_scale (float) – the x-axis scale factor

  • intensity (str) – The label of the intensity property in mytable

  • xprop (str) – The label of the x-axis property in mytable

  • uvvis (bool) – True if this is a uv/vis spectrum, False if not (default is False, vibrational spectrum)

  • smin (int) – The minimum x-value in wavenumbers.

  • smax (int) – The maximum x-value in wavenumbers.

  • stride (float) – Compute the intensity every stride values of x.

  • stride_nm (bool) – if True, “stride” is given in nm. Default is wavenumbers. Results in a series of x-values that have non-constant intervals in wavenumber space, but constant in nm space.

  • function (str) – The function used to broaden singular intensity values to a full spectrum curve. Default is Lorentzian, other option is Gaussian. Use the LORENTZIAN or GAUSSIAN module constants.

  • line_width_nm (bool) – Linewidth is given in nm. Default is wavenumbers. Not used for non-UV/Vis spectra.

  • offsets (list) – A list of floats whose length is equal to the number of rows in the table. These floats will be used to shift the values of x-positions of the curve. Defaults to None, where no offsets are used.

Return type

tuple of 1-D numpy arrays

Returns

(xvalues, yvalues) with xvalues running from smin to smax with Xn = X(n-1) + stride. Note that the X unit will be wavenumbers for all spectra.

exception schrodinger.application.matsci.spectra.PowderDiffractionException

Bases: Exception

schrodinger.application.matsci.spectra.get_powder_diffraction_pattern(st, wave_length=None, debye_waller_factors=None, two_theta_range=(0, 90), compute_intensities=True)

Get a pymatgen powder diffraction pattern.

Parameters
  • st (schrodinger.structure.Structure) – the structure

  • wave_length (float) – the wave length in Ang.

  • debye_waller_factors (dict) – the temperature dependent Debye-Waller factors, keys are elemental symbols, values are factors in Ang.^2

  • two_theta_range (tuple or None) – (min, max) pair tuple specifying the x-axis two theta range in degrees over which to calculate the powder diffraction pattern or None if it is to be calculated at all diffracted beams within the limiting sphere of 2 * radius / wave_length

  • compute_intensities (bool) – If True, compute peaks intensities (requires atoms in the structure), otherwise only peak locations

Raise

PowderDiffractionException if there is an issue

Return type

pymatgen.analysis.diffraction.core.DiffractionPattern

Returns

the pymatgen powder diffraction pattern

class schrodinger.application.matsci.spectra.SpectrumFile(data_file_name, spm_file_name, spectrum_data=None)

Bases: object

Manage a spectrum file.

HEADERS = {}
COLUMNS = {}
__init__(data_file_name, spm_file_name, spectrum_data=None)

Create an instance.

Parameters
  • data_file_name (str) – the text file containing the data

  • spm_file_name (str) – the name of the *spm file to create

  • spectrum_data (list of lists) – Spectrum data. If provided, used to fill table/write file. Otherwise, data obtained from data_file_name

static getData(data_file_name, separator=None, types=None)

Return the data from the given data file.

Parameters
  • data_file_name (str) – the text file containing the data

  • separator (str) – the data separator

  • types (list) – a list of types used to type cast the data

Return type

list

Returns

contains data tuples

write()

Write the *spm file.

class schrodinger.application.matsci.spectra.PowderDiffractionFile(data_file_name, spm_file_name, spectrum_data=None)

Bases: schrodinger.application.matsci.spectra.SpectrumFile

Manage a powder diffraction pattern file.

TWO_THETA_KEY = 'r_matsci_Two_Theta_(degrees)'
TWO_THETA_TITLE = '2*Theta/deg.'
INTENSITY_KEY = 'r_matsci_Intensity'
INTENSITY_TITLE = 'Intensity'
HKLS_KEY = 's_matsci_HKLs'
HKLS_TITLE = 'HKLs'
MULTIPLICITIES_KEY = 's_matsci_HKL_Multiplicities'
MULTIPLICITIES_TITLE = 'Mults'
INTERPLANAR_SPACING_KEY = 'r_matsci_Interplanar_Spacing_(Ang.)'
INTERPLANAR_SPACING_TITLE = 'd_HKL/Ang.'
SPECTRUM_KEY = 's_j_spectrum_type'
SPECTRUM_TITLE = 'Powder Diffraction Pattern'
X_KEY = 's_j_x_label'
X_ALIAS = 'r_matsci_Two_Theta_(degrees)'
Y_KEY = 's_j_y_label'
Y_ALIAS = 'r_matsci_Intensity'
HEADERS = {'s_j_spectrum_type': 'Powder Diffraction Pattern', 's_j_x_label': 'r_matsci_Two_Theta_(degrees)', 's_j_y_label': 'r_matsci_Intensity'}
COLUMNS = {'r_matsci_Intensity': 'Intensity', 'r_matsci_Interplanar_Spacing_(Ang.)': 'd_HKL/Ang.', 'r_matsci_Two_Theta_(degrees)': '2*Theta/deg.', 's_matsci_HKL_Multiplicities': 'Mults', 's_matsci_HKLs': 'HKLs'}
SEPARATOR = '; '
TYPES = [<class 'float'>, <class 'float'>, <class 'str'>, <class 'str'>, <class 'float'>]
static getData(data_file_name, separator=None, types=None)

Return the data from the given data file.

Parameters
  • data_file_name (str) – the text file containing the data

  • separator (str) – the data separator

  • types (list) – a list of types used to type cast the data

Return type

list

Returns

contains data tuples

schrodinger.application.matsci.spectra.write_powder_diffraction_pattern(st, wave_length=None, debye_waller_factors=None, two_theta_range=(0, 90), file_name=None)

Write a powder diffraction pattern file.

Parameters
  • st (schrodinger.structure.Structure) – the structure

  • wave_length (float) – the wave length in Ang.

  • debye_waller_factors (dict) – the temperature dependent Debye-Waller factors, keys are elemental symbols, values are factors in Ang.^2

  • two_theta_range (tuple or None) – (min, max) pair tuple specifying the x-axis two theta range in degrees over which to calculate the powder diffraction pattern or None if it is to be calculated at all diffracted beams within the limiting sphere of 2 * radius / wave_length

  • file_name (str) – the file name to which the pattern will be written

Return type

str

Returns

the file name to which the pattern was written

class schrodinger.application.matsci.spectra.VCD_Spectrum(data_file_name, spm_file_name, spectrum_data=None)

Bases: schrodinger.application.matsci.spectra.SpectrumFile

Manage a VCD (Vibrational Circular Dichroism) file.

Note that this class expects its data to be provided upon initialization via SpectrumFile’s init() fxn’s spectrum_data argument, as opposed to filled after initialization via reading a file.

In the future, if we want to initialize via reading a file, we’ll have to implement a getData() as in PowderDiffractionFile.

FREQ_KEY = 'r_j_Frequency_(cm-1)'
FREQ_TITLE = 'Frequency (cm-1)'
ROT_STR_KEY = 'r_j_Rotational_Strength_(10**-40_esu**2_cm**2)'
ROT_STR_TITLE = 'Rotational Strength (10**-40 esu**2 cm**2)'
SPECTRUM_KEY = 's_j_spectrum_type'
SPECTRUM_TITLE = 'Vibrational Circular Dichroism'
X_KEY = 's_j_x_label'
X_ALIAS = 'r_j_Frequency_(cm-1)'
Y_KEY = 's_j_y_label'
Y_ALIAS = 'r_j_Rotational_Strength_(10**-40_esu**2_cm**2)'
HEADERS = {'s_j_spectrum_type': 'Vibrational Circular Dichroism', 's_j_x_label': 'r_j_Frequency_(cm-1)', 's_j_y_label': 'r_j_Rotational_Strength_(10**-40_esu**2_cm**2)'}
COLUMNS = {'r_j_Frequency_(cm-1)': 'Frequency (cm-1)', 'r_j_Rotational_Strength_(10**-40_esu**2_cm**2)': 'Rotational Strength (10**-40 esu**2 cm**2)', 'r_j_edtm_x': 'edtm x', 'r_j_edtm_y': 'edtm y', 'r_j_edtm_z': 'edtm z', 'r_j_mdtm_x': 'mdtm x', 'r_j_mdtm_y': 'mdtm y', 'r_j_mdtm_z': 'mdtm z', 's_j_Symmetry': 'Symmetry'}
TYPES = [<class 'float'>, <class 'float'>, <class 'str'>, <class 'float'>, <class 'float'>, <class 'float'>, <class 'float'>, <class 'float'>, <class 'float'>]
class schrodinger.application.matsci.spectra.ECD_Spectrum(data_file_name, spm_file_name, spectrum_data=None)

Bases: schrodinger.application.matsci.spectra.SpectrumFile

Manage a ECD (Electronic Circular Dichroism) file.

Note that this class expects its data to be provided upon initialization via SpectrumFile’s init() fxn’s spectrum_data argument, as opposed to filled after initialization via reading a file.

In the future, if we want to initialize via reading a file, we’ll have to implement a getData() as in PowderDiffractionFile.

ENERGY_KEY = 'r_j_Electronic_Circular_Dichroism_Energy_(eV)'
ENERGY_TITLE = 'ECD Energy (eV)'
INTENSITY_KEY = 'r_j_Molar_Circular_Dichroism_(L_mol-1_cm-1)'
INTENSITY_TITLE = 'Molar Circular Dichroism (L mol-1 cm-1)'
SPECTRUM_KEY = 's_j_spectrum_type'
SPECTRUM_TITLE = 'Electronic Circular Dichroism'
X_KEY = 's_j_x_label'
X_ALIAS = 'r_j_Electronic_Circular_Dichroism_Energy_(eV)'
Y_KEY = 's_j_y_label'
Y_ALIAS = 'r_j_Molar_Circular_Dichroism_(L_mol-1_cm-1)'
HEADERS = {'s_j_spectrum_type': 'Electronic Circular Dichroism', 's_j_x_label': 'r_j_Electronic_Circular_Dichroism_Energy_(eV)', 's_j_y_label': 'r_j_Molar_Circular_Dichroism_(L_mol-1_cm-1)'}
COLUMNS = {'r_j_Electronic_Circular_Dichroism_Energy_(eV)': 'ECD Energy (eV)', 'r_j_Molar_Circular_Dichroism_(L_mol-1_cm-1)': 'Molar Circular Dichroism (L mol-1 cm-1)', 's_j_Symmetry': 'Symmetry'}
TYPES = [<class 'float'>, <class 'float'>, <class 'str'>]
class schrodinger.application.matsci.spectra.UVVis_Spectrum(data_file_name, spm_file_name, spectrum_data=None)

Bases: schrodinger.application.matsci.spectra.SpectrumFile

Manage a UV-Vis file.

Note that this class expects its data to be provided upon initialization via SpectrumFile’s init() fxn’s spectrum_data argument, as opposed to filled after initialization via reading a file.

In the future, if we want to initialize via reading a file, we’ll have to implement a getData() as in PowderDiffractionFile.

ENERGY_KEY = 'r_j_Excitation_Energy_(eV)'
ENERGY_TITLE = 'Excitation Energy (eV)'
INTENSITY_KEY = 'r_j_Oscillator_Strength'
INTENSITY_TITLE = 'Oscillator Strength'
SPECTRUM_KEY = 's_j_spectrum_type'
SPECTRUM_TITLE = 'UV-Vis Spectrum'
X_KEY = 's_j_x_label'
X_ALIAS = 'r_j_Excitation_Energy_(eV)'
Y_KEY = 's_j_y_label'
Y_ALIAS = 'r_j_Oscillator_Strength'
HEADERS = {'s_j_spectrum_type': 'UV-Vis Spectrum', 's_j_x_label': 'r_j_Excitation_Energy_(eV)', 's_j_y_label': 'r_j_Oscillator_Strength'}
COLUMNS = {'r_j_Excitation_Energy_(eV)': 'Excitation Energy (eV)', 'r_j_Oscillator_Strength': 'Oscillator Strength', 's_j_Symmetry': 'Symmetry'}
TYPES = [<class 'float'>, <class 'float'>, <class 'str'>]
class schrodinger.application.matsci.spectra.IR_Spectrum(data_file_name, spm_file_name, spectrum_data=None)

Bases: schrodinger.application.matsci.spectra.SpectrumFile

Manage an IR (Infrared/Vibrational) file.

Note that this class expects its data to be provided upon initialization via SpectrumFile’s init() fxn’s spectrum_data argument, as opposed to filled after initialization via reading a file.

In the future, if we want to initialize via reading a file, we’ll have to implement a getData() as in PowderDiffractionFile.

FREQ_KEY = 'r_j_Frequency_(cm-1)'
FREQ_TITLE = 'Frequency (cm-1)'
INTENSITY_KEY = 'r_j_Intensity_(km/mol)'
INTENSITY_TITLE = 'Intensity (km/mol)'
SPECTRUM_KEY = 's_j_spectrum_type'
SPECTRUM_TITLE = 'Infrared Vibrational Frequencies'
X_KEY = 's_j_x_label'
X_ALIAS = 'r_j_Frequency_(cm-1)'
Y_KEY = 's_j_y_label'
Y_ALIAS = 'r_j_Intensity_(km/mol)'
HEADERS = {'s_j_spectrum_type': 'Infrared Vibrational Frequencies', 's_j_x_label': 'r_j_Frequency_(cm-1)', 's_j_y_label': 'r_j_Intensity_(km/mol)'}
COLUMNS = {'r_j_Frequency_(cm-1)': 'Frequency (cm-1)', 'r_j_Intensity_(km/mol)': 'Intensity (km/mol)', 's_j_Symmetry': 'Symmetry'}
TYPES = [<class 'float'>, <class 'float'>, <class 'str'>]
class schrodinger.application.matsci.spectra.RamanSpectrum(data_file_name, spm_file_name, spectrum_data=None)

Bases: schrodinger.application.matsci.spectra.IR_Spectrum

Manage a Raman vibrational spectrum file.

Note the inheritance from IR_Spectrum class. Some of the variables referenced below are defined there.

Note that this class expects its data to be provided upon initialization via SpectrumFile’s init() fxn’s spectrum_data argument, as opposed to filled after initialization via reading a file.

In the future, if we want to initialize via reading a file, we’ll have to implement a getData() as in PowderDiffractionFile.

INTENSITY_KEY = 'r_j_Intensity_(Angstrom**4)'
INTENSITY_TITLE = 'Intensity (Angstrom**4)'
SPECTRUM_TITLE = 'Raman Vibrational Frequencies'
Y_ALIAS = 'r_j_Intensity_(Angstrom**4)'
HEADERS = {'s_j_spectrum_type': 'Raman Vibrational Frequencies', 's_j_x_label': 'r_j_Frequency_(cm-1)', 's_j_y_label': 'r_j_Intensity_(Angstrom**4)'}
COLUMNS = {'r_j_Frequency_(cm-1)': 'Frequency (cm-1)', 'r_j_Intensity_(Angstrom**4)': 'Intensity (Angstrom**4)', 's_j_Symmetry': 'Symmetry'}
class schrodinger.application.matsci.spectra.NMRSpectrum(data_file_name, spm_file_name, spectrum_data=None)

Bases: schrodinger.application.matsci.spectra.SpectrumFile

Manage an NMR file.

Note that this class expects its data to be provided upon initialization via SpectrumFile’s init() fxn’s spectrum_data argument, as opposed to filled after initialization via reading a file.

FREQ_KEY = 'r_j_Frequency_(ppm)'
FREQ_TITLE = 'Chemical shift (ppm)'
INTENSITY_KEY = 'r_j_Intensity'
INTENSITY_TITLE = 'Intensity'
SPECTRUM_KEY = 's_j_spectrum_type'
SPECTRUM_TITLE = 'NMR Spectrum'
X_KEY = 's_j_x_label'
X_ALIAS = 'r_j_Frequency_(ppm)'
Y_KEY = 's_j_y_label'
Y_ALIAS = 'r_j_Intensity'
HEADERS = {'s_j_spectrum_type': 'NMR Spectrum', 's_j_x_label': 'r_j_Frequency_(ppm)', 's_j_y_label': 'r_j_Intensity'}
COLUMNS = {'r_j_Frequency_(ppm)': 'Chemical shift (ppm)', 'r_j_Intensity': 'Intensity'}
TYPES = [<class 'float'>, <class 'float'>]