Preprocessing¶
The supported interface is the CLI, rddac preprocess; what each stage does is documented in the Preprocessing section. The Python functions below live in the private rddac._preprocess package and are listed for orientation (notebooks, custom variants), not as a stable API.
Internal API, may change without notice
Anyone replacing a stage should follow Custom processing: read raw data via the public API and match the processed schema, instead of importing from here.
Stages¶
process(data: np.ndarray, columns: Sequence[str] = FORCE_COLUMNS, *, time_window_start: float = FORCE_TIME_WINDOW[0], time_window_end: float = FORCE_TIME_WINDOW[1], position_precision_mm: float = FORCE_POSITION_PRECISION_MM) -> tuple[np.ndarray, dict]
¶
Process one experiment's raw force table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
|
required |
columns
|
Sequence[str]
|
Column layout of |
FORCE_COLUMNS
|
time_window_start
|
float
|
Forming window start in s (exclusive). |
FORCE_TIME_WINDOW[0]
|
time_window_end
|
float
|
Forming window end in s (inclusive). |
FORCE_TIME_WINDOW[1]
|
position_precision_mm
|
float
|
Punch position quantization step. |
FORCE_POSITION_PRECISION_MM
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
dict
|
with the input column order preserved; |
tuple[ndarray, dict]
|
the parameter values used (self-describing output). |
Source code in rddac/_preprocess/force.py
process(data: np.ndarray, *, last_n: int = SHEET_LAST_N) -> tuple[np.ndarray, dict]
¶
Process one experiment's raw sheet-thickness table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
|
required |
last_n
|
int
|
How many trailing traverse positions to keep. |
SHEET_LAST_N
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
dict
|
with NaN where the sensor reported error values; |
tuple[ndarray, dict]
|
counts plus the parameter values used (self-describing output). |
Source code in rddac/_preprocess/sheet.py
process(data: np.ndarray, *, max_sensor_position: int = OIL_MAX_SENSOR_POSITION, output_length: int = OIL_OUTPUT_LENGTH, hampel_window: int = OIL_HAMPEL_WINDOW, hampel_k: float = OIL_HAMPEL_K, value_quantization: float = OIL_VALUE_QUANTIZATION) -> tuple[np.ndarray, dict]
¶
Process one experiment's raw oil table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
|
required |
max_sensor_position
|
int
|
Positions at/after this (mm) are edge artifacts. |
OIL_MAX_SENSOR_POSITION
|
output_length
|
int
|
Fixed output row count (one row per integer mm). |
OIL_OUTPUT_LENGTH
|
hampel_window
|
int
|
Hampel half-window in mm. |
OIL_HAMPEL_WINDOW
|
hampel_k
|
float
|
Hampel threshold in robust sigmas. |
OIL_HAMPEL_K
|
value_quantization
|
float
|
Logging LSB; floors the flat-window fallback scale. |
OIL_VALUE_QUANTIZATION
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
dict
|
on the integer mm grid; |
tuple[ndarray, dict]
|
parameter values used (self-describing output). |
Source code in rddac/_preprocess/oil.py
hampel_filter(positions: np.ndarray, values: np.ndarray, window_size: int = OIL_HAMPEL_WINDOW, k: float = OIL_HAMPEL_K, quantization: float = OIL_VALUE_QUANTIZATION) -> np.ndarray
¶
Outlier mask for a 1D traverse via a position-windowed Hampel filter.
Windows are selected by position distance (not index), so gaps from removed dropouts do not misalign them. In flat windows where the MAD is zero the scale falls back to the mean absolute deviation, floored at one logging quantization step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
Integer sensor positions, one per measurement. |
required |
values
|
ndarray
|
Measured oil values (must not contain NaN). |
required |
window_size
|
int
|
Half-window size in position units (mm). |
OIL_HAMPEL_WINDOW
|
k
|
float
|
Threshold in robust sigmas. |
OIL_HAMPEL_K
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Boolean array; True marks an outlier. |
Source code in rddac/_preprocess/oil.py
The pointcloud stage owns its whole file section (rddac._preprocess.pointcloud.stage.process_experiment) and needs the [preprocessing] extra plus the DDACS simulations; see Point Clouds.
Orchestration and configuration¶
run(names: list[str], data_dir: str, out_dir: str, ids: str | None = None, split: str | None = None, workers: int = 1, overwrite: bool = False, quiet: bool = False, console=None, config: dict | None = None, skip_unavailable: bool = False, rebuild_models: bool = False) -> dict
¶
Process the selected modalities for all selected experiments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
list[str]
|
Modalities to run, in order. |
required |
data_dir
|
str
|
Directory holding the raw dataset (zips or loose |
required |
out_dir
|
str
|
Output directory for processed files (created if missing). |
required |
ids
|
str | None
|
Optional id selection, e.g. |
None
|
split
|
str | None
|
Optional predefined split name to restrict to. |
None
|
workers
|
int
|
Number of parallel worker processes. |
1
|
overwrite
|
bool
|
Recompute modality groups that already exist. |
False
|
quiet
|
bool
|
Suppress progress bar and summary output. |
False
|
console
|
rich console to print to; a new one is created if None. |
None
|
|
config
|
dict | None
|
Modality name → parameter overrides (see :mod: |
None
|
skip_unavailable
|
bool
|
Skip (instead of fail on) modalities whose optional dependencies are missing — used when the user did not name modalities explicitly. |
False
|
rebuild_models
|
bool
|
Force retraining of cached models in preflight. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Stats dict |
Source code in rddac/_preprocess/runner.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
load(path: str) -> dict[str, dict]
¶
Merge a user TOML file over the defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the TOML file. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
The complete configuration (defaults with the file's overrides). |
Raises:
| Type | Description |
|---|---|
ValueError
|
On unknown tables or keys — a silently ignored typo would mean silently NOT applying the user's intended override. |
OSError
|
If the file cannot be read. |
Source code in rddac/_preprocess/config.py
dump()
¶
The complete default configuration as a ready-to-edit TOML string.
Source code in rddac/_preprocess/config.py
Processing figures¶
The figures on the preprocessing pages are drawn from raw arrays by these functions; python -m rddac._preprocess.visualize --help renders them to files.
plot_oil_processing(data, *, figsize=FIGSIZE, **params)
¶
Three panels for ONE experiment's raw oil_thickness/data.
(a) raw readings with the truncation line, (b) truncated readings with the Hampel-flagged outliers, (c) the processed fixed-grid profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
|
required |
figsize
|
tuple[float, float]
|
Figure size in inches. |
FIGSIZE
|
**params
|
Keyword overrides for :func: |
{}
|
Source code in rddac/_preprocess/visualize.py
plot_force_processing(tables, columns=FORCE_COLUMNS, *, figsize=FIGSIZE, **params)
¶
Two panels with several experiments' force/data overlaid.
(a) raw total force over time with the forming window, (b) the processed curves: windowed, time re-zeroed, rest offset removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tables
|
Sequence[ndarray]
|
Raw |
required |
columns
|
Sequence[str]
|
Column layout of the tables (the h5 |
FORCE_COLUMNS
|
figsize
|
tuple[float, float]
|
Figure size in inches. |
FIGSIZE
|
**params
|
Keyword overrides for :func: |
{}
|
Source code in rddac/_preprocess/visualize.py
plot_sheet_processing(tables, *, figsize=FIGSIZE, **params)
¶
Two panels with several experiments' sheet_thickness/data overlaid.
(a) raw traverses (error codes hidden) with the tail-selection cutoff, (b) the processed, position-normalized profiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tables
|
Sequence[ndarray]
|
Raw |
required |
figsize
|
tuple[float, float]
|
Figure size in inches. |
FIGSIZE
|
**params
|
Keyword overrides for :func: |
{}
|
Source code in rddac/_preprocess/visualize.py
plot_luminescence_processing(lumi_2d, *, figsize=(14.0, 3.2), **params)
¶
Four panels for one scan's raw luminescence grid.
(a) raw grid, (b) connected foreground patches, (c) the validity mask after the patch-size filter, (d) the packed uint8 grayscale image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lumi_2d
|
ndarray
|
|
required |
figsize
|
tuple[float, float]
|
Figure size in inches. |
(14.0, 3.2)
|
**params
|
|
{}
|
Source code in rddac/_preprocess/visualize.py
plot_pointcloud_processing(z_2d, lumi_2d, processed_points, *, sim_points=None, stats=None, max_points=300000, figsize=None, **params)
¶
Top-view panels: raw calibrated scan, processed cloud, and optionally the matched simulation and the distance to it.
The raw panel applies only the validity mask and the calibration (steps
1–2 of the stage); the processed panel is the stage's output (cleaned,
ICP-aligned to the matched simulation), so gaps between the two are the
removed artifacts. With sim_points two more panels follow: the
simulation in the same frame, and the processed points coloured by their
nearest-neighbour distance to it (the kd sim-distance feature).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z_2d
|
ndarray
|
|
required |
lumi_2d
|
ndarray
|
|
required |
processed_points
|
ndarray
|
|
required |
sim_points
|
ndarray | None
|
|
None
|
stats
|
dict | None
|
The processed group's attrs; when given, removal counts are shown in the panel title. |
None
|
max_points
|
int
|
Subsampling cap per panel (keeps the figure light). |
300000
|
figsize
|
tuple[float, float] | None
|
Figure size in inches. |
None
|
**params
|
|
{}
|
Source code in rddac/_preprocess/visualize.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |