def test_interval(self): emin = 1.0 emax = 4.0 f = np.logspace(emin, emax, 50) o = Octave(interval=f) self.assertEqual(o.fmin, 10.0**emin) self.assertEqual(o.fmax, 10.0**emax) self.assertEqual(len(o.n), len(o.center)) o.unique = True self.assertEqual(len(o.n), len(f))
def test_interval(self): emin = 1.0 emax = 4.0 f = np.logspace(emin, emax, 50) o = Octave(interval=f) assert (o.fmin == 10.0**emin) assert (o.fmax == 10.0**emax) assert (len(o.n) == len(o.center)) o.unique = True assert (len(o.n) == len(f))
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)