Skip to content

API Reference

Reference material is generated from Python docstrings via mkdocstrings. The sections below mirror the main import paths used in applications and in the CLI.

Top-level package

Re-exports for common workflows (NoiseConfig, simulators, ParallelAdapter, lazy diagnostics/output symbols).

Top-level package for gwmock-noise.

ARNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate stateful detector noise from an AR model fit to a target PSD.

metadata property

Return metadata describing the fitted AR model.

__init__(*, psd_file, order=DEFAULT_AR_ORDER, detectors=None, sampling_frequency=4096.0, duration=4.0, seed=None, low_frequency_cutoff=2.0, high_frequency_cutoff=None, block_size=DEFAULT_BLOCK_SIZE, regularization=DEFAULT_REGULARIZATION)

Initialize the simulator and fit the AR model once.

from_component(component, config) classmethod

Construct an AR-noise simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate per-detector AR noise with continuity across calls.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield AR-noise chunks lazily while preserving recursion state.

reset()

Clear detector state and RNGs.

AddLines

Wrap a base simulator and add spectral lines to its output.

metadata property

Return additive-wrapper metadata.

__init__(base, lines)

Initialize the additive wrapper.

generate(duration, sampling_frequency, detectors, seed=None)

Generate base noise and add the configured spectral lines.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield additive spectral-line chunks lazily.

reset()

Reset the additive line state and any resettable base state.

BaseNoiseSimulator

Bases: ABC

Abstract base class for noise simulators.

This interface is the stable API through which the upstream gwmock package interacts with gwmock_noise. Implementations must override :meth:run.

run(config) abstractmethod

Run the noise simulation with the given configuration.

Parameters:

Name Type Description Default
config NoiseConfig

Validated noise simulation configuration.

required

Returns:

Type Description
SimulationResult

Result containing paths to generated outputs and the config used.

BlipGlitch dataclass

Bases: GlitchModel

Gaussian-windowed broadband burst.

__post_init__()

Validate blip-specific parameters.

generate_waveform(sampling_frequency, rng=None)

Generate a Gaussian-windowed white-noise burst.

serialize()

Return metadata-friendly model parameters.

ColoredNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate colored detector noise from an input PSD.

metadata property

Return simulator metadata.

previous_strain property

Expose continuity buffers for protocol-compatible state inspection.

__init__(*, psd_file=None, psd_schedule=None, detectors=None, sampling_frequency=4096.0, duration=4.0, seed=None, low_frequency_cutoff=2.0, high_frequency_cutoff=None)

Initialize the simulator.

from_component(component, config) classmethod

Construct a colored-noise simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate per-detector colored noise.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield colored-noise chunks lazily while preserving simulator state.

reset()

Clear continuity and RNG state.

CompositeNoiseSimulator

Additively combine multiple component simulators.

metadata property

Return metadata describing the composed run.

__init__(components, *, detectors, duration, sampling_frequency, seed)

Initialize the composed simulator.

generate(duration, sampling_frequency, detectors, seed=None)

Generate all component realizations and add them together.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield additive component chunks lazily.

ConfigurableNoiseSimulator

Bases: ABC

Abstract mixin for built-in simulators usable as composed components.

from_component(component, config) abstractmethod classmethod

Construct one simulator instance from a generic component config.

CorrelatedARNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate correlated detector noise with a truncated VMA representation.

metadata property

Return metadata describing the fitted VMA model.

__init__(*, psd_files, csd_files=None, order=DEFAULT_VMA_ORDER, detectors=None, sampling_frequency=4096.0, duration=4.0, seed=None, low_frequency_cutoff=2.0, high_frequency_cutoff=None, block_size=DEFAULT_BLOCK_SIZE, regularization_epsilon=DEFAULT_REGULARIZATION_EPSILON)

Initialize the simulator and fit truncated VMA taps once.

from_component(component, config) classmethod

Construct a correlated-AR simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate correlated per-detector noise with stateful continuity.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield correlated AR chunks lazily while preserving innovation state.

reset()

Clear innovation state and RNG.

CorrelatedNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate correlated detector noise from PSD and CSD inputs.

metadata property

Return simulator metadata.

previous_strain property

Expose continuity buffers for protocol-compatible state inspection.

__init__(*, psd_files, csd_files=None, detectors=None, sampling_frequency=4096.0, duration=4.0, seed=None, low_frequency_cutoff=2.0, high_frequency_cutoff=None, regularization_epsilon=1e-12)

Initialize the simulator.

from_component(component, config) classmethod

Construct a correlated-noise simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate correlated per-detector noise.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield correlated-noise chunks lazily while preserving simulator state.

reset()

Clear continuity and RNG state.

DefaultNoiseSimulator

Bases: BaseNoiseSimulator

Default noise simulator implementation.

metadata property

Return metadata describing the current simulator state.

__init__(*, duration=4.0, sampling_frequency=4096.0, detectors=None, seed=None)

Initialize the simulator with protocol-compatible state.

generate(duration, sampling_frequency, detectors, seed=None)

Return Gaussian white-noise strain arrays.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield white-noise strain chunks lazily.

run(config)

Run the noise simulation with the given configuration.

GengliBlipGlitch dataclass

Bases: GlitchModel

File-backed gengli blip generator colored against a target PSD.

__post_init__()

Validate configured files and preload the population/PSD tables.

from_population_file(population_file, **kwargs) classmethod

Construct a gengli glitch model from a population file path.

generate_waveform(sampling_frequency, rng=None)

Generate one colored gengli blip waveform.

serialize()

Return metadata-friendly model parameters.

GlitchModel dataclass

Base dataclass for transient glitch generators.

__post_init__()

Validate common glitch parameters.

generate_waveform(sampling_frequency, rng=None)

Generate a single glitch waveform.

serialize()

Return metadata-friendly model parameters.

GlitchNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate transient glitches as an additive standalone component.

from_component(component, config) classmethod

Construct a glitch-only component from one component definition.

InjectGlitches

Wrap a base simulator and inject transient glitches additively.

metadata property

Return additive-wrapper metadata.

__init__(base, glitch_models)

Initialize the additive glitch wrapper.

generate(duration, sampling_frequency, detectors, seed=None)

Generate base noise and inject the configured glitches.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield glitch-injected chunks lazily.

reset()

Reset the additive wrapper and any resettable base state.

LogNormalAmplitudeDistribution dataclass

Log-normal amplitude sampler parameterized by linear mean and std.

__post_init__()

Validate the configured distribution parameters.

sample(rng)

Draw one amplitude sample.

NoiseComponentConfig

Bases: BaseModel

One configurable noise component in a composed simulation.

normalize_component_definition(value) classmethod

Accept string, flat mapping, or explicit {simulator, options} input.

validate_component()

Validate the normalized component entry.

NoiseConfig

Bases: BaseModel

Generic configuration for composed detector-noise simulations.

NoiseSimulator

Bases: Protocol

Structural interface for downstream noise simulators.

metadata property

Return simulator metadata.

generate(duration, sampling_frequency, detectors, seed=None)

Generate per-detector strain arrays.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield per-detector strain chunks lazily.

OutputConfig

Bases: BaseModel

Configuration for simulation output.

ParallelAdapter

Wrap an independent-detector simulator factory with parallel execution.

metadata property

Return metadata describing the wrapped simulator and executor.

__init__(base_factory, *, max_workers=None, backend='auto')

Store the simulator factory and executor preferences.

generate(duration, sampling_frequency, detectors, seed=None)

Generate per-detector strain arrays in parallel.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield parallel-generated chunks lazily.

reset()

Clear cached worker simulators, resetting continuity across workers.

ScatteredLightGlitch dataclass

Bases: GlitchModel

Arch-shaped scattered-light transient with a Gaussian envelope.

__post_init__()

Validate scattered-light parameters.

generate_waveform(sampling_frequency, rng=None)

Generate a chirping scattered-light glitch.

serialize()

Return metadata-friendly model parameters.

SchumannNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate correlated strain noise from an isotropic Schumann-resonance model.

metadata property

Return simulator metadata.

previous_strain property

Expose continuity buffers for protocol-compatible state inspection.

__init__(*, positions, coupling_files, detectors=None, schumann_params=None, sampling_frequency=4096.0, duration=4.0, seed=None, low_frequency_cutoff=2.0, high_frequency_cutoff=None)

Initialize the Schumann simulator.

from_component(component, config) classmethod

Construct a Schumann-noise simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate correlated Schumann strain noise.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield Schumann-noise chunks lazily while preserving simulator state.

reset()

Clear continuity and RNG state.

spectrum(frequencies)

Return the isotropic Schumann magnetic PSD on a frequency grid.

theoretical_coherence(frequency, detector_a, detector_b)

Return the isotropic Schumann coherence approximation.

SchumannParams dataclass

Physical parameters for the isotropic Schumann-resonance model.

__post_init__()

Validate the resonance parameter vectors.

SimulationResult dataclass

Result of a noise simulation run.

Attributes:

Name Type Description
output_paths dict[str, Path]

Paths to generated output files, keyed by detector name.

config NoiseConfig

The configuration used for the simulation.

SpectralLine dataclass

Configuration for a narrow-band spectral line.

__post_init__()

Validate scalar line parameters.

SpectralLineSimulator

Bases: ConfigurableNoiseSimulator

Generate additive spectral lines directly in the time domain.

metadata property

Return simulator metadata.

__init__(*, lines, detectors=None, sampling_frequency=4096.0, duration=4.0, seed=None)

Initialize the line generator.

from_component(component, config) classmethod

Construct a spectral-line simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate line-only strain for all requested detectors.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield spectral-line chunks lazily.

reset()

Clear continuity state and phase initialization.

WhiteNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate Gaussian white noise as a composable component.

metadata property

Return metadata describing the white-noise component.

__init__(*, duration=4.0, sampling_frequency=4096.0, detectors=None, seed=None)

Initialize the white-noise component state.

from_component(component, config) classmethod

Construct one white-noise component from generic config.

generate(duration, sampling_frequency, detectors, seed=None)

Return Gaussian white-noise strain arrays.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield white-noise strain chunks lazily.

__getattr__(name)

Lazily resolve optional top-level exports.

load_config(path)

Load and validate noise configuration from a file.

Supports TOML, YAML, and JSON formats.

Parameters:

Name Type Description Default
path Path | str

Path to the configuration file.

required

Returns:

Type Description
NoiseConfig

Validated NoiseConfig instance.

Raises:

Type Description
FileNotFoundError

If the config file does not exist.

ValueError

If the file format is unsupported or validation fails.

open_stream(simulator, *, chunk_duration, sampling_frequency, detectors, seed=None)

Open a stateful chunk stream on a protocol-compatible simulator.

take(stream, total_duration, chunk_duration, sampling_frequency)

Collect stream chunks up to total_duration seconds.

Configuration

Pydantic schema models and load_config for TOML/YAML/JSON.

Configuration schema and loading helpers for gwmock_noise.

NoiseComponentConfig

Bases: BaseModel

One configurable noise component in a composed simulation.

normalize_component_definition(value) classmethod

Accept string, flat mapping, or explicit {simulator, options} input.

validate_component()

Validate the normalized component entry.

NoiseConfig

Bases: BaseModel

Generic configuration for composed detector-noise simulations.

OutputConfig

Bases: BaseModel

Configuration for simulation output.

load_config(path)

Load and validate noise configuration from a file.

Supports TOML, YAML, and JSON formats.

Parameters:

Name Type Description Default
path Path | str

Path to the configuration file.

required

Returns:

Type Description
NoiseConfig

Validated NoiseConfig instance.

Raises:

Type Description
FileNotFoundError

If the config file does not exist.

ValueError

If the file format is unsupported or validation fails.

Gaussian noise models and helpers

Spectral-line definitions plus PSD reference helpers used by Gaussian-noise configuration and simulators.

Gaussian-noise domain models and helpers.

SpectralLine dataclass

Configuration for a narrow-band spectral line.

__post_init__()

Validate scalar line parameters.

is_remote_psd_reference(value)

Return whether a PSD reference is an HTTP(S) URL.

normalize_spectral_lines(value)

Normalize heterogeneous spectral-line inputs to dataclass instances.

resolve_bundled_psd_preset(value)

Resolve a bare preset name to a bundled PSD asset.

Glitch models

Runtime glitch model definitions, including phenomenological models and the optional gengli-backed blip implementation.

Public glitch-model implementations.

BlipGlitch dataclass

Bases: GlitchModel

Gaussian-windowed broadband burst.

__post_init__()

Validate blip-specific parameters.

generate_waveform(sampling_frequency, rng=None)

Generate a Gaussian-windowed white-noise burst.

serialize()

Return metadata-friendly model parameters.

GengliBlipGlitch dataclass

Bases: GlitchModel

File-backed gengli blip generator colored against a target PSD.

__post_init__()

Validate configured files and preload the population/PSD tables.

from_population_file(population_file, **kwargs) classmethod

Construct a gengli glitch model from a population file path.

generate_waveform(sampling_frequency, rng=None)

Generate one colored gengli blip waveform.

serialize()

Return metadata-friendly model parameters.

GlitchModel dataclass

Base dataclass for transient glitch generators.

__post_init__()

Validate common glitch parameters.

generate_waveform(sampling_frequency, rng=None)

Generate a single glitch waveform.

serialize()

Return metadata-friendly model parameters.

LogNormalAmplitudeDistribution dataclass

Log-normal amplitude sampler parameterized by linear mean and std.

__post_init__()

Validate the configured distribution parameters.

sample(rng)

Draw one amplitude sample.

ScatteredLightGlitch dataclass

Bases: GlitchModel

Arch-shaped scattered-light transient with a Gaussian envelope.

__post_init__()

Validate scattered-light parameters.

generate_waveform(sampling_frequency, rng=None)

Generate a chirping scattered-light glitch.

serialize()

Return metadata-friendly model parameters.

normalize_glitch_models(value)

Normalize heterogeneous glitch-config inputs.

supported_glitch_kinds()

Return all supported glitch-model kinds.

Simulators

Simulator implementations, the NoiseSimulator protocol, ConfigurableNoiseSimulator, SimulationResult, and streaming helpers such as open_stream and take.

Noise simulators for gravitational wave detectors.

ARNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate stateful detector noise from an AR model fit to a target PSD.

metadata property

Return metadata describing the fitted AR model.

__init__(*, psd_file, order=DEFAULT_AR_ORDER, detectors=None, sampling_frequency=4096.0, duration=4.0, seed=None, low_frequency_cutoff=2.0, high_frequency_cutoff=None, block_size=DEFAULT_BLOCK_SIZE, regularization=DEFAULT_REGULARIZATION)

Initialize the simulator and fit the AR model once.

from_component(component, config) classmethod

Construct an AR-noise simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate per-detector AR noise with continuity across calls.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield AR-noise chunks lazily while preserving recursion state.

reset()

Clear detector state and RNGs.

AddLines

Wrap a base simulator and add spectral lines to its output.

metadata property

Return additive-wrapper metadata.

__init__(base, lines)

Initialize the additive wrapper.

generate(duration, sampling_frequency, detectors, seed=None)

Generate base noise and add the configured spectral lines.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield additive spectral-line chunks lazily.

reset()

Reset the additive line state and any resettable base state.

BaseNoiseSimulator

Bases: ABC

Abstract base class for noise simulators.

This interface is the stable API through which the upstream gwmock package interacts with gwmock_noise. Implementations must override :meth:run.

run(config) abstractmethod

Run the noise simulation with the given configuration.

Parameters:

Name Type Description Default
config NoiseConfig

Validated noise simulation configuration.

required

Returns:

Type Description
SimulationResult

Result containing paths to generated outputs and the config used.

BlipGlitch dataclass

Bases: GlitchModel

Gaussian-windowed broadband burst.

__post_init__()

Validate blip-specific parameters.

generate_waveform(sampling_frequency, rng=None)

Generate a Gaussian-windowed white-noise burst.

serialize()

Return metadata-friendly model parameters.

ColoredNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate colored detector noise from an input PSD.

metadata property

Return simulator metadata.

previous_strain property

Expose continuity buffers for protocol-compatible state inspection.

__init__(*, psd_file=None, psd_schedule=None, detectors=None, sampling_frequency=4096.0, duration=4.0, seed=None, low_frequency_cutoff=2.0, high_frequency_cutoff=None)

Initialize the simulator.

from_component(component, config) classmethod

Construct a colored-noise simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate per-detector colored noise.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield colored-noise chunks lazily while preserving simulator state.

reset()

Clear continuity and RNG state.

CompositeNoiseSimulator

Additively combine multiple component simulators.

metadata property

Return metadata describing the composed run.

__init__(components, *, detectors, duration, sampling_frequency, seed)

Initialize the composed simulator.

generate(duration, sampling_frequency, detectors, seed=None)

Generate all component realizations and add them together.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield additive component chunks lazily.

ConfigurableNoiseSimulator

Bases: ABC

Abstract mixin for built-in simulators usable as composed components.

from_component(component, config) abstractmethod classmethod

Construct one simulator instance from a generic component config.

CorrelatedARNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate correlated detector noise with a truncated VMA representation.

metadata property

Return metadata describing the fitted VMA model.

__init__(*, psd_files, csd_files=None, order=DEFAULT_VMA_ORDER, detectors=None, sampling_frequency=4096.0, duration=4.0, seed=None, low_frequency_cutoff=2.0, high_frequency_cutoff=None, block_size=DEFAULT_BLOCK_SIZE, regularization_epsilon=DEFAULT_REGULARIZATION_EPSILON)

Initialize the simulator and fit truncated VMA taps once.

from_component(component, config) classmethod

Construct a correlated-AR simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate correlated per-detector noise with stateful continuity.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield correlated AR chunks lazily while preserving innovation state.

reset()

Clear innovation state and RNG.

CorrelatedNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate correlated detector noise from PSD and CSD inputs.

metadata property

Return simulator metadata.

previous_strain property

Expose continuity buffers for protocol-compatible state inspection.

__init__(*, psd_files, csd_files=None, detectors=None, sampling_frequency=4096.0, duration=4.0, seed=None, low_frequency_cutoff=2.0, high_frequency_cutoff=None, regularization_epsilon=1e-12)

Initialize the simulator.

from_component(component, config) classmethod

Construct a correlated-noise simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate correlated per-detector noise.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield correlated-noise chunks lazily while preserving simulator state.

reset()

Clear continuity and RNG state.

DefaultNoiseSimulator

Bases: BaseNoiseSimulator

Default noise simulator implementation.

metadata property

Return metadata describing the current simulator state.

__init__(*, duration=4.0, sampling_frequency=4096.0, detectors=None, seed=None)

Initialize the simulator with protocol-compatible state.

generate(duration, sampling_frequency, detectors, seed=None)

Return Gaussian white-noise strain arrays.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield white-noise strain chunks lazily.

run(config)

Run the noise simulation with the given configuration.

GlitchModel dataclass

Base dataclass for transient glitch generators.

__post_init__()

Validate common glitch parameters.

generate_waveform(sampling_frequency, rng=None)

Generate a single glitch waveform.

serialize()

Return metadata-friendly model parameters.

GlitchNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate transient glitches as an additive standalone component.

from_component(component, config) classmethod

Construct a glitch-only component from one component definition.

GwoscNoiseSimulator

Real-noise simulator that fetches strain data from GWOSC.

Implements the NoiseSimulator protocol so it can be used interchangeably with synthetic simulators like ColoredNoiseSimulator and CorrelatedNoiseSimulator.

Fetches real detector strain from the Gravitational-Wave Open Science Centre and applies user-configured filters to exclude segments containing GW signals or data-quality issues.

When cache_dir is set in the config, downloaded HDF5 files are saved locally and reused — avoiding repeated downloads for the same GPS interval.

Attributes:

Name Type Description
duration float

Duration of the configured GPS interval (seconds).

sampling_frequency float

Sampling frequency in Hz.

detectors list[str]

List of detector prefixes.

seed None

Always None (real noise has no random seed).

config

The underlying GWOSC configuration.

detectors property

Return the list of detector prefixes.

duration property

Return the total duration of the configured GPS interval.

metadata property

Return metadata describing the simulator and its configuration.

Returns:

Type Description
dict[str, Any]

A dictionary with the simulator implementation name,

dict[str, Any]

GPS range, sample rate, detectors, filter configuration,

dict[str, Any]

and cache status.

sampling_frequency property

Return the sampling frequency in Hz.

seed property

Return None — real noise has no controllable random seed.

__init__(config)

Initialize the real-noise simulator.

Parameters:

Name Type Description Default
config GwoscNoiseConfig

Configuration specifying GPS range, detectors, sample rate, filtering options, and optional cache directory.

required

generate(duration, sampling_frequency, detectors, seed=None)

Fetch clean noise and return per-detector strain arrays.

Fetches data covering the configured GPS interval, applies the configured filters, and concatenates all clean segments into a single contiguous array per detector.

Parameters:

Name Type Description Default
duration float

Requested duration (ignored; the GPS interval from the config determines the output length).

required
sampling_frequency float

Requested sampling frequency (must match the configured sample_rate).

required
detectors list[str]

Requested detector list (must be a subset of the configured detectors).

required
seed int | None

Ignored for real noise.

None

Returns:

Type Description
dict[str, ndarray]

A dictionary mapping each detector to a 1-D numpy array

dict[str, ndarray]

of strain values.

Raises:

Type Description
ValueError

If sampling_frequency does not match the configured value or if detectors are not a subset.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield clean-noise chunks lazily.

Fetches the full clean data once and yields it in chunks of chunk_duration seconds.

Parameters:

Name Type Description Default
chunk_duration float

Duration of each yielded chunk in seconds.

required
sampling_frequency float

Requested sampling frequency (must match the configured sample_rate).

required
detectors list[str]

Requested detector list (must be a subset of the configured detectors).

required
seed int | None

Ignored for real noise.

None

Yields:

Type Description
dict[str, ndarray]

Per-detector strain arrays for each chunk.

InjectGlitches

Wrap a base simulator and inject transient glitches additively.

metadata property

Return additive-wrapper metadata.

__init__(base, glitch_models)

Initialize the additive glitch wrapper.

generate(duration, sampling_frequency, detectors, seed=None)

Generate base noise and inject the configured glitches.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield glitch-injected chunks lazily.

reset()

Reset the additive wrapper and any resettable base state.

LogNormalAmplitudeDistribution dataclass

Log-normal amplitude sampler parameterized by linear mean and std.

__post_init__()

Validate the configured distribution parameters.

sample(rng)

Draw one amplitude sample.

NoiseSimulator

Bases: Protocol

Structural interface for downstream noise simulators.

metadata property

Return simulator metadata.

generate(duration, sampling_frequency, detectors, seed=None)

Generate per-detector strain arrays.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield per-detector strain chunks lazily.

ScatteredLightGlitch dataclass

Bases: GlitchModel

Arch-shaped scattered-light transient with a Gaussian envelope.

__post_init__()

Validate scattered-light parameters.

generate_waveform(sampling_frequency, rng=None)

Generate a chirping scattered-light glitch.

serialize()

Return metadata-friendly model parameters.

SchumannNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate correlated strain noise from an isotropic Schumann-resonance model.

metadata property

Return simulator metadata.

previous_strain property

Expose continuity buffers for protocol-compatible state inspection.

__init__(*, positions, coupling_files, detectors=None, schumann_params=None, sampling_frequency=4096.0, duration=4.0, seed=None, low_frequency_cutoff=2.0, high_frequency_cutoff=None)

Initialize the Schumann simulator.

from_component(component, config) classmethod

Construct a Schumann-noise simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate correlated Schumann strain noise.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield Schumann-noise chunks lazily while preserving simulator state.

reset()

Clear continuity and RNG state.

spectrum(frequencies)

Return the isotropic Schumann magnetic PSD on a frequency grid.

theoretical_coherence(frequency, detector_a, detector_b)

Return the isotropic Schumann coherence approximation.

SchumannParams dataclass

Physical parameters for the isotropic Schumann-resonance model.

__post_init__()

Validate the resonance parameter vectors.

SimulationResult dataclass

Result of a noise simulation run.

Attributes:

Name Type Description
output_paths dict[str, Path]

Paths to generated output files, keyed by detector name.

config NoiseConfig

The configuration used for the simulation.

SpectralLineSimulator

Bases: ConfigurableNoiseSimulator

Generate additive spectral lines directly in the time domain.

metadata property

Return simulator metadata.

__init__(*, lines, detectors=None, sampling_frequency=4096.0, duration=4.0, seed=None)

Initialize the line generator.

from_component(component, config) classmethod

Construct a spectral-line simulator from one component definition.

generate(duration, sampling_frequency, detectors, seed=None)

Generate line-only strain for all requested detectors.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield spectral-line chunks lazily.

reset()

Clear continuity state and phase initialization.

WhiteNoiseSimulator

Bases: ConfigurableNoiseSimulator

Generate Gaussian white noise as a composable component.

metadata property

Return metadata describing the white-noise component.

__init__(*, duration=4.0, sampling_frequency=4096.0, detectors=None, seed=None)

Initialize the white-noise component state.

from_component(component, config) classmethod

Construct one white-noise component from generic config.

generate(duration, sampling_frequency, detectors, seed=None)

Return Gaussian white-noise strain arrays.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield white-noise strain chunks lazily.

open_stream(simulator, *, chunk_duration, sampling_frequency, detectors, seed=None)

Open a stateful chunk stream on a protocol-compatible simulator.

take(stream, total_duration, chunk_duration, sampling_frequency)

Collect stream chunks up to total_duration seconds.

Parallel execution

ParallelAdapter runs independent-detector simulators across threads or processes (with constraints for correlated backends).

Parallel adapter for independent-detector noise simulators.

ParallelAdapter

Wrap an independent-detector simulator factory with parallel execution.

metadata property

Return metadata describing the wrapped simulator and executor.

__init__(base_factory, *, max_workers=None, backend='auto')

Store the simulator factory and executor preferences.

generate(duration, sampling_frequency, detectors, seed=None)

Generate per-detector strain arrays in parallel.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield parallel-generated chunks lazily.

reset()

Clear cached worker simulators, resetting continuity across workers.

Diagnostics

PSD estimation/comparison and simple stationarity/gaussianity checks used in tests and notebooks.

Diagnostics helpers for gwmock-noise.

DiagnosticResult dataclass

Outcome of a statistical diagnostic check.

compare_psd(data, target_psd_file, sampling_frequency, rtol=0.1, fmin=10.0, fmax=None)

Compare an estimated PSD against a target PSD file over a frequency band.

This helper compares the median PSD level in-band rather than every bin individually, which makes it robust to the residual variance of a single Welch estimate from stochastic noise.

estimate_psd(data, sampling_frequency, segment_duration=4.0, overlap=0.5)

Estimate a one-sided PSD in physical density units.

The returned frequencies are in Hz. For strain input data, the PSD is in strain^2/Hz.

plot_psd(frequencies, psd, ax=None)

Plot a PSD on log-log axes, importing matplotlib only when needed.

run_diagnostics(data, sampling_frequency)

Run the default Gaussianity and stationarity diagnostics.

Output adapters

Lazy exports for GWpyAdapter and FrameWriter (optional gwpy / frame extras).

Output adapters for gwmock-noise.

__getattr__(name)

Lazily resolve optional adapter exports.

GWOSC real-noise fetching

Models, segment filtering, data fetching, and a NoiseSimulator wrapper for retrieving real detector strain data from GWOSC.

GWOSC real-noise fetching subpackage.

Provides configuration models, segment filtering, and data fetching for retrieving real gravitational-wave detector strain data from the Gravitational-Wave Open Science Centre (GWOSC).

FilterType

Bases: StrEnum

Types of segments that can be filtered out from GWOSC data.

GwoscFilterConfig

Bases: BaseModel

Configuration for filtering GWOSC strain segments.

Attributes:

Name Type Description
filter_types list[FilterType]

Which categories of segments to exclude.

far_threshold float

Maximum false-alarm rate (events/year) for GW event filtering. Events with FAR above this threshold are excluded from filtering (treated as noise). Default 1.0 (one per year).

event_padding float

Padding in seconds to apply around each GW event GPS time when building vetosegments.

dq_flags list[str]

DQ flag basenames (without detector prefix) to query for data-quality vetosegments. E.g. ["CBC_CAT1", "CBC_CAT2"]. The detector prefix is prepended automatically.

exclude_hardware_injections bool

Whether to also exclude segments containing hardware injections.

has_dq_filter property

Return whether the data-quality filter is active.

has_gw_filter property

Return whether any GW signal filter is active.

include_marginal_events property

Return whether to include marginal (low-confidence) GW events.

GwoscNoiseConfig

Bases: BaseModel

Configuration for fetching real detector noise from GWOSC.

Attributes:

Name Type Description
detectors list[str]

List of detector prefixes (e.g. ["H1", "L1"]).

gps_start float

GPS start time of the requested data interval.

gps_end float

GPS end time of the requested data interval.

sample_rate float

Desired sampling rate in Hz. GWOSC typically provides 4096 Hz, with some event datasets at 16384 Hz.

filters GwoscFilterConfig

Filter configuration for excluding segments.

host str

GWOSC host URL.

cache_dir Path | None

Optional directory for file-level caching. When set, downloaded HDF5 frame files are saved locally and reused on subsequent requests for the same GPS interval. When None, data is downloaded on every call without caching.

duration property

Return the duration of the requested interval in seconds.

validate_gps_range()

Validate that gps_end is after gps_start.

GwoscNoiseFetcher

Fetch real detector noise data from GWOSC with optional filtering.

Downloads strain data from GWOSC and applies user-configured filters to exclude segments containing GW signals and data-quality issues.

When cache_dir is configured, HDF5 files are saved locally and reused on subsequent requests — avoiding repeated downloads for the same GPS interval.

Attributes:

Name Type Description
config

The GWOSC noise fetching configuration.

clean_segments property

Return the computed clean segments per detector.

Returns:

Type Description
dict[str, list[tuple[float, float]]]

A dictionary mapping each detector to a list of

dict[str, list[tuple[float, float]]]

(start, end) clean segment tuples.

__init__(config)

Initialize the fetcher.

Parameters:

Name Type Description Default
config GwoscNoiseConfig

Configuration specifying detectors, GPS range, sample rate, filtering options, and optional cache directory.

required

fetch_clean()

Fetch clean noise segments for all detectors.

Clean segments are computed by excluding GW events and data-quality issues according to the filter configuration.

Returns:

Type Description
dict[str, list[TimeSeries]]

A dictionary mapping each detector to a list of

dict[str, list[TimeSeries]]

gwpy.TimeSeries, one per clean segment.

Raises:

Type Description
ValueError

If no data is available for any detector or no clean segments are found.

fetch_raw()

Fetch raw strain data for all detectors without filtering.

Returns:

Type Description
dict[str, TimeSeries]

A dictionary mapping each detector to a full-interval

dict[str, TimeSeries]

gwpy.TimeSeries.

Raises:

Type Description
ValueError

If no data is available for any detector.

GwoscSegmentFilter

Compute clean analysis segments from GWOSC metadata.

Queries GWTC event catalogs and data-quality flags to build vetosegments (time windows to exclude) and returns the remaining clean intervals suitable for noise analysis.

Attributes:

Name Type Description
config

The filter configuration.

__init__(config)

Initialize the segment filter.

Parameters:

Name Type Description Default
config GwoscFilterConfig

Filter configuration specifying which segment categories to exclude and their parameters.

required

compute_clean_segments(gps_start, gps_end, detectors)

Compute clean (analysis-ready) segments for each detector.

Clean segments are the requested GPS range minus the union of: - GW event vetosegments (if any GW filter is active) - DQ vetosegments (if the data-quality filter is active) - Hardware injection segments (if enabled)

Parameters:

Name Type Description Default
gps_start float

GPS start of the requested interval.

required
gps_end float

GPS end of the requested interval.

required
detectors list[str]

List of detector prefixes.

required

Returns:

Type Description
dict[str, SegmentList]

A dictionary mapping each detector to a list of clean

dict[str, SegmentList]

(start, end) segments.

get_dq_vetosegments(gps_start, gps_end, detector)

Query data-quality flags for detector and build vetosegments.

Uses gwosc.timeline.get_segments() to fetch pre-computed DQ veto segments for each flag in dq_flags.

Parameters:

Name Type Description Default
gps_start float

GPS start of the query interval.

required
gps_end float

GPS end of the query interval.

required
detector str

Detector prefix (e.g. "H1").

required

Returns:

Type Description
SegmentList

A list of (start, end) vetosegment tuples covering

SegmentList

time windows with data-quality issues.

get_gw_vetosegments(gps_start, gps_end)

Query GWTC events in the GPS range and build vetosegments.

For HIGH_CONFIDENCE_GW, only events with FAR <= far_threshold are included. For ALL_GW_SIGNALS, all events in the range are included.

Parameters:

Name Type Description Default
gps_start float

GPS start of the query interval.

required
gps_end float

GPS end of the query interval.

required

Returns:

Type Description
SegmentList

A list of (start, end) vetosegment tuples, each centred

SegmentList

on a GW event GPS time with event_padding on both sides.

get_hardware_injection_segments(gps_start, gps_end)

Query hardware injection events and build vetosegments.

Parameters:

Name Type Description Default
gps_start float

GPS start of the query interval.

required
gps_end float

GPS end of the query interval.

required

Returns:

Type Description
SegmentList

A list of (start, end) vetosegment tuples around

SegmentList

hardware injection times.

Real-noise simulator backed by GWOSC strain data.

Provides a :class:GwoscNoiseSimulator that satisfies the NoiseSimulator protocol, allowing GWOSC-fetched noise to be used interchangeably with the built-in synthetic simulators.

GwoscNoiseSimulator

Real-noise simulator that fetches strain data from GWOSC.

Implements the NoiseSimulator protocol so it can be used interchangeably with synthetic simulators like ColoredNoiseSimulator and CorrelatedNoiseSimulator.

Fetches real detector strain from the Gravitational-Wave Open Science Centre and applies user-configured filters to exclude segments containing GW signals or data-quality issues.

When cache_dir is set in the config, downloaded HDF5 files are saved locally and reused — avoiding repeated downloads for the same GPS interval.

Attributes:

Name Type Description
duration float

Duration of the configured GPS interval (seconds).

sampling_frequency float

Sampling frequency in Hz.

detectors list[str]

List of detector prefixes.

seed None

Always None (real noise has no random seed).

config

The underlying GWOSC configuration.

detectors property

Return the list of detector prefixes.

duration property

Return the total duration of the configured GPS interval.

metadata property

Return metadata describing the simulator and its configuration.

Returns:

Type Description
dict[str, Any]

A dictionary with the simulator implementation name,

dict[str, Any]

GPS range, sample rate, detectors, filter configuration,

dict[str, Any]

and cache status.

sampling_frequency property

Return the sampling frequency in Hz.

seed property

Return None — real noise has no controllable random seed.

__init__(config)

Initialize the real-noise simulator.

Parameters:

Name Type Description Default
config GwoscNoiseConfig

Configuration specifying GPS range, detectors, sample rate, filtering options, and optional cache directory.

required

generate(duration, sampling_frequency, detectors, seed=None)

Fetch clean noise and return per-detector strain arrays.

Fetches data covering the configured GPS interval, applies the configured filters, and concatenates all clean segments into a single contiguous array per detector.

Parameters:

Name Type Description Default
duration float

Requested duration (ignored; the GPS interval from the config determines the output length).

required
sampling_frequency float

Requested sampling frequency (must match the configured sample_rate).

required
detectors list[str]

Requested detector list (must be a subset of the configured detectors).

required
seed int | None

Ignored for real noise.

None

Returns:

Type Description
dict[str, ndarray]

A dictionary mapping each detector to a 1-D numpy array

dict[str, ndarray]

of strain values.

Raises:

Type Description
ValueError

If sampling_frequency does not match the configured value or if detectors are not a subset.

generate_stream(chunk_duration, sampling_frequency, detectors, seed=None)

Yield clean-noise chunks lazily.

Fetches the full clean data once and yields it in chunks of chunk_duration seconds.

Parameters:

Name Type Description Default
chunk_duration float

Duration of each yielded chunk in seconds.

required
sampling_frequency float

Requested sampling frequency (must match the configured sample_rate).

required
detectors list[str]

Requested detector list (must be a subset of the configured detectors).

required
seed int | None

Ignored for real noise.

None

Yields:

Type Description
dict[str, ndarray]

Per-detector strain arrays for each chunk.

Command-line interface

Typer application and the simulate command used by the gwmock-noise console script.

Main entry point for the gwmock_noise CLI application.

LoggingLevel

Bases: StrEnum

Logging levels for the CLI.

main(verbose=LoggingLevel.INFO)

Implement the main entry point for the CLI application.

Parameters:

Name Type Description Default
verbose Annotated[LoggingLevel, Option('--verbose', '-v', help='Set verbosity level.')]

Verbosity level for logging.

INFO

register_commands()

Register CLI commands.

setup_logging(level=LoggingLevel.INFO)

Set up logging with Rich handler.

Parameters:

Name Type Description Default
level LoggingLevel

Logging level.

INFO

Command for running noise simulations.

simulate(config_path)

Run noise simulation from a configuration file.

Loads the configuration, validates it, and runs the noise simulator. Output files are written to the directory specified in the config.

Package version

A script to infer the version number from the metadata.