Numerical Calculus

differentiate, sliding_window_integration, trapezoidal_integration

Differentiation

indsl.ts_utils.numerical_calculus.differentiate(series: Series, time_unit: Timedelta = Timedelta('0 days 01:00:00')) Series

Differentiation.

Differentiation (finite difference) using a second-order accurate numerical method (central difference). Boundary points are computed using a first-order accurate method.

Parameters:
  • series – Time series.

  • time_unit – Frequency. User defined granularity to potentially override unit of time. Defaults to 1 h. Accepts integer followed by time unit string (ms|s|m|h|d). For example: ‘1s’, ‘5m’, ‘3h’ or ‘1d’.

Returns:

First order derivative.

Return type:

pandas.Series

Trapezoidal integration

indsl.ts_utils.numerical_calculus.trapezoidal_integration(series: Series, time_unit: Timedelta = Timedelta('0 days 01:00:00')) Series

Integration.

Cumulative integration using trapezoidal rule with an optional user-defined time unit.

Parameters:
  • series – Time series.

  • time_unit – Frequency. User defined granularity to potentially override unit of time. Defaults to 1 h. Accepted formats can be found here: https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html. Some examples are: ‘1s’, ‘5m’, ‘3h’ or ‘1d’, but combinations also work: “1d 6h 43s”

Returns:

Cumulative integral.

Return type:

pandas.Series

Sliding window integration

indsl.ts_utils.numerical_calculus.sliding_window_integration(series: Series, window_length: Timedelta = Timedelta('0 days 00:05:00'), integrand_rate: Timedelta = Timedelta('0 days 01:00:00')) Series

Sliding window integration.

Siding window integration using trapezoidal rule.

Parameters:
  • series – Time series.

  • window_length

    window_length the length of time the window. Defaults to ‘5 minute’. Valid time units are:

    • ‘W’, ‘D’, ‘T’, ‘S’, ‘L’, ‘U’, or ‘N’

    • ‘days’ or ‘day’

    • ‘hours’, ‘hour’, ‘hr’, or ‘h’

    • ‘minutes’, ‘minute’, ‘min’, or ‘m’

    • ‘seconds’, ‘second’, or ‘sec’

    • ‘milliseconds’, ‘millisecond’, ‘millis’, or ‘milli’

    • ‘microseconds’, ‘microsecond’, ‘micros’, or ‘micro’

    • ‘nanoseconds’, ‘nanosecond’, ‘nanos’, ‘nano’, or ‘ns’.

  • integrand_rate

    integrand_rate. if the integrands rate is per sec, per hour, per day. Defaults to ‘1 hour’. Valid time units are:

    • ‘W’, ‘D’, ‘T’, ‘S’, ‘L’, ‘U’, or ‘N’

    • ‘days’ or ‘day’

    • ‘hours’, ‘hour’, ‘hr’, or ‘h’

    • ‘minutes’, ‘minute’, ‘min’, or ‘m’

    • ‘seconds’, ‘second’, or ‘sec’

    • ‘milliseconds’, ‘millisecond’, ‘millis’, or ‘milli’

    • ‘microseconds’, ‘microsecond’, ‘micros’, or ‘micro’

    • ‘nanoseconds’, ‘nanosecond’, ‘nanos’, ‘nano’, or ‘ns’.

Returns:

Time series

Return type:

pandas.Series