About AxisArray#

AxisArray is a specialized message format used within the ezmsg framework to represent multi-dimensional data structures. In simple terms they are N-dimensional arrays with labeled axes and optional metadata. It is designed for applications in signal processing, scientific computing, and data analysis, where both the data and its context are important. AxisArray originally took inspiration from the functionality of the xarray library.

AxisArray is built-in to ezmsg. Import using:

from ezmsg.core.util import AxisArray

Warning

Importing AxisArray from ezmsg.core.util will import the numpy library. For this reason, we have implemented ezmsg in such a way that if you do not import AxisArray, numpy will not be imported either. This is ideal for users wanting very lightweight applications and have no need for the functionality of numpy.

ezmsg logo Why use AxisArray?#

The purpose of including AxisArray as part of ezmsg stems from wanting to avoid having to support a vast array of different message types. This is a major cause of bloat with other similar messaging platforms.

For this to be useful, we have designed AxisArray to be convenient and flexible. It is important that it can be used for the many different use cases we have encountered. At its core it stores a numpy N-dimensional array, an array of axis labels, as well as multiple metadata attributes.

ezmsg logo Description#

An AxisArray is a multi-dimensional array with named axes. Each axis can have a name and a set of labels for its elements. This allows for more intuitive indexing and manipulation of the data.

An AxisArray has the following attributes:

  • data: a numpy ndarray containing the actual data.

  • dims: a list of axis names.

  • axes: a dictionary mapping axis names to their label information.

  • attrs: a dictionary for storing additional metadata.

  • key: a unique identifier for the array.

Unsurprisingly, all of this must be self-consistent: the number of axis names in dims must match the number of dimensions in data, and the axis names in axes should match the ones in dims. The label information in axes refers to the ‘value’ of each axis index, e.g., for a time axis, the labels might be timestamps. We provide three commonly used axes type objects:

  • A LinearAxis: represents a linear axis with evenly spaced values - you just need the offset (start value) and the gain (step size). An example of this would be simple numerical index (offset=0, gain=1) or regularly spaced time samples (offset=start time, gain=1/sampling rate).

  • A TimeAxis: this is a LinearAxis that represents a time axis. Its unit attribute is by default set to seconds (s).

  • A CoordinateAxis: this is our continuous/dense axis, which can represent any continuous variable, such as frequency or spatial coordinates. You provide the actual values for each index in a data array of values.

The AxisArray class provides several methods for manipulating and accessing the data, designed to allow standard numpy array manipulation without losing track of how the axes are affected. For a list of such methods, see AxisArray utility methods.

ezmsg logo See Also#

  1. AxisArray API Reference