gcode_reader.emulate.diagnostics¶
Sanity checks for AdditivePart inputs and derived state.
Surfaces common silent-failure modes that otherwise propagate as zero-valued or oddly-shaped statistics:
check_extrusion: extrusion did not register (often a wrong-machine config), nois_depositingrows, or zero depositing distance/volume.check_geometry: degenerate bounding-box dimensions, suspicious aspect ratios.check_layer_grouping: non-monotonic layer ordering, misalignedlayer_normal, coordinate-resolution fragmentation, or outlier moves at unrelated heights (the failure mode that motivated the original layer-grouping fix).check_additive_part: runs all of the above plus cross-cutting checks (1 layer despite measurable build extent, implausible implied layer thickness, zero deposition length/volume despite depositing rows).
Each check returns a dict with the raw numbers and a list of human-readable
warnings. The format_*_report helpers render those dicts as text.
Functions¶
|
Run the full battery of sanity checks on an AdditivePart. |
|
Verify that extrusion data is present and non-trivial. |
|
Sanity-check the deposition bounding box and overall geometry of an AdditivePart. |
|
Compute layer-grouping sanity checks for a tagged G-code DataFrame. |
|
Render the output of |
|
Render the output of |
Module Contents¶
- gcode_reader.emulate.diagnostics.check_additive_part(part) dict[source]¶
Run the full battery of sanity checks on an AdditivePart.
Combines
check_extrusion,check_geometry, andcheck_layer_grouping, plus a few cross-cutting checks (layer count plausibility, deposition length).Returns a dict with one sub-dict per check and a flat
warningslist that aggregates every warning, prefixed by which check raised it.
- gcode_reader.emulate.diagnostics.check_extrusion(df: pandas.DataFrame) dict[source]¶
Verify that extrusion data is present and non-trivial.
A common silent failure mode is configuring the wrong machine/extruder, in which case
deposited_volumestays at zero andis_depositingis empty even though the G-code clearly contains print moves. Downstream stats (layer count, volume, mass, deposition bounds) then come back as zero or missing with no error raised.Returns a dict with:
has_is_depositing_col,has_deposited_volume_coln_depositing_rows: number of rows taggedis_depositing == Truedepositing_fraction: fraction of rows that are depositingtotal_deposited_volume: sum of thedeposited_volumecolumnn_depositions: distinctdeposition_idvalues among depositing rowswarnings: human-readable flags
- gcode_reader.emulate.diagnostics.check_geometry(part) dict[source]¶
Sanity-check the deposition bounding box and overall geometry of an AdditivePart.
Flags degenerate dimensions (zero extent in any axis), unusually thin parts (aspect ratio > 1000), and missing bounds. A zero extent in the build direction is often a tell-tale of extrusion not registering or of a single-layer parse.
Returns a dict with:
bounds:((xmin, ymin, zmin), (xmax, ymax, zmax))or Nonedims:(dx, dy, dz)or Noneaspect_ratio: max(dim) / min(positive dim), or inf if any dim is zerowarnings
- gcode_reader.emulate.diagnostics.check_layer_grouping(df: pandas.DataFrame, layer_index_col: str = 'layer_index', layer_height_col: str = 'layer_height', sliver_count: int = 5, max_gap_ratio: float = 10.0) dict[source]¶
Compute layer-grouping sanity checks for a tagged G-code DataFrame.
- Parameters:
df – DataFrame with
layer_indexandlayer_heightcolumns (the output ofinsert_layer_indices_gcode_dataframe).layer_index_col – Column name for layer indices.
layer_height_col – Column name for projected heights.
sliver_count – A layer with fewer than this many rows is flagged as a sliver.
max_gap_ratio – Gaps between consecutive layers larger than
max_gap_ratio * median_gapare flagged as outliers (e.g. a probe move at an unrelated height).
- Returns:
n_layers: number of distinct layer indicesmonotonic: True iflayer_indexis in ascending physical-height orderrank_correlation: Pearson correlation between layer_index and physical height (near +1 = healthy, near 0 = scrambled ordering)min_gap,median_gap,max_gap: gaps between consecutive layer heightsmin_spread,median_spread,max_spread: within-layer height spread (large values relative to gap suggest the normal is misaligned)n_slivers: number of layers with fewer thansliver_countrowsn_outlier_gaps: number of gaps larger thanmax_gap_ratio * median_gapper_layer: DataFrame indexed by layer_index with min/max/count/spread columnswarnings: list of human-readable strings flagging anomalies
- Return type:
A dict with summary statistics and a
per_layerDataFrame. Keys