Data provenance#

Data provenance is the record of where data came from and what was done to it. This page covers what to record with a recording, and how to keep that record in Nominal beside the data.

Download this page as a notebook to run its code in JupyterLab. Running the notebooks explains how to set it up.

Why record it#

A result you can’t trace back to its data, and the steps applied to it, is hard to check or repeat. The FAIR principles, written for scientific data, ask that metadata record detailed provenance, and that data be described with rich metadata.[1] Traceability is the other half: from a result back to the recording, the software and the steps, and from a unit forward to every recording of it.

What to record#

For a recording of a test, keep:

  • The source. Which instrument or sensor produced each channel, its calibration, and the system’s configuration for the run.

  • The units. Each channel’s engineering units, stored with the data.

  • The software. The version of the program that wrote the data, and of any that changed it.

  • The steps. Each change made to the data after it was recorded, such as a filter or a unit conversion, in order.

  • The unit under test. Which unit the recording tested, so you can trace from a unit to its data and back. See Genealogy.

A manifest#

This code builds a manifest, a small JSON document with those items, for a made-up recording. It hashes the file’s bytes with SHA-256, so you can later check that a file is the one the manifest describes:

import hashlib
import json
from datetime import datetime, timezone

import pandas as pd

recording = (
    "timestamp,temperature\n"
    "2026-01-01T12:00:00Z,21.0\n"
    "2026-01-01T12:00:01Z,21.1\n"
    "2026-01-01T12:00:02Z,21.1\n"
).encode()

manifest = {
    "file": "oven-0042-soak.csv",
    "sha256": hashlib.sha256(recording).hexdigest(),
    "recorded_at": datetime(2026, 1, 1, 12, tzinfo=timezone.utc).isoformat(),
    "unit_under_test": {"serial": "0042", "type": "oven"},
    "source": {
        "channel": "temperature",
        "sensor": "thermocouple t_1",
        "calibrated": "2025-12-01",
    },
    "channels": {
        "temperature": {"unit": "Cel", "description": "Oven air temperature"}
    },
    "software": {"logger": "soak-logger 1.4.2"},
    "steps": ["none: the file is as recorded"],
}
print(json.dumps(manifest, indent=2))
{
  "file": "oven-0042-soak.csv",
  "sha256": "05c9d675e447a437464833bdd9e478899ebc31a26ca6c9d95e0aef80e5f00b6c",
  "recorded_at": "2026-01-01T12:00:00+00:00",
  "unit_under_test": {
    "serial": "0042",
    "type": "oven"
  },
  "source": {
    "channel": "temperature",
    "sensor": "thermocouple t_1",
    "calibrated": "2025-12-01"
  },
  "channels": {
    "temperature": {
      "unit": "Cel",
      "description": "Oven air temperature"
    }
  },
  "software": {
    "logger": "soak-logger 1.4.2"
  },
  "steps": [
    "none: the file is as recorded"
  ]
}
# Later: check that a file is the one the manifest describes
file_hash = hashlib.sha256(recording).hexdigest()
print("matches the manifest:", file_hash == manifest["sha256"])
pd.DataFrame(manifest["channels"]).T
matches the manifest: True
unit description
temperature Cel Oven air temperature

The names and values above are made up. The point is that the manifest travels with the file, and that it records each step as it happens, since a step you didn’t record can’t be recovered afterwards.

In Nominal#

A Nominal dataset carries properties, key-value pairs such as "serial"="ABADCAFE", and labels.[2] A run names a span of time for one test, and references data rather than copying it.[3] Store the manifest’s items as properties, so they stay with the data and you can search by them. This code creates a dataset and a run from the manifest:

from datetime import datetime, timedelta, timezone

from nominal.core import ChannelDataType, NominalClient

client = NominalClient.from_profile("default")
start = datetime(2026, 1, 1, 12, tzinfo=timezone.utc)

dataset = client.create_dataset(
    "Oven 0042 soak",
    properties={
        "sha256": manifest["sha256"],
        "serial": manifest["unit_under_test"]["serial"],
        "logger": manifest["software"]["logger"],
        "calibrated": manifest["source"]["calibrated"],
    },
    labels=["soak"],
)
dataset.add_tabular_data("oven-0042-soak.csv", timestamp_column="timestamp", timestamp_type="iso_8601")
dataset.add_channel("temperature", ChannelDataType.DOUBLE, unit="Cel", description="Oven air temperature")

run = client.create_run(
    "Oven 0042 soak",
    start=start,
    end=start + timedelta(seconds=2),
    properties={"serial": manifest["unit_under_test"]["serial"]},
)

The client’s create_dataset, add_channel and create_run take the properties, labels and units used above.[4]

Further reading#

References#