This repository was archived by the owner on Feb 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathexample_octave.py
More file actions
52 lines (38 loc) · 1.41 KB
/
Copy pathexample_octave.py
File metadata and controls
52 lines (38 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
An example of how to use :class:`acoustics.octave.Octave`.
"""
from acoustics.octave import Octave
import numpy as np
def main():
"""We happen to have the following frequency vector."""
f = np.logspace(2, 4, 100)
"""And we want to get some 1/3-octave results, so we set octave to 3."""
o = Octave(interval=f, fraction=3)
"""We can now print the center frequencies of the 1/3 octave bands belonging
to this frequency vector."""
print(o.center)
"""
Since by default ``unique=True`` in :class:`Auraliser.Octave.Octave` we get
a value for every value in ``interval``. If we only want to obtain unique
values, it is fastest to set ``unique=True`. This could be done during
initialization but also now.
"""
o.unique = True
"""Now we should only get the unique center frequencies."""
print(o.center)
"""We can also calculate the bandwidth of each band."""
print(o.bandwidth)
"""As well as the lower limits of the frequency limits..."""
print(o.lower)
"""...and the upper frequency limits."""
print(o.upper)
"""
So far we used a frequency interval. Sometimes you have a lower frequency
and an upper frequency.
Instead of requiring to generate a frequency vector you can just give these
boundary values as well.
"""
o = Octave(fmin=100.0, fmax=20000, fraction=6)
print(o.center)
if __name__ == '__main__':
main()