Utility Modules#

Despite the power of writing your own analyses, it seems likely that many of the analyses you’ll want to do won’t actually be that novel.

To that end, we furnish two modules of ‘canned’ approaches: RSoXS and fitting. User contributions are encouraged in this area.

RSoXS#

Tools in PyHyperScattering.util.RSoXS help with common resonant soft x-ray scattering analyses. The rsoxs accessor on DataArray objects provides helpers for chi slicing and for computing anisotropy. The AR() method returns the anisotropic ratio from one or two polarized measurements.

Example:

ar = data.rsoxs.AR()

or, with both polarizations available:

ar = pair.rsoxs.AR(calc2d=True)

See the PyHyperScattering.util.RSoXS API reference for details.

Fitting#

Fitting helpers live in PyHyperScattering.util.Fitting. The fit accessor stacks all dimensions except the chosen fit axis and applies a supplied function. Several ready-made fit functions are provided, including fit_lorentz(), fit_lorentz_bg() and fit_cos_anisotropy().

Example:

results = data.fit.apply(
    PyHyperScattering.util.Fitting.fit_lorentz_bg,
    guess=[0, 0, 0.0002, 0],
    pos_int_override=True,
)

See the PyHyperScattering.util.Fitting API reference for a full list of utilities.