acoupipe.datasets.features#

Module Contents#

class acoupipe.datasets.features.PowerSpectraAnalytic#

Bases: acoular.PowerSpectraImport

Provides a dummy class for using pre-calculated CSMs.

This class does not calculate the CSM. Instead, the user can inject one or multiple existing CSMs by setting the csm attribute. This can be useful when algorithms shall be evaluated with existing CSMs. The frequency or frequencies contained by the CSM must be set via the frequencies attribute. The attr:num_channels attributes is determined on the basis of the CSM shape. In contrast to the PowerSpectra object, the attributes sample_freq, source, block_size, window, overlap, cached, and num_blocks have no functionality.

fftfreq()#

Return the Discrete Fourier Transform sample frequencies.

Returns:
fndarray

Array of length block_size/2+1 containing the sample frequencies.

acoupipe.datasets.features.get_frequency_index_range(freq, f, num)#

Return the left and right indices that define the frequency range to integrate over.

Parameters:
freqnumpy.array

frequency vector (can be determined by evaluating freqdata() method at a acoular.PowerSpectra instance)

ffloat

the frequency (or center frequency) of interest

numint

the frequency band (0: single frequency line, 1: octave band, 3: third octave band)

Returns:
tuple

left and right index that belongs to the frequency of interest

acoupipe.datasets.features.get_point_sources_recursively(source)#

Recursively get all point sources from a acoular.TimeInOut object.

Parameters:
sourceinstance of class acoular.TimeInOut

the source object

Returns:
list

list of all sources

acoupipe.datasets.features.get_uncorrelated_noise_source_recursively(source)#

Recursively get all uncorrelated noise sources from a acoular.TimeInOut object.

Parameters:
sourceinstance of class acoular.TimeInOut

the source object

Returns:
list

list of all uncorrelated noise sources

class acoupipe.datasets.features.BaseFeatureCatalog#

Bases: traits.api.HasPrivateTraits

BaseFeatureCatalog base class for handling feature funcs.

Attributes:
namestr

Name of the feature.

dtypecallable

Numpy dtype of the feature.

get_feature_func()#

Will return a method depending on the class parameters.

class acoupipe.datasets.features.TimeDataFeature#

Bases: BaseFeatureCatalog

TimeDataFeature class for handling time data.

Attributes:
namestr

Name of the feature (default=’time_data’).

time_datainstance of class acoular.SamplesGenerator

The source delivering the time data.

get_feature_func()#

Return the callable for calculating the time data.

class acoupipe.datasets.features.TargetmapFeature#

Bases: BaseFeatureCatalog

BaseFeatureCatalog base class for handling feature funcs.

Attributes:
namestr

Name of the feature.

dtypecallable

Numpy dtype of the feature.

get_feature_func()#

Will return a method depending on the class parameters.

class acoupipe.datasets.features.SourcemapFeature#

Bases: BaseFeatureCatalog

Handle the generation of sourcemaps obtained with microphone array methods.

Attributes:
namestr

Name of the feature (default=’sourcemap’).

beamformerinstance of class acoular.BeamformerBase

The beamformer to calculate the sourcemap.

ffloat

The center frequency or list of frequencies of the dataset. If None, all frequencies are included.

numinteger

Controls the width of the frequency bands considered; defaults to 0 (single frequency line).

num

frequency band width

0

single frequency line

1

octave band

3

third-octave band

n

1/n-octave band

fidxlist of tuples

List of tuples containing the start and end indices of the frequency bands to be considered. Is determined automatically from attr:f and attr:num.

set_freq_limits()#

Set the beamformer frequency limits to calculate only the necessary frequencies.

get_feature_func()#

Return the callable for calculating the sourcemap.

class acoupipe.datasets.features.SpectraFeature#

Bases: BaseFeatureCatalog

Handles the calculation of features in the frequency domain.

Attributes:
namestr

Name of the feature.

freq_datainstance of class acoular.BaseSpectra

The frequency data to calculate the feature for.

ffloat

the frequency (or center frequency) of interest

numint

the frequency band (0: single frequency line, 1: octave band, 3: third octave band)

fidxlist of tuples

List of tuples containing the start and end indices of the frequency bands to be considered.

set_freq_limits()#

Set the beamformer frequency limits to calculate only the necessary frequencies.

class acoupipe.datasets.features.SpectrogramFeature#

Bases: SpectraFeature

SpectrogramFeature class for handling spectrogram features.

Attributes:
namestr

Name of the feature (default=’spectrogram’).

freq_datainstance of class acoular.RFFT

The object which calculates the spectrogram data.

ffloat

the frequency (or center frequency) of interest

numint

the frequency band (0: single frequency line, 1: octave band, 3: third octave band)

fidxlist of tuples

List of tuples containing the start and end indices of the frequency bands to be considered.

get_feature_func()#

Will return a method depending on the class parameters.

class acoupipe.datasets.features.CSMFeature#

Bases: SpectraFeature

CSMFeature class for handling cross-spectral matrix calculation.

Attributes:
namestr

Name of the feature (default=’csm’).

freq_datainstance of class acoular.PowerSpectra

The object which calculates the cross-spectral matrix.

ffloat

the frequency (or center frequency) of interest

numint

the frequency band (0: single frequency line, 1: octave band, 3: third octave band)

fidxlist of tuples

List of tuples containing the start and end indices of the frequency bands to be considered.

static calc_csm1(sampler, freq_data, name)#

Calculate the cross-spectral matrix (CSM) from time data.

Parameters:
freq_datainstance of class acoular.PowerSpectra

power spectra to calculate the csm feature

Returns:
numpy.array

The complex-valued cross-spectral matrix with shape (numfreq, num_mics, num_mics).

static calc_csm2(sampler, freq_data, fidx, name)#

Calculate the cross-spectral matrix (CSM) from time data.

Parameters:
freq_datainstance of class acoular.PowerSpectra

power spectra to calculate the csm feature

fidxlist of tuples, optional

list of tuples containing the start and end indices of the frequency bands to be considered, by default None

Returns:
numpy.array

The complex-valued cross-spectral matrix with shape (numfreq, num_mics, num_mics) with numfreq depending on the number of frequencies in fidx.

get_feature_func()#

Return the callable for calculating the cross-spectral matrix.

class acoupipe.datasets.features.CSMtriuFeature#

Bases: SpectraFeature

Handles the calculation of features in the frequency domain.

Attributes:
namestr

Name of the feature.

freq_datainstance of class acoular.BaseSpectra

The frequency data to calculate the feature for.

ffloat

the frequency (or center frequency) of interest

numint

the frequency band (0: single frequency line, 1: octave band, 3: third octave band)

fidxlist of tuples

List of tuples containing the start and end indices of the frequency bands to be considered.

static calc_csmtriu1(sampler, freq_data, name)#

Calculate the cross-spectral matrix (CSM) from time data.

Parameters:
freq_datainstance of class acoular.PowerSpectra

power spectra to calculate the csm feature

Returns:
numpy.array

The real-valued cross-spectral matrix with shape (numfreq, num_mics, num_mics).

static calc_csmtriu2(sampler, freq_data, fidx, name)#

Calculate the cross-spectral matrix (CSM) from time data.

Parameters:
freq_datainstance of class acoular.PowerSpectra

power spectra to calculate the csm feature

fidxlist of tuples, optional

list of tuples containing the start and end indices of the frequency bands to be considered, by default None

Returns:
numpy.array

The real-valued cross-spectral matrix with shape (numfreq, num_mics, num_mics) with numfreq depending on the number of frequencies in fidx.

get_feature_func()#

Will return a method depending on the class parameters.

class acoupipe.datasets.features.EigmodeFeature#

Bases: SpectraFeature

Handles the calculation of features in the frequency domain.

Attributes:
namestr

Name of the feature.

freq_datainstance of class acoular.BaseSpectra

The frequency data to calculate the feature for.

ffloat

the frequency (or center frequency) of interest

numint

the frequency band (0: single frequency line, 1: octave band, 3: third octave band)

fidxlist of tuples

List of tuples containing the start and end indices of the frequency bands to be considered.

static calc_eigmode1(sampler, freq_data, name)#

Calculate eigenvalue-scaled eigenvectors of the CSM from time data.

Parameters:
freq_datainstance of class acoular.PowerSpectra

power spectra to calculate the csm feature

Returns:
numpy.array

The eigenvalue scaled eigenvectors with shape (numfreq, num_mics, num_mics).

static calc_eigmode2(sampler, freq_data, fidx, name)#

Calculate eigenvalue-scaled eigenvectors of the CSM from time data.

Parameters:
freq_datainstance of class acoular.PowerSpectra

power spectra to calculate the csm feature

fidxlist of tuples, optional

list of tuples containing the start and end indices of the frequency bands to be considered, by default None

Returns:
numpy.array

The eigenvalue scaled eigenvectors with shape (numfreq, num_mics, num_mics) with numfreq depending on the number of frequencies in fidx.

get_feature_func()#

Will return a method depending on the class parameters.

class acoupipe.datasets.features.LocFeature#

Bases: BaseFeatureCatalog

BaseFeatureCatalog base class for handling feature funcs.

Attributes:
namestr

Name of the feature.

dtypecallable

Numpy dtype of the feature.

get_feature_func()#

Will return a method depending on the class parameters.

class acoupipe.datasets.features.AnalyticSourceStrengthFeature#

Bases: SpectraFeature

Handles the calculation of features in the frequency domain.

Attributes:
namestr

Name of the feature.

freq_datainstance of class acoular.BaseSpectra

The frequency data to calculate the feature for.

ffloat

the frequency (or center frequency) of interest

numint

the frequency band (0: single frequency line, 1: octave band, 3: third octave band)

fidxlist of tuples

List of tuples containing the start and end indices of the frequency bands to be considered.

get_feature_func()#

Will return a method depending on the class parameters.

class acoupipe.datasets.features.EstimatedSourceStrengthFeature#

Bases: SpectraFeature

Handles the calculation of features in the frequency domain.

Attributes:
namestr

Name of the feature.

freq_datainstance of class acoular.BaseSpectra

The frequency data to calculate the feature for.

ffloat

the frequency (or center frequency) of interest

numint

the frequency band (0: single frequency line, 1: octave band, 3: third octave band)

fidxlist of tuples

List of tuples containing the start and end indices of the frequency bands to be considered.

get_feature_func()#

Will return a method depending on the class parameters.

class acoupipe.datasets.features.AnalyticNoiseStrengthFeature#

Bases: SpectraFeature

Handles the calculation of features in the frequency domain.

Attributes:
namestr

Name of the feature.

freq_datainstance of class acoular.BaseSpectra

The frequency data to calculate the feature for.

ffloat

the frequency (or center frequency) of interest

numint

the frequency band (0: single frequency line, 1: octave band, 3: third octave band)

fidxlist of tuples

List of tuples containing the start and end indices of the frequency bands to be considered.

get_feature_func()#

Will return a method depending on the class parameters.

class acoupipe.datasets.features.EstimatedNoiseStrengthFeature#

Bases: SpectraFeature

Handles the calculation of features in the frequency domain.

Attributes:
namestr

Name of the feature.

freq_datainstance of class acoular.BaseSpectra

The frequency data to calculate the feature for.

ffloat

the frequency (or center frequency) of interest

numint

the frequency band (0: single frequency line, 1: octave band, 3: third octave band)

fidxlist of tuples

List of tuples containing the start and end indices of the frequency bands to be considered.

get_feature_func()#

Will return a method depending on the class parameters.

class acoupipe.datasets.features.BaseFeatureCollection#

Bases: traits.api.HasPrivateTraits

BaseFeatureCollection base class for handling feature funcs.

Attributes:
feature_funcslist

List of feature_funcs.

add_feature_func(feature_func)#

Add a feature_func to the BaseFeatureCollection.

Parameters:
feature_funcstr

Feature to be added.

get_feature_funcs()#

Get all feature_funcs of the BaseFeatureCollection.

Returns:
list

List of feature_funcs.

class acoupipe.datasets.features.BaseFeatureCollectionBuilder#

Bases: traits.api.HasPrivateTraits

BaseFeatureCollectionBuilder base class for building a BaseFeatureCollection.

Attributes:
feature_collectionBaseFeatureCollection

BaseFeatureCollection object.

add_custom(feature_func)#

Add a custom feature to the BaseFeatureCollection.

The custom feature_func should be a callable that takes a sampler as input and returns a dictionary of feature name and feature data.

Parameters:
feature_funccallable

Feature to be added.

build()#

Build a BaseFeatureCollection.

Returns:
BaseFeatureCollection

BaseFeatureCollection object.

acoupipe.datasets.features.create_feature(feature_func, name, shape, dtype)#