feat: environmental-noise determination (ISO 1996-2 tonal adjustment + uncertainty) (#133)
* feat: environmental-noise determination (ISO 1996-2 tonal adjustment + uncertainty)
ISO 1996-2:2017 is the determination part of the ISO 1996 environmental-noise
family (the descriptors Lden/Ldn live in ISO 1996-1, already in
phonometry.environmental). New module phonometry.environmental_measurement:
* Tonal adjustment (engineering method, ISO 1996-2:2007 Annex C):
tonal_audibility() forms ΔLta = Lpt − Lpn + 2 + lg[1 + (fc/502)^2.5] dB
(Formula C.3) and tonal_adjustment() the piecewise Kt (Formulae C.4-C.6);
assess_tonal_audibility() bundles them with the critical bandwidth (Table
C.1) into a plottable result. tonal_seeking_survey() is the one-third-octave
15/8/5 dB screen (Annex K) and tonal_adjustment_from_mean_audibility() the
Table J.1 mean-audibility route.
* Residual-noise correction: residual_sound_correction() (Formula 16, flags a
<3 dB margin as an upper bound) and gaussian_residual_level() (Annex I).
* Measurement uncertainty: combined_standard_uncertainty() (Formula 2),
environmental_expanded_uncertainty() (k=2/1.3), residual_correction_uncertainty()
(Formulae F.7-F.9) and uncertainty_from_repeated_measurements() (Formulae 17-20).
Unlike the removed 2017 engineering method (which defers to ISO/PAS 20065), the
detailed 2007/2009 Annex C algorithm is self-contained and has worked numeric
examples: conformance is anchored on Annex C.5 (ΔLta and Kt) and Annex G.2 (the
combined uncertainty u = 2.18 dB) -- three new checks (115/115, byte-stable).
The raw-FFT tone-detection pipeline is intentionally out of scope: the standard
gives no raw input spectra, so it could not be verified. 25 unit tests; docs
(GitHub + site EN/ES) get a new levels section with a figure and API rows.
* test: anchor ISO 1996-2 residual/gaussian/uncertainty tests on hand-computed values
Review found four tests re-derived their expected value from the same
arithmetic expression as the implementation, so a transcription error would
go undetected. Replace them with independent hand-computed literals (residual
correction Formula 16, Gaussian residual I.1/I.2, residual-correction
uncertainty F.9, repeated-measurement mean/uncertainty 18/20).
* fix: avoid assert for type narrowing in gaussian_residual_level (bandit B101)
The CI quality job runs bandit -r src, which flags assert statements (stripped
under python -O). Replace the mypy-narrowing assert with an elif/else-raise so
the branch is both bandit-clean and correctly narrowed.
Standards traceability fixes and the target taxonomy (#118)
* docs: traceability fixes and the target taxonomy
Approved conclusions of the standards-traceability report:
Traceability (P1):
- the room-acoustics footer claimed ISO 3382-3:2022 while the code
implements and verifies :2012 - the footer now tells the truth
- CONFORMANCE.md becomes visible: a Reference page on the site (EN/ES)
explains the report and links the generated table (copying 300
auto-generated lines would drift), docs/README.md indexes it, and
why-phonometry links it after its comparison table
- nine citation patches with honest scoping: the ISO 1996-2 facade
claim reworded as measurement context; ECMA-74 out of the
tone-prominence footer (context note added); ISO 9613-1 declared in
surface-scattering with clause delimitation; materials cites the
BS EN ISO 10534:2001 editions the code cites; the EN 12354 typo;
ISO 266 and ISO 5725 added with narrow scope; IEC 61252 designations
unified
- class_limits exported (it was public-but-unimportable), documented in
the API reference and surfaced in filter-banks section 6
Taxonomy (approved target, sidebar moves only - zero URL changes):
- renamed: Signal processing & filters
- new groups: Instrumentation, calibration & compliance; Materials &
surfaces
- Perception & speech splits into Psychoacoustics (+tone-prominence),
Speech & intelligibility, and Hearing & occupational exposure
(+occupational-exposure)
- docs/README.md mirrors the new order; Conformance joins Reference
* docs: terminology polish on the new conformance pages
key differentiator (not 'differential asset'), governing band/frequency
(not 'binding'), pasa/no pasa, expresiones en forma cerrada, 'en la que
se basan las etiquetas nominales', and air-attenuation relations in
both languages (Gemini)
Standards traceability fixes and the target taxonomy (#118)
* docs: traceability fixes and the target taxonomy
Approved conclusions of the standards-traceability report:
Traceability (P1):
- the room-acoustics footer claimed ISO 3382-3:2022 while the code
implements and verifies :2012 - the footer now tells the truth
- CONFORMANCE.md becomes visible: a Reference page on the site (EN/ES)
explains the report and links the generated table (copying 300
auto-generated lines would drift), docs/README.md indexes it, and
why-phonometry links it after its comparison table
- nine citation patches with honest scoping: the ISO 1996-2 facade
claim reworded as measurement context; ECMA-74 out of the
tone-prominence footer (context note added); ISO 9613-1 declared in
surface-scattering with clause delimitation; materials cites the
BS EN ISO 10534:2001 editions the code cites; the EN 12354 typo;
ISO 266 and ISO 5725 added with narrow scope; IEC 61252 designations
unified
- class_limits exported (it was public-but-unimportable), documented in
the API reference and surfaced in filter-banks section 6
Taxonomy (approved target, sidebar moves only - zero URL changes):
- renamed: Signal processing & filters
- new groups: Instrumentation, calibration & compliance; Materials &
surfaces
- Perception & speech splits into Psychoacoustics (+tone-prominence),
Speech & intelligibility, and Hearing & occupational exposure
(+occupational-exposure)
- docs/README.md mirrors the new order; Conformance joins Reference
* docs: terminology polish on the new conformance pages
key differentiator (not 'differential asset'), governing band/frequency
(not 'binding'), pasa/no pasa, expresiones en forma cerrada, 'en la que
se basan las etiquetas nominales', and air-attenuation relations in
both languages (Gemini)