# Measurement

## class Measurement( channel_data: dict[str, list[float] | list[str]], timestamps: list[int], tags: dict[str, str] | None = None, )[source]

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object "(in Python v3.15)")

Data structure to hold measurement data. All channels have a common timebase.

Variables:
:   - **channel_data** ([*dict*](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")*[*[*str*](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")*,* [*list*](https://docs.python.org/3/builtins/stdtypes.html#list "(in Python v3.15)")*[*[*float*](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")*]* *|* [*list*](https://docs.python.org/3/builtins/stdtypes.html#list "(in Python v3.15)")*[*[*str*](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")*]**]*) – Maps channel names (or numbers, as strings) to that channel’s
      samples. Every value in a channel’s list is the same type, either `float`
      or `str`, never mixed; a categorical read such as a mode name or state is
      a string-valued list.
    - **timestamps** ([*list*](https://docs.python.org/3/builtins/stdtypes.html#list "(in Python v3.15)")*[*[*int*](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")*]*) – Timestamps in integer nanoseconds since the Unix epoch, one per
      sample and aligned with the values in `channel_data`. Its length matches
      the length of every list in `channel_data`.
    - **tags** ([*dict*](https://docs.python.org/3/builtins/stdtypes.html#dict "(in Python v3.15)")*[*[*str*](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")*,* [*str*](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")*]* *|* *None*) – Optional metadata for the acquisition, such as a test ID, operator name,
      or environmental qualifier. Used for search, provenance, and analysis.

See [`Command`](https://dev.nominal.io/instro/ref/library/instro.lib.types.Command.md#instro.lib.types.Command "instro.lib.types.Command") for the write counterpart, which carries one datapoint per channel.

### channel_data: dict[str, list[float] | list[str]]

### timestamps: list[int]

### tags: dict[str, str] | None = None

### static create_timestamps_from_dt( t0: int, dt: int, length: int, backstamp: bool, ) → list[int][source]

Build a `length`-long timestamp list at `dt` ns spacing starting at `t0` (ns since epoch).

With `backstamp=True`, shift `t0` back by `dt * (length - 1)` so the
last sample lands at the original `t0` (useful when `t0` is the
completion time of a finite acquisition).

### property values: list[float] | list[str]

Values for the only channel; raises `ValueError` if the Measurement holds multiple channels.

### property latest: float | str

Most recent value of the only channel; raises `ValueError` if the Measurement holds multiple.
