Plotting utilities


source

plot_poles_zeros

 plot_poles_zeros (p:numpy.ndarray, ax=None, **kwargs)
Type Default Details
p ndarray (B, p) zeros
ax NoneType None
kwargs

source

plot_solution

 plot_solution (gt:numpy.ndarray, pred:numpy.ndarray,
                ar_gt:numpy.ndarray=None, ar_pred:numpy.ndarray=None)

*Plot a comparison of the ground truth and predicted solution.

Args: gt: A numpy array of shape (time_steps, grid_size) representing the ground truth values. pred: A numpy array of shape (time_steps, grid_size) representing the predicted values. ar_pred (optional): A numpy array of shape (time_steps, grid_size) representing the autoregressive predicted values.

Returns: A matplotlib figure object containing the subplots of the ground truth, predicted, and autoregressive predicted solutions.*

Type Default Details
gt ndarray (time_steps, grid_size)
pred ndarray (time_steps, grid_size)
ar_gt ndarray None (time_steps, grid_size)
ar_pred ndarray None (time_steps, grid_size)
Returns Figure

source

plot_solution_2d

 plot_solution_2d (gt:numpy.ndarray, pred:numpy.ndarray,
                   ar_pred:numpy.ndarray=None, random_sample:bool=False)

*Plot a comparison of the ground truth and predicted solution.

Args: gt: A numpy array of shape (time_steps, grid_size) representing the ground truth values. pred: A numpy array of shape (time_steps, grid_size) representing the predicted values. ar_pred (optional): A numpy array of shape (time_steps, grid_size) representing the autoregressive predicted values.

Returns: A matplotlib figure object containing the subplots of the ground truth, predicted, and autoregressive predicted solutions.*

Type Default Details
gt ndarray (T, H, W)
pred ndarray (T, H, W)
ar_pred ndarray None (T, H, W)
random_sample bool False whether to randomly sample a time step
Returns Figure

source

plot_eigenvalues

 plot_eigenvalues (eigenvalues:numpy.ndarray, sample_rate:int=None,
                   log:bool=False)
Type Default Details
eigenvalues ndarray (B, p)
sample_rate int None sample rate of the signal for radians otherwise we use normalized frequency
log bool False

source

get_max_row_size

 get_max_row_size (alpha, dtype=<class 'float'>)

source

ewma_vectorized_safe

 ewma_vectorized_safe (data, alpha, row_size=None, dtype=None, order='C',
                       out=None)

Reshapes data before calculating EWMA, then iterates once over the rows to calculate the offset without precision issues :param data: Input data, will be flattened. :param alpha: scalar float in range (0,1) The alpha parameter for the moving average. :param row_size: int, optional The row size to use in the computation. High row sizes need higher precision, low values will impact performance. The optimal value depends on the platform and the alpha being used. Higher alpha values require lower row size. Default depends on dtype. :param dtype: optional Data type used for calculations. Defaults to float64 unless data.dtype is float32, then it will use float32. :param order: {‘C’, ‘F’, ‘A’}, optional Order to use when flattening the data. Defaults to ‘C’. :param out: ndarray, or None, optional A location into which the result is stored. If provided, it must have the same shape as the desired output. If not provided or None, a freshly-allocated array is returned. :return: The flattened result.


source

ewma_vectorized_2d

 ewma_vectorized_2d (data, alpha, axis=None, offset=None, dtype=None,
                     order='C', out=None)

Calculates the exponential moving average over a given axis. :param data: Input data, must be 1D or 2D array. :param alpha: scalar float in range (0,1) The alpha parameter for the moving average. :param axis: The axis to apply the moving average on. If axis==None, the data is flattened. :param offset: optional The offset for the moving average. Must be scalar or a vector with one element for each row of data. If set to None, defaults to the first value of each row. :param dtype: optional Data type used for calculations. Defaults to float64 unless data.dtype is float32, then it will use float32. :param order: {‘C’, ‘F’, ‘A’}, optional Order to use when flattening the data. Ignored if axis is not None. :param out: ndarray, or None, optional A location into which the result is stored. If provided, it must have the same shape as the desired output. If not provided or None, a freshly-allocated array is returned.


source

ewma_vectorized

 ewma_vectorized (data, alpha, offset=None, dtype=None, order='C',
                  out=None)

Calculates the exponential moving average over a vector. Will fail for large inputs. :param data: Input data :param alpha: scalar float in range (0,1) The alpha parameter for the moving average. :param offset: optional The offset for the moving average, scalar. Defaults to data[0]. :param dtype: optional Data type used for calculations. Defaults to float64 unless data.dtype is float32, then it will use float32. :param order: {‘C’, ‘F’, ‘A’}, optional Order to use when flattening the data. Defaults to ‘C’. :param out: ndarray, or None, optional A location into which the result is stored. If provided, it must have the same shape as the input. If not provided or None, a freshly-allocated array is returned.


source

plot_freqz

 plot_freqz (h:numpy.ndarray, ax=None, **kwargs)

*Plots the frequency response of a filter.

Parameters: - h: jtx.ArrayLike: The filter’s frequency response. - ax: matplotlib.axes.Axes, optional: The axes to plot on. If not provided, a new figure and axes will be created.

Returns: - ax: matplotlib.axes.Axes: The plotted axes.*

Type Default Details
h ndarray The filter’s frequency response.
ax NoneType None The axes to plot on. If not provided, a new figure and axes will be created.
kwargs
Returns Axes Additional arguments to pass to the plot function.