indexer#
- class arte.time_series.indexer.DefaultIndexer#
Bases:
IndexerGeneric element indexer for uniform 1D ensemble data.
Provides flexible indexing for time series where ensemble elements are not organized in a special structure (modes, rows/cols, etc.) but simply form a flat list.
Examples
>>> indexer = DefaultIndexer() >>> >>> # Select all elements >>> indexer.elements() # slice(None, None, None) >>> >>> # Select single element >>> indexer.elements(22) # 22 >>> >>> # Select list of elements >>> indexer.elements([2, 5, 10]) # [2, 5, 10] >>> >>> # Select range >>> indexer.elements(from_element=10, to_element=20) # slice(10, 20, None)
Methods
elements(*args, **kwargs)Generate element indices for selection.
interleaved_xy(*args, **kwargs)Create slice for interleaved x/y data layout.
myrange(*args, maxrange)sequential_xy(maxindex, *args, **kwargs)Create slice for sequential x/y data layout.
xy(*args, **kwargs)default: coord Accepted keywords: coord= x and/or y
- elements(*args, **kwargs)#
Generate element indices for selection.
- Parameters:
*args (int, list, or array-like, optional) – Single element index or list of indices to select.
element (int, list, or array-like, optional) – Alternative keyword-based element selection.
elements (int, list, or array-like, optional) – Alternative keyword-based element selection.
from_element (int, optional) – Starting element index for range selection.
to_element (int, optional) – Ending element index for range selection.
- Returns:
Index/indices for array selection.
- Return type:
int, list, or slice
Examples
>>> indexer = DefaultIndexer() >>> >>> # All elements (no filtering) >>> indexer.elements() # slice(None, None) >>> >>> # Single element >>> indexer.elements(5) # 5 >>> >>> # List of elements >>> indexer.elements([1, 3, 5, 7]) # [1, 3, 5, 7] >>> >>> # Range from index 10 onwards >>> indexer.elements(from_element=10) # slice(10, None)
- class arte.time_series.indexer.Indexer#
Bases:
objectBase indexer class for accessing subsets of time series ensemble data.
Provides utility methods for indexing 2D coordinate data (x, y) which is common in wavefront sensor measurements and other spatial data.
This class serves as a foundation for specialized indexers like
ModeIndexer,DefaultIndexer, andRowColIndexer.Methods
interleaved_xy(*args, **kwargs)Create slice for interleaved x/y data layout.
myrange(*args, maxrange)sequential_xy(maxindex, *args, **kwargs)Create slice for sequential x/y data layout.
xy(*args, **kwargs)default: coord Accepted keywords: coord= x and/or y
- interleaved_xy(*args, **kwargs)#
Create slice for interleaved x/y data layout.
This indexer is designed for wavefront sensor slopes stored in interleaved format: [x0, y0, x1, y1, x2, y2, …]
- Parameters:
*args (str or int, optional) – If ‘x’: select x coordinates (indices 0, 2, 4, …) If ‘y’: select y coordinates (indices 1, 3, 5, …) If int: select single element at that index If not provided: select all elements
coord ({'x', 'y'}, optional) – Alternative keyword-based coordinate selection.
coords ({'x', 'y'}, optional) – Alternative keyword-based coordinate selection.
axis ({'x', 'y'}, optional) – Alternative keyword-based coordinate selection.
- Returns:
Python slice object for indexing the requested coordinates.
- Return type:
slice
Examples
>>> indexer = Indexer() >>> slopes = np.array([sx0, sy0, sx1, sy1, sx2, sy2]) # interleaved >>> >>> # Select all x slopes >>> x_slopes = slopes[indexer.interleaved_xy('x')] # [sx0, sx1, sx2] >>> >>> # Select all y slopes >>> y_slopes = slopes[indexer.interleaved_xy(coord='y')] # [sy0, sy1, sy2]
- static myrange(*args, maxrange)#
- sequential_xy(maxindex, *args, **kwargs)#
Create slice for sequential x/y data layout.
This indexer is for data stored with all x coordinates followed by all y coordinates: [x0, x1, x2, …, y0, y1, y2, …]
- Parameters:
maxindex (int) – Total number of elements (length of the array to index).
*args (str or int, optional) – If ‘x’: select x coordinates (first half) If ‘y’: select y coordinates (second half) If int: select single element at that index If not provided: select all elements
coord ({'x', 'y'}, optional) – Alternative keyword-based coordinate selection.
coords ({'x', 'y'}, optional) – Alternative keyword-based coordinate selection.
axis ({'x', 'y'}, optional) – Alternative keyword-based coordinate selection.
- Returns:
Python slice object for indexing the requested coordinates.
- Return type:
slice
Examples
>>> indexer = Indexer() >>> slopes = np.array([sx0, sx1, sx2, sy0, sy1, sy2]) # sequential >>> >>> # Select all x slopes >>> x_slopes = slopes[indexer.sequential_xy(6, 'x')] # [sx0, sx1, sx2] >>> >>> # Select all y slopes >>> y_slopes = slopes[indexer.sequential_xy(6, coord='y')] # [sy0, sy1, sy2]
- xy(*args, **kwargs)#
default: coord Accepted keywords: coord= x and/or y
- class arte.time_series.indexer.ModeIndexer(max_mode=None)#
Bases:
IndexerIndexer for modal decomposition data (Zernike, KL modes, etc.).
Provides convenient indexing for time series containing modal coefficients, allowing selection by mode number, mode ranges, or lists of specific modes.
- Parameters:
max_mode (int, optional) – Maximum mode number available in the data. Used as default upper bound for range selections.
Examples
>>> # For Zernike coefficients time series with 100 modes >>> indexer = ModeIndexer(max_mode=100) >>> >>> # Select all modes >>> all_modes = indexer.modes() # [0, 1, 2, ..., 99] >>> >>> # Select mode range (tip, tilt, focus, astig) >>> low_order = indexer.modes(from_mode=2, to_mode=6) # [2, 3, 4, 5] >>> >>> # Select specific modes >>> selected = indexer.modes(modes=[2, 5, 10]) # [2, 5, 10]
Methods
interleaved_xy(*args, **kwargs)Create slice for interleaved x/y data layout.
modes(*args, **kwargs)Generate mode indices for selection.
myrange(*args, maxrange)sequential_xy(maxindex, *args, **kwargs)Create slice for sequential x/y data layout.
xy(*args, **kwargs)default: coord Accepted keywords: coord= x and/or y
- modes(*args, **kwargs)#
Generate mode indices for selection.
- Parameters:
*args (int or array-like, optional) – Single mode number or list of mode numbers to select.
mode (int or array-like, optional) – Alternative keyword-based mode selection.
modes (int or array-like, optional) – Alternative keyword-based mode selection.
from_mode (int, optional) – Starting mode number for range selection. Default is 0.
to_mode (int, optional) – Ending mode number (exclusive) for range selection. If not specified, uses
max_modefrom initialization.
- Returns:
Mode index/indices for array indexing.
- Return type:
int, list, or ndarray
- Raises:
Exception – If
to_modeis not specified andmax_modewas not set during initialization.
Examples
>>> indexer = ModeIndexer(max_mode=50) >>> >>> # All modes >>> indexer.modes() # array([0, 1, 2, ..., 49]) >>> >>> # Single mode >>> indexer.modes(mode=5) # 5 >>> >>> # Mode range (e.g., low-order Zernikes) >>> indexer.modes(from_mode=2, to_mode=11) # array([2, 3, ..., 10]) >>> >>> # Specific modes >>> indexer.modes(modes=[2, 3, 4, 10, 15]) # [2, 3, 4, 10, 15]
- class arte.time_series.indexer.RowColIndexer#
Bases:
IndexerIndexer for 2D array data organized in rows and columns.
Useful for time series data with natural 2D spatial structure, such as deformable mirror actuators arranged in a grid or detector pixels.
Examples
>>> indexer = RowColIndexer() >>> >>> # Select specific rows and columns >>> idx = indexer.rowcol(rows=5, cols=slice(0, 10)) >>> data_subset = data[:, idx[0], idx[1]] # time x rows x cols >>> >>> # Using from/to syntax >>> idx = indexer.rowcol(row_from=10, row_to=20, col_from=5, col_to=15)
Methods
interleaved_xy(*args, **kwargs)Create slice for interleaved x/y data layout.
myrange(*args, maxrange)rowcol(*args, **kwargs)Create row and column indices for 2D data selection.
sequential_xy(maxindex, *args, **kwargs)Create slice for sequential x/y data layout.
xy(*args, **kwargs)default: coord Accepted keywords: coord= x and/or y
- rowcol(*args, **kwargs)#
Create row and column indices for 2D data selection.
- Parameters:
*args (int, slice, or array-like) – Positional arguments for row and column selection: - If 1 arg: used for rows, all columns selected - If 2 args: (rows, cols)
rows (int, slice, or array-like, optional) – Row index/indices to select.
cols (int, slice, or array-like, optional) – Column index/indices to select.
row_from (int, optional) – Convenience parameters for building row slice.
row_to (int, optional) – Convenience parameters for building row slice.
row_step (int, optional) – Convenience parameters for building row slice.
col_from (int, optional) – Convenience parameters for building column slice.
col_to (int, optional) – Convenience parameters for building column slice.
col_step (int, optional) – Convenience parameters for building column slice.
- Returns:
Indices suitable for 2D array indexing.
- Return type:
tuple of (row_index, col_index)
- Raises:
IndexError – If unsupported keywords or too many positional arguments provided.
Examples
>>> indexer = RowColIndexer() >>> >>> # Select row 5, columns 0-10 >>> rows, cols = indexer.rowcol(rows=5, col_from=0, col_to=10) >>> >>> # Using positional arguments >>> rows, cols = indexer.rowcol(slice(10, 20), slice(5, 15)) >>> >>> # Select all rows, specific column range with step >>> rows, cols = indexer.rowcol(col_from=0, col_to=100, col_step=2)