filters.compliance
IEC 61260-1:2014 band-filter class verification.
Acceptance limits on relative attenuation transcribed from the official text (BS EN 61260-1:2014, Table 1, standard pages 15-16): octave-band breakpoint frequencies with class 1 and class 2 minimum/maximum limits. Fractional-octave-band breakpoints are derived with Formulas (9) and (10) (subclauses 5.10.3-5.10.4) and limits between breakpoints are interpolated linearly in per Formula (11) (subclause 5.10.6). Relative attenuation is (Formula 8) with (Formula 7); here is the attenuation at the exact mid-band frequency (subclause 5.9: the pass-band reference attenuation).
IEC 61260-1:2014 defines only classes 1 and 2. Class 0 (the tightest,
laboratory-grade class) lives only in the withdrawn IEC 61260:1995 /
EN 61260:1995 Table 1 and its US twin ANSI S1.11-2004 Table 1, whose
class 1/2 masks differ numerically from the 2014 edition (e.g. the 2014
pass-band reference tolerance is ±0.4 dB for class 1 vs ±0.3 dB in 1995, and
the 2014 stop-band edge minimum is +1.2 dB vs +2.0 dB in 1995). The two editions
are therefore kept as separate mask tables selected by the edition argument
("2014" default -> classes 1/2; "1995" -> classes 0/1/2). The 1995 /
ANSI-2004 octave-band table was transcribed digit-for-digit and cross-checked
between the two standards (they agree exactly).
One subject: the class of a band-filter design, graded against what IEC 61260-1:2014 requires of the transfer function of a set of filters and run the way IEC 61260-2:2016 (pattern evaluation) says the requirement is tested. Besides the Table 1 mask there are two more requirements, both computed from the same designed sections:
- Effective bandwidth deviation (61260-1 5.11 and 5.12). The normalized effective bandwidth is the integral of Formula (13), , evaluated as IEC 61260-2 7.2.3.2 recommends: by the trapezoidal rule of its Formula (2) over the test frequencies of its Formula (1), , with frequencies per bandwidth (7.2.1.4). Its deviation from the reference (Formula (15)) is (Formula (16)), within dB for class 1 and dB for class 2 (5.12.2).
- Summation of output signals (61260-1 5.16). At the test frequencies , , inside a band, the outputs of that band and of its two neighbours are summed on an energy basis, IEC 61260-2 Formula (3): , for every band that has a neighbour on both sides (7.2.4.4). The limits are dB and dB for class 1 and dB and dB for class 2. They are applied to Formula (3) as printed, as 7.2.4.5 instructs; the words of 7.2.4.3 and of 5.16 name the difference the other way round, “input minus reference attenuation, and the summed output”, which with limits this asymmetric is not the same test (see the errata registry).
Both are graded for edition="2014" only, whose Part 2 prescribes them; a
1995-edition verdict remains the Table 1 mask.
The time-invariant operation of 5.14, tested with an exponential sweep
(IEC 61260-2 7.4), is phonometry.filters.verify_time_invariance: it
runs the bank itself, decimation included, rather than reading its transfer
functions.
The acceptance limits of the A/B/C/AU/Z frequency weightings, which qualify a
network applied to the whole signal against a design-goal response, live in
phonometry.filters.weighting_compliance.
Auto-generated from the source docstrings by
scripts/generate_api_docs.py(make api-docs). Do not edit by hand.
class_limits
Section titled “class_limits”class_limits( fraction: float, filter_class: int, omega: np.ndarray, *, edition: str = '2014',) -> tuple[np.ndarray, np.ndarray]Acceptance limits on relative attenuation at normalized frequencies.
Parameters
| Name | Description |
|---|---|
fraction | Bandwidth designator denominator b (1 for octave, 3 for one-third octave, …). |
filter_class | Performance class: 1 or 2 for edition="2014"; 0, 1 or 2 for edition="1995". |
omega | Normalized frequencies (> 0). |
edition | "2014" (IEC 61260-1:2014, classes 1/2) or "1995" (IEC 61260:1995 / ANSI S1.11-2004, classes 0/1/2). |
Returns: Tuple (minimum, maximum) relative attenuation in dB per point; the maximum is +inf outside the pass-band.
FilterComplianceResult
Section titled “FilterComplianceResult”FilterComplianceResult( overall_class: int | None, bands: tuple[dict[str, Any], ...], fraction: int, edition: str, sos: tuple[np.ndarray, ...], band_frequencies: np.ndarray, factors: tuple[int, ...], fs: float, num_points: int, *, range_limited: bool = False, points_per_bandwidth: int = 24,)IEC 61260-1 class-compliance verdict of an OctaveFilterBank.
What verify_filter_class returns: the verdict together with the
minimal filter-bank data needed to redraw the measured relative-attenuation
curve, so the result exposes the standard plot / report pair without
holding a reference to the (possibly stateful) bank.
Attributes
| Name | Description |
|---|---|
overall_class | The strictest class every band meets (0/1/2), or None when at least one band meets no class of the edition. |
bands | The per-band verdicts (one {"freq", "class", "margin_class<c>_db", ...} per band), as an immutable tuple. |
fraction | Bandwidth designator b (1 for octave, 3 for one-third-octave). |
edition | "2014" (IEC 61260-1:2014, classes 1/2) or "1995" (IEC 61260:1995 / ANSI S1.11-2004, classes 0/1/2). |
sos | Per-band second-order sections of the analysed bank (one array per band), kept so the relative attenuation can be recomputed with scipy.signal.sosfreqz exactly as the verifier does. |
band_frequencies | The exact mid-band frequencies f_m in Hz. |
factors | Per-band decimation factor; the band’s processing sample rate is fs / factor (the multirate rate the SOS were designed at). Stored because the response must be evaluated at that decimated rate, which the verifier’s public return does not expose. |
fs | The bank’s full sampling rate in Hz. |
num_points | Frequency grid points per band used by the verification, retained so the redrawn curve matches the analysed grid. |
range_limited | True when at least one band’s stop-band mask extends beyond its processing Nyquist frequency, so the verification could not exercise the full Table 1 mask there (the multirate anti-aliasing removes signal energy beyond it, but the limits are not demonstrated); the stated class then attests the verified frequency range and the .report() fiche prints a qualifying note. |
points_per_bandwidth | S, the test frequencies per bandwidth of IEC 61260-2:2016 Formula (1) the effective bandwidth and the summation were evaluated on. |
For edition="2014" every band entry carries, besides its Table 1
margins margin_class<c>_db, the two requirements IEC 61260-2 tests on
the same measurements:
bandwidth_deviation_db, the effective bandwidth deviation of 5.12, andbandwidth_margin_class<c>_db, its distance to each class’s limit;summation_min_dbandsummation_max_db, the range of the summation of 5.16 across the band, andsummation_margin_class<c>_db, the nearer of its distances to each class’s two limits; all three areNoneon the first and the last band, which have a neighbour on one side only (IEC 61260-2 7.2.4.4).
A band’s class is then the strictest class it meets on all of them.
FilterComplianceResult.available_classes()
Section titled “FilterComplianceResult.available_classes()”FilterComplianceResult.available_classes() -> list[int]The performance classes carried by the per-band verdict dictionaries.
Reads the margin_class<n>_db keys of a band verdict, so it reflects
the edition (the 1995 edition adds class 0; the 2014 edition keeps only
classes 1 and 2). An empty result (a bank with no bands in range)
carries no verdicts, so this returns an empty list.
The first band answers for all of them: construction pins every band to the same margin classes.
FilterComplianceResult.binding_margin_db()
Section titled “FilterComplianceResult.binding_margin_db()”FilterComplianceResult.binding_margin_db( requirement: str, filter_class: int,) -> floatThe smallest margin, in dB, of any band to one class on one requirement.
Parameters
| Name | Description |
|---|---|
requirement | One of requirements. |
filter_class | One of available_classes. |
Returns: The binding margin; negative when a band misses the class.
Raises
| Exception | When |
|---|---|
| KeyError | for a requirement this verdict did not grade, or a class it carries no margins for. |
FilterComplianceResult.plot()
Section titled “FilterComplianceResult.plot()”FilterComplianceResult.plot( ax: Axes | None = None, *, requirement: str = 'relative_attenuation', language: str = 'en', **kwargs: Any,) -> AxesPlot one graded requirement.
"relative_attenuation" (the default) draws the measured relative
attenuation of the binding band over the acceptance corridor of the
achieved (or, when non-compliant, the loosest) class; see
phonometry._plot.filters.plot_filter_class.
"effective_bandwidth" draws of every band between
the limits of 5.12.2, and "summation" the Formula (3) curve of
every inner band between the limits of 5.16. Requires matplotlib
(pip install phonometry[plot]) and returns the
Axes.
Parameters
| Name | Description |
|---|---|
ax | Existing axes, or None to create a figure. |
requirement | One of requirements. |
language | Label language, "en" (default) or "es". |
kwargs | Forwarded to the renderer’s measured curve. |
Raises
| Exception | When |
|---|---|
| ValueError | for a requirement this verdict did not grade. |
FilterComplianceResult.reference_class()
Section titled “FilterComplianceResult.reference_class()”FilterComplianceResult.reference_class() -> intThe class whose corridor the fiche/plot overlays.
The achieved overall class when the bank complies, else the loosest class of the edition (the one it comes closest to meeting).
Raises
| Exception | When |
|---|---|
| ValueError | If the result carries no bands, so there is no reference class to report. |
FilterComplianceResult.report()
Section titled “FilterComplianceResult.report()”FilterComplianceResult.report( path: str, *, metadata: ReportMetadata | None = None, engine: str = 'reportlab', verbose: bool = False, language: str = 'en',) -> strRender an IEC 61260-1 filter-class-compliance fiche to a PDF.
Writes a one-page accredited report: the standard-basis line, an
optional metadata header block, a per-band classification table beside
the mask-overlay plot (the result’s own plot), the boxed
class-compliance result, an optional verdict row against a supplied
required_class and a footer with the fixed disclaimer.
Parameters
| Name | Description |
|---|---|
path | Destination path of the PDF file. |
metadata | Optional ReportMetadata; None produces a prediction fiche (body, result and disclaimer only). A supplied required_class drives the verdict row. |
engine | Rendering back end; only "reportlab" is supported. |
verbose | Accepted for a uniform signature; it has no effect on the single-layout filter-compliance fiche. |
language | Fiche language: "en" (default, English) or "es" (Spanish, with a comma decimal separator). |
Returns: The written path as a str.
Raises
| Exception | When |
|---|---|
| ValueError | If engine is not "reportlab". |
| ImportError | If reportlab is not installed (pip install phonometry[report]), or matplotlib is missing for the embedded figure (pip install phonometry[plot]). |
FilterComplianceResult.requirement_class()
Section titled “FilterComplianceResult.requirement_class()”FilterComplianceResult.requirement_class(requirement: str) -> int | NoneThe strictest class every band meets on one requirement alone.
Parameters
| Name | Description |
|---|---|
requirement | One of requirements. |
Returns: The class, or None when a band meets none. The bands a requirement does not apply to (the end bands of the summation) do not constrain it.
Raises
| Exception | When |
|---|---|
| KeyError | for a requirement this verdict did not grade. |
FilterComplianceResult.requirements
Section titled “FilterComplianceResult.requirements”property
The requirements of IEC 61260-1:2014 this verdict graded.
"relative_attenuation" (5.10, Table 1) always; for the 2014
edition also "effective_bandwidth" (5.12) and, when the bank has
a band with a neighbour on each side, "summation" (5.16), which
IEC 61260-2:2016 7.2.4.4 grades on those bands only. Empty for a bank
with no bands.
verify_filter_class
Section titled “verify_filter_class”verify_filter_class( bank: OctaveFilterBank, *, num_points: int = 32768, edition: str = '2014', points_per_bandwidth: int = 24,) -> FilterComplianceResultVerify a filter bank against the IEC 61260 class limits.
Each band’s relative attenuation (referenced to the attenuation at its
exact mid-band frequency) is checked against every acceptance-limit class of
the selected edition’s Table 1, evaluated on a dense frequency grid up to
the band’s processing Nyquist. The Table 1 breakpoint frequencies inside
that range are always included in the evaluation, so the pass-band
constraints are checked even if the grid were coarse. Frequencies beyond
the processing Nyquist cannot carry signal energy at the band’s decimated
rate (the multirate anti-aliasing filter removes them), so they are
treated as compliant; because the Table 1 limits there are nevertheless
not demonstrated, the returned range_limited flag is set whenever a
band’s stop-band mask extends beyond its processing Nyquist, and the
per-band checked_to_omega records how far the check reached.
For edition="2014" two more requirements of IEC 61260-1:2014 are
graded on the same sections, the way IEC 61260-2:2016 tests them (see
the module docstring): the effective bandwidth deviation of every band
(5.12, Formulas (1) and (2) of Part 2) and the summation of the output
signals of every band that has a neighbour on each side (5.16, Formula
(3) of Part 2). A band’s class, and so the bank’s, is the strictest class
met on every requirement graded; FilterComplianceResult.requirement_class
gives the class of each requirement on its own.
Parameters
| Name | Description |
|---|---|
bank | The filter bank to verify (its designed SOS are analyzed; works for stateful and stateless banks alike). |
num_points | Number of frequency grid points per band (>= 16). |
edition | "2014" (IEC 61260-1:2014, classes 1/2) or "1995" (IEC 61260:1995 / ANSI S1.11-2004, adds the stricter class 0; the verdict is its Table 1 mask alone). |
points_per_bandwidth | S, the test frequencies per filter bandwidth of IEC 61260-2:2016 Formula (1), at least 24 (7.2.1.4). |
Returns: A FilterComplianceResult, which carries the verdict together with the sections, mid-band frequencies, decimation factors and sampling rate it was measured through, so it can redraw the relative attenuation and render an accredited .report() fiche without keeping a reference to the (possibly stateful) bank.