dprocess#

Implements data processing classes.

BasePresenter

Provide a base presenter between Acoular models and a user interface.

MicGeomPresenter

Provide data for visualization of a microphone geometry.

BeamformerPresenter

Provide data for visualization of beamformed data.

PointSpreadFunctionPresenter

Provide data for visualization of a point spread function.

TimeSamplesPresenter

Provide selected channel data for visualization.

class spectacoular.dprocess.BasePresenter#

Bases: BaseSpectacoular

Provide a base presenter between Acoular models and a user interface.

This class provides methods for filtering and translating data of an Acoular class into the format of a ColumnDataSource that can be consumed by plots and glyphs of the interface. Interactive elements (widgets) that can be used to control the data transformation can be accessed via the get_widgets() method.

This class has no real functionality on its own and should not be used.

source#

Data source (Model)

cdsource#

ColumnDataSource that holds data that can be consumed by plots and glyphs

update(**optional_items)#

Update the cdsource attribute.

No processing happens here, since BasePresenter only represents a base class to derive other classes from.

get_widgets(trait_widget_mapper=None, trait_widget_args=None)#

Create a mapping between several class trait attributes and Bokeh widgets.

This function is implemented in all SpectAcoular classes and is added to Acoular’s classes via the bokehview module. For each attribute provided, it builds a corresponding Bokeh widget.

The function handles multiple cases of View construction:

  • Default View: the function is called as a method by a BaseSpectacoular derived instance without specifying trait_widget_mapper and trait_widget_args explicitly as function arguments. In this case, the default widget mapping, defined in bokehview, will be used:

    from spectacoular import RectGrid
    from bokeh.io import show
    from bokeh.layouts import gridplot
    
    grid = RectGrid()
    
    widgets = list(grid.get_widgets().values())
    show(gridplot(widgets, ncols=5, sizing_mode='stretch_both'))
    
  • No Predefined View: get_widgets() is called and a HasTraits derived instance is given as the first argument to the function without any further arguments. In this case, a default mapping is created from all editable traits to create the view.

from acoular import RectGrid
from spectacoular import get_widgets
from bokeh.io import show
from bokeh.layouts import gridplot

grid = RectGrid()

widgets = list(get_widgets(grid).values())
show(gridplot(widgets, ncols=5, sizing_mode='stretch_both'))
  • Custom View: get_widgets() is called by a BaseSpectacoular derived instance and an explicit mapping is given. In this case, the instance attributes (self.trait_widget_mapper, self.trait_widget_args) are superseded.

    from spectacoular import RectGrid
    from bokeh.io import show
    from bokeh.models.widgets import Slider
    from bokeh.layouts import column
    
    grid = RectGrid()
    
    trait_widget_mapper = {'x_min': Slider}
    trait_widget_args = {'x_min': {'title': 'X Min', 'start': -1, 'end': 1, 'step':0.1}}
    
    widgets = list(grid.get_widgets(
          trait_widget_mapper=trait_widget_mapper,
          trait_widget_args=trait_widget_args
    ).values())
    show(column(widgets,sizing_mode='stretch_both'))
    

    The same functionality can also be used with HasTraits-derived classes that are not part of SpectAcoular:

    from acoular import RectGrid
    from spectacoular import get_widgets
    from bokeh.io import show
    from bokeh.models.widgets import Slider
    from bokeh.layouts import column
    
    grid = RectGrid()
    
    trait_widget_mapper = {'x_min': Slider}
    trait_widget_args = {'x_min': {'title': 'X Min', 'start': -1, 'end': 1, 'step':0.1}}
    
    widgets = list(get_widgets(grid,
          trait_widget_mapper=trait_widget_mapper,
          trait_widget_args=trait_widget_args
    ).values())
    show(column(widgets,sizing_mode='stretch_both'))
    
Parameters:
trait_widget_mapperdict, optional

contains the desired mapping of a variable name (dict key) to a Bokeh widget type (dict value), by default {}

trait_widget_argsdict, optional
contains the desired widget kwargs (dict values) for each variable name (dict key),

by default {}

Returns:
dict

A dictionary containing the variable names as the key and the Bokeh widget instance as value.

set_widgets(**kwargs)#

Set instances of Bokeh widgets to certain trait attributes.

This function is implemented in all SpectAcoular classes and is added to Acoular’s classes in bokehview.py. It allows to reference an existing widget to a certain class trait attribute. Expects a class traits name as parameter and the widget instance as value.

For example:
>>> from spectacoular import RectGrid
>>> from bokeh.models.widgets import Select
>>>
>>> rg = RectGrid()
>>> sl = Select(value='10.0')
>>> rg.set_widgets(x_max=sl)

The value of the trait attribute changes to the widgets value when it is different.

Parameters:
**kwargs

The name of the class trait attributes. Depends on the class.

Returns:
None.
trait_widget_mapper#

dictionary containing the mapping between a class trait attribute and a Bokeh widget. Keys: name of the trait attribute. Values: Bokeh widget.

trait_widget_args#

dictionary containing arguments that belongs to a widget that is created from a trait attribute and should be considered when the widget is built. For example: {“traitname”:{‘disabled’:True,’background_color’:’red’,…}}.

class spectacoular.dprocess.MicGeomPresenter#

Bases: BasePresenter

Provide data for visualization of a microphone geometry.

The data of its ColumnDataSource fits different Bokeh glyphs, for example circle.

source#

Data source; MicGeom or derived object.

cdsource#

ColumnDataSource that holds data that can be consumed by plots and glyphs

update(**optional_items)#

Update the cdsource attribute with microphone geometry data.

get_widgets(trait_widget_mapper=None, trait_widget_args=None)#

Create a mapping between several class trait attributes and Bokeh widgets.

This function is implemented in all SpectAcoular classes and is added to Acoular’s classes via the bokehview module. For each attribute provided, it builds a corresponding Bokeh widget.

The function handles multiple cases of View construction:

  • Default View: the function is called as a method by a BaseSpectacoular derived instance without specifying trait_widget_mapper and trait_widget_args explicitly as function arguments. In this case, the default widget mapping, defined in bokehview, will be used:

    from spectacoular import RectGrid
    from bokeh.io import show
    from bokeh.layouts import gridplot
    
    grid = RectGrid()
    
    widgets = list(grid.get_widgets().values())
    show(gridplot(widgets, ncols=5, sizing_mode='stretch_both'))
    
  • No Predefined View: get_widgets() is called and a HasTraits derived instance is given as the first argument to the function without any further arguments. In this case, a default mapping is created from all editable traits to create the view.

from acoular import RectGrid
from spectacoular import get_widgets
from bokeh.io import show
from bokeh.layouts import gridplot

grid = RectGrid()

widgets = list(get_widgets(grid).values())
show(gridplot(widgets, ncols=5, sizing_mode='stretch_both'))
  • Custom View: get_widgets() is called by a BaseSpectacoular derived instance and an explicit mapping is given. In this case, the instance attributes (self.trait_widget_mapper, self.trait_widget_args) are superseded.

    from spectacoular import RectGrid
    from bokeh.io import show
    from bokeh.models.widgets import Slider
    from bokeh.layouts import column
    
    grid = RectGrid()
    
    trait_widget_mapper = {'x_min': Slider}
    trait_widget_args = {'x_min': {'title': 'X Min', 'start': -1, 'end': 1, 'step':0.1}}
    
    widgets = list(grid.get_widgets(
          trait_widget_mapper=trait_widget_mapper,
          trait_widget_args=trait_widget_args
    ).values())
    show(column(widgets,sizing_mode='stretch_both'))
    

    The same functionality can also be used with HasTraits-derived classes that are not part of SpectAcoular:

    from acoular import RectGrid
    from spectacoular import get_widgets
    from bokeh.io import show
    from bokeh.models.widgets import Slider
    from bokeh.layouts import column
    
    grid = RectGrid()
    
    trait_widget_mapper = {'x_min': Slider}
    trait_widget_args = {'x_min': {'title': 'X Min', 'start': -1, 'end': 1, 'step':0.1}}
    
    widgets = list(get_widgets(grid,
          trait_widget_mapper=trait_widget_mapper,
          trait_widget_args=trait_widget_args
    ).values())
    show(column(widgets,sizing_mode='stretch_both'))
    
Parameters:
trait_widget_mapperdict, optional

contains the desired mapping of a variable name (dict key) to a Bokeh widget type (dict value), by default {}

trait_widget_argsdict, optional
contains the desired widget kwargs (dict values) for each variable name (dict key),

by default {}

Returns:
dict

A dictionary containing the variable names as the key and the Bokeh widget instance as value.

set_widgets(**kwargs)#

Set instances of Bokeh widgets to certain trait attributes.

This function is implemented in all SpectAcoular classes and is added to Acoular’s classes in bokehview.py. It allows to reference an existing widget to a certain class trait attribute. Expects a class traits name as parameter and the widget instance as value.

For example:
>>> from spectacoular import RectGrid
>>> from bokeh.models.widgets import Select
>>>
>>> rg = RectGrid()
>>> sl = Select(value='10.0')
>>> rg.set_widgets(x_max=sl)

The value of the trait attribute changes to the widgets value when it is different.

Parameters:
**kwargs

The name of the class trait attributes. Depends on the class.

Returns:
None.
trait_widget_mapper#

dictionary containing the mapping between a class trait attribute and a Bokeh widget. Keys: name of the trait attribute. Values: Bokeh widget.

trait_widget_args#

dictionary containing arguments that belongs to a widget that is created from a trait attribute and should be considered when the widget is built. For example: {“traitname”:{‘disabled’:True,’background_color’:’red’,…}}.

class spectacoular.dprocess.BeamformerPresenter#

Bases: BasePresenter

Provide data for visualization of beamformed data.

The data of its ColumnDataSource fits Bokeh’s image glyph.

source#

Data source; BeamformerBase or derived object.

cdsource#

ColumnDataSource that holds data that can be consumed by plots and glyphs

num#

Trait to set the width of the frequency bands considered. defaults to 0 (single frequency line).

freq#

Trait to set the band center frequency to be considered.

trait_widget_mapper: ClassVar[dict[str, type]]#

dictionary containing the mapping between a class trait attribute and a Bokeh widget. Keys: name of the trait attribute. Values: Bokeh widget.

trait_widget_args: ClassVar[dict[str, dict[str, bool]]]#

dictionary containing arguments that belongs to a widget that is created from a trait attribute and should be considered when the widget is built. For example: {“traitname”:{‘disabled’:True,’background_color’:’red’,…}}.

update(**optional_items)#

Update the keys and values of cdsource.

get_widgets(trait_widget_mapper=None, trait_widget_args=None)#

Create a mapping between several class trait attributes and Bokeh widgets.

This function is implemented in all SpectAcoular classes and is added to Acoular’s classes via the bokehview module. For each attribute provided, it builds a corresponding Bokeh widget.

The function handles multiple cases of View construction:

  • Default View: the function is called as a method by a BaseSpectacoular derived instance without specifying trait_widget_mapper and trait_widget_args explicitly as function arguments. In this case, the default widget mapping, defined in bokehview, will be used:

    from spectacoular import RectGrid
    from bokeh.io import show
    from bokeh.layouts import gridplot
    
    grid = RectGrid()
    
    widgets = list(grid.get_widgets().values())
    show(gridplot(widgets, ncols=5, sizing_mode='stretch_both'))
    
  • No Predefined View: get_widgets() is called and a HasTraits derived instance is given as the first argument to the function without any further arguments. In this case, a default mapping is created from all editable traits to create the view.

from acoular import RectGrid
from spectacoular import get_widgets
from bokeh.io import show
from bokeh.layouts import gridplot

grid = RectGrid()

widgets = list(get_widgets(grid).values())
show(gridplot(widgets, ncols=5, sizing_mode='stretch_both'))
  • Custom View: get_widgets() is called by a BaseSpectacoular derived instance and an explicit mapping is given. In this case, the instance attributes (self.trait_widget_mapper, self.trait_widget_args) are superseded.

    from spectacoular import RectGrid
    from bokeh.io import show
    from bokeh.models.widgets import Slider
    from bokeh.layouts import column
    
    grid = RectGrid()
    
    trait_widget_mapper = {'x_min': Slider}
    trait_widget_args = {'x_min': {'title': 'X Min', 'start': -1, 'end': 1, 'step':0.1}}
    
    widgets = list(grid.get_widgets(
          trait_widget_mapper=trait_widget_mapper,
          trait_widget_args=trait_widget_args
    ).values())
    show(column(widgets,sizing_mode='stretch_both'))
    

    The same functionality can also be used with HasTraits-derived classes that are not part of SpectAcoular:

    from acoular import RectGrid
    from spectacoular import get_widgets
    from bokeh.io import show
    from bokeh.models.widgets import Slider
    from bokeh.layouts import column
    
    grid = RectGrid()
    
    trait_widget_mapper = {'x_min': Slider}
    trait_widget_args = {'x_min': {'title': 'X Min', 'start': -1, 'end': 1, 'step':0.1}}
    
    widgets = list(get_widgets(grid,
          trait_widget_mapper=trait_widget_mapper,
          trait_widget_args=trait_widget_args
    ).values())
    show(column(widgets,sizing_mode='stretch_both'))
    
Parameters:
trait_widget_mapperdict, optional

contains the desired mapping of a variable name (dict key) to a Bokeh widget type (dict value), by default {}

trait_widget_argsdict, optional
contains the desired widget kwargs (dict values) for each variable name (dict key),

by default {}

Returns:
dict

A dictionary containing the variable names as the key and the Bokeh widget instance as value.

set_widgets(**kwargs)#

Set instances of Bokeh widgets to certain trait attributes.

This function is implemented in all SpectAcoular classes and is added to Acoular’s classes in bokehview.py. It allows to reference an existing widget to a certain class trait attribute. Expects a class traits name as parameter and the widget instance as value.

For example:
>>> from spectacoular import RectGrid
>>> from bokeh.models.widgets import Select
>>>
>>> rg = RectGrid()
>>> sl = Select(value='10.0')
>>> rg.set_widgets(x_max=sl)

The value of the trait attribute changes to the widgets value when it is different.

Parameters:
**kwargs

The name of the class trait attributes. Depends on the class.

Returns:
None.
class spectacoular.dprocess.PointSpreadFunctionPresenter#

Bases: BasePresenter

Provide data for visualization of a point spread function.

source#

Data source; PointSpreadFunction or derived object.

cdsource#

ColumnDataSource that holds data that can be consumed by plots and glyphs

update(**optional_items)#

Update the keys and values of cdsource.

get_widgets(trait_widget_mapper=None, trait_widget_args=None)#

Create a mapping between several class trait attributes and Bokeh widgets.

This function is implemented in all SpectAcoular classes and is added to Acoular’s classes via the bokehview module. For each attribute provided, it builds a corresponding Bokeh widget.

The function handles multiple cases of View construction:

  • Default View: the function is called as a method by a BaseSpectacoular derived instance without specifying trait_widget_mapper and trait_widget_args explicitly as function arguments. In this case, the default widget mapping, defined in bokehview, will be used:

    from spectacoular import RectGrid
    from bokeh.io import show
    from bokeh.layouts import gridplot
    
    grid = RectGrid()
    
    widgets = list(grid.get_widgets().values())
    show(gridplot(widgets, ncols=5, sizing_mode='stretch_both'))
    
  • No Predefined View: get_widgets() is called and a HasTraits derived instance is given as the first argument to the function without any further arguments. In this case, a default mapping is created from all editable traits to create the view.

from acoular import RectGrid
from spectacoular import get_widgets
from bokeh.io import show
from bokeh.layouts import gridplot

grid = RectGrid()

widgets = list(get_widgets(grid).values())
show(gridplot(widgets, ncols=5, sizing_mode='stretch_both'))
  • Custom View: get_widgets() is called by a BaseSpectacoular derived instance and an explicit mapping is given. In this case, the instance attributes (self.trait_widget_mapper, self.trait_widget_args) are superseded.

    from spectacoular import RectGrid
    from bokeh.io import show
    from bokeh.models.widgets import Slider
    from bokeh.layouts import column
    
    grid = RectGrid()
    
    trait_widget_mapper = {'x_min': Slider}
    trait_widget_args = {'x_min': {'title': 'X Min', 'start': -1, 'end': 1, 'step':0.1}}
    
    widgets = list(grid.get_widgets(
          trait_widget_mapper=trait_widget_mapper,
          trait_widget_args=trait_widget_args
    ).values())
    show(column(widgets,sizing_mode='stretch_both'))
    

    The same functionality can also be used with HasTraits-derived classes that are not part of SpectAcoular:

    from acoular import RectGrid
    from spectacoular import get_widgets
    from bokeh.io import show
    from bokeh.models.widgets import Slider
    from bokeh.layouts import column
    
    grid = RectGrid()
    
    trait_widget_mapper = {'x_min': Slider}
    trait_widget_args = {'x_min': {'title': 'X Min', 'start': -1, 'end': 1, 'step':0.1}}
    
    widgets = list(get_widgets(grid,
          trait_widget_mapper=trait_widget_mapper,
          trait_widget_args=trait_widget_args
    ).values())
    show(column(widgets,sizing_mode='stretch_both'))
    
Parameters:
trait_widget_mapperdict, optional

contains the desired mapping of a variable name (dict key) to a Bokeh widget type (dict value), by default {}

trait_widget_argsdict, optional
contains the desired widget kwargs (dict values) for each variable name (dict key),

by default {}

Returns:
dict

A dictionary containing the variable names as the key and the Bokeh widget instance as value.

set_widgets(**kwargs)#

Set instances of Bokeh widgets to certain trait attributes.

This function is implemented in all SpectAcoular classes and is added to Acoular’s classes in bokehview.py. It allows to reference an existing widget to a certain class trait attribute. Expects a class traits name as parameter and the widget instance as value.

For example:
>>> from spectacoular import RectGrid
>>> from bokeh.models.widgets import Select
>>>
>>> rg = RectGrid()
>>> sl = Select(value='10.0')
>>> rg.set_widgets(x_max=sl)

The value of the trait attribute changes to the widgets value when it is different.

Parameters:
**kwargs

The name of the class trait attributes. Depends on the class.

Returns:
None.
trait_widget_mapper#

dictionary containing the mapping between a class trait attribute and a Bokeh widget. Keys: name of the trait attribute. Values: Bokeh widget.

trait_widget_args#

dictionary containing arguments that belongs to a widget that is created from a trait attribute and should be considered when the widget is built. For example: {“traitname”:{‘disabled’:True,’background_color’:’red’,…}}.

class spectacoular.dprocess.TimeSamplesPresenter#

Bases: BasePresenter

Provide selected channel data for visualization.

The data of its ColumnDataSource fits Bokeh’s MultiLine glyph.

source#

Data source; TimeSamples or derived object.

cdsource#

ColumnDataSource that holds data that can be consumed by plots and glyphs

channels#

Indices of channel to be considered for updating of ColumnDataSource

trait_widget_mapper: ClassVar[dict[str, type]]#

dictionary containing the mapping between a class trait attribute and a Bokeh widget. Keys: name of the trait attribute. Values: Bokeh widget.

trait_widget_args: ClassVar[dict[str, dict[str, bool]]]#

dictionary containing arguments that belongs to a widget that is created from a trait attribute and should be considered when the widget is built. For example: {“traitname”:{‘disabled’:True,’background_color’:’red’,…}}.

update(**optional_items)#

Update the keys and values of cdsource.

get_widgets(trait_widget_mapper=None, trait_widget_args=None)#

Create a mapping between several class trait attributes and Bokeh widgets.

This function is implemented in all SpectAcoular classes and is added to Acoular’s classes via the bokehview module. For each attribute provided, it builds a corresponding Bokeh widget.

The function handles multiple cases of View construction:

  • Default View: the function is called as a method by a BaseSpectacoular derived instance without specifying trait_widget_mapper and trait_widget_args explicitly as function arguments. In this case, the default widget mapping, defined in bokehview, will be used:

    from spectacoular import RectGrid
    from bokeh.io import show
    from bokeh.layouts import gridplot
    
    grid = RectGrid()
    
    widgets = list(grid.get_widgets().values())
    show(gridplot(widgets, ncols=5, sizing_mode='stretch_both'))
    
  • No Predefined View: get_widgets() is called and a HasTraits derived instance is given as the first argument to the function without any further arguments. In this case, a default mapping is created from all editable traits to create the view.

from acoular import RectGrid
from spectacoular import get_widgets
from bokeh.io import show
from bokeh.layouts import gridplot

grid = RectGrid()

widgets = list(get_widgets(grid).values())
show(gridplot(widgets, ncols=5, sizing_mode='stretch_both'))
  • Custom View: get_widgets() is called by a BaseSpectacoular derived instance and an explicit mapping is given. In this case, the instance attributes (self.trait_widget_mapper, self.trait_widget_args) are superseded.

    from spectacoular import RectGrid
    from bokeh.io import show
    from bokeh.models.widgets import Slider
    from bokeh.layouts import column
    
    grid = RectGrid()
    
    trait_widget_mapper = {'x_min': Slider}
    trait_widget_args = {'x_min': {'title': 'X Min', 'start': -1, 'end': 1, 'step':0.1}}
    
    widgets = list(grid.get_widgets(
          trait_widget_mapper=trait_widget_mapper,
          trait_widget_args=trait_widget_args
    ).values())
    show(column(widgets,sizing_mode='stretch_both'))
    

    The same functionality can also be used with HasTraits-derived classes that are not part of SpectAcoular:

    from acoular import RectGrid
    from spectacoular import get_widgets
    from bokeh.io import show
    from bokeh.models.widgets import Slider
    from bokeh.layouts import column
    
    grid = RectGrid()
    
    trait_widget_mapper = {'x_min': Slider}
    trait_widget_args = {'x_min': {'title': 'X Min', 'start': -1, 'end': 1, 'step':0.1}}
    
    widgets = list(get_widgets(grid,
          trait_widget_mapper=trait_widget_mapper,
          trait_widget_args=trait_widget_args
    ).values())
    show(column(widgets,sizing_mode='stretch_both'))
    
Parameters:
trait_widget_mapperdict, optional

contains the desired mapping of a variable name (dict key) to a Bokeh widget type (dict value), by default {}

trait_widget_argsdict, optional
contains the desired widget kwargs (dict values) for each variable name (dict key),

by default {}

Returns:
dict

A dictionary containing the variable names as the key and the Bokeh widget instance as value.

set_widgets(**kwargs)#

Set instances of Bokeh widgets to certain trait attributes.

This function is implemented in all SpectAcoular classes and is added to Acoular’s classes in bokehview.py. It allows to reference an existing widget to a certain class trait attribute. Expects a class traits name as parameter and the widget instance as value.

For example:
>>> from spectacoular import RectGrid
>>> from bokeh.models.widgets import Select
>>>
>>> rg = RectGrid()
>>> sl = Select(value='10.0')
>>> rg.set_widgets(x_max=sl)

The value of the trait attribute changes to the widgets value when it is different.

Parameters:
**kwargs

The name of the class trait attributes. Depends on the class.

Returns:
None.