Multirate Utilities¤
Multirate signal-alignment helpers for aligning streams sampled at different rates.
See Also¤
- Utilities Overview - All utility helpers
- PRNG - Random-number utilities
datarax.utils.multirate ¤
Multirate signal alignment — preprocessing-time helper.
For sensor-fusion / wearable workloads, channels arrive at different sample
rates. Each channel array is upsampled along the time axis by an integer
factor via np.repeat so all channels share a common rate post-alignment.
The result is then cached (e.g., as .npy) and consumed by standard
batching downstream — runtime multirate batching is intentionally NOT
provided so the rate-conversion cost is paid once per dataset, not per batch.
multirate_align ¤
multirate_align(channels: dict[str, ndarray], rate_factors: dict[str, int], *, axis: int = 0) -> dict[str, ndarray]
Upsample each rate-factored channel along axis via np.repeat.
Channels absent from rate_factors (or with factor 1) pass through
unchanged. Used at dataset preprocessing time to align signals captured at
different sample rates onto a common timebase before batching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channels
|
dict[str, ndarray]
|
Mapping from channel name to ndarray. |
required |
rate_factors
|
dict[str, int]
|
Mapping from channel name to positive integer upsample factor. Missing keys default to factor 1 (passthrough). |
required |
axis
|
int
|
Axis along which to apply the repeat (default 0). |
0
|
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
New dict with each channel's array upsampled per its rate factor. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any rate factor is not a positive integer. |