# Measurements
URL: /measurements
Learn how to capture and validate data within OpenHTF phases, including boolean, string, numeric, multidimensional, and marginal measurements.
Create measurements to capture and validate data within phases.
Hardware tests are more complex than simple pass/fail checks like in software testing. They often require measuring physical values and comparing them to limits. OpenHTF simplifies logging and validating numeric, string, and boolean values, either individually or in arrays, using built-in decorators.
You can define and validate numeric measurements.
Ensure the measurement is within the given range.
Ensure the measurement is within the given percentage range.
Ensure the measurement exactly matches the specified value.
Apply a custom validator function to the measurement.
Define the unit of the measurement (e.g. `units.AMPERE`, `units.VOLT`). All 2,134 constants are listed in the units reference.
Round the value to the specified precision before validation.
You can define and validate string measurements.
Ensure the measurement exactly matches the specified value.
Ensure the string matches the specified regex pattern.
Apply a custom validator function to the measurement.
You can define and validate boolean measurements.
Ensure the measurement exactly matches the specified value.
Apply a custom validator function to the measurement.
You can capture data in arrays, like time-series or sweeps, with multidimensional measurements. Each dimension is an input axis (the coordinates you index with); `with_units` describes the stored value.
Indexing a dimensioned measurement returns a `DimensionedMeasuredValue`; call `.to_dataframe()` on it (requires `pandas`) to analyse the samples inside a later phase. Monitors create a one-dimensional time series like `temperature_over_time` automatically from a background thread.
Declare one input axis per argument. Use `htf.Dimension(description=..., unit=...)` to label an axis.
Apply a scalar validator to every stored value, e.g. `.dimension_pivot_validate(validators.in_range(20, 30))`. See the validators reference.
You can also use multiple measurements in a single phase.
You can mark a measure as marginal to show it's close to failing, even if it passes.
You can add a description to your measurements.
You can customize measurement names dynamically at execution.
You can apply measurement transformation functions before validation.
Python decorators are callables, so you can define measurement parameters dynamically at runtime and apply them to phase functions. The Decorators page explains the mechanism; this is the measurement-specific case.
Typical use: limits loaded from a configuration file or a product database at station start.