Data.decompose

Data.decompose(xcol: str | int | Pattern | Sequence[int | str | Pattern] | None = None, ycol: str | int | Pattern | Sequence[int | str | Pattern] | None = None, sym: str | int | Pattern | Sequence[int | str | Pattern] | None = None, asym: str | int | Pattern | Sequence[int | str | Pattern] | None = None, replace: bool = True, hysteretic: bool = False, **kwargs: Mapping[str, Any]) Data

Given (x,y) data, decomposes the y part into symmetric and antisymmetric contributions in x.

Parameters:

datafile (Data) – If not being used as a bound menthod, specifies the instance of Data to work with.

Keyword Arguments:
  • xcol (index) – Index of column with x data - defaults to first x column in datafile.setas

  • ycol (index or list of indices) – indices of y column(s) data

  • sym (index) – Index of column to place symmetric data in default, append to end of data

  • asym (index) – Index of column for asymmetric part of ata. Defaults to appending to end of data

  • replace (bool) – Overwrite data with output (true)

  • hysteretic (book) – Look separately for outgoing and incoming data first.

  • **kwargs – Other keyword arguments.

Returns:

datafile – The newly modified AnalysisMixin.

Example

"""Decompose Into symmetric and antisymmetric parts example."""

from numpy import array, linspace, reshape

from Stoner import Data
from Stoner.tools import format_val

x = linspace(-10, 10, 201)
y = 0.3 * x**3 - 6 * x**2 + 11 * x - 20
d = Data(x, y, setas="xy", column_headers=["X", "Y"])
d.decompose()
d.setas = "xyyy"
coeffs = d.polyfit(polynomial_order=3)
str_coeffs = [format_val(c, mode="eng", places=1) for c in coeffs.ravel()]
str_coeffs = reshape(array(str_coeffs), coeffs.shape)
d.plot()
d.text(
    -6,
    -800,
    f"Coefficients\n{str_coeffs}",
    fontdict={"size": "x-small"},
)
d.ylabel = "Data"
d.title = "Decompose Example"

(png, hires.png, pdf)

../_images/decompose.png