Skip to content

particula.data.product

Validated materialized measurement products and portable field contracts.

Classes

NameDescription
DerivedMeasurementA scalar product with per-scan quality, parents and calibration links.
FieldContractSelect a field by quantity, unit and optional coordinate requirements.

Functions

NameDescription
_reference_unitsRead physical dimensions from the installed measurement schema.
product_fieldsDescribe scalar and array inputs with their coordinate grids.

DerivedMeasurementclass#

class DerivedMeasurement(scans: pl.LazyFrame, issues: pl.LazyFrame, manifest: dict)

Bases: Measurement

A scalar product with per-scan quality, parents and calibration links.

gridsattributeinstance attribute#

grids = {}

lazy_frameattributeinstance attribute#

lazy_frame = scans.with_columns(pl.lit(manifest['source_sha256']).alias('source_sha256'))

lazy_issuesattributeinstance attribute#

lazy_issues = issues

manifestattributeinstance attribute#

manifest = manifest

__init__method#

def __init__(scans: pl.LazyFrame, issues: pl.LazyFrame, manifest: dict) -> None

Verify the declared operation, result field and row-level lineage.

Inherited from particula.data.measurement.Measurement

frameproperty#

frame: pl.DataFrame

Collect the selected scans in memory, including their source IDs.

issuesproperty#

issues: pl.DataFrame

Collect source-located diagnostics.

product_idproperty#

product_id: str

Identify the source interpretation, deployment and selected scans.

_delimited_schemamethod#

def _delimited_schema(manifest)

Derive the combined scan schema from the recorded file segments.

_flag_columnmethod#

def _flag_column() -> str | None

Return the name of the scan-level flag column, if present.

available_operationsmethod#

def available_operations() -> dict[str, tuple[str, ...]]

Map compatible operation names to their required input names.

filtermethod#

def filter(predicate: pl.Expr | pl.Series | str | Iterable[pl.Expr | pl.Series | str] | bool | list[bool] | np.ndarray) -> Self

Select scans while retaining the original source diagnostics.

Parameters

NameTypeDescription
predicatepl.Expr | pl.Series | str | Iterable[pl.Expr | pl.Series | str] | bool | list[bool] | np.ndarrayBoolean expression, column, mask, or predicates accepted by Polars LazyFrame.filter.

Returns

Self
Measurement of the same type with a lazily filtered scan table.
Self
The manifest and diagnostics still describe the full source.

flag_summarymethod#

def flag_summary() -> pl.LazyFrame

Count each quality condition once per scan.

Returns

pl.LazyFrame
Lazy table of flag labels, affected and total scan counts, and
pl.LazyFrame
the first and last UTC time at which each flag appeared.

Raises

ValueError
The measurement has no declared quality flags.

quality_summarymethod#

def quality_summary(field: str, *, exclude_flags: str | Iterable[str] = (), exclude_repaired: bool = False) -> pl.LazyFrame

Summarize a scalar field after explicit source-quality exclusions.

Parameters

NameTypeDefaultDescription
fieldstrrequiredName of a scalar field declared in the profile.
exclude_flagsstr | Iterable[str]()Exclude scans carrying these vendor or derived flags.
exclude_repairedboolFalseOmit scans reconstructed from logger fragments.

Returns

pl.LazyFrame
One lazy row with the source, exclusion policy, scan and sample
pl.LazyFrame
counts, and UTC bounds of excluded scans. The mean weights each
pl.LazyFrame
retained, non-null sample equally and uses the field’s output unit.

Raises

ValueError
The field is undeclared or the requested flag exclusions require a missing vendor status field.

FieldContractclassdataclass#

class FieldContract(quantity: str, unit: str, field: str | None = None, axes: tuple[str, ...] = (), basis: str | None = None)

Select a field by quantity, unit and optional coordinate requirements.

Parameters

NameTypeDefaultDescription
quantitystrrequiredMeasured quantity, e.g. voltage or number_per_log10_diameter.
unitstrrequiredUnit expected by the implementation.
fieldstr | NoneNoneOptional explicit column if several channels match.
axestuple[str, ...]()Ordered axis names for an array or spectrum. Empty for a scalar.
basisstr | NoneNoneRequired diameter convention, e.g. electrical_mobility.

axesattributeclass attributeinstance attribute#

axes: tuple[str, ...] = ()

basisattributeclass attributeinstance attribute#

basis: str | None = None

fieldattributeclass attributeinstance attribute#

field: str | None = None

quantityattributeinstance attribute#

quantity: str

unitattributeinstance attribute#

unit: str

__init__method#

def __init__(quantity: str, unit: str, field: str | None = None, axes: tuple[str, ...] = (), basis: str | None = None) -> None

__post_init__method#

def __post_init__() -> None

Require enough information to interpret the measured values.

resolvemethod#

def resolve(fields: list[dict]) -> dict

Select exactly one compatible field by quantity and optional name.

_reference_unitsfunctioncached#

def _reference_units() -> dict[str, str]

Read physical dimensions from the installed measurement schema.

product_fieldsfunction#

def product_fields(product: Measurement) -> list[dict]

Describe scalar and array inputs with their coordinate grids.