Package topo :: Package pattern :: Module basic :: Class PowerSpectrum
[hide private]
[frames] | no frames]

Class PowerSpectrum

source code


Outputs the spectral density of a rolling window of the input signal each time it is called. Over time, the results could be arranged into a spectrogram, e.g. for an audio signal.
Nested Classes [hide private]

Inherited from param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
__init__(self, signal, **params)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_initialize_window_parameters(parameterized_instance, *args, **kw) source code
 
_create_spacing(self, mini, maxi)
Overload if custom frequency spacing is required.
source code
 
_create_indices(self, p) source code
 
_extract_sample_window(self, p)
Overload if special behaviour is required when a signal ends.
source code
 
_get_amplitudes(self, p)
Perform a real Discrete Fourier Transform (DFT; implemented using a Fast Fourier Transform algorithm, FFT) of the current sample from the signal multiplied by the smoothing window.
source code
 
__call__(self, **params_to_override)
Call the subclass's 'function' method on a rotated and scaled coordinate system.
source code

Inherited from base.patterngenerator.PatternGenerator: function

Inherited from param.parameterized.Parameterized: __getstate__, __repr__, __setstate__, __str__, debug, defaults, force_new_dynamic_value, get_param_values, get_value_generator, inspect_value, message, print_param_values, script_repr, set_default, set_dynamic_time_fn, set_param, state_pop, state_push, verbose, warning

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from param.parameterized.Parameterized: params, print_param_defaults

Class Variables [hide private]
  __abstract = True
bool(x) -> bool
  window_increment = param.Number(default= 1, constant= True, do...
The most recent portion of the signal on which to perform the Fourier transform, in units of 1/sample_rate, i.e., the length of a sliding window on which to operate.
  window_length = param.Number(default= 0.0001, constant= True, ...
The amount of overlap between each window, in units of 1/sample_rate.
  sample_rate = param.Number(default= 44100, constant= True, doc...
Number of samples per second, which defines the range for frequency.
  windowing_function = param.Parameter(default= rectangular, con...
This function is multiplied with the current window, i.e.
  min_frequency = param.Number(default= 1, doc= ...
Smallest frequency for which to return an amplitude.
  max_frequency = param.Number(default= 20000, doc= ...
Largest frequency for which to return an amplitude.
  name = <param.parameterized.String object at 0xb20d9ec>
String identifier for this object.

Inherited from base.patterngenerator.PatternGenerator: bounds, mask, mask_shape, offset, orientation, output_fns, position, scale, size, x, xdensity, y, ydensity

Inherited from param.parameterized.Parameterized: print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, signal, **params)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

_initialize_window_parameters(parameterized_instance, *args, **kw)

source code 
Decorators:
  • @as_uninitialized

_get_amplitudes(self, p)

source code 

Perform a real Discrete Fourier Transform (DFT; implemented using a Fast Fourier Transform algorithm, FFT) of the current sample from the signal multiplied by the smoothing window.

See numpy.rfft for information about the Fourier transform.

__call__(self, **params_to_override)
(Call operator)

source code 

Call the subclass's 'function' method on a rotated and scaled coordinate system.

Creates and fills an array with the requested pattern. If called without any params, uses the values for the Parameters as currently set on the object. Otherwise, any params specified override those currently set on the object.

Overrides: base.patterngenerator.PatternGenerator.__call__
(inherited documentation)

Class Variable Details [hide private]

__abstract

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

Value:
True

window_increment

The most recent portion of the signal on which to perform the Fourier transform, in units of 1/sample_rate, i.e., the length of a sliding window on which to operate.

Note that the Fourier transform algorithm is most efficient for matrix sizes that are powers of 2, or that can be decomposed into small prime factors; see numpy.fft.rfft.

Value:
param.Number(default= 1, constant= True, doc= """
        The most recent portion of the signal on which to perform the Fourier
        transform, in units of 1/sample_rate, i.e., the length of a
        sliding window on which to operate.

        Note that the Fourier transform algorithm is most efficient
        for matrix sizes that are powers of 2, or that can be
        decomposed into small prime factors; see numpy.fft.rfft.""")

window_length

The amount of overlap between each window, in units of 1/sample_rate.
Value:
param.Number(default= 0.0001, constant= True, doc= """
        The amount of overlap between each window, in units of 1/sample_rate.""")

sample_rate

Number of samples per second, which defines the range for frequency.
Value:
param.Number(default= 44100, constant= True, doc= """
        Number of samples per second, which defines the range for frequency.""")

windowing_function

This function is multiplied with the current window, i.e. the most recent portion of the waveform interval of a signal, before performing the Fourier transform. It thus shapes the interval, which would otherwise always be rectangular.

The function chosen here dictates the tradeoff between resolving comparable signal strengths with similar frequencies, and resolving disparate signal strengths with dissimilar frequencies.

numpy provides a number of options, e.g. bartlett, blackman, hamming, hanning, kaiser; see http://docs.scipy.org/doc/numpy/reference/routines.window.html You can also supply your own.

Value:
param.Parameter(default= rectangular, constant= True, doc= """
        This function is multiplied with the current window, i.e. the
        most recent portion of the waveform interval of a signal, before
        performing the Fourier transform.  It thus shapes the
        interval, which would otherwise always be rectangular.

        The function chosen here dictates the tradeoff between
        resolving comparable signal strengths with similar
...

min_frequency

Smallest frequency for which to return an amplitude.
Value:
param.Number(default= 1, doc= """
        Smallest frequency for which to return an amplitude.""")

max_frequency

Largest frequency for which to return an amplitude.
Value:
param.Number(default= 20000, doc= """
        Largest frequency for which to return an amplitude.""")