pyprobe.analysis.base.differentiation_functions#

Module containing functions for differentiating experimental data.

Functions

calc_gradient_with_lean(x, y, k, gradient)

Calculate the gradient of the data, assuming x is uniformly spaced.

get_dx(x)

Get the x sampling interval, assuming uniformly spaced x values.

get_dy_and_counts(y, dy)

Get the y sampling interval, bin midpoints and counts.

get_x_sections(x)

Split the x data into uniformly sampled sections.

smooth_gradient(gradient, alpha)

Smooth the calculated gradient.

y_sampling_interval(y)

Get the y sampling interval, \(\delta R\) in Feng et al.[#Feng2020]_.

get_x_sections(x)#

Split the x data into uniformly sampled sections.

Parameters:

x (NDArray[np.float64]) – The x values.

Returns:

a list of slices representing the uniformly sampled sections.

Return type:

List[slice]

get_dx(x)#

Get the x sampling interval, assuming uniformly spaced x values.

Parameters:

x (NDArray[np.float64]) – The x values.

Returns:

The x sampling interval.

Return type:

float

Raises:

ValueError – If the x values are not uniformly spaced.

get_dy_and_counts(y, dy)#

Get the y sampling interval, bin midpoints and counts.

Parameters:
  • y (NDArray[np.float64]) – The y values.

  • dy (float) – The bin size.

Returns:

The y sampling interval, bin midpoints and counts.

Return type:

Tuple[float, NDArray[np.float64], NDArray[np.float64]]

y_sampling_interval(y)#

Get the y sampling interval, \(\delta R\) in Feng et al.[#Feng2020]_.

Parameters:

y (NDArray[np.float64]) – The y values.

Returns:

The y sampling interval.

Return type:

float

calc_gradient_with_lean(x, y, k, gradient)#

Calculate the gradient of the data, assuming x is uniformly spaced.

Parameters:
  • x (NDArray[np.float64]) – The x values.

  • y (NDArray[np.float64]) – The y values.

  • k (int) – The integer multiple to apply to the sampling interval for the bin size (\(\delta R\) in paper).

  • gradient (str) – The gradient to calculate, either ‘dydx’ or ‘dxdy’.

Returns:

The x values, the y midpoints and the calculated gradient.

Return type:

Tuple[NDArray[np.float64], NDArray[np.float64], NDArray[np.float64]]

smooth_gradient(gradient, alpha)#

Smooth the calculated gradient.

Parameters:
  • gradient (NDArray[np.float64]) – The gradient vector.

  • alpha (list[float]) – The smoothing coefficients.

Returns:

The smoothed gradient vector.

Return type:

NDArray[np.float64]

References