create_bounds
Functions:
| Name | Description |
|---|---|
create_bounds |
Creates a 2D array of start and end times between the start and stop bounds. |
create_bounds_from_labels |
|
Functions#
create_bounds #
create_bounds(
start: float | datetime64 | str,
stop: float | datetime64 | str,
interval: float | str,
width: float | str | None = None,
alignment: (
Literal["left", "right", "center"] | float
) = "left",
) -> tuple[np.ndarray, np.ndarray]
Creates a 2D array of start and end times between the start and stop bounds. Returns both the 1D coordinate labels and the 2D array of coordinate bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
datetime64 | str
|
The starting time corresponding with the first
bound (inclusive). Can be provided either as a numpy datetime64 scalar or as
a yyyy-mm-dd hh |
required |
stop
|
datetime64 | str
|
The ending point of the bounds (exclusive). The
bounds array is guaranteed to end sometime before this point. Can be
provided either as a numpy datetime64 scalar or as a yyyy-mm-dd hh |
required |
interval
|
int | str
|
The gap between the centers of the output bounds in seconds. Can be provided as either a number or as a string (e.g., "30min") |
required |
width
|
int | str | None
|
The difference between the end of each bound and the start of each bound in seconds. Can be provided as either a number or a string (e.g., "30min"). This can be set independently of the interval to make the bounds overlap (if the width is greater than the interval), introduce gaps (if the width is less than the interval - why, idk), or to make the bounds align perfectly (by setting width = interval, the default). |
None
|
alignment
|
float
|
Controls where the bounds are located relative to the label for each bin. Can be provided as a literal string ("left", "right", or "center"), or a value from 0.0 - 1.0 to specify an alignment in-between the two (left=0, right=1, center=0.5). |
'left'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Raises an error if the stop time is not greater than the start time. |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The 1-dimensional array of labels for the bounds. |
ndarray
|
np.ndarray: The 2-dimensional array of time bounds. |
Source code in tsdat/transform_v2/utils/create_bounds.py
create_bounds_from_labels #
create_bounds_from_labels(
labels: ndarray,
width: float | str | None = None,
alignment: (
Literal["left", "right", "center"] | float
) = "left",
) -> np.ndarray