---
jupytext:
  text_representation:
    format_name: myst
kernelspec:
  display_name: Python 3 (ipykernel)
  language: python
  name: python3
---

# Introduction to measurement

{.lead}
A measurement turns a physical quantity into numbers a computer can store. Each step on the way sets a limit you can see in the data.

{download}`Download this page as a notebook <introduction-to-measurement.md>` to run its code in JupyterLab. [Running the notebooks](notebooks/running.md) explains how to set it up.

## From physical quantity to data

A measurement chain has four steps:

1. A {gloss}`transducer` turns the quantity, such as pressure or temperature, into an electrical signal.
2. A {gloss}`data acquisition (DAQ) <data acquisition>` system or an {gloss}`instrument` measures that signal.
3. Its {gloss}`analog-to-digital converter (ADC) <analog-to-digital converter>` reads the signal at a fixed rate, as numbers.
4. Software stores each number with a timestamp.

[Sensors and instrumentation](sensors-and-instrumentation.md) covers the first two steps. This page covers the two limits that the third step adds to every measurement: how often it samples, and how finely it reads each sample.

## Sampling rate

To capture a signal, sample faster than twice the highest frequency in it. Content above half the sample rate shows up in the data at false, lower frequencies. This is {gloss}`aliasing`, and it can't be undone afterwards, so an anti-aliasing filter goes before the ADC.[^ee-sampling] Choose the rate before you record, because no later step can restore what the sampling left out. [Measurement quality](measurement-quality.md) shows an alias in a plot.

## Resolution

An ADC reads a signal as a whole number of steps, so it rounds each reading to the nearest step. That adds an error of up to half a step.[^ee-quantization] More bits make the steps smaller:

```{code-cell} ipython3
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from learning.style import set_matplotlib_style

set_matplotlib_style()
```

```{code-cell} ipython3
t = np.linspace(0, 1, 1_000)  # s
signal = 2.5 + 2.0 * np.sin(
    2 * np.pi * 3 * t
)  # V: a 3 Hz signal between 0.5 V and 4.5 V


def read(x, bits, full_scale=5.0):
    """Round x, in volts, to the nearest step of an ADC with a 0 to full_scale range."""
    step = full_scale / 2**bits
    return np.round(x / step) * step, step


fig, ax = plt.subplots()
ax.plot(t, signal, color="0.5", label="True signal")
rows = []
for bits in (3, 8):
    reading, step = read(signal, bits)
    ax.step(t, reading, where="mid", label=f"{bits}-bit reading")
    rows.append(
        {
            "bits": bits,
            "step (mV)": step * 1e3,
            "largest error (mV)": np.abs(reading - signal).max() * 1e3,
        }
    )
ax.set_xlabel("Time (s)")
ax.set_ylabel("Voltage (V)")
ax.legend()
plt.show()
pd.DataFrame(rows).round(1)
```

The largest error in each row is no more than half its step. A 3-bit ADC can't show the signal's shape, and an 8-bit one shows it almost exactly. Resolution is only one source of error, and a fine step doesn't make a reading accurate: [Measurement quality](measurement-quality.md) compares resolution with accuracy and noise.

## In Nominal

Once the readings have timestamps, upload them to Nominal to chart them against your other data. A CSV file needs one timestamp column, and every other column becomes a channel.[^nominal-csv-parquet] This code uploads a CSV file of a temperature reading, and gives its channel a unit:

```python
from nominal.core import ChannelDataType, NominalClient

client = NominalClient.from_profile("default")
dataset = client.create_dataset("Bench temperature")

# temperature.csv has a "timestamp" column in ISO 8601 and a "temperature" column
dataset.add_tabular_data("temperature.csv", timestamp_column="timestamp", timestamp_type="iso_8601")
dataset.add_channel("temperature", ChannelDataType.DOUBLE, unit="Cel")
```

The unit is a UCUM symbol, such as `Cel` for degrees Celsius, so workbooks can convert between units.[^nominal-channels] The client's `add_tabular_data` and `add_channel` methods are the ones used above.[^nominal-client] To send values as they're measured instead, see [Telemetry ingestion](telemetry-ingestion.md).

## Further reading

- [Sensors and instrumentation](sensors-and-instrumentation.md), on what sits before the ADC.
- [Measurement quality](measurement-quality.md), on accuracy, resolution, noise and sampling.
- [Frequency domain](frequency-domain.md), on what a sampled signal contains.

## References

[^ee-sampling]: EE Notebook, ["Sampling Theory"](https://applied-ee.github.io/ee-notebook/docs/audio-signal/sampling-and-conversion/sampling-theory/). Retrieved 2026-11-12.
[^ee-quantization]: EE Notebook, ["Quantization Effects"](https://applied-ee.github.io/ee-notebook/docs/audio-signal/practical-signal-reality/quantization-effects/). Retrieved 2026-11-12.
[^nominal-csv-parquet]: Nominal, ["CSV and Parquet"](https://dev.nominal.io/file-ingestion/csv-parquet/). Retrieved 2026-11-24.
[^nominal-channels]: Nominal, ["Channels and data types"](https://dev.nominal.io/python/guides/datasets/channels/), Python client guide. Retrieved 2026-11-24.
[^nominal-client]: Nominal, `NominalClient.create_dataset`, `Dataset.add_tabular_data` and `Dataset.add_channel` in the [nominal](https://pypi.org/project/nominal/) Python client, version 1.186.0. Retrieved 2026-11-30.
