skultrafast.utils

Module with various utility functions. Was called dv in older Versions.

Module Contents

Classes

LinRegResult

Linear regression result.

Functions

weighted_binning(x, arr, bins[, weights])

Bins a 1D array to given bins using weights.

simulate_binning([wrapped, fac])

Simulates

sigma_clip(data[, sigma, max_iter, axis, use_mad])

Masks outliers by iteratively removing points outside given

gauss_step(x, amp, center, sigma)

Returns the stepfunction (erf-style) for given arguments.

pfid_r4(T, om, om_10, T_2)

Calculates the PFID contribution for pure bleaching.

pfid_r6(T, om, om_10, om_21, T_2)

Calculates the PFID contribution for the shifted frequecy.

pfid(T, om, om_10, fac, om_21, T_2)

linreg_std_errors(A, y)

Calculates the solution and error terms in a linear regression.

ExpDecay(x, A1, tau1, c)

TwoExpDecay(x, A1, tau1, A2, tau2, c)

ThreeExpDecay(x, A1, tau1, A2, tau2, A3, tau3, c)

poly_bg_correction(wavelengths, data[, left, right, deg])

Fit and subtract baseline from given data

inbetween(a, lower, upper)

Returns index-array where a is between upper and lower

skultrafast.utils.weighted_binning(x, arr, bins, weights=None)[source]

Bins a 1D array to given bins using weights.

skultrafast.utils.simulate_binning(wrapped=None, *, fac=5)[source]

Simulates

skultrafast.utils.sigma_clip(data, sigma: float = 3, max_iter: int = 5, axis: int = -1, use_mad: bool = False)[source]

Masks outliers by iteratively removing points outside given standard deviations.

Parameters:
  • data (np.ndarray) – The data array.

  • sigma (float) – All data outside +/- sigma*std will be masked in each iteration.

  • max_iter (int) – How many iterations are done. If a new iteration does not mask new values, the function will break the loop.

Returns:

Array with outliers being masked.

Return type:

np.ma.MaskedArray

skultrafast.utils.gauss_step(x, amp: float, center: float, sigma: float)[source]

Returns the stepfunction (erf-style) for given arguments.

Parameters:
  • x (array) – Independent variable

  • amp (float) – Amplitude of the step

  • center (float) – Position of the step

  • sigma (float) – Width of the step

Returns:

The step functions

Return type:

array

skultrafast.utils.pfid_r4(T, om, om_10, T_2)[source]

Calculates the PFID contribution for pure bleaching.

See the PFID tutorial for a longer explanation. The function does broadcasting, hence it is possible to calculate the PFID contributions of serveral bands at once. For that, om_10 and T_2 must have the same shape.

Parameters:
  • T (1D-ndarry) – Delays between pump and probe. The formula assume a postive delays.

  • om (1D-ndarray) – Array of frequencies given in wavenumbers (cm-1).

  • om_10 (1D-ndarray or float) – Frequencies of the ground-state absorbtions

  • T_2 (1D_ndarray or float) – Decoherence time of the bands.

Return type:

ndarry

skultrafast.utils.pfid_r6(T, om, om_10, om_21, T_2)[source]

Calculates the PFID contribution for the shifted frequecy.

See the PFID tutorial for a longer explanation. The function does broadcasting, hence it is possible to calculate the PFID contributions of serveral bands at once. For that, om_10, om_21 and T_2 must have the same shape.

Parameters:
  • T (1D-ndarry) – Delays between pump and probe. The formula assume a postive delays.

  • om (1D-ndarray) – Array of frequencies given in wavenumbers (cm-1).

  • om_10 (1D-ndarray or float) – Frequencies of the ground-state absorbtions

  • om_21 (1D-ndarray or float) – Frequencies of the shifted frequency

  • T_2 (1D_ndarray or float) – Decoherence time of the bands.

Return type:

ndarry

skultrafast.utils.pfid(T, om, om_10, fac, om_21, T_2)[source]
class skultrafast.utils.LinRegResult[source]

Linear regression result.

data: numpy.ndarray[source]
weights: numpy.ndarray | None[source]
fit: numpy.ndarray[source]
residuals: numpy.ndarray[source]
sol: numpy.ndarray[source]
r2: numpy.ndarray[source]
var: numpy.ndarray[source]
stderr: numpy.ndarray[source]
rel_err: numpy.ndarray[source]
classmethod fit_data(A, y, weights: numpy.ndarray | None = None)[source]

Fit data to a linear model.

Parameters:
  • A (array_like) – The design matrix.

  • y (array_like) – The data to fit.

Return type:

LinRegResult

skultrafast.utils.linreg_std_errors(A, y)[source]

Calculates the solution and error terms in a linear regression.

Parameters:
  • A (ndarray) – Basis matrix

  • y (ndarray) – Data

Returns:

Tuple of three arrays: standard error, variance matrix, r2

Return type:

(ndarray, ndarray, ndarray,)

skultrafast.utils.ExpDecay(x, A1, tau1, c)[source]
skultrafast.utils.TwoExpDecay(x, A1, tau1, A2, tau2, c)[source]
skultrafast.utils.ThreeExpDecay(x, A1, tau1, A2, tau2, A3, tau3, c)[source]
skultrafast.utils.poly_bg_correction(wavelengths, data, left=30, right=30, deg=1)[source]

Fit and subtract baseline from given data

Parameters:
  • wavelengths (np.ndarry) – Shared x-values

  • data (np.ndarray) – Dataarray

  • left (int, optional) – left points to use, by default 30

  • right (int, optional) – right points to use, by default 30

  • deg (int, optional) – Degree of the polynomial fit, by default 1 (linear)

Returns:

[description]

Return type:

[type]

skultrafast.utils.inbetween(a: numpy.ndarray, lower: float, upper: float)[source]

Returns index-array where a is between upper and lower