Post-Production Action Reference

Use these actions in the steps section of a postproduction workflow. For a complete example, start with Post-Production Workflow Guide.

Choosing The Main Actions

Most production workflows need only the following path through the catalog:

Pipeline stage

Recommended action

Important choice

Split background

postprocess.selection.trigger_selection

Use split.by: interval_livetime when jobs contain multiple lag or shift intervals. Exclude zero lag from background.

Prepare simulations

postprocess.matching.match_simulations

Use how: outer before training cleanup and how: right when missed injections must remain in the efficiency denominator.

Clean simulation training data

postprocess.selection.filter_real_simulation

Require recovered events and decide explicitly whether vetoed events are excluded.

Train a ranking model

postprocess.train_xgboost.train_xgboost

Keep the model and its XGBoost configuration together; scoring must use the same features and ranking definitions.

Score the FAR holdout

postprocess.evaluate.evaluate_far_rho

Pass only disjoint holdout background and its matching live time.

Score evaluation simulations

postprocess.evaluate.evaluate_efficiency

Do not use simulation events that trained the model.

Build efficiency products

postprocess.plot_efficiency.compute_efficiency_vs_hrss_by_waveform

Use a right-matched simulation table so non-recoveries are counted.

Report background and candidates

postprocess.report.standard_background_report

Zero lag is included by default (include_zero_lag: true), which opens the box. While blind, set include_zero_lag: false and use include_fake_openbox: true. Give zero-lag and fake-open-box inputs explicitly.

Select events for reconstruction

postprocess.event_selection.select_events

Rank explicit groups of one or more scored catalogs. Keep source-run identity and separate background/zero-lag quotas in the persisted list.

Prepare event follow-up

postprocess.event_followup.prepare_event_run

Prepare independent native real-data runs, submission files and pending pages. This action never submits jobs. Workers use shared storage or Condor file transfer. Returned event-output directories are linked into the report without copying products or rendering the pages again.

Assemble the final report

postprocess.report_builder.postproduction_report

Point its nested sections to artifacts already produced by earlier steps.

Publish the report

postprocess.publish.publish_report

Link the entire report directory into the configured web space so relative plots and downloads remain available.

How To Use An Action

The YAML action name is the module and function below pycwb.modules. Use the short form shown throughout this page:

steps:
  - id: far
    name: Score Background Holdout
    action: postprocess.evaluate.evaluate_far_rho
    inputs:
      catalog_file: "@split.far.triggers_file"
      model_file: ${paths.model_file}
      config_file: ${paths.config_file}
    args:
      livetime: "@split.far.livetime.seconds"
      ranking_par: rhor
      exclude_zero_lag: true
    outputs:
      output_file: ${paths.far_rho_file}
      scored_catalog: ${paths.bkg_far_scored}
inputs

Data artifacts consumed by the action. Put upstream catalogs, models, progress files, and manifests here.

args

Behavior and scientific choices such as fractions, seeds, ranking parameters, thresholds, and matching modes.

outputs

Destinations for artifacts written by the action, when the function signature accepts those destination names. A flat mapping is passed both as named keyword arguments and as outputs. Nested output mappings are passed only as outputs; this form is used by trigger_selection for named split partitions. Some actions instead create derived or fixed-name products and expose their paths only in the returned dictionary.

The runner combines those three mappings into keyword arguments, so the function signatures below are the authoritative spelling and type reference. Most actions accept **kwargs for workflow context; consequently, a typo in an argument may not fail immediately. Copy parameter names exactly and check the generated diagram before a long run.

Data Flow And Paths

Give every reusable step a unique id. An action’s returned dictionary is stored below that ID, and a later step can read it with @step.path:

inputs:
  catalog_file: "@bkg_split.far.triggers_file"

Here bkg_split is a trigger_selection split step whose far partition wrote triggers_file. The reference is to a returned key, not merely to the name written in the earlier step’s outputs block; for example, evaluate_far_rho returns only far_rho and binned. The steps still execute in YAML order; the DAG diagram visualizes dependencies but does not reorder them.

Use ${name} or ${nested.name} for values under vars. A whole-value reference preserves lists and mappings, while an embedded reference becomes text. Use tmp://name.parquet for intermediates under runtime.tmp_dir. Ordinary relative paths are interpreted by the individual action, normally relative to work_dir. Keep cleanup_tmp: never until the workflow is validated, then choose on_success for routine production.

Prepare consistent inputs

Use consistent selections and inputs across workflow actions:

  • Background used for FAR is disjoint from model training data, and its live time describes exactly the selected rows or intervals.

  • Remove zero lag when selecting background for training and FAR estimation (trigger_selection with exclude_zero_lag: true), and select it deliberately for candidate evaluation. Training uses its inputs as given and only warns about unshifted background triggers.

  • Simulation training and evaluation sets are disjoint. Missed injections remain in efficiency denominators.

  • Model scoring uses the same config_file, feature definitions, detector count, and search type as training.

  • Random selections have recorded seeds, fractions, job lists, and interval tables. Keep the workflow YAML beside the final report.

  • Every @step.path points backward to a key actually returned by that action. Run pycwb post-process workflow.yaml --diagram-only before the full workflow.

Complete Action Catalog

Selection, filtering, and matching

Action

Use and crucial information

postprocess.selection.trigger_selection

Preferred high-level selector. Select or split by jobs or by interval live time and optionally materialize jobs, progress, intervals, triggers, and live-time summaries.

postprocess.selection.filter_real_simulation

Filter a matched table to recovered simulation triggers for training; control veto removal and whether output uses matched or catalog schema.

postprocess.matching.match_simulations

Match recovered triggers with simulations.parquet. The how join mode changes whether missed injections survive.

postprocess.job_selector.select_jobs_by_livetime

Lower-level legacy building block that writes a randomized job-ID list approximating a requested live-time fraction.

postprocess.job_selector.filter_catalog_by_jobs

Lower-level building block that filters a parquet catalog by a job-ID list.

postprocess.job_selector.compute_livetime

Lower-level building block that sums progress live time for selected jobs and returns the result as data rather than a file.

postprocess.random_filter.random_filter_parquet

Simple row subsampling and optional zero-lag removal. Prefer trigger_selection when whole-job or interval-level independence is scientifically required.

postprocess.multi_run.read_catalog_runs

Combine an array of catalogs using a generic name for each run, add stable run identity, reindex events, and optionally extract scheduled injections and a run manifest. Extra run fields remain arbitrary metadata rather than prescribed study factors.

postprocess.event_selection.select_events

Persist bounded top-N selections from named multi-source groups, with physical lag provenance, recorded selection memberships and source fingerprints. Parquet and CSV use the shared Pandas ranking function on bounded batches, retaining the best occurrence of each source identity and breaking score ties lexically. Input validation and source content hashes remain enabled. duckdb_memory_limit is a deprecated, validated compatibility argument with no effect on selection. top_n: 0 disables a group.

postprocess.event_followup.prepare_event_run

Create reduced jobs and independent catalogs from selected recorded real-data events, with a validated configuration override partial. Native CPU processing is required. Shared storage and Condor container/file-transfer workers are supported. Returned event pages are served through links to their event-output directories. Rerun preparation after completion to refresh the combined status index. The action does not submit jobs; set submit: false explicitly in production YAML.

Training, scoring, and FAR

Action

Use and crucial information

postprocess.train_xgboost.train_xgboost

Train one XGBoost model from one or more pre-filtered background and simulation catalogs; save the model and optional training-review artifacts.

postprocess.xgb_heatmap.plot_xgb_heatmap

Inspect feature distributions and pairwise correlations from a parquet catalog. Set output_file to an HTML or PNG path, or a list of paths for both formats.

postprocess.evaluate.score_catalog

Apply a trained model and configured ranking expressions to a catalog. lag_selection can restrict scoring to zero lag or non-zero lag.

postprocess.evaluate.evaluate_far_rho

Score background and build the FAR-versus-ranking lookup. The supplied live time and background selection define the statistical exposure.

postprocess.evaluate.evaluate_efficiency

Score a simulation catalog and compute threshold efficiency. Use the waveform actions below for IFAR-dependent injection efficiency.

postprocess.evaluate.score_mdc_catalog

Score a blind MDC catalog against a scored background and write events above an IFAR threshold.

postprocess.far.far_rho_plot

Compute and plot FAR directly from an already-ranked catalog. Use evaluate_far_rho when XGBoost scoring is also required.

Efficiency products

Action

Use and crucial information

postprocess.plot_efficiency.compute_hrss50

Compute the amplitude at 50 percent efficiency for one IFAR threshold.

postprocess.plot_efficiency.plot_efficiency_vs_hrss

Plot the aggregate efficiency-versus-amplitude curve for one IFAR.

postprocess.plot_efficiency.compute_efficiency_by_waveform

Compute detection efficiency separately for each waveform using a right-matched simulation table.

postprocess.plot_efficiency.compute_efficiency_vs_hrss_by_waveform

Plot waveform and Q-factor efficiency curves and optionally write fit parameters. This is the usual complete-workflow choice.

postprocess.plot_efficiency.compute_hrss50_by_waveform_csv

Write per-waveform hrss50 values for several comma-separated IFAR thresholds.

Reports and specialized studies

Action

Use and crucial information

postprocess.zero_lag.zero_lag_report

Attach FAR and Poisson significance to zero-lag triggers and create candidate plots.

postprocess.fake_openbox.fake_openbox_report

Sample background intervals reproducibly and present them with open-box-style significance for validation.

postprocess.report.standard_background_report

Composite background action combining FAR products with zero-lag (on by default) and fake-open-box (off by default) sections.

postprocess.report_builder.postproduction_report

Build the standard multi-tab HTML and JSON report from background, training, and simulation artifacts.

postprocess.publish.publish_report

Publish the report directory through a configurable web directory. Reuse the correct symlink and refuse to replace other destinations.

postprocess.event_pages.render_event_pages

Optionally refresh saved event HTML pages from explicit index/status JSON paths. Keep event records and reconstruction products unchanged. Directly linked worker pages do not require this action.

postprocess.training_report.training_diagnostics

Write learning-curve and feature-gain plots for a saved model; fail if an optional reference model differs.

postprocess.simulation_report.simulation_efficiency

Apply one explicit ranking cut to a right-matched simulation table; select any numeric parameter, efficiency direction, grouping, colors and shared curve/sensitivity/coverage generators through presets.

postprocess.cwb_report.collect_comparisons

Combine recorded JSON comparison checks into one validation file for the report’s Consistency checks tab.

postprocess.generic_report.generic_web_report

Package arbitrary interactive HTML plots from upstream actions into a portable single-page report.

postprocess.angle_comparison.plot_angle_error_comparison

Compare injection truth with sky recovery across multiple labeled runs and write interactive map, histogram, summary, and event data. Clicking a shared injection on the map highlights its matching recoveries and great-circle paths while dimming unrelated events and paths.

postprocess.waveform_report.generate_waveform_report

Generate aggregate waveform-reconstruction quality products for one or more interferometers from a waveform file.

Action Signatures

The signatures and docstrings below come directly from the implementation. Parameters without defaults are required unless an earlier workflow context value supplies them.

Selection, filtering, and matching

pycwb.modules.postprocess.selection.trigger_selection(work_dir: str, catalog_file: str, progress_file: str, returns: list[str] | None = None, selection: dict[str, Any] | None = None, split: dict[str, Any] | None = None, outputs: dict[str, Any] | None = None, fraction: float = 1.0, exclude_zero_lag: bool = True, seed: int = 150914, job_filter: dict[str, Any] | None = None, trigger_filter: dict[str, Any] | None = None, columns: list[str] | None = None, batch_size: int = 65536, **kwargs) → dict[source]

Select or split triggers by whole jobs.

Parameters:
  • work_dir (str) – Base directory for relative paths.

  • catalog_file (str) – Trigger catalog parquet.

  • progress_file (str) – Progress parquet containing job_id and livetime.

  • returns (list[str], optional) – Values to return/materialize: jobs, triggers, livetime. Defaults to all three.

  • selection (dict, optional) – Single-subset options. Supports fraction, seed and exclude_zero_lag.

  • split (dict, optional) – Disjoint split options. Supports fractions (mapping or list), seed and exclude_zero_lag.

  • outputs (dict, optional) – Output paths. For split mode this is nested by partition name. progress_file writes the selected job/lag exposure rows, which match triggers_file for process_background.

Returns:

Structured result keyed by partition name for split mode, with livetime summaries nested under each partition.

Return type:

dict

pycwb.modules.postprocess.selection.filter_real_simulation(work_dir: str, matched_file: str, output_file: str, sim_catalog: str | None = None, require_recovered: bool = True, exclude_vetoed: bool = True, veto_columns: list[str] | None = None, output_schema: str = 'matched', **kwargs) → dict[source]

Filter a matched simulation table to real recovered injection triggers.

pycwb.modules.postprocess.matching.match_simulations(work_dir: str, catalog_file: str, simulation_file: str, output_file: str, how: str = 'right', window_buffer: float = 0.0, ranking_par: str = 'rho', **kwargs) → dict[source]

Match a trigger catalog to simulation summary rows and write parquet.

pycwb.modules.postprocess.job_selector.select_jobs_by_livetime(work_dir: str, progress_file: str, output_file: str, fraction: float = 0.1, exclude_zero_lag: bool = True, seed: int = 150914, **kwargs) → dict[source]

Select a random subset of job_ids representing ~*fraction* of live time.

Parameters:
  • work_dir (str) – Base directory for relative path resolution.

  • progress_file (str) – Path to progress.M1.parquet (relative to work_dir).

  • output_file (str) – Path where the newline-separated job_id list is written.

  • fraction (float) – Target fraction of total live time (default 0.10 = 10%).

  • exclude_zero_lag (bool) – If True, exclude physically unshifted zero-lag rows from live-time calculation.

  • seed (int) – Random seed.

Returns:

job_ids_file, n_jobs_selected, n_jobs_total, livetime_selected, livetime_total.

Return type:

dict

pycwb.modules.postprocess.job_selector.filter_catalog_by_jobs(work_dir: str, input_file: str, job_ids_file: str, output_file: str, **kwargs) → dict[source]

Filter a catalog parquet, keeping only rows with selected job_ids.

Parameters:
  • work_dir (str) – Base directory.

  • input_file (str) – Path to input catalog parquet.

  • job_ids_file (str) – Path to the job list file (one job_id per line).

  • output_file (str) – Path for the filtered output parquet.

Returns:

filtered_file, n_before, n_after.

Return type:

dict

pycwb.modules.postprocess.job_selector.compute_livetime(work_dir: str, progress_file: str, job_ids_file: str, exclude_zero_lag: bool = True, **kwargs) → dict[source]

Sum live time from a progress file for the selected jobs.

Parameters:
  • work_dir (str) – Base directory.

  • progress_file (str) – Path to progress parquet.

  • job_ids_file (str) – Path to job list file.

  • exclude_zero_lag (bool) – Exclude physically unshifted zero-lag rows from the sum.

Returns:

livetime (float, seconds), livetime_days (float).

Return type:

dict

pycwb.modules.postprocess.random_filter.random_filter_parquet(work_dir: str, input_file: str, output_file: str, fraction: float = 1.0, zero_lag_filter: bool = False, seed: int = 150914, **kwargs) → dict[source]

Read, filter, subsample, and write a parquet catalog.

Parameters:
  • work_dir (str) – Base working directory. Relative input_file / output_file paths are resolved against this directory.

  • input_file (str) – Path to the input parquet file.

  • output_file (str) – Path for the filtered output parquet file.

  • fraction (float) – Fraction of remaining events to keep (0 < fraction ≤ 1).

  • zero_lag_filter (bool) – If True, exclude zero-lag coincident rows.

  • seed (int) – Random seed for DataFrame.sample().

Returns:

Keys: filtered_file (str), n_before (int), n_after (int).

Return type:

dict

pycwb.modules.postprocess.multi_run.read_catalog_runs(work_dir: str, runs: list[Any], output_file: str = 'tmp/postprod/catalog_runs.parquet', injections_output_file: str | None = None, manifest_file: str | None = None, columns: list[str] | None = None, require_injections: bool = False, **kwargs) → dict[str, Any][source]

Combine multiple catalogs while retaining their run identity.

The output trigger table has a fresh global RangeIndex and explicit run_index, run_name, run_row_index and source_row_index columns. run_label is retained as a compatibility alias for run_name. Scheduled injections are read from each catalog’s job metadata and written to a second table using the same run identifiers. This preserves injections that were not recovered and therefore have no trigger row.

Training, scoring, and FAR

pycwb.modules.postprocess.train_xgboost.train_xgboost(work_dir: str, bkg_catalog: str | None = None, sim_catalog: str | None = None, model_file: str = 'models/xgb_model.ubj', bkg_catalogs: list[str] | None = None, sim_catalogs: list[str] | None = None, search: str = 'blf', nifo: int = 0, config_file: str | None = None, dump: bool = False, dump_training_review: bool = False, training_settings_file: str | None = None, training_output_file: str | None = None, verbose: bool | int = False, read_batch_size: int | None = None, n_threads: int | None = None, device: str | None = None, **kwargs) → dict[source]

Train an XGBoost classifier from pre-filtered plain Parquet catalogs.

pycwb.modules.postprocess.evaluate.score_catalog(work_dir: str, catalog_file: str, model_file: str, search: str = 'blf', nifo: int = 2, config_file: str | None = None, output_file: str | None = None, lag_selection: str = 'all', batch_size: int = 65536, **kwargs) → dict[source]

Score a catalog in parquet batches.

lag_selection can be "all", "zero_lag", or "nonzero_lag". Batch processing is mainly useful for scoring the zero-lag subset of a large production catalog without materializing all background triggers at once.

pycwb.modules.postprocess.evaluate.evaluate_far_rho(work_dir: str, catalog_file: str, model_file: str, livetime: float, search: str = 'blf', nifo: int = 2, config_file: str | None = None, ranking_par: str = 'rho', output_file: str | None = None, exclude_zero_lag: bool = True, bin_size: float | None = None, vmin: float | None = None, vmax: float | None = None, batch_size: int | None = None, **kwargs) → dict[source]

Score a BKG catalog and compute FAR vs. ranking parameter.

Parameters:
  • work_dir (str) – Base directory.

  • catalog_file (str) – Path to the BKG catalog parquet.

  • model_file (str) – Path to the trained model.

  • livetime (float) – Total live time in seconds for the selected BKG jobs.

  • search (str) – Search label.

  • nifo (int) – Number of interferometers.

  • config_file (str, optional) – Path to xgb_config override.

  • ranking_par (str) – Column to use as ranking statistic (default "rho").

  • output_file (str, optional) – If provided, write FAR values to this JSON. When bin_size is set the output is a binned lookup table ("bins", "far", "cum_events", "livetime"); otherwise it is a per-event list.

  • bin_size (float, optional) – If set together with output_file, produce a binned FAR lookup table instead of the default per-event list.

  • vmin (float, optional) – Override minimum bin edge for binned output. Defaults to the minimum ranking_par value in the catalog.

  • vmax (float, optional) – Override maximum bin edge for binned output. Defaults to the maximum ranking_par value in the catalog.

Returns:

far_rho — per-event list by default, or the compact binned lookup table when bin_size is set and return_per_event is false. The binned key is also included when binned output is produced.

Return type:

dict

pycwb.modules.postprocess.evaluate.evaluate_efficiency(work_dir: str, catalog_file: str, model_file: str, search: str = 'blf', nifo: int = 2, config_file: str | None = None, output_file: str | None = None, threshold: float = 0.5, **kwargs) → dict[source]

Score a SIM catalog with a trained model and compute efficiency.

Parameters:
  • work_dir (str) – Base directory.

  • catalog_file (str) – Path to the SIM catalog parquet.

  • model_file (str) – Path to the trained .ubj model.

  • search (str) – Search label ("blf", …).

  • nifo (int) – Number of interferometers.

  • config_file (str, optional) – Path to xgb_config override (e.g. xgb_config.py), relative to work_dir.

  • output_file (str, optional) – If provided, write scored probabilities to this parquet.

  • threshold (float) – Classification threshold for efficiency calculation.

Returns:

n_total, n_recovered, efficiency, threshold.

Return type:

dict

pycwb.modules.postprocess.evaluate.score_mdc_catalog(work_dir: str, mdc_catalog: str, model_file: str, bkg_scored_catalog: str, progress_file: str | None = None, job_ids_file: str | None = None, livetime: float | None = None, search: str = 'blf', nifo: int = 2, config_file: str | None = None, ranking_par: str = 'xgb_prob', ifar_threshold: str = '1yr', output_csv: str | None = None, **kwargs) → dict[source]

Score a blind MDC catalog and output triggers above an IFAR threshold.

Parameters:
  • mdc_catalog (str) – Path to the MDC parquet.

  • model_file (str) – Trained XGBoost model.

  • bkg_scored_catalog (str) – Scored BKG catalog (with xgb_prob) for IFAR calibration.

  • progress_file (str, optional) – Progress parquet for live-time computation when livetime is not provided.

  • job_ids_file (str, optional) – Job IDs used for legacy BKG live-time computation when livetime is not provided.

  • livetime (float, optional) – FAR live time in seconds. Preferred for interval-based BKG splits.

  • search (str) – Search label.

  • nifo (int) – Number of interferometers.

  • config_file (str, optional) – Path to xgb_config override.

  • ranking_par (str) – Scored catalog column used for FAR calibration and MDC thresholding. Defaults to "xgb_prob" for backward compatibility.

  • ifar_threshold (str) – IFAR preset ("1yr", "1mo", "1day", …) or seconds.

  • output_csv (str, optional) – Save CSV to this path.

Returns:

n_total, n_detections, prob_threshold, ifar_sec, livetime, output_csv.

Return type:

dict

pycwb.modules.postprocess.far.far_rho_plot(work_dir: str, catalog_file: str, progress_file: str, job_ids_file: str | None = None, livetime: float | None = None, ranking_par: str = 'rho', exclude_zero_lag: bool = True, bin_size: float = 0.1, vmin: float | None = None, vmax: float | None = None, output_dir: str = 'public', **kwargs) → dict[source]

Compute FAR vs ranking parameter and save report artifacts.

Efficiency products

pycwb.modules.postprocess.plot_efficiency.compute_hrss50(work_dir: str, sim_catalog: str, bkg_catalog: str, livetime: float, ifar: str = '1yr', output_file: str | None = None, **kwargs) → dict[source]

Compute hrss at 50% efficiency for a given IFAR threshold.

Parameters:
  • work_dir (str) – Base directory.

  • sim_catalog (str) – Path to scored SIM parquet (with xgb_prob column).

  • bkg_catalog (str) – Path to BKG parquet (used to compute prob threshold from FAR).

  • livetime (float) – Background live time in seconds.

  • ranking_par (str, optional (via kwargs)) – Statistic shared with the background calibration, default xgb_prob.

  • scored_file (str, optional (via kwargs)) – Pre-scored SIM catalog. Scores are joined by ID; events removed by prediction cuts remain misses. Takes precedence over model_file.

  • ifar (str) – IFAR threshold: "1yr", "6mo", "1mo", "1wk", "1day".

  • output_file (str, optional) – Save plot to this path.

  • matched_right_file (str, required (via kwargs)) – Path to matched_right.parquet. Efficiency is computed by counting unique simulations (sim_sim_idx) rather than individual triggers. One injection → one trial.

  • exclude_vetoed (bool, optional (via kwargs)) – If True and matched_right_file provided, exclude vetoed simulations (cat0|cat1|cat2|across_segments) from the denominator.

Returns:

hrss50, ifar_sec, prob_threshold, efficiency_curve.

Return type:

dict

pycwb.modules.postprocess.plot_efficiency.plot_efficiency_vs_hrss(work_dir: str, sim_catalog: str, bkg_catalog: str, livetime: float, ifar: str = '1yr', output_file: str = 'efficiency_vs_hrss.png', **kwargs) → dict[source]

Plot efficiency vs hrss at a given IFAR threshold.

See compute_hrss50() for parameter details.

pycwb.modules.postprocess.plot_efficiency.compute_efficiency_by_waveform(work_dir: str, sim_catalog: str, matched_file: str, bkg_catalog: str, livetime: float, model_file: str, search: str = 'blf', nifo: int = 2, config_file: str | None = None, ifar: str = '1mo', output_file: str | None = None, **kwargs) → dict[source]

Score unique matched injections, retaining unrecovered sources in the denominator.

Uses matched_right.parquet (from pycwb match-simulations) to identify which injections were detected by the cWB pipeline. The XGBoost IFAR threshold provides an additional cut.

Parameters:
  • work_dir (str) – Base directory.

  • sim_catalog (str) – Retained for call compatibility; the matched injection table supplies the denominator.

  • matched_file (str) – Path to matched_right.parquet.

  • bkg_catalog (str) – Path to scored BKG catalog (with xgb_prob column).

  • livetime (float) – Background live time in seconds.

  • model_file (str) – Path to trained XGBoost model.

  • ranking_par (str, optional (via kwargs)) – Statistic shared with the background calibration, default xgb_prob.

  • scored_file (str, optional (via kwargs)) – Pre-scored SIM catalog. Scores are joined by ID; events removed by prediction cuts remain misses. Takes precedence over model_file.

  • ifar (str) – IFAR threshold: "1yr", "1mo", "1wk", "1day".

  • output_file (str, optional) – Save per-waveform efficiency bar chart to this path.

Returns:

efficiency_by_waveform list, prob_threshold, ifar_sec.

Return type:

dict

pycwb.modules.postprocess.plot_efficiency.compute_efficiency_vs_hrss_by_waveform(work_dir: str, sim_catalog: str, matched_file: str, bkg_catalog: str, livetime: float, model_file: str, search: str = 'blf', nifo: int = 2, config_file: str | None = None, ifar: str = '1mo', output_file: str | None = None, **kwargs) → dict[source]

Efficiency vs hrss curves for each waveform, grouped by Q-factor.

Produces a multi-panel plot with efficiency vs hrss for all waveforms, organized by Q-factor (Q3, Q9, Q100) in separate subplots.

Parameters:
  • work_dir (str) – Base directory.

  • sim_catalog (str) – Retained for call compatibility; the matched injection table supplies the denominator.

  • matched_file (str) – Path to matched_right.parquet.

  • bkg_catalog (str) – Path to scored BKG catalog.

  • livetime (float) – Background live time in seconds.

  • model_file (str) – Trained XGBoost model path.

  • ranking_par (str, optional (via kwargs)) – Statistic shared with the background calibration, default xgb_prob.

  • scored_file (str, optional (via kwargs)) – Pre-scored SIM catalog. Scores are joined by ID; events removed by prediction cuts remain misses. Takes precedence over model_file.

  • ifar (str) – IFAR threshold ("1yr", "1mo", "1wk", "1day").

  • output_file (str, optional) – Save plot to this path.

Returns:

curves list of per-waveform efficiency data, prob_threshold, ifar_sec.

Return type:

dict

pycwb.modules.postprocess.plot_efficiency.compute_hrss50_by_waveform_csv(work_dir: str, sim_catalog: str, matched_file: str, bkg_catalog: str, livetime: float, model_file: str, search: str = 'blf', nifo: int = 2, config_file: str | None = None, ifars: str = '1mo,1yr,10yr', output_csv: str | None = None, **kwargs) → dict[source]

Compute hrss50 for each waveform at multiple IFAR thresholds, save CSV.

Parameters:
  • ifars (str) – Comma-separated IFAR labels, e.g. "1mo,1yr,10yr".

  • output_csv (str, optional) – Save CSV to this path.

Reports and specialized studies

pycwb.modules.postprocess.event_selection.select_events(work_dir: str, groups: list[dict], events_file: str, manifest_file: str | None = None, batch_size: int = 65536, duckdb_memory_limit: str = '128MB', **kwargs: Any) → dict[source]

Export a deduplicated, deterministic top-N event follow-up CSV.

Cuts are data-only comparisons: {column: rho, op: ge, value: 6.5}. Available operators are eq/ne/lt/le/gt/ge/in/not_in. Group time intervals are half-open [start, end) pairs applied to time_column (GPS by default). Nonfinite ranking values are ineligible and counted separately. A top_n of zero disables a group without reading its catalogs. Group quotas are applied independently, with overlap deduplicated in the final CSV and membership retained as JSON columns.

CSV and Parquet catalogs use the same shared Pandas ranking function on bounded batches. Parquet reads project required columns and recover the selected payloads afterward. duckdb_memory_limit remains accepted and validated for compatibility with existing workflows, but has no effect.

This action intentionally recomputes selection when called. Generic action resume tracks paths only and cannot detect replaced scoring catalogs. The selection manifest records content hashes for auditing instead.

pycwb.modules.postprocess.event_followup.prepare_event_run(work_dir: str | Path = '.', events_file: str | Path | None = None, selection_manifest: str | Path | None = None, working_dir: str | Path | None = None, source_run: str | Path | None = None, config_file: str | Path | None = None, override_profile: str | Path | Mapping[str, Any] | None = None, pages_dir: str | Path | None = None, cluster: str | None = None, submit: bool = False, time_padding: float = 1.0, frequency_padding: float = 0.0, batch_options: Mapping[str, Any] | None = None, **kwargs: Any) → dict[str, Any][source]

Prepare independent event-only runs using a CSV or selection manifest.

Relative paths resolve against work_dir. override_profile may be a YAML partial or inline mapping. batch_options contains native batch resource options. Global workflow context is not passed to batch setup. Preparation always sets submit=False and rejects a true request.

pycwb.modules.postprocess.event_pages.render_event_pages(work_dir: str | Path = '.', paths: str | Path | Iterable[str | Path] = (), **kwargs: Any) → dict[str, Any][source]

Refresh saved event HTML without reconstruction or status changes.

paths is one event-index/status JSON path or an iterable of paths. Relative inputs resolve against work_dir; home-directory notation is expanded. Each status record retains its own recorded page location. The action always runs so a changed renderer can update existing HTML.

pycwb.modules.postprocess.zero_lag.zero_lag_report(work_dir: str, catalog_file: str, progress_file: str, job_ids_file: str | None = None, far_rho_data: dict | None = None, ranking_par: str = 'rho', output_dir: str = 'public', public_alerts_file: str | None = None, public_alert_time_window: float = 1.0, split_panels: bool = False, foreground_plot_options: dict | None = None, known_bbh_file: str | None = None, known_bbh_time_window: float = 1.0, **kwargs) → dict[source]

Plot zero-lag triggers, optionally adding a known-BBH-removed diagnostic.

known_bbh_file is an explicit BBH-only name/GPS list. All triggers within known_bbh_time_window seconds are removed from the additional Poisson plot only; the full trigger CSV, FAR and exposure are unchanged.

pycwb.modules.postprocess.fake_openbox.fake_openbox_report(work_dir: str, catalog_file: str, intervals_file: str, far_rho_data: dict | None = None, ranking_par: str = 'rho', output_dir: str = 'public', ifo_order: list[str] | None = None, fake_openbox_n: int = 3, fake_openbox_seed: int = 150914, exclude_zero_lag: bool = True, split_panels: bool = False, foreground_plot_options: dict | None = None, **kwargs) → dict[source]

Select random FAR intervals and report them as fake openbox data.

pycwb.modules.postprocess.report.standard_background_report(work_dir: str, catalog_file: str, progress_file: str, job_ids_file: str | None = None, livetime: float | None = None, ranking_par: str = 'rho', exclude_zero_lag: bool = True, bin_size: float = 0.1, vmin: float | None = None, vmax: float | None = None, far_rho_file: str | None = None, output_dir: str = 'public', include_zero_lag: bool = True, zero_lag_catalog_file: str | None = None, zero_lag_job_ids_file: str | None = None, include_fake_openbox: bool = False, fake_openbox_intervals_file: str | None = None, ifo_order: list[str] | None = None, fake_openbox_n: int = 3, fake_openbox_seed: int = 150914, public_alerts_file: str | None = None, public_alert_time_window: float = 1.0, split_panels: bool = False, foreground_plot_options: dict | None = None, known_bbh_file: str | None = None, known_bbh_time_window: float = 1.0, **kwargs) → dict[source]

Generate standard background report artifacts.

pycwb.modules.postprocess.report_builder.postproduction_report(work_dir: str, workflow_file: str, production_catalog_file: str, title: str = 'pycWB postproduction report', output_file: str = 'public/postproduction_report/index.html', data_file: str | None = None, bkg: dict[str, Any] | None = None, training: dict[str, Any] | None = None, simulation_runs: list[dict[str, Any]] | None = None, validation_file: str | None = None, mdc_runs: list[dict[str, Any]] | None = None, max_plot_points: int = 2000, max_bins: int = 80, table_limit: int = 50, workflow_bundle: dict[str, Any] | None = None, zero_lag: dict[str, Any] | None = None, fake_openbox: dict[str, Any] | None = None, event_followup: Any | None = None, **kwargs) → dict[source]

Build a multi-tab postproduction report.

Parameters are intentionally workflow-friendly: nested bkg, training and simulation_runs dictionaries point at existing artifacts, and missing optional files are recorded rather than fatal. mdc_runs entries provide a ranked CSV, scoring result, and a strict ifar_years reporting threshold (default 10 years). bkg.zero_lag_reference_catalog_file may be provided when zero-lag progress belongs to a different original catalog than production_catalog_file. Set bkg.include_reduced_diagnostics to false when supplied plot groups and density maps replace the automatic FAR and per-bin extrema plots. Exposure plots and event tables remain available. The exposure plot uses all superlag/regular-lag pairs from intervals_file independently of table preview limits, with numeric regular-lag fallback. Optional zero_lag and fake_openbox mappings create separate open-box tabs with plot_results, plots/plot_groups and triggers_csv. Zero-lag also accepts progress_file, reference_catalog_file, poisson_diagnostic_file and removed_triggers_csv. Existing workflows without these mappings retain their BKG layout. event_followup accepts an event-page index JSON path or the complete prepare_event_run result. Stable event links are added to trigger tables and an Event follow-up tab, including pages awaiting reconstruction. The workflow runner supplies workflow_bundle for preset workflows so the original YAML, expanded YAML and source files are packaged together.

pycwb.modules.postprocess.publish.publish_report(work_dir: str, report_file: str, public_dir: str, link_name: str | None = None, public_url: str | None = None, **kwargs: Any) → dict[source]

Link the report directory into an existing site’s web space.

Parameters:
  • work_dir (str) – Base for relative filesystem paths. Tildes are expanded.

  • report_file (str) – Completed report page, normally @report.output_file.

  • public_dir (str) – Destination web directory, for example ~/public_html/pycwb. Missing parent directories are created. The web server must already serve this location and permit symlinks to the report directory.

  • link_name (str, optional) – Single directory name to create under public_dir. Defaults to the report directory’s name.

  • public_url (str, optional) – HTTP(S) URL corresponding to public_dir. Used only to construct the returned report URL; no HTTP request or server setup is performed.

Returns:

Absolute source_dir, link_dir, published_report_file and report_url (None when public_url was omitted).

Return type:

dict

Notes

The entire directory is linked so relative images, data and downloads remain accessible. All files within it become available under the site’s existing access rules. Permissions are not changed and files are not copied. An existing link to the same directory is reused; any other destination raises FileExistsError without replacement. Each workflow run verifies the link, even when report generation resumes from completed outputs.

pycwb.modules.postprocess.generic_report.generic_web_report(work_dir: str, plots: list[dict[str, Any]], title: str = 'pycWB postproduction report', subtitle: str = 'Interactive products generated by the postproduction workflow.', output_file: str = 'public/generic_report/index.html', metadata: dict[str, Any] | None = None, **kwargs) → dict[str, Any][source]

Build one portable page from interactive HTML plots produced upstream.

pycwb.modules.postprocess.angle_comparison.plot_angle_error_comparison(work_dir: str, triggers_file: str, injections_file: str, manifest_file: str, output_dir: str = 'public/angle_error_comparison/plots', map_filename: str = 'sky_recovery.html', histogram_filename: str = 'angle_error_histogram.html', summary_filename: str = 'angle_error_summary.json', data_filename: str = 'angle_error_events.csv', injection_angle_unit: str = 'rad', recovered_angle_unit: str = 'deg', ranking_column: str = 'rho', strict_truth: bool = True, truth_tolerance_deg: float = 1e-06, histogram_bin_size_deg: float = 5.0, **kwargs) → dict[str, Any][source]

Plot shared injection truth against recovery from any number of runs.

pycwb.modules.postprocess.waveform_report.generate_waveform_report(work_dir: str, wave_file: str, ifo: list[str], confidence_level: float = 0.9, whitened: bool = False, ordering: str = 'percentiles', plot_median: bool = False, plot_mean: bool = False, early_start: float = 0.0, scale: int = 0, max_workers: int = 8, **kwargs) → dict[source]

Generate aggregate waveform reconstruction report for one or more IFOs.

Parameters:
  • work_dir (str) – Base working directory. Relative paths are resolved against this.

  • wave_file (str) – Path to the consolidated wave.h5 file (absolute or relative to work_dir).

  • ifo (list of str) – Interferometer names to process (e.g. ["L1", "H1"]).

  • confidence_level (float) – Confidence level for shaded bands (default 0.9 = 90%).

  • whitened (bool) – If True, read whitened wf_REC_whiten / wf_INJ_whiten datasets instead of unwhitened wf_REC / wf_INJ.

  • ordering (str) – Bootstrap method for confidence intervals. One of "percentiles", "BCa", "studentized_bootstrap", "upper", "lower".

  • plot_median (bool) – Overlay the median waveform on reconstruction plots.

  • plot_mean (bool) – Overlay the mean waveform on reconstruction plots.

  • early_start (float) – Extra padding (seconds) before the injection start when slicing waveforms.

  • scale (int) – Wavelet scale correction factor: each waveform is multiplied by sqrt(2) ** scale before alignment.

  • max_workers (int) – Number of parallel workers for waveform synchronization.

Returns:

Keys: report_folder (output directory), ifo (list of IFOs processed), n_processed (number of IFOs processed).

Return type:

dict

Controlled simulation comparisons

For a cWB comparison using pp_irho=1, set ranking_par: rho_alt on postprocess.matching.match_simulations. The default rho corresponds to cWB rho[0] and is intentionally retained for existing workflows. Unique recovery selection and the reconstructed/injected time cut are separate steps; selecting a different event after a time cut changes the reference rule.

Efficiency entry points now use use_unique_sim=True by default and reject False: reconstructed triggers cannot supply an injection denominator. compute_hrss50 requires matched_right_file and either a model or scores in that matched table; it no longer silently falls back to trigger counts. The unique-simulation path requires a right-joined matched catalog with exactly one non-null sim_sim_idx per row. Missed injections must remain in that catalog. Duplicate simulation rows now raise an error, preventing a numerator counted in triggers from being divided by a denominator counted in injections. Independently prepared catalogs must have globally distinct simulation IDs before concatenation.

Probability-based efficiency uses the inclusive empirical background tail N(background xgb_prob >= signal xgb_prob) / livetime. This handles equal scores and scores between background ranks. Zero exceedances mean empirical FAR zero, not an independently measured infinite background exposure; a finite-exposure confidence bound is a separate inference. These probability curves must not be confused with a comparison calibrated on the user-defined rhor statistic.

An unbracketed 50-percent efficiency crossing is not a measured hrss50. Interpolation returns no estimate and the matched sigmoid path reports above_sampled_range or below_sampled_range with the relevant bound.

When source sky metadata is available, stored injection times follow cWB’s network energy-squared weighting and geometric detector offsets. Individual whitened energy centroids remain in injection parameters as detector_energy_centroids. This changes truth metadata used by the recovery time cut, not the injected strain or reconstruction.

XGBoost feature heatmap

pycwb.modules.postprocess.xgb_heatmap.plot_xgb_heatmap(work_dir: str, catalog: str, label: str | None = None, features: list[str] | None = None, log_features: list[str] | None = None, bins: int = 40, cmap: str = 'Blues', output_file: str | list[str] = 'xgb_heatmap.html', title: str | None = None, width: int = 1400, height: int = 1200, downsample: int | None = None, **kwargs) → dict[source]

Generate XGBoost feature correlation heatmap.

Reads catalog (parquet), extracts features, and produces a lower-triangle grid: 1D histograms on the diagonal, 2D heatmaps (with Pearson r) in the lower triangle. Output format is determined by the output_file extension(s).

Common background processing

pycwb.modules.postprocess.background.process_background(triggers: str | Path | DataFrame | Table, progress: str | Path | DataFrame | Table, *, ranking_par: str = 'rho', thresholds: Sequence[float] | ndarray | None = None, comparison: str = '>=', trigger_query: str | None = None, work_dir: str | Path = '.') → dict[str, Any][source]

Process native or adapted tables/Parquet identically; rates are Hz.

Triggers and exposure are used as given: this function applies no lag selection. Select background upstream, for example with trigger_selection and its triggers_file and progress_file outputs. Every trigger needs a completed job/lag exposure row; a warning is logged when triggers carry no time or segment shift (zero lag). Event-quality cuts do not reduce exposure. Supply already veto-adjusted progress for time vetoes. A trained ranking can be supplied as a column; this function neither trains a model nor creates missing ranking values.

cWB ROOT catalog import

pycwb.modules.postprocess.root_adapter.import_cwb_root(work_dir, wave_files, ifo_list, live_files=None, output_dir=None, batch_size=10000, **kwargs)[source]

Workflow action; return tables in memory and optionally write Parquet.

Standard cWB comparison and report diagnostics

These actions adapt cWB simulation truth, compare standard cWB command outputs, and add explicit training/efficiency diagnostics. See cWB ROOT input and same-trigger cross-checks.

pycwb.modules.postprocess.root_simulation.import_cwb_simulation(work_dir, wave_file, ifo_list, output_dir, mdc_file=None, ranking_par='rho_alt', time_window=0.1, batch_size=10000, **kwargs)[source]

Adapt a merged simulation tree, retaining all MDC rows in the denominator.

cWB’s injection association (time[nIFO]) is used, rather than matching the reconstructed time to the nearest injection. Unique selection occurs before the recovery-time cut, like Toolbox::setUniqueEvents followed by cwb_report_sim. The supplied file must be a single simulation campaign. Unmatched or ambiguous truth associations are errors.

pycwb.modules.postprocess.model_io.import_cwb_model(work_dir, model_file, output_file, trusted_pickle=False, **kwargs)[source]

cWB writes pickle even when its CLI requires a .json filename.

Pickle can execute code. Set trusted_pickle=True only for a model whose provenance you trust, e.g. your own local cwb_xgboost training output. Output must use the standard JSON or UBJ serialization understood by native postproduction scoring actions.

pycwb.modules.postprocess.simulation_report.simulation_efficiency(work_dir: str | Path, matched_file: str | Path, output_dir: str | Path, ranking_par: str = 'rho_alt', threshold: float | None = 0.0, comparison: str = '>', scored_file: str | Path | None = None, amplitude_rtol: float = 0.0, parameter: str = 'hrss', parameter_label: str | None = None, parameter_scale: str = 'log', efficiency_direction: str = 'increasing', group_by: list[str] | None = None, case_fields: list[str] | None = None, metadata_fields: list[str] | None = None, derived_parameters: dict[str, str | dict[str, Any]] | None = None, parameter_domains: dict[str, dict[str, Any]] | None = None, exclude_vetoed: bool = False, min_count: int = 1, plots: list[dict[str, Any]] | None = None, selection_note: str = '', population_note: str = '', require_unscaled: bool = True, ifar: str | float | None = None, bkg_catalog: str | Path | None = None, livetime: float | None = None, fit_method: str = 'interpolation', model_file: str | Path | None = None, config_file: str | Path | None = None, nifo: int = 2, search: str = 'blf', exclude_across_segments: bool = False, **kwargs: Any) → dict[str, Any][source]

Use one decision table and reducer for any recorded injection parameter.

HRSS defaults retain the legacy CSV/summary interface. Distance, frequency, duration and other populations use the same code with declared axes, cohorts, transforms, filters and direction. No families or physics are inferred from names. Misses remain in every denominator; no crossing is extrapolated.

pycwb.modules.postprocess.training_report.training_diagnostics(work_dir: str, model_file: str, output_dir: str, reference_model_file: str | None = None, **kwargs: object) → dict[source]

Write saved learning curves and gain plots.

Models without recorded history still produce feature importance, with history_status="unavailable" and no learning plot. An explicit reference comparison fails if history is unavailable/incomplete or the models differ. Undefined metrics are null in JSON and gaps in the learning curves.

pycwb.modules.postprocess.cwb_report.compare_cwb_report(work_dir, output_file, catalog_file=None, progress_file=None, reference_dir=None, efficiency_file=None, simulation_reference_dir=None, ranking_par='rho_alt', **kwargs)[source]

Compare counts; allow only the reference text’s printed precision.

Reference directories must be the data subdirectories of cwb_report. FAR values are printed to six significant digits and amplitudes to seven. The caller supplies matching selections and the complete injection truth: background files are used as given, so pass selected triggers and the matching progress_file from trigger_selection. A failed check is recorded in JSON, then raises to stop the workflow.

pycwb.modules.postprocess.cwb_report.compare_cwb_scores(work_dir: str, scored_file: str, reference_file: str, output_file: str, independent_scored_file: str | None = None, time_window: float | None = None, **kwargs: object) → dict[source]

Write membership, score and IFAR comparisons; time_window is in GPS seconds.

pycwb.modules.postprocess.cwb_report.attach_cwb_ifar(work_dir, catalog_file, far_file, output_file, ranking_par='rhor', **kwargs)[source]

Use cWB setIFAR’s step graph, including tiny linear boundary ramps.

This explicit compatibility action reads a two-column FAR table (Hz), drops zero-rate bins, clamps outside the range, and stores IFAR seconds. Ranking and IFAR are rounded to ROOT float precision. It does not replace the native empirical-tail calibration or assert infinite tail exposure.

pycwb.modules.postprocess.cwb_report.collect_comparisons(work_dir: str, comparison_files: list[str], output_file: str, notes: list[str] | None = None, **kwargs: object) → dict[source]

Combine recorded JSON checks without rerunning analyses; write and return the report.

Amplitude-efficiency input contract

The hrss efficiency actions and simulation_efficiency require fixed-hrss injection populations. For target-SNR populations, hrss is the initial waveform normalization, before the runtime snr_scale multiplier. These reports reject matched catalogs carrying a nonzero sim_target_snr or sim_targeted_snr, or a non-unit sim_snr_scale, instead of treating the initial normalization as the injected amplitude. Retain this metadata when exporting or matching target-SNR catalogs.

Shared fitted parameter efficiency

postprocess.plot_efficiency.compute_efficiency_vs_parameter_by_waveform is an alias of simulation_report.simulation_efficiency. Both STDINJ and CBC presets use this action with ifar: 100yr, bkg_catalog and background livetime in seconds. Set parameter: hrss / distance and efficiency_direction: increasing / decreasing respectively. fit_method: logN uses the shared statistics model, fitting decreasing parameters in reciprocal signal strength and returning physical units. Preset figure generators select curves, sensitivity candles or coverage; there is no CBC-specific efficiency module. The historical HRSS actions remain supported for existing workflows.