calamari.repeats.AggregatedMeasurement#

class calamari.repeats.AggregatedMeasurement(path, data_format, measurement_type, file_role, title, header=dict(), data=DataFrame(), moment_base=None, source=None, grouped_by='', grouped_by_family=dict(), error_rule='', params=dict())#

Bases: Measurement

A Measurement whose repeats are combined.

Produced by aggregate_repeats(), never constructed directly. It is a real Measurement subclass, and deliberately so: because aggregation writes the combined values back under the file’s own column spellings, every accessor – moment_emu, moment_err_emu, chi_real, field_oe, the whole unit-resolution machinery – is inherited and simply works, and every consumer in calamari.plot, calamari.fitting, calamari.transitions and calamari.sweeps takes one unchanged. Not one accessor is overridden.

restrict and with_moment return an AggregatedMeasurement too, with the provenance intact, because they derive via dataclasses.replace(), which constructs type(self). The per-quantity [n] and [Birge] diagnostics are ordinary columns rather than parallel arrays for the same reason: restrict subsets them correctly with no code of its own.

data#

Not the raw table the base class documents. This is the one derived case in calamari: the value and error columns hold combined numbers under the file’s original column names, so data['Moment (emu)'] is no longer what the instrument wrote. The unaggregated table is on source. Two provenance columns per combined quantity, X [n] and X [Birge], are added.

Type:

pandas.DataFrame

source#

The measurement this was aggregated from. Constituent rows are recoverable by re-running repeat_groups() on it with params, since grouping is deterministic – which is why no row-membership bookkeeping is stored here.

Note this is the original, always: after restrict() it still refers to the unfiltered measurement.

Type:

calamari.measurement.Measurement

grouped_by#

Which mechanism grouped the rows: 'measurement-number', 'setpoint-tolerance', or 'empty' when there was nothing to group – a file with no rows, or one holding only housekeeping rows, which are carried through as themselves either way.

Mechanisms are chosen per family, so a combined run whose AC rows carry a usable Measurement Number and whose VSM rows do not reports the composite 'VSM:setpoint-tolerance+AC:measurement-number', in FAMILY_ORDER. This attribute follows measurement_type exactly: one plain name while the families agree – which is every single-family file – and a composite only when they genuinely differ. Branch on grouped_by_family rather than parsing it.

Type:

str

grouped_by_family#

The same answer keyed by measurement family, {'VSM': 'setpoint-tolerance', 'AC': 'measurement-number'}. This is the structured form of grouped_by, and the one to read: which mechanism grouped a given family decides how much its [n] column can be trusted, and a file can now answer differently for each.

Empty when grouped_by is 'empty'. A file calamari could place in no family at all – one with no moment or susceptibility column populated anywhere – keys its single population as 'unknown'.

Type:

dict

error_rule#

Which uncertainty was written: 'birge', 'internal' or 'external'.

Type:

str

params#

The tolerances and options actually used, not merely the mechanism’s name – without them, “re-running the grouping reproduces the groups” would only hold for default calls.

Type:

dict

Notes

The error columns carry two conventions at once after aggregation. A group of one keeps whatever the instrument wrote, including its “0 means a single scan, not exact” zero (see moment_err_emu); a group of two or more holds a combined, possibly Birge-inflated error. The [n] column is what tells the two apart, and is the thing to check before using an error column as a fit weight.

summary()#

The base summary plus how the aggregation was done.

Adds grouped_by, grouped_by_family, error_rule, median_n and max_birge. n_points means what it says – rows in this object, i.e. groups – so it is no longer the file’s row count; that is len(source.data).

Return type:

dict