Skip to content

Models

blipss.models.base

Shared base class for blipss config models.

BlipssConfigModel

Bases: BaseModel

Base for config models where a blank/null YAML field is treated as absent, falling back to the field's declared default.

blipss.models.compare_cands

Pydantic models for validating input configs read from config/compare_cands.yaml

CandidateGroupingConfig

Bases: BlipssConfigModel

cluster_radius_positive(v) classmethod

Validate that the clustering radius is positive.

Parameters:

Name Type Description Default
v float

Clustering radius from the config.

required

Returns:

Type Description
float

The validated clustering radius.

Raises:

Type Description
ValueError

When the clustering radius is not positive.

Source code in blipss/models/compare_cands.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
@field_validator("cluster_radius")
@classmethod
def cluster_radius_positive(cls, v: float) -> float:
    """
    Validate that the clustering radius is positive.

    Args:
        v: Clustering radius from the config.

    Returns:
        The validated clustering radius.

    Raises:
        ValueError: When the clustering radius is not positive.
    """
    if v <= 0:
        raise ValueError(f"cluster_radius must be positive; got {v}")
    return v

n_jobs_valid(v) classmethod

Validate that n_jobs is a positive worker count.

Parameters:

Name Type Description Default
v int

Worker process count from the config.

required

Returns:

Type Description
int

The validated worker process count.

Raises:

Type Description
ValueError

When n_jobs is not positive.

Source code in blipss/models/compare_cands.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
@field_validator("n_jobs")
@classmethod
def n_jobs_valid(cls, v: int) -> int:
    """
    Validate that n_jobs is a positive worker count.

    Args:
        v: Worker process count from the config.

    Returns:
        The validated worker process count.

    Raises:
        ValueError: When n_jobs is not positive.
    """
    if v < 1:
        raise ValueError(f"n_jobs must be >= 1; got {v}")
    return v

CompareCandsConfig

Bases: BlipssConfigModel

labels_match_csv_list()

Validate that one pointing label is provided per candidate CSV file.

Returns:

Type Description
CompareCandsConfig

The model instance, unchanged.

Raises:

Type Description
ValueError

When the number of labels does not match the number of CSV files.

Source code in blipss/models/compare_cands.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
@model_validator(mode="after")
def labels_match_csv_list(self) -> "CompareCandsConfig":
    """
    Validate that one pointing label is provided per candidate CSV file.

    Returns:
        The model instance, unchanged.

    Raises:
        ValueError: When the number of labels does not match the number of CSV files.
    """
    n_files = len(self.candidate_files.csv_list)
    n_labels = len(self.on_off_classification.labels)
    if n_files != n_labels:
        raise ValueError(f"csv_list has {n_files} entries but labels has {n_labels}; lengths must match")
    return self

OnOffClassificationConfig

Bases: BlipssConfigModel

cutoff_positive(v) classmethod

Validate that an S/N cutoff is positive.

Parameters:

Name Type Description Default
v float

Cutoff value from the config.

required

Returns:

Type Description
float

The validated cutoff value.

Raises:

Type Description
ValueError

When the cutoff is non-negative.

Source code in blipss/models/compare_cands.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@field_validator("on_cutoff", "off_cutoff")
@classmethod
def cutoff_positive(cls, v: float) -> float:
    """
    Validate that an S/N cutoff is positive.

    Args:
        v: Cutoff value from the config.

    Returns:
        The validated cutoff value.

    Raises:
        ValueError: When the cutoff is non-negative.
    """
    if v <= 0:
        raise ValueError(f"S/N cutoff must be > 0; got {v}")
    return v

labels_are_on_or_off(v) classmethod

Validate that every label is either 'ON' or 'OFF'.

Parameters:

Name Type Description Default
v list[str]

Uppercased label strings.

required

Returns:

Type Description
list[str]

The validated label strings.

Raises:

Type Description
ValueError

When any label is not 'ON' or 'OFF'.

Source code in blipss/models/compare_cands.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@field_validator("labels")
@classmethod
def labels_are_on_or_off(cls, v: list[str]) -> list[str]:
    """
    Validate that every label is either 'ON' or 'OFF'.

    Args:
        v: Uppercased label strings.

    Returns:
        The validated label strings.

    Raises:
        ValueError: When any label is not 'ON' or 'OFF'.
    """
    invalid = sorted(set(v) - {"ON", "OFF"})
    if invalid:
        raise ValueError(f"labels must be 'ON' or 'OFF'; got invalid values: {invalid}")
    return v

uppercase_labels(v) classmethod

Normalise pointing labels to uppercase.

Parameters:

Name Type Description Default
v list[str]

Raw label strings from the config.

required

Returns:

Type Description
list[str]

Labels converted to uppercase.

Source code in blipss/models/compare_cands.py
26
27
28
29
30
31
32
33
34
35
36
37
38
@field_validator("labels", mode="before")
@classmethod
def uppercase_labels(cls, v: list[str]) -> list[str]:
    """
    Normalise pointing labels to uppercase.

    Args:
        v: Raw label strings from the config.

    Returns:
        Labels converted to uppercase.
    """
    return [label.upper() for label in v]

blipss.models.compute_phase_resolved_ds

Pydantic models for validating input configs read from config/phaseresolved_ds.yaml

PhaseResolvedDsConfig

Bases: BlipssConfigModel

resolve_output_defaults()

Resolve plot_dir default from input data configuration.

Returns:

Type Description
PhaseResolvedDsConfig

The model instance with plot_dir resolved.

Source code in blipss/models/compute_phase_resolved_ds.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
@model_validator(mode="after")
def resolve_output_defaults(self) -> "PhaseResolvedDsConfig":
    """
    Resolve plot_dir default from input data configuration.

    Returns:
        The model instance with plot_dir resolved.
    """
    if self.output.plot_dir is None:
        self.output.plot_dir = self.input_data.data_dir
    return self

blipss.models.inject_signal

Pydantic models for validating input configs read from config/inject_signal.yaml

InjectSignalConfig

Bases: BlipssConfigModel

resolve_defaults()

Resolve output_ext and output_dir defaults from input data configuration.

Returns:

Type Description
InjectSignalConfig

The model instance with resolved defaults.

Source code in blipss/models/inject_signal.py
58
59
60
61
62
63
64
65
66
67
68
69
70
@model_validator(mode="after")
def resolve_defaults(self) -> "InjectSignalConfig":
    """
    Resolve output_ext and output_dir defaults from input data configuration.

    Returns:
        The model instance with resolved defaults.
    """
    if not self.output.output_ext:
        self.output.output_ext = ".h5" if self.input_data.datafile.endswith(".h5") else ".fil"
    if self.output.output_dir is None:
        self.output.output_dir = self.input_data.data_dir
    return self

OutputConfig

Bases: BlipssConfigModel

validate_output_ext(v) classmethod

Validate that the output extension is a recognised filterbank format.

Parameters:

Name Type Description Default
v str

The output extension string from the config.

required

Returns:

Type Description
str

The validated extension string.

Raises:

Type Description
ValueError

When the extension is non-empty but not .fil or .h5.

Source code in blipss/models/inject_signal.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
@field_validator("output_ext")
@classmethod
def validate_output_ext(cls, v: str) -> str:
    """
    Validate that the output extension is a recognised filterbank format.

    Args:
        v: The output extension string from the config.

    Returns:
        The validated extension string.

    Raises:
        ValueError: When the extension is non-empty but not .fil or .h5.
    """
    if v and v not in FILTERBANK_EXTENSIONS:
        raise ValueError(f"output_ext must be .fil or .h5, got {v!r}")
    return v

blipss.models.plot_cands

Pydantic models for validating input configs read from config/plot_cands.yaml

InputDataConfig

Bases: BlipssConfigModel

resolve_beam_labels()

Default beam_labels to one blank label per data file.

Returns:

Type Description
InputDataConfig

The model instance with beam_labels resolved.

Source code in blipss/models/plot_cands.py
19
20
21
22
23
24
25
26
27
28
29
@model_validator(mode="after")
def resolve_beam_labels(self) -> "InputDataConfig":
    """
    Default beam_labels to one blank label per data file.

    Returns:
        The model instance with beam_labels resolved.
    """
    if not self.beam_labels:
        self.beam_labels = [""] * len(self.datafile_list)
    return self

PlotCandsConfig

Bases: BlipssConfigModel

resolve_plot_dir()

Resolve plot_dir default from input data configuration.

Returns:

Type Description
PlotCandsConfig

The model instance with plot_dir resolved.

Source code in blipss/models/plot_cands.py
65
66
67
68
69
70
71
72
73
74
75
@model_validator(mode="after")
def resolve_plot_dir(self) -> "PlotCandsConfig":
    """
    Resolve plot_dir default from input data configuration.

    Returns:
        The model instance with plot_dir resolved.
    """
    if self.plotting_parameters.plot_dir is None:
        self.plotting_parameters.plot_dir = self.input_data.data_dir
    return self

Pydantic models for validating input configs read from a blipss YAML config file.

blipss.models.simulate_data

Pydantic models for validating input configs read from config/simulate_data.yaml