Imaging

Plotting functions using matplotlib library.

Warning

You need to have matplotlib installed in order to use this module.

class acoustics.imaging.OctaveBandScale(axis, **kwargs)[source]

Octave band scale.

class BandTransform[source]
__init__()[source]

Creates a new TransformNode.

shorthand_name : str
A string representing the “name” of the transform. The name carries no significance other than to improve the readability of str(transform) when DEBUG=True.
transform_non_affine(a)[source]

Performs only the non-affine part of the transformation.

transform(values) is always equivalent to transform_affine(transform_non_affine(values)).

In non-affine transformations, this is generally equivalent to transform(values). In affine transformations, this is always a no-op.

Accepts a numpy array of shape (N x input_dims) and returns a numpy array of shape (N x output_dims).

Alternatively, accepts a numpy array of length input_dims and returns a numpy array of length output_dims.

__init__(axis, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

get_transform()[source]

Return the Transform object associated with this scale.

limit_range_for_scale(vmin, vmax, minpos)[source]

Returns the range vmin, vmax, possibly limited to the domain supported by this scale.

minpos should be the minimum positive value in the data.
This is used by log scales to determine a minimum value.
set_default_locators_and_formatters(axis)[source]

Set the Locator and Formatter objects on the given axis to match this scale.

acoustics.imaging.TICKS_OCTAVE = ['16', '31.5', '63', '125', '250', '500', '1000', '2000', '4000', '8000', '16000']

Octave center frequencies as strings.

acoustics.imaging.TICKS_OCTAVE_KHZ = ['16', '31.5', '63', '125', '250', '500', '1k', '2k', '4k', '8k', '16k']

Octave center frequencies as strings. Uses kHz notation.

acoustics.imaging.TICKS_THIRD_OCTAVE = ['12.5', '16', '20', '25', '31.5', '40', '50', '63', '80', '100', '125', '160', '200', '250', '315', '400', '500', '630', '800', '1000', '1250', '1600', '2000', '2500', '3150', '4000', '5000', '6300', '8000', '10000', '12500', '16000', '20000']

Third-octave center frequencies as strings.

acoustics.imaging.TICKS_THIRD_OCTAVE_KHZ = ['12.5', '16', '20', '25', '31.5', '40', '50', '63', '80', '100', '125', '160', '200', '250', '315', '400', '500', '630', '800', '1000', '1250', '1600', '2000', '2500', '3150', '4000', '5000', '6300', '8000', '10000', '12500', '16000', '20000']

Third-octave center frequencies as strings. Uses kHz notation.

class acoustics.imaging.ThirdBandScale(axis, **kwargs)[source]

Third-octave band scale.

class BandTransform[source]
__init__()[source]

Creates a new TransformNode.

shorthand_name : str
A string representing the “name” of the transform. The name carries no significance other than to improve the readability of str(transform) when DEBUG=True.
transform_non_affine(a)[source]

Performs only the non-affine part of the transformation.

transform(values) is always equivalent to transform_affine(transform_non_affine(values)).

In non-affine transformations, this is generally equivalent to transform(values). In affine transformations, this is always a no-op.

Accepts a numpy array of shape (N x input_dims) and returns a numpy array of shape (N x output_dims).

Alternatively, accepts a numpy array of length input_dims and returns a numpy array of length output_dims.

__init__(axis, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

get_transform()[source]

Return the Transform object associated with this scale.

limit_range_for_scale(vmin, vmax, minpos)[source]

Returns the range vmin, vmax, possibly limited to the domain supported by this scale.

minpos should be the minimum positive value in the data.
This is used by log scales to determine a minimum value.
set_default_locators_and_formatters(axis)[source]

Set the Locator and Formatter objects on the given axis to match this scale.

acoustics.imaging.plot_bands(data, bands, axes, band_type, k_ticks=False, xlabel=None, ylabel=None, title=None, separator=None, *args, **kwargs)[source]

Plot bands from data levels and bands. Only use if you want to plot from arbitrary octave or third octave data.

data: levels in an 1-D NumPy array.

axes: matplotlib.axes object.

band_type: ‘octave’ or ‘third’ are accepted values.

axes: a matplotlib.axes object (None by default, optional).

kHz: if True it shows “1k” or “2.5k” instead of “1000” or “2500” as tick labels (False by default, optional).

xlabel: a str containing label for x axis (optional).

ylabel: a str containing label for y axis (optional).

title: a str containing title (optional).

separator: a str defining the decimal separator. By default takes ‘.’ or ‘,’ values according to system settings (when separator is None).

acoustics.imaging.plot_octave(data, octaves, axes=None, kHz=False, xlabel=None, ylabel=None, title=None, separator=None, *args, **kwargs)[source]

Plot octave bands from data levels and octaves bands.

data: levels in an 1-D NumPy array.

octaves: octaves in an 1-D NumPy array. Note that you can use trompe.utils.bands.octave() for this or manually enter all bands.

axes: a matplotlib.axes object (optional).

kHz: if True it shows “1k” or “2k” instead of “1000” or “2000” as tick labels (False by default, optional).

xlabel: a str containing label for x axis (optional).

ylabel: a str containing label for y axis (optional).

title: a str containing title (optional).

separator: a str defining the decimal separator. By default takes ‘.’ or ‘,’ values according to system settings (when separator is None).

acoustics.imaging.plot_third(data, thirds, axes=None, kHz=False, xlabel=None, ylabel=None, title=None, separator=None, *args, **kwargs)[source]

Plot third octave bands from data levels and thirds bands.

data: levels in an 1-D NumPy array.

thirds: thirds in an 1-D NumPy array. Note that you can use trompe.utils.bands.thirds() for this or manually enter all bands.

axes: a matplotlib.axes object (None by default, optional).

kHz: if True it shows “1k” or “2.5k” instead of “1000” or “2500” as tick labels (False by default, optional).

xlabel: a str containing label for x axis (optional).

ylabel: a str containing label for y axis (optional).

title: a str containing title (optional).

separator: a str defining the decimal separator. By default takes ‘.’ or ‘,’ values according to system settings (when separator is None).