acoupipe.datasets.utils#
Module Contents#
- class acoupipe.datasets.utils.WriteH5Dataset#
Bases:
BaseWriteDatasetClass intended to write data to a .h5 file.
- save(progress_bar=True, start_idx=1)#
Save the
get_data()output of thesourceto .h5 file format.
- get_data(progress_bar=True, start_idx=1)#
Save the source data to a *.h5 file and yield it to the next object.
- Returns:
- dict
Dictionary containing a sample of the data set {feature_name[key] : feature[values]}.
- acoupipe.datasets.utils.calc_transfer(ir, fs, blocksize, fftfreq, time_axis=-1)#
Compute one-sided transfer functions H(f) from (measured) impulse responses on a target rFFT bin grid defined by blocksize, returning only fftfreq.
The function enforces that the FFT length is a power-of-two by zero-padding the impulse responses to nfft = 2**ceil(log2(max(L, blocksize))), where L is the IR length.
- Parameters:
- irndarray
Impulse responses. The time axis is given by time_axis. Common shapes are (n_channels, n_samples) with time_axis=1, or (n_samples, n_channels) with time_axis=0.
- fsfloat
Sampling frequency in Hz.
- blocksizeint
Target block size defining the desired rFFT bin grid (power-of-two). The associated bin centers are f_k = k*fs/blocksize, k=0..blocksize//2.
- fftfreqarray_like of int or float, optional
Desired frequency bins to return.
If integer dtype: interpreted as rFFT bin indices on the blocksize grid, i.e., k in [0, blocksize//2]. This case is exact because both blocksize and nfft are powers-of-two, hence nfft/blocksize is integer and mapping is exact.
If float dtype: interpreted as frequencies in Hz. Values are mapped to the nearest rFFT bin of the computed FFT grid; a ValueError is raised if the frequency is not (approximately) on the grid.
If None, all one-sided bins of the computed FFT are returned.
- time_axisint, optional
Axis of ir corresponding to time samples. Default: -1.
- Returns:
- H_selndarray (complex)
One-sided transfer function values at the requested bins. The returned array has the same shape as ir, except the time axis is replaced by a frequency axis. If fftfreq is None, this frequency axis has length nfft//2+1. Otherwise, it has length len(fftfreq).
- acoupipe.datasets.utils._handle_log(fname)#
- acoupipe.datasets.utils.generate_uniform_parametric_eq(num_points, max_order, rng)#
Generate a random parametric EQ cascase.
Method according to [Nercessian 2020](https://dafx2020.mdw.ac.at/proceedings/papers/DAFx2020_paper_7.pdf). This method is part of the IIRNet project. License: Apache License 2.0
- Returns:
- coef
- mag
- phs
- acoupipe.datasets.utils.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.utils.set_pipeline_seeds(pipeline, start_idx, size, dataset='training')#
Create the random seed list for each sampler object held by the pipeline.
- Parameters:
- pipelineinstance of class BasePipeline
the pipeline object holding the sampler classes
- start_idxint
start index to be calculated by the pipeline
- sizeint
number of samples to be yielded by the pipeline
- datasetstr, optional
the data set type, by default “training”. Choose from [“training”,”validation”]
- acoupipe.datasets.utils.set_filename(writer, path='.', *args)#
Set the filename of the dataset.
- Parameters:
- writerinstance of class BaseWriteDataset
the writer object holding the filename
- pathstr, optional
the path to the dataset, current directory by default
- *argsstr
concatenated strings to be used as the filename
- acoupipe.datasets.utils.complex_to_real(func)#
- acoupipe.datasets.utils.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.utils._get_signals_recursively(source, signals)#
- acoupipe.datasets.utils.get_all_source_signals(source_list)#
Get all signals from a list of acoular.SamplesGenerator derived objects.
- Parameters:
- source_listlist
list of acoular.SamplesGenerator derived objects
- Returns:
- list
list of all acoular.SignalGenerator derived objects
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