DRMHB / docs /GROUND_TRUTH.md
AlejandroGZ's picture
fixes
65e41ab
|
Raw History Blame Contribute Delete
5.69 kB

Ground truth for DRMHB researchers

Four different kinds of information

Measured input is raw acceleration/velocity information and measurement context: units, sample rate/frequency grid, point, mode, speed and timing. Construction truth records the simulator's process, health and nuisance states. Waveform truth explains how a captured source became a stored crop. Diagnostic truth (DiagGT) carries diagnostic documents, observations, findings and materialization rules. These are complementary, not interchangeable.

Where Use
obs Snapshot identity and measurement context
X, var Explicit signal-derived feature values and definitions
obsm['raw_waveforms'], raw_spectra and companions Reusable raw signals, real lengths, positions, speeds and tachometer edges
obsm['ground_truth'] Snapshot-aligned construction labels
obsm['waveform_ground_truth'] Per-snapshot records_json with zero or more channel-bound waveform labels
uns['vibframe_evaluation'] Original evaluation files, byte-exact, with source/path/size/SHA-256
uns['vibframe_anndata'] Source, conversion, alignment, channel and feature provenance

Import all the information

from vibframe_anndata import import_raw_to_h5ad
base = import_raw_to_h5ad(
    "data/DRMHB-compact.vibframe.zip", "derived/DRMHB-compact.v0.3.0.raw.h5ad",
    config={
        "version": 1,
        "raw_import": {"on_missing_signal": "nan"},
        "ground_truth": {"enabled": True, "scope": "all",
                         "on_missing": "error", "max_sidecar_mib": 512},
        "output": {"dtype": "float32", "raw_compression": "none"},
    }, block_size_mib=8,
)

Full scope retains regular files under evaluation/, ground-truth/ and ground_truth/, root JSON/YAML documents and machine JSON context. This includes unknown future annotation fields and files. Files outside those locations are not indiscriminately copied. The evaluation archive is not a duplicate waveform archive. Raw trends.parquet is never a source of production feature values.

Identity and time

Use (source, machine_id, snap_t) for snapshot labels. Times are integer microseconds since Unix epoch, UTC. Never infer the unit from the magnitude. Waveform labels additionally bind point and available mode/definition/config identifiers. Missing identity, duplicated bindings and ambiguous modes must not be fixed by row-order or nearest-time guessing.

A source acquisition starts at snap_t; a stored crop starts at t:

t = snap_t + crop offset

New imports retain raw_waveforms_capture_t, raw_spectra_capture_t and the corresponding *_known matrices on the channel axis. Always check real lengths and the known flags: an absent capture is not a date, and a legacy fallback is not an explicitly measured time. Tachometer edges are relative to the stored crop.

Read labels without loading signals

from vibframe_anndata import (
    get_snapshot_ground_truth, get_waveform_ground_truth, list_evaluation_files,
    read_evaluation_table, read_evaluation_json,
)
path = "derived/DRMHB-compact.v0.3.0.features.h5ad"
snapshot = get_snapshot_ground_truth(path)
waveform = get_waveform_ground_truth(path, point_id="pump_DE_H", proc_mode_id="ACC_10K")
files = list_evaluation_files(path)
# Pick an exact source/path from files before calling a reader.
rows = files.loc[files["path"].str.endswith("observations.parquet")]
if not rows.empty:
    item = rows.iloc[0]
    diagnostics = read_evaluation_table(path, item["path"], source=item["source"])

Convenience views can stringify nested fields for HDF5 compatibility. The table reader recovers the original Arrow schema; the byte reader verifies the original hash by default. A selected table is materialized, but unrelated raw buffers are not loaded. Avoid reading the entire uns group just to inspect metadata.

Protocol decisions remain explicit

Normality training must not automatically consume fault identity, severity, physical state, nuisance/OOD flags, simulation seeds or future labels. A known operating state is an oracle input only under an explicitly declared experiment. Do not infer health from missing DiagGT. Consolidated diagnoses and intervals must be interpreted using their original document/materialization semantics.

The aligned views follow observation slicing, but the original archive remains dataset-wide. Features added/recalculated/removed by the package preserve both. Keep independently generated paired controls out of the longitudinal training and evaluation splits; use a separate H5AD/source and pair identities.

Existing H5ADs

Example 04 wraps add_ground_truth_to_h5ad(). It adds originals and aligned annotations to an existing file without recomputing features or source raw signals. Keep obs.source, obs.machine, obs.snap_t and the original source set. The transactional copy requires additional disk space. It does not recreate legacy capture-time companion arrays; new raw imports do. Original waveform truth still provides offsets/durations for audit.

Resource accounting

The H5AD grows by original sidecar bytes, aligned labels, the manifest and timing companions. list_evaluation_files() reports exact original sizes. The 512 MiB budget refers to encoded sidecars, not total RAM. No raw compression is changed. The current longitudinal ZIP is 7,635,324,956 bytes; full-annotation H5AD sizes must be measured after conversion rather than reusing the older snapshot-only sizes.

Authoritative API and full coverage rules: https://413hq.github.io/vibframe-anndata-docs/0.3.0/guides/ground-truth/