Filters Module

Contents

modespy.filters._parse_filter_arg

Helper function for resolving different filter arguments passed to MODES.

modespy.filters.filter_order

Function returning the order of the given filter vector vec.

modespy.filters.filter_r

Compute the step size ratio based on filtered interpretation of previous step sizes and associated controller errors.

Members

This module establishes standard filter vectors and functions to implement discrete PID-style stepsize controllers. The following filters are provided:

  • First order filters:
    • Elementary: [1] (Also used as fallback filter if no step history exists)

  • Second order filters:
    • H211D: [1, 1, -1] / 2

    • H211b: [1, 1, -1] / (b) (* Default b = 4)

    • H211PI: [1, 1, 0] / 6

    • PI3333: [2, -1, 0] / 3

    • PI3040: [7, -4, 0] / 10

    • PI4020: [3, -1, 0] / 5

  • Third order filters:
    • H312D: [1, 2, 1, -3, -1] / 4,

    • H312b: [1, 2, 1, -3, -1] / (b) (* Default b = 8)

    • H312PID: [1, 2, 1, 0, 0] / 18

    • H321D: [5, 2 - 3, 1, 3] / 4

    • H321: [6, 1, -5, 15, 3] / 18

Note

Filters marked (*) must be passed as a tuple to MODES __init__ with a given divisor b e.g. (‘H312b’, 8). This allows for a non-default value of the b parameter in these cases.

modespy.filters._parse_filter_arg(filt_arg)

Helper function for resolving different filter arguments passed to MODES.

modespy.filters.filter_order(vec: ndarray) int

Function returning the order of the given filter vector vec.

modespy.filters.filter_r(vec: ndarray, p: int, hs: array, errs: array, unit_errors: bool) float

Compute the step size ratio based on filtered interpretation of previous step sizes and associated controller errors.

Parameters:
  • vec (array_like) – Filter vector.

  • p (int) – Order of method being filtered, used when scaling errors.

  • hs (array_like) – Recent step sizes with len(hs) >= filter order.

  • errs (array_like) – Recent controller errors corresponding to hs.

  • unit_errors (bool) – True if scaling errors to unit step sizes is required.

Returns:

r – Step size ratio obtained via filtering.

Return type:

float