Search Workflow

Intermediate · Prerequisite: a completed Your First Search demo. This page explains pipeline internals after the first user-facing run.

The main user-facing entry point is pycwb.workflow.run.search(). It reads a YAML user-parameter file, prepares the working directory, creates job segments, runs the configured segment processor, and writes trigger and progress rows to the catalog.

The command-line interface calls the same function:

pycwb run user_parameters.yaml
from pycwb.workflow.run import search

search("user_parameters.yaml", working_dir=".", n_proc=4)

Grouping and allocation limits

Local and batch runs use one bounded segment runner. By default a cluster allocation processes one scientific segment at a time; CPU or GPU lag workers operate inside that segment. segment_processer selects the scientific backend.

job_per_worker controls the number of segments assigned to an allocation, not concurrent workers. Shared-frame grouping can reduce repeated file staging:

job_per_worker: 8
execution:
  grouping: shared_frames
  memory_limit: 32GiB
  worker_memory: 8GiB
  headroom: 1GiB

grouping: adjacent is the default. Optional execution.batch_size overrides the YAML grouping bound; omitted or null uses job_per_worker. An explicit batch-setup --job-per-worker takes precedence. Neither grouping changes a scientific segment, decodes frames nor changes the CPU/GPU analysis. Setup stores exact group membership in self-contained catalog fragments. Resume uses that membership and rejects regrouping existing results.

nproc is the per-segment CPU preparation budget; CPU lag workers additionally use parallel_lag_workers and parallel_lag_inner_threads. GPU lag workers use gpu.lag_workers. Submission requests enough CPU slots for the busiest stage unless a CLI allocation was explicitly supplied; an insufficient explicit request is rejected. CUDA submission requests one GPU. Generated scripts run one segment at a time and pass the same CPU/RAM allocation ceilings to the runner. Manual batch-runner --n-workers can request more concurrent CPU segments, bounded by total CPU and RAM admission; CUDA segments remain sequential per GPU.

Omitted/null worker_memory shares available allocation RAM among admitted segments. An explicit estimate must cover a segment’s entire process tree, including frame reading, lag workers and numerical scratch. It is an admission estimate, not an OS memory limit. The supervisor monitors actual process memory; scheduler/cgroup limits provide the hard ceiling. Resource measurements appear in the execution log.

Omitted CLI resource values preserve YAML. Retries are additional attempts: zero runs once on both Condor and Slurm. Known former simple/scalable settings in staged YAML and records are read narrowly as grouping choices; the retired raw-frame cache and custom planner/executor factories are not runtime features.

Job Control

Job setup is handled by pycwb.workflow.subflow.prepare_job_runs.prepare_job_runs(). It checks the YAML against any existing catalogs, loads the configuration, generates job segments, creates output directories, and creates the root catalog. It does not initialize logging; pycwb.workflow.run.search() calls logger_init() first, so call it yourself when using prepare_job_runs directly.

from pycwb.modules.logger import logger_init
from pycwb.workflow.subflow.prepare_job_runs import prepare_job_runs

logger_init(log_file=None, log_level="INFO")
job_segments, config, working_dir = prepare_job_runs(
    ".",
    "user_parameters.yaml",
    n_proc=4,
    overwrite=False,
)

The user-parameter YAML is loaded into pycwb.config.Config. Both local runs and batch workers use YAML as the runtime configuration. The staged config/user_parameters.yaml is included in Condor file transfers; external pycwb_schema definitions are embedded in that copy. Custom detector definition JSON files are copied alongside it and referenced by a relative path.

Before reusing prepared jobs, the YAML settings are compared with the settings record in the existing catalog’s Parquet metadata. Defaults are included; comments, formatting and key order do not matter. CLI overrides are applied separately. Scheduler, resource and diagnostic settings may change; output settings may change with a warning. Any other change stops the run and reports the changed settings, even with --force-overwrite (overwrite=True in Python). Use a new working directory, or clean the existing catalog, job manifest, progress and fragment Parquet files and regenerate the run. See Reproducing and Archiving an Analysis for the categories and the version rule. Older catalogs without a settings record also require regeneration because their metadata mixes YAML values, derived fields and runtime overrides. Custom detector definitions are checked by content hash, so moving their files does not invalidate a run but changing their contents does. Other referenced data files are not hashed; changed input data requires regenerating the prepared jobs.

from pycwb.config import Config

config = Config()
config.load_from_yaml("user_parameters.yaml")

Job segments are created from data-quality periods, explicit GPS windows, GWOSC/event settings, or simulation settings. If injections are configured, they are scheduled onto the relevant segments.

from pycwb.modules.job_segment import create_job_segment_from_config

job_segments = create_job_segment_from_config(config)
job_segment = job_segments[0]

The segment processor is loaded from config.segment_processer. The default processor is pycwb.workflow.subflow.process_job_segment_native.process_job_segment(). For background searches, parallel_lag_workers > 1 uses processes sharing prepared inputs; no alternate processor needs to be selected. One worker and injection trials run serially. See Performance Guide for CPU allocation.

from pycwb.utils.module import import_function

segment_processor = import_function(config.segment_processer)

You normally do not need to call the processor directly. Use pycwb run or search(...) so catalog collection and run bookkeeping are configured for you.

Data Analysis

The native segment processor analyzes one pycwb.types.job.WaveSegment at a time. The high-level stages are:

  1. Read frame data and/or generate configured noise.

  2. Generate and inject simulated signals when the segment has injections.

  3. Resample to the analysis rate, regress (line removal), whiten, and compute per-detector noise RMS maps.

  4. Build lag-independent coherence, time-delay, supercluster, and likelihood setup objects.

  5. For each lag, run coherence, supercluster, likelihood, waveform reconstruction, optional plots, and catalog writes.

Data loading uses pycwb.modules.read_data.read_from_job_segment(), pycwb.modules.read_data.simulations.generate_noise_for_job_seg(), and pycwb.modules.injection.generate_strain_from_injection().

from pycwb.modules.injection import generate_strain_from_injection
from pycwb.modules.read_data import read_from_job_segment
from pycwb.modules.read_data.simulations import generate_noise_for_job_seg

data = None
if job_segment.frames:
    data = read_from_job_segment(config, job_segment)
if job_segment.noise:
    data = generate_noise_for_job_seg(job_segment, config.inRate, f_low=config.fLow, data=data)
# Injections (generate_strain_from_injection) are omitted here;
# see tutorial_injection.

The raw data are first resampled to the analysis rate (fResample or inRate, divided by 2levelR) with pycwb.modules.read_data.data_check.check_and_resample_py(). Data conditioning then regresses and whitens each detector and returns conditioned strains and per-detector nRMS maps.

from pycwb.modules.data_conditioning import condition_strains
from pycwb.modules.read_data import check_and_resample_py

data = [check_and_resample_py(data[i], config, i) for i in range(len(job_segment.ifos))]
strains, nRMS = condition_strains(config, data)

The production processor applies the enabled noise_variability correction, then gating selection exclusions. It performs both steps before whitening the signal-only injection buffers and building reusable setup objects, once per trial, and then processes each lag. See Noise-variability correction and gating.

from pycwb.modules.coherence_native.coherence import setup_coherence, coherence_single_lag
from pycwb.modules.likelihoodWP.likelihood import evaluate_cluster_likelihood, prepare_likelihood_inputs
from pycwb.modules.super_cluster_native.super_cluster import setup_supercluster, supercluster_single_lag
from pycwb.modules.xtalk.type import XTalk
from pycwb.utils.td_vector_batch import build_td_inputs_cache

# One-time, lag-independent setup
coherence_setup = setup_coherence(config, strains, job_seg=job_segment, nRMS=nRMS)
td_inputs_cache = build_td_inputs_cache(config, strains)
xtalk = XTalk.load(config.MRAcatalog)
supercluster_setup = setup_supercluster(config, gps_time=float(strains[0].start_time))
likelihood_setup = prepare_likelihood_inputs(
    config,
    strains,
    config.nIFO,
    ml=supercluster_setup.get("ml_likelihood", supercluster_setup["ml"]),
    FP=supercluster_setup.get("FP_likelihood", supercluster_setup["FP"]),
    FX=supercluster_setup.get("FX_likelihood", supercluster_setup["FX"]),
)

# CAT2 keep windows for this segment (None when no CAT2 files are configured)
veto_windows = (
    job_segment.cwb_veto_windows
    if job_segment.cwb_veto_windows is not None
    else job_segment.veto_windows
)

accepted = []
for lag in range(job_segment.n_lag):
    fragment_clusters = coherence_single_lag(coherence_setup, lag_idx=lag, veto_windows=veto_windows)
    selected_clusters = supercluster_single_lag(
        supercluster_setup,
        config,
        fragment_clusters,
        lag_idx=lag,
        xtalk=xtalk,
        td_inputs_cache=td_inputs_cache,
    )
    if selected_clusters is None:
        continue
    for k, cluster in enumerate(selected_clusters.clusters):
        if cluster.cluster_status > 0:
            continue
        cluster.cluster_id = k + 1
        result_cluster, sky_stats = evaluate_cluster_likelihood(
            config.nIFO,
            cluster,
            config,
            cluster_id=k + 1,
            nRMS=nRMS,
            setup=likelihood_setup,
            xtalk=xtalk,
            chirp_seed=job_segment.index,
        )
        if result_cluster is not None and result_cluster.cluster_status == -1:
            accepted.append((lag, result_cluster, sky_stats))

The production processor also skips lags whose post-CAT2 livetime is below segTHR, removes intervals excluded by gating from the veto windows, intersects them with the injection windows when analyze_injection_only is set, and handles lag bookkeeping, waveform reconstruction, Q-veto, plots, memory cleanup, and catalog writes. For the full implementation, see pycwb.workflow.subflow.process_job_segment_native.process_job_segment().


You have learned

  • ✅ How pycWB structures a search with segments, jobs, and lags

  • ✅ How to use the search() function from Python and pycwb run from CLI

  • ✅ How job segments are created from the config file

  • ✅ How the segment processor orchestrates each pipeline stage

Next: Step by Step Injection Search — add simulated signals and recover them