Post-Production Workflow Guide¶
This guide explains how to write and run a pycWB post-production workflow. Post-production starts after search jobs have produced catalog and progress Parquet files. A workflow YAML then selects analysis subsets, matches simulation triggers to injection truth, trains or applies ranking models, builds FAR products, computes simulation efficiency, and writes report artifacts.
The main command is:
pycwb post-process path/to/postprocess_workflow.yaml
To inspect the dependency graph without running any action:
pycwb post-process path/to/postprocess_workflow.yaml --diagram-only
The user-facing template
examples/postproduction/standard_analysis_10pct_workflow.yaml is a good
starting point for a complete background, simulation, FAR, efficiency, and
HTML-report workflow.
Terminal progress and detailed logs¶
Install the optional terminal display dependency:
pip install 'pycwb[terminal]'
The native CLI automatically uses a Rich dashboard when stdout and stderr are attached to an interactive terminal and Rich is installed. The vertical workflow uses step names from the YAML, marks pending, running, completed, resumed, failed and interrupted steps, and shows elapsed time and counts of finished and pending stages. A recent-output panel shows action output and INFO/warning/error messages. DEBUG logging from PycWB goes to the detailed file without filling the recent-output panel.
pycwb post-process workflow.yaml --log-file logs/postproduction.log
--log-file appends a UTF-8 plain-text log with the complete step plan,
timestamped step transitions, stdout/stderr, PycWB DEBUG diagnostics and failure
tracebacks. Relative log paths are relative to the shell’s current directory;
missing parent directories are created. Terminal control sequences are removed
from the log. The dashboard itself is never written into it. Without this
option, no detailed log file is created.
Action messages focus on progress, aggregate event counts, scientific results,
selected compute resources, and output locations. Per-batch column mappings,
ranking-hook confirmations, feature add/remove messages, and raw parameter
dumps are omitted. Training configuration remains available in the saved
training settings when dump_training_review is enabled. Warnings, errors,
and failure tracebacks are retained; performance JSONL records are independent
of the terminal display.
The dashboard refreshes twice per second and retains only a bounded recent output buffer. Long workflows show a window around the active step; small terminals stack the workflow and output panels. Stage counts are not estimates of remaining computation time. Individual actions still execute sequentially with their existing output and resume behavior.
Use ordinary line-based progress for a batch job or a readable terminal stream:
pycwb post-process workflow.yaml --progress plain --log-file logs/postproduction.log
--progress auto is the CLI default. It falls back to plain output when
redirected, when TERM=dumb, or when Rich is unavailable. --progress live
explicitly requests Rich, including when terminal detection is unavailable;
it fails with installation instructions if Rich is missing. These execution
options do not affect --diagram-only.
On normal POSIX CLI sessions, capture includes C/C++ output and output inherited by synchronous child processes. With embedded Python streams (such as StringIO) or on other platforms, capture covers Python streams only. Capture and temporary logging configuration are process-wide and restored on completion, failure or interruption; use separate processes for concurrent workflows. PycWB imports that happen before workflow execution, such as initial ROOT startup, are outside this log’s scope. Failed actions still raise their original exception and the CLI exits unsuccessfully.
Python callers retain plain output by default and may opt in with
run_workflow(..., progress="auto", log_file="logs/postproduction.log").
Resuming completed actions¶
Resume is enabled by default, including for direct calls to supported Python
actions. A single hidden status record is saved beside the first essential
output: model.ubj uses .model.ubj.status.json. The record is atomically
marked running before execution, then complete after the action returns
successfully, all essential outputs exist, and its result can be serialized.
It stores the action and argument fingerprints, input/output paths, returned
counts and other serializable metadata. When the same action runs again with
unchanged settings, code and input/output paths, and all essential output files
exist, it logs a warning and restores that result without recomputing. Later
@step.path references and output_alias values work as usual.
Supported products include saved selections/splits, models, matched and scored
catalogs, and reports with a complete file inventory. An action returning
DataFrames, Arrow tables or other transient objects executes normally; no
complete status is written for that result. Selection requesting in-memory
intervals or triggers therefore continues to run. Existing products without a
status record run once to establish one. Missing essential outputs, changed
input/output paths or arguments, or a failed/interrupted action prevent reuse.
A running record means completion was not confirmed; it can remain after
failure, interruption, missing required outputs or an unsuccessful status write.
Such a step executes again even when all output filenames exist. Outputs are
written directly to their normal paths; only the status record uses an atomic
temporary-file rename.
Existing <output>.resume.json completion records are still accepted. On
successful reuse they are migrated to the hidden complete record without
recomputing. A hidden status record takes precedence over any legacy record,
including when the hidden record is incomplete or invalid.
Resume trusts pipeline artifacts at the same resolved paths: it ignores file
contents, size, modification time, device and inode numbers, including metadata
in older completion records. Input existence is not checked by the completion
record; action-specific inventory resolvers may still inspect small manifests
or catalog metadata to determine dependency paths. Use --no-resume when
replacing data at an existing path and wanting to recompute its products.
The action’s module source is fingerprinted as well. This conservatively invalidates its actions after any edit to that module, but does not automatically track every imported helper or library version. Additional file dependencies are declared by each action’s resume contract; after changing an untracked dependency, force the affected actions to run again. INFO logs explain why a completion record was rejected (settings, implementation, inventory, file paths, or missing/invalid records and outputs).
import_cwb_root, process_background and compute_livetime retain
their transient results and run normally. generate_waveform_report and
training with dump: true also run normally because their complete output
inventory depends on the data or executable configuration. Training with
dump_training_review: true supports resume. Reports that intentionally
produce no required plots, such as empty foreground reports or diagnostics
for models without saved training history, run again.
To disable resume for a workflow or an individual step:
runtime:
resume: false
steps:
- id: split
action: postprocess.selection.trigger_selection
resume: true
# inputs, args and outputs as usual
A step’s resume overrides runtime.resume; args.resume is also
accepted when no step-level switch is supplied. To force the entire workflow
to execute its actions, including steps with resume: true, use:
pycwb post-process workflow.yaml --no-resume
The equivalent Python switches are run_workflow(..., resume=False) and,
for supported actions, action(..., resume=False). A successful forced run
updates its completion record. Output collision protections still apply to
merge actions; disabling resume does not authorize overwriting a merge label.
Catalog merging reuses its existing committed merge[.LABEL].json manifest
instead of a new sidecar, validating the snapshot’s catalog, progress and
simulation truth. A labeled partial merge is a frozen snapshot: it stays the
same when workers produce more results. Use a new label to merge newer work.
The original incomplete-run permission and metadata-checking requirements
still apply when reusing a snapshot. Removing tmp:// outputs during cleanup
also removes the ability to reuse those particular steps.
Standalone pycwb merge also accepts --no-resume. Merge resume reads the
saved Parquet or HDF5 payloads to validate their integrity, so large merged
products still incur sequential I/O without reprocessing worker fragments.
Performance for large catalogs¶
The waveform efficiency report counts inclusive background tails in Parquet batches for rare-event IFAR cuts, retaining only the values needed for the displayed threshold. It preserves ties and the injection denominator. Less restrictive cuts use the original single-column calculation. The background HTML summary retains compact numeric vectors for its global ranks and plots; event details are decoded only for the displayed rows. These report reductions still require memory proportional to the number of background events, but no longer retain every event ID and descriptive field.
Catalog selection writes bounded 65,536-row batches. For a training-only
catalog, trigger_selection can take columns to read and write only
explicitly required raw feature columns. Identity and physical-lag columns
are retained automatically. Include every column required by downstream
features, cuts and ranking hooks; projection is explicit and never inferred
from a sample. Omit columns to retain the complete catalog schema.
Projection requires trigger file outputs and cannot be combined with a
trigger_filter expression. batch_size controls the row buffer, whose
byte size depends on the catalog’s column types.
File-output interval splits automatically use DuckDB for supported plain progress schemas with integer membership keys. The split keeps the original source-order pandas exposure sums, seeded partition assignment, trigger order, Parquet payloads and catalog provenance. It reads compact numeric metadata and writes progress and trigger payloads in batches, avoiding a complete enriched progress DataFrame. Existing Python arguments, YAML settings and result fields are unchanged. Custom job filters, complex progress schemas and in-memory progress results use the existing selection path.
This path uses a private one-thread DuckDB connection with a 2 GB database memory limit. DuckDB may spill joins and sorts to a temporary directory on the trigger output filesystem; allow disk space there. The directory is removed when selection finishes or fails. Compact numeric metadata and other Python buffers still consume memory proportional to progress rows, so the database limit is not a limit on total process RAM.
For XGBoost training, read_batch_size: 65536 preprocesses projected raw
columns in batches before concatenating compact float32 feature tables.
It preserves file/row order, cleaning, caps, the configured random seed,
balancing and the evaluation split. Cuts must be row-local: reductions such
as rho0.mean() are rejected because computing them per batch changes
the population. Clean matched simulations upstream when using this mode;
the legacy matched_outer_file option uses the eager reader. Training
still retains all compact features and the booster in memory; this is not
out-of-core booster training. n_threads optionally sets the booster CPU
allocation; verbose: 25 prints metrics every 25 rounds without changing
the configured stopping rules or number of trees.
evaluate_far_rho supports an exact histogram accumulation path with
batch_size: 65536, fixed vmin/vmax, positive bin_size and
return_per_event: false. It scores bounded batches, streams the optional
scored catalog, and sums integer bin counts. Bin edges, finite-value handling,
prediction cuts, tail counts and exposure normalization follow the eager
path. User ranking hooks must be row-local, as for score_catalog; hooks
that normalize using the complete population must use the eager action.
No complete-population sort is performed in histogram mode. Scored Parquet
and JSON products are published after successful processing.
To record timings for each action, add:
runtime:
profile_file: pp_logs/step_timings.jsonl
Each record contains elapsed seconds, completion/failure status and the process RSS at step exit. The RSS value is not a measurement of that step’s peak memory. Existing selected outputs do not imply workflow resumption; the runner still starts at the first action on each invocation.
For a compact multi-run study, see
examples/postproduction/angle_error_comparison_workflow.yaml. It shows a
generic three-action pattern: combine and reindex an array of catalogs, pass
the combined data to interactive plot actions, then assemble every returned
HTML plot in one generic report page. Each input needs only a generic name
and catalog_file. The reader adds run_index and run_name columns
and also reads scheduled injections from catalog job metadata, so an injection
missed by the search is not lost from the denominator. Optional extra fields
are retained as metadata, without prescribing which factor the study varies.
What The Workflow Consumes¶
A complete post-production workflow usually consumes these files:
Artifact |
Typical path |
Purpose |
|---|---|---|
Background catalog |
|
Trigger rows used for training, FAR holdout, and zero-lag scoring. |
Background progress |
|
Job/livetime rows used for train/FAR splits and reports. |
Simulation trigger catalog |
|
Recovered simulation triggers. |
Simulation progress |
|
Job metadata for selecting a simulation training subset. |
Simulation summary |
|
One row per injected signal, generated before post-production. |
XGBoost config |
|
Feature and ranking-statistic configuration. |
Public alerts |
|
Optional known-event candidates for the background report. |
For simulation studies, build simulations.parquet before running the
workflow:
pycwb simulation-summary user_parameters.yaml \
--work-dir /path/to/sim/run \
--output /path/to/sim/run/catalog/simulations.parquet
You can also run matching as a standalone command, but complete workflows
should prefer the explicit postprocess.matching.match_simulations action:
pycwb match-simulations catalog.parquet simulations.parquet \
--how right --output matched_right.parquet
YAML Structure¶
A workflow has three top-level sections:
varsUser-editable values and reusable paths. Put run names, chunks, split fractions, output locations, and input file paths here.
runtimeExecution settings owned by the workflow runner, especially the temporary directory and cleanup policy.
stepsOrdered actions. Each step declares an
id, human-readablename, action path,inputs, optionalargs, andoutputs.
Minimal shape:
vars:
work_dir: .
paths:
bkg_catalog: BKG/run/catalog/catalog.parquet
runtime:
tmp_dir: ${work_dir}/tmp/postprod
cleanup_tmp: never
steps:
- id: example_step
name: Example Step
action: postprocess.selection.trigger_selection
inputs:
catalog_file: ${paths.bkg_catalog}
progress_file: BKG/run/catalog/progress.parquet
args:
returns: [jobs, triggers, livetime]
outputs:
triggers_file: tmp://selected.parquet
Variables, References, And Temporary Files¶
Use ${...} to expand values from vars. Dotted paths are supported:
vars:
work_dir: .
chunks:
train_bkg_1: K20
train_bkg_2: K22
target: K21
tag: k20_k22_k21
train_fraction_label: 10pct
run:
output_name: O4_${chunks.target}_run1
analysis_slug: bkg_${chunks.tag}_${train_fraction_label}
paths:
output_dir: public/${run.output_name}
model_file: ${paths.output_dir}/models/${run.analysis_slug}_xgb_model_blf.ubj
When an entire value is one variable reference, its YAML type is preserved. Use this to make structured action inputs explicit and reviewable rather than relying on values inherited implicitly from the workflow context:
vars:
runs:
- name: reference
catalog_file: first/catalog.parquet
- name: comparison
catalog_file: second/catalog.parquet
steps:
- id: read_runs
action: postprocess.multi_run.read_catalog_runs
inputs:
runs: ${runs} # remains a list, not a string
Use @step.path to read values returned by earlier steps:
catalog_file: "@k21_bkg_split.far.triggers_file"
livetime: "@k21_bkg_split.far.livetime.seconds"
Use tmp:// for intermediate files. The workflow runner resolves those
paths under runtime.tmp_dir:
runtime:
tmp_dir: ${work_dir}/tmp/${run.analysis_slug}
outputs:
output_file: tmp://bkg_far_scored.parquet
Cleanup policies are:
neverKeep temporary files. This is best while developing or debugging.
on_successRemove
runtime.tmp_dirafter a successful workflow.alwaysRemove
runtime.tmp_direven if a later step fails.
Recommended Complete Workflow¶
The standard 10 percent workflow has six phases. The names below match the template and test workflows, but the same pattern works for other chunks or fractions.
1. Split Background¶
Split the target background into a training subset and a FAR holdout. Use
interval_livetime when the same physical jobs can appear in different lag
or shift intervals; this keeps train and FAR livetime disjoint by interval.
- id: k21_bkg_split
name: Split Target BKG Train/FAR
action: postprocess.selection.trigger_selection
inputs:
catalog_file: ${paths.target_bkg_catalog}
progress_file: ${paths.target_bkg_progress}
args:
exclude_zero_lag: true
returns: [jobs, triggers, livetime]
split:
by: interval_livetime
seed: 42
fractions:
train: ${k21_train_fraction}
far: ${k21_far_fraction}
outputs:
train:
jobs_file: tmp://k21_bkg_train_jobs.txt
progress_file: tmp://k21_bkg_train_progress.parquet
intervals_file: tmp://k21_bkg_train_intervals.parquet
intervals_csv_file: tmp://k21_bkg_train_intervals.csv
triggers_file: tmp://k21_bkg_train.parquet
far:
jobs_file: tmp://k21_bkg_far_jobs.txt
progress_file: tmp://k21_bkg_far_progress.parquet
intervals_file: tmp://k21_bkg_far_intervals.parquet
intervals_csv_file: tmp://k21_bkg_far_intervals.csv
triggers_file: tmp://k21_bkg_far.parquet
2. Match And Filter Simulation Training¶
Match the target simulation training trigger catalog to simulations.parquet.
Use how: outer for training cleanup so the matched table includes recovered
and unrecovered simulation truth rows. Then keep recovered, non-vetoed, real
simulation triggers for classifier training.
- id: k21_sim_train_match
name: Match Target SIM Training
action: postprocess.matching.match_simulations
inputs:
catalog_file: ${paths.target_sim_train_catalog}
simulation_file: ${paths.target_sim_train_simulations}
args:
how: outer
window_buffer: 0.0
outputs:
output_file: tmp://k21_sim_train_matched_outer.parquet
- id: k21_sim_train_real
name: Filter Target Real SIM Training
action: postprocess.selection.filter_real_simulation
inputs:
matched_file: "@k21_sim_train_match.matched_file"
sim_catalog: ${paths.target_sim_train_catalog}
args:
require_recovered: true
exclude_vetoed: true
output_schema: matched
outputs:
output_file: tmp://k21_sim_training_real.parquet
3. Select Simulation Training Fraction¶
Select the target simulation training fraction after filtering. Keep
exclude_zero_lag: false for simulation catalogs.
- id: k21_sim_train_select
name: Select Target SIM Training Fraction
action: postprocess.selection.trigger_selection
inputs:
catalog_file: "@k21_sim_train_real.triggers_file"
progress_file: ${paths.target_sim_train_progress}
args:
exclude_zero_lag: false
returns: [jobs, triggers, livetime]
selection:
fraction: ${k21_train_fraction}
seed: 43
outputs:
jobs_file: tmp://k21_sim_train_jobs.txt
triggers_file: tmp://k21_sim_train.parquet
4. Train And Build FAR¶
Train the ranking model with the full training chunks plus the selected target training subset. Then score the target FAR holdout and build the FAR lookup.
Training uses its inputs as given, so prepare the full training chunks like the
target: select each background chunk without zero lag, and match and filter each
simulation chunk as in step 2 (train_sim_1_real and train_sim_2_real in
the template). Training warns if a background input still contains unshifted
triggers.
- id: train_bkg_1_select
name: Select Training BKG 1 (No Zero Lag)
action: postprocess.selection.trigger_selection
inputs:
catalog_file: ${paths.train_bkg_1_catalog}
progress_file: ${paths.train_bkg_1_progress}
args:
exclude_zero_lag: true
returns: [triggers, livetime]
outputs:
triggers_file: tmp://train_bkg_1.parquet
- id: model
name: Train XGBoost
action: postprocess.train_xgboost.train_xgboost
inputs:
bkg_catalogs:
- "@train_bkg_1_select.triggers_file"
- "@train_bkg_2_select.triggers_file"
- "@k21_bkg_split.train.triggers_file"
sim_catalogs:
- "@train_sim_1_real.triggers_file"
- "@train_sim_2_real.triggers_file"
- "@k21_sim_train_select.triggers_file"
config_file: ${paths.config_file}
args:
model_file: ${paths.model_file}
dump: false
dump_training_review: true
verbose: false
outputs:
training_settings_file: ${paths.xgb_training_settings}
training_output_file: ${paths.xgb_training_output}
- id: far_rho
name: Score Target Holdout BKG And Build FAR
action: postprocess.evaluate.evaluate_far_rho
inputs:
catalog_file: "@k21_bkg_split.far.triggers_file"
model_file: ${paths.model_file}
config_file: ${paths.config_file}
args:
livetime: "@k21_bkg_split.far.livetime.seconds"
exclude_zero_lag: false # Preserve the upstream background selection
ranking_par: rhor
bin_size: 0.0001
vmin: 0.0
vmax: 10.0
outputs:
output_file: ${paths.far_rho_file}
scored_catalog: ${paths.bkg_far_scored}
5. Score Evaluation Simulations¶
Select and score the simulation evaluation catalog. Match it with how:
right when computing efficiency so the matched table has one row per
simulation, including missed injections.
- id: sim_eval_selection
name: Select SIM Evaluation
action: postprocess.selection.trigger_selection
inputs:
catalog_file: ${paths.sim_eval_catalog}
progress_file: ${paths.sim_eval_progress}
args:
exclude_zero_lag: false
returns: [jobs, triggers, livetime]
selection:
fraction: 1.0
seed: 44
outputs:
jobs_file: tmp://sim_eval_jobs.txt
triggers_file: tmp://sim_eval.parquet
- id: sim_eval_match
name: Match SIM Evaluation
action: postprocess.matching.match_simulations
inputs:
catalog_file: ${paths.sim_eval_catalog}
simulation_file: ${paths.sim_eval_simulations}
args:
how: right
window_buffer: 0.0
outputs:
output_file: tmp://sim_eval_matched_right.parquet
- id: sim_efficiency_score
name: Score SIM Evaluation
action: postprocess.evaluate.evaluate_efficiency
inputs:
catalog_file: "@sim_eval_selection.triggers_file"
model_file: ${paths.model_file}
config_file: ${paths.config_file}
args:
threshold: 0.5
outputs:
output_file: ${paths.sim_eval_scored}
- id: waveform_hrss_curves_100yr
name: Waveform HRSS Curves At 100 Years
action: postprocess.plot_efficiency.compute_efficiency_vs_hrss_by_waveform
inputs:
sim_catalog: ${paths.sim_eval_catalog}
matched_file: "@sim_eval_match.matched_file"
bkg_catalog: ${paths.bkg_far_scored}
model_file: ${paths.model_file}
config_file: ${paths.config_file}
args:
livetime: "@k21_bkg_split.far.livetime.seconds"
ranking_par: rhor
scored_file: ${paths.sim_eval_scored}
ifar: 100yr
use_unique_sim: true
exclude_vetoed: false
outputs:
output_file: ${paths.output_dir}/simulations/${run.analysis_slug}_efficiency_vs_hrss_by_waveform_100yr.png
fit_parameters_file: ${paths.output_dir}/simulations/${run.analysis_slug}_fit_parameters_by_waveform_100yr.csv
6. Build Reports¶
Score zero lag if needed, produce the standard background report, optionally
score MDC detections at an IFAR threshold, and aggregate everything into the
post-production HTML report. The report’s background tab embeds only the
images listed under bkg.plots and fills its zero-lag table from
bkg.zero_lag_csv.
See Postproduction Reports for every report section and the blind-analysis
settings.
- id: zero_lag_score
name: Score Target Zero Lag BKG
action: postprocess.evaluate.score_catalog
inputs:
catalog_file: ${paths.target_bkg_catalog}
model_file: ${paths.model_file}
config_file: ${paths.config_file}
args:
lag_selection: zero_lag
outputs:
output_file: ${paths.bkg_zero_lag_scored}
- id: background_report
name: Standard Background Report
action: postprocess.report.standard_background_report
inputs:
catalog_file: ${paths.bkg_far_scored}
zero_lag_catalog_file: ${paths.bkg_zero_lag_scored}
fake_openbox_intervals_file: "@k21_bkg_split.far.intervals_csv_file"
progress_file: ${paths.target_bkg_progress}
job_ids_file: "@k21_bkg_split.far.jobs_file"
args:
livetime: "@k21_bkg_split.far.livetime.seconds"
ranking_par: rhor
exclude_zero_lag: true
far_rho_file: ${paths.far_rho_file}
output_dir: ${paths.output_dir}
include_zero_lag: true # opens the box; false while blind
include_fake_openbox: true
- id: postproduction_report
name: Build Postproduction Report
action: postprocess.report_builder.postproduction_report
inputs:
workflow_file: ${paths.workflow_filename}
production_catalog_file: ${paths.target_bkg_catalog}
args:
title: O4 ${chunks.train_bkg_1}+${chunks.train_bkg_2} full plus ${chunks.target} ${train_fraction_label} BKG training postproduction report
output_file: ${paths.output_dir}/index.html
data_file: ${paths.output_dir}/report_data.json
bkg:
scored_catalog: ${paths.bkg_far_scored}
far_json: ${paths.far_rho_file}
progress_file: "@k21_bkg_split.far.progress_file"
intervals_file: "@k21_bkg_split.far.intervals_file"
zero_lag_progress_file: ${paths.target_bkg_progress}
zero_lag_catalog_file: ${paths.bkg_zero_lag_scored}
livetime: "@k21_bkg_split.far.livetime.seconds"
ranking_par: rhor
zero_lag_csv: ${paths.output_dir}/zero_lag_triggers.csv # omit while blind
plots:
- ${paths.output_dir}/far_rho.png
- ${paths.output_dir}/far_rho_n_events.png
- ${paths.output_dir}/zero_lag_report.png
- ${paths.output_dir}/zero_lag_poisson.png
- ${paths.output_dir}/fake_openbox_01_report.png
- ${paths.output_dir}/fake_openbox_01_poisson.png
training:
bkg_catalog: "@k21_bkg_split.train.triggers_file"
sim_catalog: "@k21_sim_train_select.triggers_file"
model_file: ${paths.model_file}
config_file: ${paths.config_file}
simulation_runs:
- label: STDINJs Set1
scored_catalog: ${paths.sim_eval_scored}
matched_file: "@sim_eval_match.matched_file"
plots:
- ${paths.output_dir}/simulations/${run.analysis_slug}_efficiency_vs_hrss_by_waveform_100yr.png
Changing Chunks Or Fractions¶
For a chunk-swap workflow, keep the paths derived from a small set of values:
train_fraction_label: 10pct
chunks:
train_bkg_1: K20
train_bkg_2: K22
target: K21
tag: k20_k22_k21
run:
output_name: O4_${chunks.target}_run1
analysis_slug: bkg_${chunks.tag}_${train_fraction_label}
To use K23 instead of K22, update:
chunks:
train_bkg_1: K20
train_bkg_2: K23
target: K21
tag: k20_k23_k21
The derived catalog paths, temporary directory, model name, FAR JSON, plots, and report paths will update together.
If you change the training fraction, update all three values together:
k21_train_fraction: 0.3
k21_far_fraction: 0.7
train_fraction_label: 30pct
Common Actions¶
The actions below are the main building blocks used by the standard workflow. See Post-Production Action Reference for the complete registered-action catalog, exact signatures, and guidance on composing actions safely.
postprocess.selection.trigger_selectionSelects or splits trigger catalogs by jobs or intervals. Use it for BKG train/FAR splits, SIM training fractions, and full SIM evaluation selections.
postprocess.matching.match_simulationsMatches a trigger catalog to
simulations.parquet. Usehow: outerbefore SIM training filters andhow: rightfor efficiency curves.postprocess.selection.filter_real_simulationKeeps recovered simulation triggers and optionally removes vetoed or across-segment injections.
postprocess.train_xgboost.train_xgboostTrains the XGBoost ranking model from BKG and SIM catalog lists.
postprocess.evaluate.evaluate_far_rhoScores the FAR holdout and writes the FAR-vs-ranking lookup.
postprocess.evaluate.score_catalogScores a catalog, commonly the target zero-lag background.
postprocess.evaluate.evaluate_efficiencyScores simulation evaluation triggers and writes a scored catalog.
postprocess.plot_efficiency.compute_efficiency_vs_hrss_by_waveformBuilds waveform-level efficiency curves using a matched simulation table.
postprocess.report.standard_background_reportWrites the standard background plots, fake-open-box outputs, and zero-lag report products.
postprocess.evaluate.score_mdc_catalogScores MDC detections against a background IFAR threshold.
postprocess.report_builder.postproduction_reportAggregates workflow artifacts into the final HTML and JSON report.
Validation And Debugging¶
Start with a diagram-only dry run:
pycwb post-process postprocess_workflow.yaml --diagram-only
Useful checks before a full run:
All
${...}variables resolve to the intended files.Every
@step.pathreference points to an earlier step.runtime.tmp_diris unique for this analysis.how: outeris used for SIM training matching.how: rightis used for SIM evaluation matching.BKG selections use
exclude_zero_lag: true.SIM selections use
exclude_zero_lag: false.Report paths point to the same files produced by earlier steps.
Common failure modes:
- Missing
simulations.parquet Run
pycwb simulation-summaryfor the simulation production, then rerun post-production.duckdbimport errorInstall the catalog matching dependency in the active environment.
- Reference resolution error
Check that the producing step has an
idand that the referenced key is returned by that action.- Unexpected train/FAR overlap
Use
split.by: interval_livetimeand make sure the input catalog carries job shift metadata.- Temporary file missing
Keep
cleanup_tmp: neverwhile debugging so intermediate parquet files remain inspectable.
Outputs To Expect¶
A complete workflow typically produces:
trained model under
${paths.output_dir}/models/;XGBoost training settings and training output logs;
FAR JSON lookup table;
scored FAR and zero-lag background catalogs;
scored simulation evaluation catalog;
waveform efficiency plot and fit-parameter CSV;
background report plots;
optional MDC detection CSV;
final
index.htmlandreport_data.json.
Keep the workflow YAML with the report output. It records the exact inputs, fractions, seeds, matching modes, and artifact paths used for the analysis.
Reusable Report Presets¶
Page and figure defaults can live in YAML files alongside the workflow. A preset
is expanded before workflow variables and action references are resolved; loading
one never executes an action. For example, presets/background.yaml contains:
version: 1
parameters:
frequency_column: central_freq_L1
density_bins: [160, 120]
config:
parameter_space:
plots:
rank_vs_frequency:
x: ${preset.frequency_column}
y: ${page.ranking_par}
bins: ${preset.density_bins}
The corresponding report page supplies its campaign inputs:
- id: postproduction_report
action: postprocess.report_builder.postproduction_report
inputs:
production_catalog_file: ${paths.target_bkg_catalog}
args:
bkg:
preset: presets/background.yaml
parameters:
frequency_column: central_freq_H1
scored_catalog: "@bkg_far_score.output_file"
livetime: "@k21_bkg_split.far.livetime.seconds"
ranking_par: rhor
overrides:
parameter_space:
plots:
rank_vs_frequency:
bins: [200, 140]
parameters fills declared preset placeholders. A null default requires an
explicit parameter. overrides changes the resulting configuration, including
individual plots by name. Precedence is preset defaults, supplied parameters,
explicit page fields, then overrides. Mappings merge recursively; lists replace
whole lists. Whole-value substitutions retain their types. Normal ${...}
workflow variables and @step.path references keep their existing meaning.
Named parameter_space.plots and parameter_plots mappings become ordered
renderer lists. Plot groups and marginals may refer to the parameter-space plot
names. Unknown parameter names, plot names and template references are errors.
Presets use safe YAML and schema version 1. By default, preset paths are relative
to the workflow’s real directory and must stay inside that directory. Multiple
campaigns can instead share a preset directory using a top-level preset_root:
post-process/
presets/
background.yaml
examples/
O1_K01/
workflow.yaml
O2_K01/
workflow.yaml
For either workflow in this layout:
preset_root: ../../presets
steps:
- id: postproduction_report
action: postprocess.report_builder.postproduction_report
args:
bkg:
preset: background.yaml
scored_catalog: "@bkg_far_score.output_file"
ranking_par: rhor
livetime: "@split.far.livetime.seconds"
preset_root must be a non-empty, literal relative path to an existing
directory. It resolves from the workflow’s real directory regardless of the
current working directory; workflow variables such as ${paths.presets} are
not supported in this field. The declared root may be a sibling or ancestor
directory outside the workflow directory. Every preset path must stay inside
the selected root, including after resolving symbolic links. Absolute preset
paths, paths escaping the root, recursive aliases and preset chains are rejected.
Preset source records use paths relative to this root. Preserve the relative
layout of the workflows, shared presets and any inputs/ maps when transferring
them to another machine.
The runner supplies the current workflow_file to the final report when it is
omitted. Reports package the original and expanded workflows, the exact loaded
preset files and supplied waveform family maps under workflow_bundle/, with a
SHA-256 manifest and download links. Preset input paths, expanded configuration and
packaged output paths participate in report resume checks. Changes to expanded
presentation arguments rebuild the affected reports while unchanged scientific
actions retain their own resume records. Background selections, exposure and
training results continue to flow through upstream actions; there is no
saved-background configuration to fill in.
A complete K21 example, including background, training, standard-injection and
optional CBC presets, is in examples/postproduction/k21_presets/. The CBC
example plots injection coverage; it does not reinterpret HRSS curves as distance
efficiencies.
Reusable configuration helpers¶
pycwb.post_production.presets.normalize_named_plots(config) converts named
plot mappings and their group/marginal references into renderer lists. It works
without preset files, modifies the supplied configuration in place, and returns
that same mapping. Existing list-based layouts are unchanged.
Report code can reuse build_plot_card, plot_group_specs,
build_plot_groups and validate_plot_columns from
pycwb.modules.postprocess.report_context. They share artifact registration,
layout validation and SVG download handling across report sections.
pycwb.modules.postprocess.report_render.render_report_template renders bundled
report templates with the same escaping and numerical-display filters.
pycwb.modules.postprocess.efficiency_metrics.parse_ifar_seconds is the shared
parser for finite positive seconds or duration labels such as 100yr.
Historical month presets remain 30 days.