Ir al contenido
Esta documentación describe la versión 4.0.0, todavía sin publicar. La versión actual en PyPI es la 3.3.0 y no incluye todo lo que se describe aquí.

environment.assessment.soundscape

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.

How people hear a place: the soundscape questionnaire and its analysis (ISO/TS 12913-2:2018 Annexes A and C, ISO/TS 12913-3:2019 Annexes A and B).

A soundscape is the acoustic environment as a person perceives it in context (ISO 12913-1). Its study “relies primarily upon human perception and only then turns to physical measurement” (ISO/TS 12913-2, Introduction), which makes this the first module of the library whose input is not a signal but a questionnaire: the boxes people ticked on a soundwalk, turned into numbers and statistics the way ISO/TS 12913-3 prescribes.

What is implemented, in the order a study runs:

  • the questionnaires of ISO/TS 12913-2 Annex C as read-only tables: Method A (clause C.3.1, Figures C.2 to C.6), four parts on five-category scales, and the continuous-category scales of Method B (clause C.3.2, Figure C.7), with every question, item and response category as printed, in METHOD_A_SCALES, METHOD_A_ALTERNATIVE_PART_1 and METHOD_B_SCALES; the eight attributes of the perceived affective quality in PERCEIVED_AFFECTIVE_QUALITY_ATTRIBUTES;
  • the scale values of Method A (ISO/TS 12913-3 A.2, Table A.1): parts 1 and 4 run 1 to 5 from the left-hand box to the right-hand one, parts 2 and 3 run 5 to 1, method_a_scale_values; and their median and range per site and item, method_a_summary;
  • the pleasantness and eventfulness coordinates of Formulas (A.1) and (A.2), per respondent and per site, raw and normalised to , with the two-dimensional model of Figure A.1 as the plot, pleasantness_eventfulness;
  • the correlations that link ratings to acoustic data: Spearman’s rank correlation with the untied Formula (A.3) and the tied Formula (A.4), spearman_rank_correlation, and Pearson’s of Formulas (B.1) and (B.2), pearson_correlation, each with its probability value;
  • Method B (Annex B): the scale value of a mark on a continuous-category scale with one decimal, method_b_scale_values; the arithmetic mean, standard deviation and 95 % confidence interval per site, method_b_summary; and the median and range of the rank each recognised sound source was given, method_b_source_ranking;
  • the minimum reporting requirements of ISO/TS 12913-2 Annex A (normative), as a record that checks itself when it is built, SoundscapeReport.

The binaural analysis of ISO/TS 12913-3 Annex D is phonometry.environment.assessment.soundscape_binaural.

This module implements the first edition of ISO/TS 12913-3, published in 2019. ISO has since published ISO/TS 12913-3:2025, which revises Annex A; that edition has not been read for this implementation, so nothing here claims to follow it, and a study that cites the 2025 edition should check Formulas (A.1) and (A.2) against it.

Readings the text leaves to the implementer

Section titled “Readings the text leaves to the implementer”

Which part feeds Formulas (A.1) and (A.2). Clause A.3 says “the results from part 3 (see A.1) are further processed”, but the eight attributes the formulas use are the perceived affective quality, which is part 2 of the questionnaire everywhere else: in Table A.1, in the paragraph of A.2 that assigns its scale values, and in ISO/TS 12913-2 C.3.1.3 and Figure C.4. Part 3 is the single overall rating of Figure C.5, which has no attributes. The formulas are applied to part 2, and the slip is in docs/ERRATA.md.

Per site. A.3 derives “the values on two dimensions (pleasantness and eventfulness) for each site” from the results of the questionnaire, and A.2 makes the median the central tendency of every Method A scale. The site coordinates are therefore Formulas (A.1) and (A.2) applied to the site medians of the eight attributes. When every respondent answered all eight attributes, the formulas being linear, the alternative central_tendency="mean" gives the same point as the mean of the respondents’ own coordinates. A blank answer breaks that equality: each attribute mean is then taken over the respondents who answered that attribute, while a respondent with a blank in a formula has no coordinate of it. The median of the respondents’ coordinates is a third reading, which the per-respondent values let a caller form.

Formula (A.3). The page prints , with a stray factor 1; read as a product it is the usual coefficient for untied ranks, which is what is implemented.

Formulas (B.1) and (B.2). (B.2) divides the covariance by n, so the standard deviations of (B.1) are taken with n as well; with the n - 1 of a sample standard deviation the coefficient would shrink by .

Probability values. A.4 and B.3 ask for the significance of each coefficient and its probability value without naming a test. Both use the Student statistic with degrees of freedom, which is exact for Pearson’s coefficient of bivariate normal data and the usual large-sample approximation for Spearman’s. The 95 % confidence interval of Method B uses the Student distribution with degrees of freedom about the mean, with the sample standard deviation.

The where-lists of Formulas (A.4) and (B.2). The page defines as “the number of in tied ranks” and as “the numbers of tied ranks”; the formula needs the size of the -th group of tied values and the number of such groups, which is what is implemented. Under (B.2) the mean is “of the array ”, for . Both slips are in docs/ERRATA.md.

Auto-generated from the source docstrings by scripts/generate_api_docs.py (make api-docs). Do not edit by hand.

Constant (phonometry.environment.assessment.soundscape.QuestionnaireScale).

method_a_scale_values(
positions: ArrayLike,
*,
part: int,
) -> float | NDArray[np.float64]

The scale value of a ticked box of Method A (ISO/TS 12913-3 Table A.1).

A box is counted from the left-hand end of its scale, 1 to 5, as the questionnaire of ISO/TS 12913-2 prints it. Parts 1 and 4 assign the scale values 1 to 5 from left to right, so the value is the position; parts 2 and 3 assign 5 to 1, so “strongly agree” (part 2) and “very good” (part 3) are 5 and the value is 6 - position.

Parameters

NameDescription
positionsThe position of each ticked box, 1 (left) to 5 (right); NaN for a question left blank.
partThe part of the questionnaire, 1 to 4.

Returns: The scale values, a float for a scalar input; an array is always a new one, never a view of positions.

Raises

ExceptionWhen
ValueErrorfor a part other than 1 to 4 or a position that is not a whole number from 1 to 5.

Constant (mapping).

method_a_summary(
scale_values: Mapping[str, ArrayLike] | ArrayLike,
*,
part: int,
sites: ArrayLike | Sequence[object] | None = None,
) -> MethodASummary

Median and range of the Method A scale values per site and item (ISO/TS 12913-3 A.2, Table A.1).

Parameters

NameDescription
scale_valuesThe scale values of Table A.1, 1 to 5, NaN for a blank answer: a mapping from item name to one value per response; or, for a part with a single scale (3, 4), a 1-D array; or a 2-D array (responses, items) in the order of the part’s figure (part 1: four columns for Figure C.2 or three for Figure C.3; part 2: the eight attributes of Figure C.4). Box positions are converted with method_a_scale_values first.
partThe part of the questionnaire, 1 to 4.
sitesThe site of each response, any labels; None puts every response at one site named "all".

Returns: A MethodASummary.

Raises

ExceptionWhen
ValueErrorfor a part other than 1 to 4, a scale value that is not a whole number from 1 to 5, or sites that do not match the responses.

Constant (int).

METHOD_B_MAXIMUM_SOURCES = 8
method_b_scale_values(
marked_fraction: ArrayLike,
) -> float | NDArray[np.float64]

The scale value of a mark on a Method B scale (ISO/TS 12913-3 B.2).

A continuous-category scale of Figure C.7 runs from its left-hand tick (“not at all”, or “never” on the fourth scale), scale value 1, to its right-hand one (“extremely”, or “very often”), scale value 5, and a mark may fall anywhere along it. Its position is measured with a ruler, or on screen, as a fraction of the distance between the two end ticks, and the value is rounded to one decimal, the resolution B.2 requires (“determined at least with one decimal place”).

Parameters

NameDescription
marked_fractionThe position of each mark from the left-hand tick, 0, to the right-hand one, 1; NaN for a scale left blank.

Returns: The scale values, a float for a scalar input.

Raises

ExceptionWhen
ValueErrorfor a fraction outside 0 to 1 or an infinite one.

Constant (tuple).

METHOD_B_SCALES = (QuestionnaireScale(method='B', part=1, figure='C.7', subject='assessment of the sound environment', question='How loud is it here?', instruction='Mark your impression at any location on the scale below.', items=(), categories=('not at all', 'slightly', 'moderately', 'very', 'extremely'), scale_values=(1, 2, 3, 4, 5), continuous=True), QuestionnaireScale(method='B', part=1, figure='C.7', subject='assessment of the sound environment', question='How unpleasant is it here?', instruction='Mark your impression at any location on the scale below.', items=(), categories=('not at all', 'slightly', 'moderately', 'very', 'extremely'), scale_values=(1, 2, 3, 4, 5), continuous=True), QuestionnaireScale(method='B', part=1, figure='C.7', subject='assessment of the sound environment', question='How appropriate is the sound to the surrounding?', instruction='Mark your impression at any location on the scale below.', items=(), categories=('not at all', 'slightly', 'moderately', 'very', 'extremely'), scale_values=(1, 2, 3, 4, 5), continuous=True), QuestionnaireScale(method='B', part=1, figure='C.7', subject='assessment of the sound environment', question='How often would you like to visit this place again?', instruction='Mark your impression at any location on the scale below.', items=(), categories=('never', 'rarely', 'sometimes', 'often', 'very often'), scale_values=(1, 2, 3, 4, 5), continuous=True))
method_b_source_ranking(
rankings: Sequence[Sequence[str]],
*,
sites: ArrayLike | Sequence[object] | None = None,
) -> SourceRanking

Median and range of the rank of each recognised sound source per site (ISO/TS 12913-3 B.2, ISO/TS 12913-2 C.3.2.4 and Figure C.8).

Parameters

NameDescription
rankingsFor each participant, the sources they listed, the most noticeable first, at most eight and none twice. The names are compared as given, so a study should code them to one vocabulary first (for instance the taxonomy of ISO/TS 12913-2 Figure C.1).
sitesThe site of each participant; None puts every participant at one site named "all".

Returns: A SourceRanking.

Raises

ExceptionWhen
ValueErrorfor a list longer than eight, a source listed twice by one participant, an empty source name, no participants, or sites that do not match the participants.
method_b_summary(
scale_values: Mapping[str, ArrayLike] | ArrayLike,
*,
sites: ArrayLike | Sequence[object] | None = None,
confidence_level: float = 0.95,
) -> MethodBSummary

Mean, standard deviation and confidence interval of Method B ratings per site (ISO/TS 12913-3 B.2, Table B.1).

The confidence interval of the mean is , with the sample standard deviation and the confidence level, 95 % as B.2 asks.

Parameters

NameDescription
scale_valuesThe scale values from 1 to 5, read to one decimal by method_b_scale_values, NaN for a blank: a mapping from scale name to one value per response, a 1-D array for one scale, or a 2-D array (responses, scales) whose three or four columns are the scales of Figure C.7 in their printed order.
sitesThe site of each response; None puts every response at one site named "all".
confidence_levelThe level of the interval, 0.95 by default.

Returns: A MethodBSummary.

Raises

ExceptionWhen
ValueErrorfor a value outside 1 to 5, a confidence level not strictly between 0 and 1, or sites that do not match the responses.
MethodASummary(
part: int,
items: tuple[str, ...],
sites: tuple[str, ...],
medians: NDArray[np.float64],
minima: NDArray[np.float64],
maxima: NDArray[np.float64],
ranges: NDArray[np.float64],
counts: NDArray[np.int64],
)

Median and range of Method A responses per site and item (ISO/TS 12913-3 A.2 and Table A.1).

The level of measurement of every Method A scale is ordinal, so the median is the measure of central tendency and the range, the largest scale value given less the smallest, the measure of dispersion. A blank answer is left out of both; a site where nobody answered an item has NaN there and a count of zero.

Attributes

NameDescription
partThe part of the questionnaire, 1 to 4.
itemsThe items rated (the attributes, the source types), or the subject of the part for a single scale.
sitesThe sites, in the order they first appear in the responses.
mediansMedian scale value, shape (sites, items).
minimaSmallest scale value given, shape (sites, items).
maximaLargest scale value given, shape (sites, items).
rangesmaxima - minima, the measure of dispersion.
countsNumber of answers, shape (sites, items).
MethodASummary.plot(
ax: Axes | None = None,
*,
language: str = 'en',
**kwargs: Any,
) -> Axes

Plot the median of each item per site, with its range as a bar.

Parameters

NameDescription
axExisting axes, or None to create a figure.
languageLabel language, "en" (default) or "es".
kwargsForwarded to the median markers of the first site; the other sites keep their own colour and style.

Returns: The axes. Requires matplotlib (pip install phonometry[plot]).

MethodBSummary(
items: tuple[str, ...],
sites: tuple[str, ...],
means: NDArray[np.float64],
standard_deviations: NDArray[np.float64],
confidence_lower: NDArray[np.float64],
confidence_upper: NDArray[np.float64],
medians: NDArray[np.float64],
counts: NDArray[np.int64],
confidence_level: float,
)

Arithmetic mean, standard deviation and confidence interval of Method B ratings per site and scale (ISO/TS 12913-3 B.2 and Table B.1).

The level of measurement of the continuous-category scales is interval, so B.2 reports the arithmetic mean with its standard deviation and 95 % confidence interval. “Statistics for an ordinal scale level may be additionally applied”, so the median is here too. A blank answer is left out; a site with fewer than two answers to a scale has no standard deviation or interval there (NaN).

Attributes

NameDescription
itemsThe scales (their questions, for Figure C.7).
sitesThe sites, in the order they first appear.
meansArithmetic mean, shape (sites, items).
standard_deviationsSample standard deviation, with n - 1.
confidence_lowerLower end of the confidence interval of the mean.
confidence_upperUpper end of the confidence interval of the mean.
mediansMedian, the ordinal statistic.
countsNumber of answers.
confidence_levelThe level of the interval, 0.95 unless chosen.
MethodBSummary.plot(
ax: Axes | None = None,
*,
language: str = 'en',
**kwargs: Any,
) -> Axes

Plot the mean of each scale per site with its confidence interval.

Parameters

NameDescription
axExisting axes, or None to create a figure.
languageLabel language, "en" (default) or "es".
kwargsForwarded to the mean markers of the first site; the other sites keep their own colour and style.

Returns: The axes. Requires matplotlib (pip install phonometry[plot]).

pearson_correlation(
x: ArrayLike,
y: ArrayLike,
*,
alternative: Literal['two-sided', 'greater', 'less'] = 'two-sided',
) -> SoundscapeCorrelation

Pearson’s correlation coefficient, for interval data (ISO/TS 12913-3 B.3, Formulas (B.1) and (B.2)).

Formula (B.2) divides by n, so the standard deviations are taken with n too, which makes the usual coefficient; with the n - 1 of a sample standard deviation it would shrink by . The probability value is that of the Student statistic with degrees of freedom, exact for bivariate normal data.

Parameters

NameDescription
xThe first variable, for instance the mean Method B rating of each site.
yThe second, for instance an acoustic indicator of each site.
alternativeThe alternative hypothesis: "two-sided" (default), "greater" or "less".

Returns: A SoundscapeCorrelation.

Raises

ExceptionWhen
ValueErrorfor variables of different lengths, fewer than three pairs, a non-finite value or a constant variable.

Constant (tuple).

PERCEIVED_AFFECTIVE_QUALITY_ATTRIBUTES = ('pleasant', 'chaotic', 'vibrant', 'uneventful', 'calm', 'annoying', 'eventful', 'monotonous')
pleasantness_eventfulness(
scale_values: Mapping[str, ArrayLike] | ArrayLike,
*,
sites: ArrayLike | Sequence[object] | None = None,
central_tendency: Literal['median', 'mean'] = 'median',
) -> PleasantnessEventfulness

Pleasantness and eventfulness of a soundscape from its perceived affective quality (ISO/TS 12913-3 A.3, Formulas (A.1) and (A.2)).

The scale values are those of part 2 of Method A, 5 for “strongly agree” down to 1 for “strongly disagree” (Table A.1); method_a_scale_values converts box positions, which run the other way. Every respondent who answered all eight attributes gets a coordinate pair. Each site gets the pair of Formulas (A.1) and (A.2) applied to the site’s median of each attribute (A.2 makes the median the central tendency of the scale), or to its mean with central_tendency="mean". When every respondent answered all eight attributes, that mean point is also the mean of the respondents’ coordinates, the formulas being linear; with blank answers it is not, because each attribute mean is then taken over a different set of respondents.

Clause A.3 says the formulas process “the results from part 3”; the attributes they name are part 2, and that is what they are applied to (see the module docstring and docs/ERRATA.md).

Parameters

NameDescription
scale_valuesThe eight attributes: a mapping from each name of PERCEIVED_AFFECTIVE_QUALITY_ATTRIBUTES to one scale value per respondent, or a 2-D array (respondents, 8) in that order. NaN marks a blank answer. A row may also be a statistic of a group of answers, such as a site’s medians, which is why a value between two boxes is accepted here; anything outside 1 to 5 is not a scale value.
sitesThe site of each respondent, any labels; None puts every respondent at one site named "all".
central_tendency"median" (default) or "mean".

Returns: A PleasantnessEventfulness.

Raises

ExceptionWhen
ValueErrorfor a mapping that does not name the eight attributes, a value outside 1 to 5, or sites that do not match the respondents.

Constant (float).

PLEASANTNESS_EVENTFULNESS_RANGE = 9.65685424949238
PleasantnessEventfulness(
sites: tuple[str, ...],
central_tendency: str,
attribute_values: NDArray[np.float64],
pleasantness: NDArray[np.float64],
eventfulness: NDArray[np.float64],
respondent_sites: tuple[str, ...],
respondent_pleasantness: NDArray[np.float64],
respondent_eventfulness: NDArray[np.float64],
respondent_counts: NDArray[np.int64],
)

Pleasantness and eventfulness of each site and each respondent (ISO/TS 12913-3 A.3, Formulas (A.1) and (A.2)).

on the scale values of the eight attributes of part 2. The coordinates range over ; the normalized_* properties divide by that, for the of A.3.

Attributes

NameDescription
sitesThe sites, in the order they first appear.
central_tendency"median" or "mean", the statistic of each attribute per site that the site coordinates are computed from.
attribute_valuesThat statistic, shape (sites, 8) in the order of PERCEIVED_AFFECTIVE_QUALITY_ATTRIBUTES.
pleasantness of each site.
eventfulness of each site.
respondent_sitesThe site of each respondent.
respondent_pleasantness of each respondent, NaN where one of the six attributes of Formula (A.1) was left blank.
respondent_eventfulness of each respondent, NaN where one of the six attributes of Formula (A.2) was left blank.
respondent_countsRespondents per site who answered all eight.

PleasantnessEventfulness.normalized_eventfulness

Section titled “PleasantnessEventfulness.normalized_eventfulness”

property

of each site, in .

PleasantnessEventfulness.normalized_pleasantness

Section titled “PleasantnessEventfulness.normalized_pleasantness”

property

of each site, in .

PleasantnessEventfulness.plot(
ax: Axes | None = None,
*,
normalized: bool = True,
respondents: bool = False,
language: str = 'en',
**kwargs: Any,
) -> Axes

Plot the sites on the two-dimensional model of Figure A.1.

Pleasantness on the horizontal axis and eventfulness on the vertical one, with the eight attributes at the ends of their axes, the diagonal ones at 45 degrees, and every site a point.

Parameters

NameDescription
axExisting axes, or None to create a figure.
normalizedDraw the coordinates divided by (default), in ; False draws them raw, in .
respondentsAlso draw every respondent, faintly, in the colour of their site.
languageLabel language, "en" (default) or "es".
kwargsForwarded to the site markers.

Returns: The axes. Requires matplotlib (pip install phonometry[plot]).

QuestionnaireScale(
method: str,
part: int,
figure: str,
subject: str,
question: str,
instruction: str,
items: tuple[str, ...],
categories: tuple[str, ...],
scale_values: tuple[int, ...],
continuous: bool,
)

One scale of the soundscape questionnaire, as ISO/TS 12913-2 prints it.

The text is transcribed from the figure, misprints included: the questions of Figures C.2 to C.4 read “To what extend” and their instructions “reponse alternative”, which docs/ERRATA.md records; a study that prints its own questionnaire from this table should correct them.

Attributes

NameDescription
method"A" (clause C.3.1, the questionnaire) or "B" (clause C.3.2, the soundwalk data collection).
partThe part of the questionnaire the scale belongs to.
figureThe figure of ISO/TS 12913-2 Annex C that prints it.
subjectWhat the part assesses, as the heading of its clause and Table A.1 or Table B.1 of ISO/TS 12913-3 name it.
questionThe question, as printed.
instructionThe instruction line under the question, as printed; empty where the figure has none.
itemsThe rows rated on the same categories (the sound source types of part 1, the eight attributes of part 2); empty for a scale that rates the environment as a whole.
categoriesThe response categories from the left-hand box to the right-hand one, as printed; for a continuous-category scale of Method B, the labels of its five ticks.
scale_valuesThe scale value of each category, in the same order: ISO/TS 12913-3 Table A.1 for Method A, Table B.1 for Method B.
continuousWhether a mark may fall anywhere along the scale (Method B) rather than in one of the boxes (Method A).
SoundscapeAcousticEnvironment(
environment_type: str,
sound_sources: str,
weather_and_wind: str,
time_of_year_and_day: str,
measurement_points: str,
measurement_results: Mapping[str, float],
site_description: str | None = None,
recording_and_reproduction: str | None = None,
)

The studied acoustic environment (ISO/TS 12913-2 A.3 a) to h)).

Attributes

NameDescription
environment_typeA.3 a), "real", "recorded" or "virtual".
sound_sourcesA.3 b), the sound sources and the composition of the acoustic environment, including the total sound, the background and the foreground sounds.
weather_and_windA.3 c).
time_of_year_and_dayA.3 d).
measurement_pointsA.3 e), the measurement points, including the height and orientation of the binaural measurement system, and what acoustic measurements were taken.
measurement_resultsA.3 f), the results of the measurements, keyed by the symbols A.3 f) prints: "LAeq,T", "LCeq,T", "LAF5,T", "LAF95,T" (dB), "N5", "N95" and "Nrmc" (sone), all seven required, others allowed. BinauralIndicators.reporting_results builds it from a binaural analysis.
site_descriptionA.3 g), required for a field study or a study based on audio recordings ("real" or "recorded"): the study site, including its type.
recording_and_reproductionA.3 h), required for a recorded or virtual environment: how it was recorded or created and how it was reproduced.
SoundscapeCorrelation(
method: str,
formula: str,
coefficient: float,
p_value: float,
t_statistic: float,
degrees_of_freedom: int,
alternative: str,
x: NDArray[np.float64],
y: NDArray[np.float64],
x_ranks: NDArray[np.float64] | None = None,
y_ranks: NDArray[np.float64] | None = None,
)

A correlation coefficient between two variables and its probability value (ISO/TS 12913-3 A.4 and B.3).

Attributes

NameDescription
method"spearman" (ordinal data, A.4) or "pearson" (interval data, B.3).
formulaThe formula that gave the coefficient: "(A.3)" for untied ranks, "(A.4)" for tied ranks, "(B.1)" for Pearson.
coefficientThe correlation coefficient, in [-1, 1].
p_valueProbability, under the null hypothesis of no correlation, of a coefficient at least as extreme as this one in the direction alternative names (either sign for "two-sided").
t_statisticThe Student statistic the probability value comes from, ; infinite for .
degrees_of_freedom.
alternative"two-sided", "greater" or "less".
xThe first variable, as given (a copy, read-only).
yThe second variable, as given (a copy, read-only).
x_ranksThe ranks of x (average ranks for ties); None for Pearson.
y_ranksThe ranks of y; None for Pearson.

property

Number of cases, the pairs the coefficient was computed from.

SoundscapeCorrelation.plot(
ax: Axes | None = None,
*,
language: str = 'en',
**kwargs: Any,
) -> Axes

Plot the pairs, as ranks for Spearman, with the coefficient.

Parameters

NameDescription
axExisting axes, or None to create a figure.
languageLabel language, "en" (default) or "es".
kwargsForwarded to the scatter markers.

Returns: The axes. Requires matplotlib (pip install phonometry[plot]).

SoundscapeDataCollection(
methods: str,
questions: str,
language: str,
instrument_copy: str,
rating_scale_construction: str | None = None,
behaviour_observation: str | None = None,
)

How the perception data were collected (ISO/TS 12913-2 A.4 a) to e)).

Attributes

NameDescription
methodsA.4 a), the methods used.
questionsA.4 b), the questions asked, how they were formulated and how the responses were documented.
languageA.4 d), the language of the study, with examples of the questions in the original language and in translation.
instrument_copyWhere the copy of the data collection instrument (the questionnaire or the scales) that A.4 requires the report to include is found.
rating_scale_constructionA.4 c), for a study based on rating scales: how the questions, the response alternatives and the response format were constructed and formulated; None for a study without.
behaviour_observationA.4 e), for observations of behaviour: how they were conducted and documented; None for a study without.
SoundscapeParticipants(
selection: str,
residents_or_visitors: str,
lay_or_expert: str,
age_and_gender_distribution: str,
other_relevant_information: str,
)

The participants of a soundscape study (ISO/TS 12913-2 A.2 a) to e)).

Every field is required: “the participants shall be identified and the following information recorded”. Each is free text, because the annex prescribes what is stated and not how.

Attributes

NameDescription
selectionA.2 a), how the participants were selected.
residents_or_visitorsA.2 b), whether they were residents at or visitors to the study site.
lay_or_expertA.2 c), whether they were lay people or experts in a field relevant to the study.
age_and_gender_distributionA.2 d).
other_relevant_informationA.2 e), for example hearing ability; state “none” if there is nothing to add.
SoundscapeReport(
participants: SoundscapeParticipants,
acoustic_environment: SoundscapeAcousticEnvironment,
data_collection: SoundscapeDataCollection,
)

The minimum reporting requirements of a soundscape study (ISO/TS 12913-2 Annex A, normative, and clause 6).

A.1 lists three things a report shall comprise, and each is one record: the selection and classification of the participants (A.2), the characterization of the studied acoustic environment (A.3), and the data collection on how people perceived it (A.4). Each record refuses to be built with a required item missing, so a SoundscapeReport that exists meets the minimum of Annex A as far as a record can tell; whether what is written is true and sufficient stays with the author.

Attributes

NameDescription
participantsA.1 a), A.2.
acoustic_environmentA.1 b), A.3.
data_collectionA.1 c), A.4.
SourceRanking(
sources: tuple[str, ...],
sites: tuple[str, ...],
median_ranks: NDArray[np.float64],
lowest_ranks: NDArray[np.float64],
highest_ranks: NDArray[np.float64],
rank_ranges: NDArray[np.float64],
mentions: NDArray[np.int64],
participants: NDArray[np.int64],
)

The rank each recognised sound source was given, per site (ISO/TS 12913-3 B.2, part 2 of Method B, Table B.1).

Every participant lists the sources they noticed from the most noticeable down, at most eight, so a source listed first has rank 1. The level of measurement is ordinal: the median rank is the central tendency and the range the dispersion. Sources are ordered by their median rank over all sites, then by how often they were listed.

Attributes

NameDescription
sourcesEvery source listed at any site.
sitesThe sites, in the order they first appear.
median_ranksMedian rank, shape (sites, sources); NaN where nobody at the site listed the source.
lowest_ranksThe best rank the source was given, same shape.
highest_ranksThe worst rank it was given, same shape.
rank_rangeshighest_ranks - lowest_ranks, the dispersion.
mentionsHow many participants listed the source, same shape.
participantsParticipants per site.
SourceRanking.plot(
ax: Axes | None = None,
*,
language: str = 'en',
**kwargs: Any,
) -> Axes

Plot the median rank of each source per site, with its range.

Parameters

NameDescription
axExisting axes, or None to create a figure.
languageLabel language, "en" (default) or "es".
kwargsForwarded to the bars of the first site; the other sites keep their own colour and style.

Returns: The axes. Requires matplotlib (pip install phonometry[plot]).

spearman_rank_correlation(
x: ArrayLike,
y: ArrayLike,
*,
alternative: Literal['two-sided', 'greater', 'less'] = 'two-sided',
) -> SoundscapeCorrelation

Spearman’s rank correlation coefficient, for ordinal data (ISO/TS 12913-3 A.4, Formulas (A.3) and (A.4)).

Each variable is ranked, tied values sharing the mean of the ranks they span, and is the difference of the ranks of pair . Without ties Formula (A.3) applies,

and with ties in either variable Formula (A.4),

where is the number of values in the -th group of tied ranks of x and U is the same sum over y. (The page’s where-list garbles these definitions, see docs/ERRATA.md; this is the reading the formula needs.) Formula (A.4) is Pearson’s coefficient of the average ranks, and reduces to (A.3) when nothing is tied.

The probability value is that of the Student statistic with degrees of freedom, the usual approximation for Spearman’s coefficient, which A.4 asks to be reported without naming a test.

Parameters

NameDescription
xThe first variable, for instance the median rating of each site.
yThe second, for instance an acoustic indicator of each site.
alternativeThe alternative hypothesis: "two-sided" (default), "greater" (positive correlation) or "less".

Returns: A SoundscapeCorrelation.

Raises

ExceptionWhen
ValueErrorfor variables of different lengths, fewer than three pairs, a non-finite value or a constant variable.