pyprobe.analysis.differentiation module#

A module for differentiating experimental data.

gradient(input_data, x, y)#

Differentiate smooth data with a finite difference method.

A wrapper of the numpy.gradient function. This method calculates the gradient of the data in the y column with respect to the data in the x column.

Parameters:
  • input_data (RawData | Procedure | Experiment | Cycle | Step | Result) – The input data PyProBE object for the differentiation

  • x (str) – The name of the x variable.

  • y (str) – The name of the y variable.

Returns:

A result object containing the columns, x, y and the calculated gradient.

Return type:

Result

differentiate_LEAN(input_data, x, y, k=1, gradient='dydx', smoothing_filter=[0.0668, 0.2417, 0.383, 0.2417, 0.0668], section='longest')#

A method for differentiating noisy data.

Uses ‘Level Evaluation ANalysis’ (LEAN) method described in the paper of Feng et al.[1].

This method assumes \(x\) datapoints to be evenly spaced, it can return either \(\frac{dy}{dx}\) or \(\frac{dx}{dy}\) depending on the argument provided to the gradient parameter.

Parameters:
  • input_data (RawData | Procedure | Experiment | Cycle | Step | Result) – The input data PyProBE object for the differentiation.

  • x (str) – The name of the x variable.

  • y (str) – The name of the y variable.

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

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

  • smoothing_filter (List[float]) –

    The coefficients of the smoothing matrix.

    Examples provided by Feng et al.[1] include:

    • [0.25, 0.5, 0.25] for a 3-point smoothing filter.

    • [0.0668, 0.2417, 0.3830, 0.2417, 0.0668] (default) for a 5-point

      smoothing filter.

    • [0.1059, 0.121, 0.1745, 0.1972, 0.1745, 0.121, 0.1059] for a

      7-point smoothing filter.

  • section (str) – The section of the data with constant sample rate in x to be considered. Default is ‘longest’, which just returns the longest unifomly sampled section. Alternative is ‘all’, which returns all sections.

Returns:

A result object containing the columns, x, y and the calculated gradient.

Return type:

Result

pydantic model Differentiation(*, input_data)#

Bases: BaseModel

A class for differentiating experimental data.

Parameters:

input_data (RawData | Procedure | Experiment | Cycle | Step | Result)

Return type:

None

field input_data: RawData | Procedure | Experiment | Cycle | Step | Result [Required]#

The input data for the differentiation.

differentiate_FD(x, y, gradient='dydx')#

Differentiate smooth data with the finite difference method.

A light wrapper of the numpy.gradient function.

Parameters:
  • x (str) – The name of the x variable.

  • y (str) – The name of the y variable.

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

Returns:

A result object containing the columns, x, y and the calculated gradient.

Return type:

Result

differentiate_LEAN(x, y, k=1, gradient='dydx', smoothing_filter=[0.0668, 0.2417, 0.383, 0.2417, 0.0668], section='longest')#

A method for differentiating noisy data.

Uses ‘Level Evaluation ANalysis’ (LEAN) method described in the paper of Feng et al.[1].

This method assumes \(x\) datapoints to be evenly spaced, it can return either \(\frac{dy}{dx}\) or \(\frac{dx}{dy}\) depending on the argument provided to the gradient parameter.

Parameters:
  • x (str) – The name of the x variable.

  • y (str) – The name of the y variable.

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

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

  • smoothing_filter (List[float], optional) –

    The coefficients of the smoothing matrix.

    Examples provided by Feng et al.[1] include:

    • [0.25, 0.5, 0.25] for a 3-point smoothing filter.

    • [0.0668, 0.2417, 0.3830, 0.2417, 0.0668] (default) for a 5-point smoothing filter.

    • [0.1059, 0.121, 0.1745, 0.1972, 0.1745, 0.121, 0.1059] for a 7-point smoothing filter.

  • section (str, optional) – The section of the data with constant sample rate in x to be considered. Default is ‘longest’, which just returns the longest unifomly sampled section. Alternative is ‘all’, which returns all sections.

Returns:

A result object containing the columns, x, y and the calculated gradient.

Return type:

Result

References