matador.magres package

class matador.magres.MagresReferencer(structures_exp: Dict[str, Crystal], shifts_exp: List[Dict[str, List[float]]], species: str, structures: Optional[List[Crystal]] = None, warn_tolerance: float = 0.1)[source]

Bases: object

Class for referencing computed NMR chemical shielding tensors with experimental data on chemical shifts, and related plotting.

fit_model

The underlying statsmodel model.

Type:

statsmodels.regression.linear_model.WLS

fit_results

The results of the statsmodel fit.

Type:

statsmodels.regression.linear_model.RegressionResults

fit_intercept

The intercept of the fit.

Type:

float

fit_gradient

The gradient of the fit.

Type:

float

fit_rsquared

The R^2 value of the fit.

Type:

float

structures_exp

A dictionary of experimental structures, keyed by label

Type:

Dict[str, matador.crystal.crystal.Crystal]

shifts_exp

A dictionary of measured shifts with the same keys as structures_exp.

Type:

List[Dict[str, List[float]]]

species

The species of interest.

Type:

str

structures

An optional list of theoretical structures with computed shieldings to be referenced.

Type:

Optional[List[matador.crystal.crystal.Crystal]]

warn_tolerance

The maximum deviation from the ideal “-1” gradient above which to warn the user during the fit.

Type:

float

fit_model: WLS = None
fit_results: RegressionResults = None
fit_intercept: float
fit_gradient: float
fit_rsquared: float
structures_exp: Dict[str, Crystal]
shifts_exp: List[Dict[str, List[float]]]
species: str
structures: Optional[List[Crystal]]
warn_tolerance: float = 0.1
match_exp_structure_shifts(structure, shifts)[source]

For a model structure and a set of experimental shifts, match each site in the structure to the closest shift value, allowing for multiplicity.

Sets the weights to be used for each site based on the number of unique shifts/local environments in the structure.

Parameters:
  • structure – The model structure for each exp. shift.

  • shifts – An array of measured chemical shifts.

set_shifts_from_fit(structures)[source]

Set the chemical shifts of the given structures to the predicted values.

Parameters:

structures – A list of structures with computed shieldings.

fit()[source]

Construct a statsmodels weighted least squares model between experimental shifts and computed shieldings.

Sets the following attributes:

fit_model: The underlying statsmodel model. fit_results: The output of the statsmodel fit. fit_intercept: The intercept of the fit. fit_gradient: The gradient of the fit. fit_rsquared: The R^2 value of the fit.

predict(shieldings) Tuple[array, array][source]

Compute the predicted chemical shifts (and errors) for given chemical shieldings, based on the linear fit.

Returns:

A tuple of shift values and associated errors.

print_fit_summary()[source]

Print the fitted parameters and their errors.

plot_fit(ax=None, padding=100, figsize=None)[source]

Plot the fit of shifts vs shieldings to experimental data.

Parameters:
Returns:

The axis object used for plotting.

plot_fit_and_predictions(ax=None, padding=100)[source]

Make a plot of the fit and predictions for the experimental chemical shifts.

Parameters:

Submodules

matador.magres.referencer module

class matador.magres.referencer.MagresReferencer(structures_exp: Dict[str, Crystal], shifts_exp: List[Dict[str, List[float]]], species: str, structures: Optional[List[Crystal]] = None, warn_tolerance: float = 0.1)[source]

Bases: object

Class for referencing computed NMR chemical shielding tensors with experimental data on chemical shifts, and related plotting.

fit_model

The underlying statsmodel model.

Type:

statsmodels.regression.linear_model.WLS

fit_results

The results of the statsmodel fit.

Type:

statsmodels.regression.linear_model.RegressionResults

fit_intercept

The intercept of the fit.

Type:

float

fit_gradient

The gradient of the fit.

Type:

float

fit_rsquared

The R^2 value of the fit.

Type:

float

structures_exp

A dictionary of experimental structures, keyed by label

Type:

Dict[str, matador.crystal.crystal.Crystal]

shifts_exp

A dictionary of measured shifts with the same keys as structures_exp.

Type:

List[Dict[str, List[float]]]

species

The species of interest.

Type:

str

structures

An optional list of theoretical structures with computed shieldings to be referenced.

Type:

Optional[List[matador.crystal.crystal.Crystal]]

warn_tolerance

The maximum deviation from the ideal “-1” gradient above which to warn the user during the fit.

Type:

float

fit_model: WLS = None
fit_results: RegressionResults = None
fit_intercept: float
fit_gradient: float
fit_rsquared: float
structures_exp: Dict[str, Crystal]
shifts_exp: List[Dict[str, List[float]]]
species: str
structures: Optional[List[Crystal]]
warn_tolerance: float = 0.1
match_exp_structure_shifts(structure, shifts)[source]

For a model structure and a set of experimental shifts, match each site in the structure to the closest shift value, allowing for multiplicity.

Sets the weights to be used for each site based on the number of unique shifts/local environments in the structure.

Parameters:
  • structure – The model structure for each exp. shift.

  • shifts – An array of measured chemical shifts.

set_shifts_from_fit(structures)[source]

Set the chemical shifts of the given structures to the predicted values.

Parameters:

structures – A list of structures with computed shieldings.

fit()[source]

Construct a statsmodels weighted least squares model between experimental shifts and computed shieldings.

Sets the following attributes:

fit_model: The underlying statsmodel model. fit_results: The output of the statsmodel fit. fit_intercept: The intercept of the fit. fit_gradient: The gradient of the fit. fit_rsquared: The R^2 value of the fit.

predict(shieldings) Tuple[array, array][source]

Compute the predicted chemical shifts (and errors) for given chemical shieldings, based on the linear fit.

Returns:

A tuple of shift values and associated errors.

print_fit_summary()[source]

Print the fitted parameters and their errors.

plot_fit(ax=None, padding=100, figsize=None)[source]

Plot the fit of shifts vs shieldings to experimental data.

Parameters:
Returns:

The axis object used for plotting.

plot_fit_and_predictions(ax=None, padding=100)[source]

Make a plot of the fit and predictions for the experimental chemical shifts.

Parameters: