Skip to content

Configuration

Validated configuration schema for the Newtonian-noise scaffold simulator.

This is a structural scaffold config only: coupling parameterizes a placeholder equicorrelation statistical model, not a physical Newtonian-noise coupling. The physical configuration schema for the seismic field and detector/witness response is the physical joint backend's (:mod:gwmock_newtonian_noise.joint).

NewtonianScaffoldConfig

Bases: BaseModel

Validated configuration for :class:~gwmock_newtonian_noise.simulator.NewtonianScaffoldSimulator.

detectors and witnesses are tuple[str, ...], not list[str]: frozen=True only blocks field reassignment (config.detectors = ... raises), it does not stop in-place mutation of a mutable container a frozen field happens to hold. A tuple has no mutating methods, so the frozen contract holds for the container itself, not just for the attribute name.

Attributes:

Name Type Description
detectors tuple[str, ...]

Strain channel names, non-empty and unique.

witnesses tuple[str, ...]

Witness channel names, non-empty, unique, and disjoint from detectors.

sampling_frequency float

Sampling frequency in hertz, must be positive.

duration float

Nominal generation duration in seconds, must be positive.

seed int | None

Seed for the deterministic RNG policy (see :mod:gwmock_newtonian_noise.rng), or None for a non-reproducible generator.

coupling float

Equicorrelation coefficient of the placeholder statistical model, applied between every channel pair. Must satisfy 0.0 <= coupling < 1.0.

strain_unit str

Unit string recorded for strain channels.

witness_unit str

Unit string recorded for witness channels.

Source code in src/gwmock_newtonian_noise/config.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class NewtonianScaffoldConfig(BaseModel):
    """Validated configuration for :class:`~gwmock_newtonian_noise.simulator.NewtonianScaffoldSimulator`.

    ``detectors`` and ``witnesses`` are ``tuple[str, ...]``, not ``list[str]``:
    ``frozen=True`` only blocks field *reassignment* (``config.detectors = ...``
    raises), it does not stop in-place mutation of a mutable container a frozen
    field happens to hold. A tuple has no mutating methods, so the frozen
    contract holds for the container itself, not just for the attribute name.

    Attributes:
        detectors: Strain channel names, non-empty and unique.
        witnesses: Witness channel names, non-empty, unique, and disjoint from
            ``detectors``.
        sampling_frequency: Sampling frequency in hertz, must be positive.
        duration: Nominal generation duration in seconds, must be positive.
        seed: Seed for the deterministic RNG policy (see
            :mod:`gwmock_newtonian_noise.rng`), or ``None`` for a non-reproducible
            generator.
        coupling: Equicorrelation coefficient of the placeholder statistical
            model, applied between every channel pair. Must satisfy
            ``0.0 <= coupling < 1.0``.
        strain_unit: Unit string recorded for strain channels.
        witness_unit: Unit string recorded for witness channels.
    """

    model_config = ConfigDict(frozen=True, extra="forbid")

    detectors: tuple[str, ...]
    witnesses: tuple[str, ...]
    sampling_frequency: float
    duration: float
    seed: int | None = None
    coupling: float = 0.3
    strain_unit: str = "strain"
    witness_unit: str = "counts"

    @field_validator("detectors", "witnesses")
    @classmethod
    def _non_empty_and_unique(cls, value: tuple[str, ...], info: ValidationInfo) -> tuple[str, ...]:
        """Reject an empty or duplicate-containing channel list."""
        if not value:
            raise ValueError(f"{info.field_name} must contain at least one channel name.")
        if len(set(value)) != len(value):
            raise ValueError(f"{info.field_name} must not contain duplicate channel names.")
        return value

    @field_validator("sampling_frequency", "duration")
    @classmethod
    def _positive(cls, value: float, info: ValidationInfo) -> float:
        """Reject a non-positive sampling frequency or duration."""
        if value <= 0:
            raise ValueError(f"{info.field_name} must be greater than zero.")
        return value

    @field_validator("coupling")
    @classmethod
    def _coupling_in_range(cls, value: float) -> float:
        """Reject a coupling coefficient that would make the covariance matrix singular or invalid."""
        if not (0.0 <= value < 1.0):
            raise ValueError("coupling must satisfy 0.0 <= coupling < 1.0.")
        return value

    @model_validator(mode="after")
    def _disjoint_channel_sets(self) -> NewtonianScaffoldConfig:
        """Reject a config where a name is used as both a detector and a witness."""
        overlap = set(self.detectors) & set(self.witnesses)
        if overlap:
            raise ValueError(f"detectors and witnesses must not share channel names: {sorted(overlap)}")
        return self