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.
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
¶
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
¶
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
¶
NoiseComponentConfig
¶
NoiseConfig
¶
Bases: BaseModel
Generic configuration for composed detector-noise simulations.
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.
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
¶
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.
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
¶
LogNormalAmplitudeDistribution
dataclass
¶
ScatteredLightGlitch
dataclass
¶
Bases: GlitchModel
Arch-shaped scattered-light transient with a Gaussian envelope.
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.
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
¶
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
¶
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 |
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
¶
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 |
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 |
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 |
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
¶
ScatteredLightGlitch
dataclass
¶
Bases: GlitchModel
Arch-shaped scattered-light transient with a Gaussian envelope.
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).
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. |
exclude_hardware_injections |
bool
|
Whether to also exclude segments containing hardware injections. |
GwoscNoiseConfig
¶
Bases: BaseModel
Configuration for fetching real detector noise from GWOSC.
Attributes:
| Name | Type | Description |
|---|---|---|
detectors |
list[str]
|
List of detector prefixes (e.g. |
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 |
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
¶
__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]]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no data is available for any detector or no clean segments are found. |
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]
|
|
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. |
required |
Returns:
| Type | Description |
|---|---|
SegmentList
|
A list of |
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 |
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 |
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 |
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
¶
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 |
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 |
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 |
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.
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.