Calculate the pure tone attenuation of sound in air according to
ISO 9613-1.
Calculation is in accordance with ISO 9613-1 [8]. The shape of the
outputs is broadcasted from the shapes of the temperature,
relative_humidity, and atmospheric_pressure.
The frequency bins represents the last dimension.
Parameters:
temperature (float, array_like) – Temperature in °C.
Must be in the range of -20 °C to 50 °C for accuracy of +/-10% or
must be greater than -70 °C for accuracy of +/-50%.
frequencies (float, array_like) – Frequency in Hz. Must be greater than 50 Hz.
Just one dimensional array is allowed.
relative_humidity (float, array_like) – Relative humidity in the range from 0 to 1.
atmospheric_pressure (float, array_like, optional) – Atmospheric pressure in Pascal, by default
reference_atmospheric_pressure.
Returns:
alpha (np.ndarray[float]) – Pure tone air attenuation coefficient in dB/m for atmospheric
absorption.
m (FrequencyData) – Pure tone energy attenuation coefficient in 1/m for atmospheric
absorption. The parameter m is calculated as
\(m = \alpha / (10 \log_{10}(e))\).
accuracy (FrequencyData) – accuracy of the results according to the standard:
10, +/- 10% accuracy
molar concentration of water vapour: 0.05% to 5%.
air temperature: 253.15 K to 323.15 K (-20 °C to +50 °C)
atmospheric pressure: less than 200 000 Pa (2 atm)
frequency-to-pressure ratio: 0.0004 Hz/Pa to 10 Hz/Pa.
20, +/- 20% accuracy
molar concentration of water vapour: 0.005% to 0.05%,
and greater than 5%
air temperature: 253.15 K to 323.15 K (-20 °C to +50 °C)
atmospheric pressure: less than 200 000 Pa (2 atm)
frequency-to-pressure ratio: 0.0004 Hz/Pa to 10 Hz/Pa.
50, +/- 50% accuracy
molar concentration of water vapour: less than 0.005%
air temperature: greater than 200 K (- 73 °C)
atmospheric pressure: less than 200 000 Pa (2 atm)
frequency-to-pressure ratio: 0.0004 Hz/Pa to 10 Hz/Pa.
Calculate the density of air in kg/m³ based on the temperature,
relative humidity, and atmospheric pressure.
The density of air is calculated based on chapter 6.3 in [9].
All input parameters must be broadcastable to the same shape.
Parameters:
temperature (float, array_like) – Temperature in degrees Celsius (°C).
relative_humidity (float, array_like) – Relative humidity in the range from 0 to 1.
atmospheric_pressure (float, array_like, optional) – Atmospheric pressure in Pascal (Pa), by default
reference_atmospheric_pressure.
saturation_vapor_pressure (float, array_like, optional) – Saturation vapor pressure in Pascal (Pa).
The default uses the value and valid temperature range from
saturation_vapor_pressure_magnus.
Calculate the tolerance limits for fractional octave band filters.
Calculation is in accordance with IEC 61260-1:2014 [10] (Section 5.10 and
Table 1).
Note
The standard defines some lower tolerance limits as \(-\infty\),
which is inconvenient for plotting. The returned tolerance is -60000 dB
in these cases, which is below the smallest possible value of
20*np.log10(np.finfo(float).tiny\(\approx\)-6000 dB.
Parameters:
exact_center_frequency (float) – The exact center frequency of the band filter in Hz (see
fractional_octave_frequencies).
num_fractions (Literal[1, 3]) – The number of bands an octave is divided into. 1 for octave bands
and 3 for third octave bands.
tolerance_class (Literal[1, 2]) – The tolerance class as defined in the standard. Must be 1 or 2.
Returns:
lower_tolerance (numpy array) – Lower tolerance limits in dB of shape (19, ).
upper_tolerance (numpy array) – Upper tolerance limits in dB of shape (19, ).
frequencies (numpy array) – The frequencies in Hz at which the tolerance is given of shape (19, ).
References
Examples
Class 1 tolerance region and filter for the 1000 Hz octave band.
\(f_r\) is the reference frequency, set to 1000 Hz.
\(x\) is the index of the frequency band.
Parameters:
num_fractions (int, optional) – The number of bands an octave is divided into. E.g., 1 refers to
octave bands and 3 to third octave bands. The default is 1.
All positive integers are allowed.
frequency_range (array, tuple) – The lower and upper frequency limits, the default is
(20,20e3).
Returns:
center_frequencies (numpy.ndarray) – The exact center frequencies in Hz of the bandpass filters
for each fractional octave band.
lower_cutoff_frequencies (numpy.ndarray) – The lower cutoff frequencies in Hz of the bandpass filters
for each fractional octave band.
upper_cutoff_frequencies (numpy.ndarray) – The upper cutoff frequencies in Hz of the bandpass filters
for each fractional octave band.
References
Notes
The specified frequency_range is interpreted as frequencies lying
within (fractional) octave bands defined by their cutoff frequencies
(not their center frequencies). All bands that overlap with the
specified frequency range are returned.
Return the nominal center frequencies for octave-band and
one-third-octave-band filters.
Nominal center frequencies, as specified in the IEC 61260-1:2014 standard
[12] (Section 5.5 and Annex E), are standardized values that approximate
the exact center frequencies. They are defined from 10 Hz to 20 kHz.
Parameters:
num_fractions ({1, 3}) – The number of octave fractions. 1 returns octave center
frequencies, 3 returns third-octave center frequencies.
The default is 1.
frequency_range (array, tuple) – The lower and upper frequency limits, the default is
(20,20e3) following IEC 61260-1.
E.g. (10,20e3) would follow IEC 61672-1 [13].
The specified frequency_range is interpreted as frequencies lying
within (fractional) octave bands defined by their cutoff frequencies
(not their center frequencies). All bands that overlap with the
specified frequency range are returned.
Returns the A or C frequency weighting correction values for
octave or third-octave bands in a given frequency range.
This function uses the nominal frequencies and their respective
weights as given in the IEC 62672-1 standard [14].
Parameters:
weighting (str ('A' or 'C')) – Which frequency weighting type to use.
num_fractions ({1, 3}) – The number of octave fractions. 1 returns octave band
corrections, 3 returns third-octave band corrections.
frequency_range ((float, float)) – A range of what nominal center frequencies to include. The lowest
defined center frequency is 10 Hz and the highest is 20 kHz.
Returns:
nominal_frequencies (numpy.ndarray[float]) – The nominal center frequencies included in the given range.
weights (numpy.ndarray[float]) – The correction values in dB for the specific frequency weighting.
References
Examples
Plot the band correction levels.
>>> importpyfaraspf>>> importmatplotlib.pyplotasplt>>> f_range=(10,20000)>>> nominals_third,weights_A=pf.constants.frequency_weighting_band_corrections(... "A",3,f_range)>>> nominals_octave,weights_C=pf.constants.frequency_weighting_band_corrections(... "C",1,f_range)>>> # plotting>>> plt.plot(nominals_third,weights_A,"--",c=(0.5,0.5,0.5,0.5))>>> plt.plot(nominals_third,weights_A,"bo",label="A weighting in third bands")>>> plt.plot(nominals_octave,weights_C,"--",c=(0.5,0.5,0.5,0.5))>>> plt.plot(nominals_octave,weights_C,"go",label="C weighting in octave bands")>>> plt.legend()>>> ticks=nominals_octave[::2].astype(int)>>> plt.semilogx()>>> plt.xticks(ticks,ticks)>>> plt.xlabel("f in Hz")>>> plt.ylabel("Corrections in dB")>>> plt.grid()
temperature (float, array_like) – Temperature in degree Celsius from 0°C to 30°C.
relative_humidity (float, array_like) – Relative humidity in the range of 0 to 1.
co2_ppm (float, array_like, optional) – CO2 concentration in parts per million. The default is
425.19 ppm, based on [18]. Value must be below
10 000 ppm (1%).
atmospheric_pressure (float, array_like, optional) – Atmospheric pressure in Pascal, by default
reference_atmospheric_pressure.
Value must be between 75 000 Pa to 102000 Pa.
Calculate speed of sound in air using the ideal gas law.
The speed of sound in air can be calculated based on chapter 6.3 in [19].
All input parameters must be broadcastable to the same shape.
Parameters:
temperature (float, array_like) – Temperature in degree Celsius.
relative_humidity (float, array_like) – Relative humidity in the range of 0 to 1.
atmospheric_pressure (float, array_like, optional) – Atmospheric pressure in Pascal, by default
reference_atmospheric_pressure.
saturation_vapor_pressure (float, array_like, optional) – Saturation vapor pressure in Pascal.
If not given, the function
saturation_vapor_pressure_magnus is used.
Note that the valid temperature range therefore also depends on
saturation_vapor_pressure_magnus.