Skip to content

API TimeSeries

Emil Wagman edited this page Nov 27, 2023 · 3 revisions

TimeSeries(start, end)

A Python class for adding time-based variables to a numerical expression.

This class supports all the basic arithmetic operations and is meant to be used alongside numpy arrays to create dynamic time-evaluated coordinates. Applying functions onto a TimeSeries is also possible but most be done through the intermediary static method .apply(...).

Preview is not available with TimeSeries, so you use the saving functionality instead.

Attributes:

  • start (int): Start value.
  • end (int): End value.

Example usage:

import numpy as np
import src.wplt as wplt

c = wplt.TimeSeries(0, np.pi*2)  # Will interpolate between 0 and 2*pi
X = np.linspace(0, 10, 101)
Y = c * X

wplt.plot(X, Y)
wplt.save()

.apply(func, *args)

Apply a function to a TimeSeries object or a statement that includes a TimeSeries. This will not immediately run this function, because all evaluations are done while plotting.

Parameters:

  • func (function): Function to apply.
  • *args: Arguments that you want use inside the function.

Example usage:

import numpy as np
import wplt

c = wplt.TimeSeries(0, 4)
X = np.linspace(0, 4*np.pi, 100)
Y = wplt.TimeSeries.apply(np.sin, c*X)

wplt.plot(X, Y)
wplt.save()

Clone this wiki locally