axis_handler#
Axis transposition handler for multi-dimensional time series data.
This module provides utilities for managing named axes in time series arrays and performing axis reordering based on axis names rather than numeric indices.
- class arte.time_series.axis_handler.AxisHandler(axes=None)#
Bases:
objectHandle axis transpositions in multi-dimensional arrays using named axes.
This class enables intuitive axis reordering for time series data with multiple ensemble dimensions. Instead of using numeric indices, axes can be referenced by meaningful names (e.g., ‘subaperture’, ‘wavelength’, ‘mode’).
- Parameters:
axes (sequence of str or str, optional) – Names for each axis in the data (excluding time axis, which is always first). If None, no axis transposition will be possible. If a single string, wraps it in a tuple.
Examples
>>> # Define 3D time series: (time, subaperture, wavelength) >>> handler = AxisHandler(axes=['subaperture', 'wavelength']) >>> >>> # Transpose to (subaperture, wavelength, time) >>> data_transposed = handler.transpose(data, ['subaperture', 'wavelength']) >>> >>> # Reorder axes: (time, wavelength, subaperture) >>> data_reordered = handler.transpose(data, ['wavelength', 'subaperture'])
Methods
transpose(data[, axes])Transpose array axes according to named axis order.
axes
- axes()#
- transpose(data, axes=None)#
Transpose array axes according to named axis order.
- Parameters:
data (ndarray) – Array to transpose. First dimension (time) is not affected.
axes (sequence of str or str, optional) – Desired axis order using axis names defined during initialization. If None, no transposition is performed.
- Returns:
Transposed array with axes reordered as specified.
- Return type:
ndarray
- Raises:
ValueError – If any requested axis name was not defined during initialization.
Examples
>>> handler = AxisHandler(axes=['x', 'y', 'wavelength']) >>> data = np.random.rand(100, 10, 20, 5) # (time, x, y, wavelength) >>> >>> # Reorder to (time, wavelength, x, y) >>> data_new = handler.transpose(data, ['wavelength', 'x', 'y']) >>> data_new.shape # (100, 5, 10, 20)