environment.assessment.spain
La referencia de la API se publica en inglés en los dos idiomas: se genera a partir de los docstrings del código, que son su texto original.
Spanish noise regulation: the corrected level LKeq (Real Decreto 1367/2007).
Real Decreto 1367/2007 develops Ley 37/2003 del Ruido on acoustic zoning, quality objectives and emitter limit values. Its assessment chain is built on one index the ISO 1996 family does not define: the corrected equivalent continuous level (Annex I A.2 c), where the three corrections penalise emergent tonal components, low-frequency components and impulsive character. Each is 0, 3 or 6 dB and their sum is capped at 9 dB (Annex IV A.3.3).
Corrections (Annex IV A.3.3). The reference procedures are:
Kt: unweighted one-third-octave analysis; for the bandfholding the tone, withLsthe arithmetic mean of the two adjacent band levels.Ktis 0/3/6 dB by the thresholds 8/12 dB (20 to 125 Hz), 5/8 dB (160 to 400 Hz) and 3/5 dB (500 Hz to 10 kHz); with several emergent tones the largest applies.Kf: (background-corrected), giving 0 dB for , 3 dB for and 6 dB above.Ki: (background-corrected), with the same 0/3/6 dB thresholds asKf.
Relationship with the ISO 1996 procedures already in the library. They are relatives, not the same procedure, so this module implements the RD’s own variants rather than delegating:
tonal_audibility/tonal_adjustmentare the ISO 1996-2 Annex C engineering method: a critical-band audibilityΔLtamapped to a continuousKtin 0 to 6 dB. The RD works on one-third-octave band differences and yields 0/3/6 dB only.tonal_seeking_surveyis the closest relative (ISO 1996-2:2017 Annex K also splits the spectrum at 125/400 Hz), but it requires the band to exceed both neighbours by 15/8/5 dB and returns a boolean flag, whereas the RD compares against the mean of the neighbours with 8/5/3 dB thresholds and grades the result.impulsive_sound_adjustmentis the ISO/PAS 1996-3 onset-rate method on a calibrated time signal. The RD’sKiis the classic impulse-vs-fast difference read off a sound level meter.- No ISO 1996 counterpart exists for
Kf: the difference is specific to the RD.
Evaluation periods and integration. Day 07:00-19:00 (12 h), evening
19:00-23:00 (4 h) and night 23:00-07:00 (8 h) (Annex I A.1). A period whose
emission varies is split into noise phases Ti of steady level, and the
period level is the energy mean weighted by phase duration (Annex IV
A.3.4.2 b):
The result is
rounded by adding 0.5 dB and taking the integer part. The long-term index
LK,x is the energy mean of the daily LKeq,x over a year (Annex I
A.2 d).
Limit tables. Annex II holds the acoustic quality objectives (Table A outdoor by area type, as amended by RD 1038/2012; Table B indoor by room; Table C vibration), Annex III the emitter immission limits (Table A1/A2 new road, rail and airport infrastructure; Table B1 port infrastructure and activities; Table B2 noise transmitted to acoustically adjacent premises).
Compliance. For activities and port infrastructure (Article 25.1 b) the
limits are respected when no annual average LK,x exceeds the table value,
no daily LKeq,x exceeds it by more than 3 dB and no measured LKeq,Ti
exceeds it by more than 5 dB. For the inspection of an activity already in
operation (Article 25.2) only the last two apply.
Auto-generated from the source docstrings by
scripts/generate_api_docs.py(make api-docs). Do not edit by hand.
ACOUSTIC_AREA_TYPES
Section titled “ACOUSTIC_AREA_TYPES”Constant (mappingproxy).
ACOUSTIC_AREA_TYPES = {'e': 'sanitary, educational and cultural land use requiring special protection', 'a': 'residential land use', 'd': 'tertiary land use other than type c', 'c': 'recreational and public-entertainment land use', 'b': 'industrial land use', 'f': 'general transport-infrastructure systems and public facilities'}activity_limits
Section titled “activity_limits”activity_limits(area_type: str) -> RegulationLimitsOutdoor immission limits for activities and ports (Annex III Table B1).
The LK,d/LK,e/LK,n an installation, establishment or activity
(industrial, commercial, storage, sports, recreational or leisure) and port
infrastructure must not exceed in the outdoor environment of the acoustic
area they sit in (Article 24.1).
Parameters
| Name | Description |
|---|---|
area_type | Acoustic area type letter, or an alias. |
Returns: The applicable RegulationLimits for the index LK,x.
Raises
| Exception | When |
|---|---|
| ValueError | For an unknown area type. |
ActivityAssessment
Section titled “ActivityAssessment”ActivityAssessment( periods: tuple[PeriodAssessment, ...], limits: RegulationLimits, new_activity: bool,)Compliance of an activity or port infrastructure (Article 25).
Attributes
| Name | Description |
|---|---|
periods | The per-period assessments, in day/evening/night order. |
limits | The limit table row the assessment was made against. |
new_activity | True when the activity is new in the sense of the regulation, so the annual criterion of Article 25.1 b i applies; for the inspection of an activity already in operation only the daily and phase criteria apply (Article 25.2). |
ActivityAssessment.complies
Section titled “ActivityAssessment.complies”property
Whether every period meets every evaluated criterion.
ActivityAssessment.plot()
Section titled “ActivityAssessment.plot()”ActivityAssessment.plot( ax: Axes | None = None, *, language: str = 'en', **kwargs: Any,) -> AxesPlot the per-period indices against their RD 1367/2007 limits.
ActivityAssessment.report()
Section titled “ActivityAssessment.report()”ActivityAssessment.report( path: str, *, metadata: ReportMetadata | None = None, verbose: bool = False, language: str = 'es',) -> strRender a one-page noise inspection fiche (acta) to path.
The layout follows the Spanish municipal / accredited-laboratory noise
inspection report: an identification header, the per-phase measurement
table with the Kt/Kf/Ki corrections, the per-period
assessment against the applicable limits and the boxed verdict.
Parameters
| Name | Description |
|---|---|
path | Destination path of the PDF file. |
metadata | Optional ReportMetadata supplying the header and footer identity fields. |
verbose | Add the per-phase duration and correction breakdown columns. |
language | Fiche language: "es" (default, the language of the regulation) or "en". |
Returns: The written path.
Raises
| Exception | When |
|---|---|
| ImportError | If reportlab (or, for the figure, matplotlib) is not installed. |
adjacent_premises_limits
Section titled “adjacent_premises_limits”adjacent_premises_limits( building_use: str, room_type: str,) -> RegulationLimitsLimits on noise transmitted to adjacent premises (Annex III Table B2).
Two premises are acoustically adjacent when noise never travels between emitter and receiver through the outdoor environment (Article 24.3): the workshop on the ground floor and the flat above it are, the building across the street is not.
Parameters
| Name | Description |
|---|---|
building_use | "residential", "office" (alias "administrative"), "sanitary" or "educational". |
room_type | "living", "bedrooms", "professional_offices", "offices", "classrooms" or "reading_rooms". |
Returns: The applicable RegulationLimits for the index LK,x.
Raises
| Exception | When |
|---|---|
| ValueError | For an unknown combination. |
assess_activity
Section titled “assess_activity”assess_activity( measurements: Mapping[str, Sequence[NoisePhase]], limits: RegulationLimits, *, long_term_levels: Mapping[str, float] | None = None, operating_days: int | None = None, year_days: int = 365, closed_level: float = 0.0, new_activity: bool = True, period_hours: Mapping[str, float] | None = None,) -> ActivityAssessmentAssess an activity against the RD 1367/2007 limit values (Article 25).
For every evaluation period supplied the function integrates the noise
phases into LKeq,x (Annex IV A.3.4.2 b), derives the annual LK,x
when annual information is given, and checks the three criteria of Article
25.1 b: no annual LK,x above the table limit, no daily LKeq,x more
than 3 dB above it, and no measured LKeq,Ti more than 5 dB above it.
With new_activity=False only the last two apply (Article 25.2, the
inspection of an activity in operation).
The annual index can be supplied directly through long_term_levels or
derived from operating_days: the reported daily level then represents
operating_days days of the year and closed_level the remaining
year_days - operating_days.
Parameters
| Name | Description |
|---|---|
measurements | Noise phases keyed by evaluation period ("day", "evening", "night"). Periods that are absent are not assessed. |
limits | The applicable limit row, from activity_limits or adjacent_premises_limits. |
long_term_levels | Annual LK,x per period, in dB, when known. |
operating_days | Number of days a year the activity operates; used to derive LK,x from the daily LKeq,x when long_term_levels is not given. |
year_days | Days in the year considered (default 365). |
closed_level | Level, in dB, representing a day on which the activity does not operate (default 0 dB, as in the Spanish worked literature). |
new_activity | Whether the annual criterion applies. |
period_hours | Period durations T, in hours, overriding RD1367_PERIOD_HOURS. |
Returns: An ActivityAssessment.
Raises
| Exception | When |
|---|---|
| ValueError | For an unknown period key, empty phase list, inconsistent durations, or invalid annual parameters. |
corrected_level
Section titled “corrected_level”corrected_level( laeq: float, *, kt: float = 0.0, kf: float = 0.0, ki: float = 0.0,) -> floatCorrected equivalent continuous level LKeq,T (Annex I A.2 c).
with the sum of the corrections capped at 9 dB. Although it is derived from an A-weighted level, the index is expressed in dB by definition.
Parameters
| Name | Description |
|---|---|
laeq | A-weighted equivalent continuous level LAeq,T, in dB, already corrected for background noise. |
kt | Tonal correction, in dB. |
kf | Low-frequency correction, in dB. |
ki | Impulsive correction, in dB. |
Returns: LKeq,T in dB.
Raises
| Exception | When |
|---|---|
| ValueError | If laeq is not finite or a correction is negative. |
evaluation_period_level
Section titled “evaluation_period_level”evaluation_period_level( phases: Sequence[NoisePhase], *, hours: float | None = None,) -> floatEvaluation-period level LKeq,T from its noise phases.
(Annex IV
A.3.4.2 b): the duration-weighted energy mean of the phase levels. The
returned value is not rounded; apply round_reported_level for the value
the regulation asks to report.
Parameters
| Name | Description |
|---|---|
phases | The noise phases of the period. |
hours | Total period duration T, in hours. None (default) uses the sum of the phase durations, as the regulation requires . |
Returns: LKeq,T in dB.
Raises
| Exception | When |
|---|---|
| ValueError | If phases is empty, hours is not positive, or the phase durations do not sum to hours. |
impulsive_correction
Section titled “impulsive_correction”impulsive_correction(laieq: float, laeq: float) -> floatImpulsive correction Ki (Annex IV A.3.3).
From the impulse- and fast-time-weighted equivalent levels of the same noise phase, both already corrected for background noise, gives for dB, for dB and above.
Parameters
| Name | Description |
|---|---|
laieq | Impulse-weighted equivalent level LAIeq,Ti, in dB. |
laeq | A-weighted equivalent continuous level LAeq,Ti, in dB. |
Returns: Ki in dB (0, 3 or 6).
Raises
| Exception | When |
|---|---|
| ValueError | If either level is not finite. |
indoor_quality_objectives
Section titled “indoor_quality_objectives”indoor_quality_objectives( building_use: str, room_type: str,) -> RegulationLimitsIndoor acoustic quality objectives Ld/Le/Ln (Annex II Table B).
The objectives that the whole set of emitters reaching a habitable room must respect: dwellings and residential uses, hospitals, and educational or cultural buildings.
Parameters
| Name | Description |
|---|---|
building_use | "residential", "sanitary" (alias "hospital") or "educational". |
room_type | "living" (living areas), "bedrooms", "classrooms" or "reading_rooms". |
Returns: The applicable RegulationLimits for the index Lx.
Raises
| Exception | When |
|---|---|
| ValueError | For an unknown combination. |
infrastructure_limits
Section titled “infrastructure_limits”infrastructure_limits(area_type: str) -> RegulationLimitsImmission limits for new transport infrastructure (Annex III Table A1).
New road, rail and airport infrastructure must not transmit to the outdoor
environment of an acoustic area levels above these Ld/Le/Ln
values (Article 23.1).
Parameters
| Name | Description |
|---|---|
area_type | Acoustic area type letter, or an alias. |
Returns: The applicable RegulationLimits for the index Lx.
Raises
| Exception | When |
|---|---|
| ValueError | For an unknown area type. |
long_term_corrected_level
Section titled “long_term_corrected_level”long_term_corrected_level( daily_levels: Sequence[float] | np.ndarray, *, weights: Sequence[float] | np.ndarray | None = None,) -> floatLong-term index LK,x from the daily period levels (Annex I A.2 d).
:
the energy mean of the
daily corrected levels of the same evaluation period over a year. With
weights the mean is weighted, which lets a whole block of identical
days be entered once (e.g. 303 operating days at one level and 62 closed
days at another).
Parameters
| Name | Description |
|---|---|
daily_levels | Daily LKeq,x values, in dB. |
weights | Optional number of days each level represents (positive). |
Returns: LK,x in dB, unrounded.
Raises
| Exception | When |
|---|---|
| ValueError | If the input is empty, non-finite, or the weights do not match the levels or are not positive. |
low_frequency_correction
Section titled “low_frequency_correction”low_frequency_correction(lceq: float, laeq: float) -> floatLow-frequency correction Kf (Annex IV A.3.3).
From the C- and A-weighted equivalent levels of the same noise phase, both already corrected for background noise, gives for dB, for dB and above.
Parameters
| Name | Description |
|---|---|
lceq | C-weighted equivalent continuous level LCeq,Ti, in dB. |
laeq | A-weighted equivalent continuous level LAeq,Ti, in dB. |
Returns: Kf in dB (0, 3 or 6).
Raises
| Exception | When |
|---|---|
| ValueError | If either level is not finite. |
max_infrastructure_limit
Section titled “max_infrastructure_limit”max_infrastructure_limit(area_type: str) -> floatMaximum LAmax for rail and airport infrastructure (Annex III Table A2).
The limit is respected when, over a year, 97 % of all daily values stay at or below it (Article 25.1 a iii).
Parameters
| Name | Description |
|---|---|
area_type | Acoustic area type letter, or an alias. |
Returns: The LAmax limit, in dB.
Raises
| Exception | When |
|---|---|
| ValueError | For an unknown area type. |
NoisePhase
Section titled “NoisePhase”NoisePhase( hours: float, laeq: float, kt: float = 0.0, kf: float = 0.0, ki: float = 0.0, label: str | None = None,)A noise phase Ti of steady emission within an evaluation period.
RD 1367/2007 (Annex IV A.3.4.2 b) splits an evaluation period whose
emission varies into phases in which the sound pressure level at the
assessment point is perceived uniformly, measures LAeq,Ti over at
least 5 s in each, and corrects it for tonal, low-frequency and impulsive
character.
Attributes
| Name | Description |
|---|---|
hours | Duration Ti of the phase, in hours (positive). |
laeq | Background-corrected LAeq,Ti, in dB. A phase in which the activity is shut down carries the level actually measured; the worked examples of the Spanish literature enter it as 0 dB. |
kt | Tonal correction of the phase, in dB. |
kf | Low-frequency correction of the phase, in dB. |
ki | Impulsive correction of the phase, in dB. |
label | Optional free-text description of the phase. |
Raises
| Exception | When |
|---|---|
| ValueError | If hours is not positive and finite, laeq is not finite, or a correction is negative. |
NoisePhase.correction
Section titled “NoisePhase.correction”property
Summed correction , capped at 9 dB.
NoisePhase.lkeq
Section titled “NoisePhase.lkeq”property
The corrected level LKeq,Ti of the phase, in dB.
outdoor_quality_objectives
Section titled “outdoor_quality_objectives”outdoor_quality_objectives( area_type: str, *, urbanisation: str = 'existing',) -> RegulationLimitsOutdoor acoustic quality objectives Ld/Le/Ln (Annex II Table A).
The values are those of Table A as amended by RD 1038/2012. For an area urbanised after the regulation entered into force (24 October 2007) the objective is the same table reduced by 5 dB (Article 14.2); the same 5 dB reduction defines the objective of quiet areas (Article 14.4).
Area type "f" (general transport-infrastructure systems) carries no
numeric objective: footnote (2) refers it to the adjoining areas.
Parameters
| Name | Description |
|---|---|
area_type | Acoustic area type: the letter "e", "a", "d", "c" or "b", or an alias such as "residential". |
urbanisation | "existing" (default) for areas already urbanised on 24 October 2007, or "new" for the rest (5 dB stricter). |
Returns: The applicable RegulationLimits for the index Lx.
Raises
| Exception | When |
|---|---|
| ValueError | For an unknown area type or urbanisation state. |
PeriodAssessment
Section titled “PeriodAssessment”PeriodAssessment( period: str, phases: tuple[NoisePhase, ...], duration_hours: float, evaluation_period_level: float, reported_level: int, long_term_corrected_level: float | None, reported_long_term: int | None, limit: float, max_phase_level: float, phase_pass: bool, daily_pass: bool, long_term_pass: bool | None,)The assessment of one evaluation period against its limit.
Attributes
| Name | Description |
|---|---|
period | "day", "evening" or "night". |
phases | The noise phases the period was split into. |
duration_hours | The period duration T, in hours. |
evaluation_period_level | LKeq,x of the period, in dB, unrounded. |
reported_level | LKeq,x rounded per Annex IV A.3.4.2. |
long_term_corrected_level | Annual LK,x, in dB, unrounded, or None when no annual information was supplied. |
reported_long_term | LK,x rounded, or None. |
limit | The table limit of the period, in dB. |
max_phase_level | The largest LKeq,Ti of the period, in dB. |
phase_pass | Whether every LKeq,Ti stays within limit + 5 dB. |
daily_pass | Whether LKeq,x stays within limit + 3 dB. |
long_term_pass | Whether LK,x stays at or below limit, or None when the criterion was not evaluated. |
PeriodAssessment.complies
Section titled “PeriodAssessment.complies”property
Whether every evaluated criterion of this period is met.
PeriodAssessment.daily_limit
Section titled “PeriodAssessment.daily_limit”property
The daily limit limit + 3 dB (Article 25.1 b ii).
PeriodAssessment.phase_limit
Section titled “PeriodAssessment.phase_limit”property
The phase limit limit + 5 dB (Article 25.1 b iii).
RD1367_CORRECTION_VALUES
Section titled “RD1367_CORRECTION_VALUES”Constant (tuple).
RD1367_CORRECTION_VALUES = (0.0, 3.0, 6.0)RD1367_EVALUATION_PERIODS
Section titled “RD1367_EVALUATION_PERIODS”Constant (tuple).
RD1367_EVALUATION_PERIODS = ('day', 'evening', 'night')RD1367_MAX_CORRECTION
Section titled “RD1367_MAX_CORRECTION”Constant (float).
RD1367_MAX_CORRECTION = 9.0RD1367_PERIOD_CLOCK_LIMITS
Section titled “RD1367_PERIOD_CLOCK_LIMITS”Constant (mappingproxy).
RD1367_PERIOD_CLOCK_LIMITS = {'day': (7, 19), 'evening': (19, 23), 'night': (23, 7)}RD1367_PERIOD_HOURS
Section titled “RD1367_PERIOD_HOURS”Constant (mappingproxy).
RD1367_PERIOD_HOURS = {'day': 12.0, 'evening': 4.0, 'night': 8.0}RegulationLimits
Section titled “RegulationLimits”RegulationLimits( day: float, evening: float, night: float, index: str, reference: str, description: str,)A day/evening/night limit triple read from RD 1367/2007.
Attributes
| Name | Description |
|---|---|
day | Limit of the day period, in dB. |
evening | Limit of the evening period, in dB. |
night | Limit of the night period, in dB. |
index | Noise index the limits apply to (e.g. "LK,x", "Lx"). |
reference | The table the values were read from. |
description | The row of that table, in plain words. |
RegulationLimits.as_dict()
Section titled “RegulationLimits.as_dict()”RegulationLimits.as_dict() -> dict[str, float]The three limits keyed by evaluation period.
round_reported_level
Section titled “round_reported_level”round_reported_level(value: float) -> intRound a level the way RD 1367/2007 prescribes (Annex IV A.3.4.2).
“El valor del nivel sonoro resultante se redondeará incrementándolo en
0,5 dB(A), tomando la parte entera como valor resultante”: add 0,5 dB and
take the integer part. This is a half-up rounding towards +inf, which
for a negative level differs from Python’s banker’s round.
Parameters
| Name | Description |
|---|---|
value | Sound level, in dB. |
Returns: The rounded level, as an int.
Raises
| Exception | When |
|---|---|
| ValueError | If value is not finite. |
tonal_correction
Section titled “tonal_correction”tonal_correction( levels: Sequence[float] | np.ndarray, frequencies: Sequence[float] | np.ndarray,) -> TonalCorrectionResultTonal correction Kt from a one-third-octave spectrum (Annex IV A.3.3).
The spectrum must be unweighted (no frequency weighting applied, as
required by step a). For every interior band f the procedure forms
with Ls the arithmetic mean of the levels of
the bands
immediately above and below (step b), and reads Kt off the table of
step c: with 20 Hz to 125 Hz bands gives 0 dB,
gives 3 dB and gives 6 dB; the thresholds are 5/8 dB over
160 Hz to 400 Hz and 3/5 dB over 500 Hz to 10 kHz. With more than one
emergent tone the largest Kt governs (step d).
Parameters
| Name | Description |
|---|---|
levels | Unweighted one-third-octave band levels, in dB. |
frequencies | Band centre frequencies, in Hz, in ascending order (one per level). |
Returns: A TonalCorrectionResult.
Raises
| Exception | When |
|---|---|
| ValueError | If fewer than three bands are given, the shapes differ, the frequencies are not positive and strictly ascending, or any value is not finite. |
TonalCorrectionResult
Section titled “TonalCorrectionResult”TonalCorrectionResult( frequencies: np.ndarray, levels: np.ndarray, differences: np.ndarray, band_corrections: np.ndarray, correction: float, governing_frequency: float | None,)Tonal correction Kt of RD 1367/2007 (Annex IV A.3.3).
Attributes
| Name | Description |
|---|---|
frequencies | One-third-octave band centre frequencies, in Hz. |
levels | Unweighted band sound pressure levels, in dB. |
differences | per band, in dB, where Ls is the arithmetic mean of the two adjacent band levels. NaN for bands that cannot be evaluated (the two end bands, and bands outside the 20 Hz to 10 kHz range of the table). |
band_corrections | The Kt each band would contribute, in dB (0, 3 or 6); NaN where differences is NaN. |
correction | The governing Kt, in dB: the largest band contribution (Annex IV A.3.3 d), or 0 dB if no band qualifies. |
governing_frequency | Centre frequency of the governing band, in Hz, or None when correction is 0 dB. |
TonalCorrectionResult.plot()
Section titled “TonalCorrectionResult.plot()”TonalCorrectionResult.plot( ax: Axes | None = None, *, language: str = 'en', **kwargs: Any,) -> AxesPlot the band spectrum with the emergent-tone differences Lt.
total_correction
Section titled “total_correction”total_correction(kt: float = 0.0, kf: float = 0.0, ki: float = 0.0) -> floatSummed correction , capped at 9 dB (Annex IV A.3.3).
Each of the three tables of Annex IV A.3.3 grades its parameter 0, 3 or 6 dB, so any other value is rejected rather than silently accepted: a correction of, say, 4.5 dB is not a reading the regulation can produce.
Parameters
| Name | Description |
|---|---|
kt | Tonal correction, in dB (0, 3 or 6). |
kf | Low-frequency correction, in dB (0, 3 or 6). |
ki | Impulsive correction, in dB (0, 3 or 6). |
Returns: The summed correction, in dB, never above RD1367_MAX_CORRECTION.
Raises
| Exception | When |
|---|---|
| ValueError | If a correction is not one of 0, 3 or 6 dB. |
vibration_quality_objective
Section titled “vibration_quality_objective”vibration_quality_objective(building_use: str) -> floatIndoor vibration quality objective Law, in dB (Annex II Table C).
Parameters
| Name | Description |
|---|---|
building_use | "residential", "sanitary" (alias "hospital") or "educational". |
Returns: The Law objective, in dB.
Raises
| Exception | When |
|---|---|
| ValueError | For an unknown building use. |