8000 new mono drivingfunction handling by fs446 · Pull Request #125 · sfstoolbox/sfs-python · GitHub
[go: up one dir, main page]

Skip to content

new mono drivingfunction handling #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 13, 2019
36 changes: 18 additions & 18 deletions doc/examp 8000 les/horizontal_plane_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,34 @@ def compute_and_plot_soundfield(title):
# linear array, secondary point sources, virtual monopole
array = sfs.array.linear(N, dx, center=acenter, orientation=anormal)

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_3d_point(
d, selection, secondary_source = sfs.mono.wfs.point_3d(
omega, array.x, array.n, xs)
compute_and_plot_soundfield('linear_ps_wfs_3d_point')

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(
d, selection, secondary_source = sfs.mono.wfs.point_25d(
omega, array.x, array.n, xs, xref=xnorm)
compute_and_plot_soundfield('linear_ps_wfs_25d_point')

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_point(
d, selection, secondary_source = sfs.mono.wfs.point_2d(
omega, array.x, array.n, xs)
compute_and_plot_soundfield('linear_ps_wfs_2d_point')

# linear array, secondary line sources, virtual line source
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_line(
d, selection, secondary_source = sfs.mono.wfs.line_2d(
omega, array.x, array.n, xs)
compute_and_plot_soundfield('linear_ls_wfs_2d_line')


# linear array, secondary point sources, virtual plane wave
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_3d_plane(
d, selection, secondary_source = sfs.mono.wfs.plane_3d(
omega, array.x, array.n, npw)
compute_and_plot_soundfield('linear_ps_wfs_3d_plane')

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(
d, selection, secondary_source = sfs.mono.wfs.plane_25d(
omega, array.x, array.n, npw, xref=xnorm)
compute_and_plot_soundfield('linear_ps_wfs_25d_plane')

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_plane(
d, selection, secondary_source = sfs.mono.wfs.plane_2d(
omega, array.x, array.n, npw)
compute_and_plot_soundfield('linear_ps_wfs_2d_plane')

Expand All @@ -82,11 +82,11 @@ def compute_and_plot_soundfield(title):
array = sfs.array.linear_diff(N//3 * [dx] + N//3 * [dx/2] + N//3 * [dx],
center=acenter, orientation=anormal)

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(
d, selection, secondary_source = sfs.mono.wfs.point_25d(
omega, array.x, array.n, xs, xref=xnorm)
compute_and_plot_soundfield('linear_nested_ps_wfs_25d_point')

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(
d, selection, secondary_source = sfs.mono.wfs.plane_25d(
omega, array.x, array.n, npw, xref=xnorm)
compute_and_plot_soundfield('linear_nested_ps_wfs_25d_plane')

Expand All @@ -95,34 +95,34 @@ def compute_and_plot_soundfield(title):
array = sfs.array.linear_random(N, dx/2, 1.5*dx, center=acenter,
orientation=anormal)

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(
d, selection, secondary_source = sfs.mono.wfs.point_25d(
omega, array.x, array.n, xs, xref=xnorm)
compute_and_plot_soundfield('linear_random_ps_wfs_25d_point')

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(
d, selection, secondary_source = sfs.mono.wfs.plane_25d(
omega, array.x, array.n, npw, xref=xnorm)
compute_and_plot_soundfield('linear_random_ps_wfs_25d_plane')


# rectangular array, secondary point sources
array = sfs.array.rectangular((N, N//2), dx, center=acenter, orientation=anormal)
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(
d, selection, secondary_source = sfs.mono.wfs.point_25d(
omega, array.x, array.n, xs, xref=xnorm)
compute_and_plot_soundfield('rectangular_ps_wfs_25d_point')

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(
d, selection, secondary_source = sfs.mono.wfs.plane_25d(
omega, array.x, array.n, npw, xref=xnorm)
compute_and_plot_soundfield('rectangular_ps_wfs_25d_plane')


# circular array, secondary point sources
N = 60
array = sfs.array.circular(N, 1, center=acenter)
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(
d, selection, secondary_source = sfs.mono.wfs.point_25d(
omega, array.x, array.n, xs, xref=xnorm)
compute_and_plot_soundfield('circular_ps_wfs_25d_point')

d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(
d, selection, secondary_source = sfs.mono.wfs.plane_25d(
omega, array.x, array.n, npw, xref=xnorm)
compute_and_plot_soundfield('circular_ps_wfs_25d_plane')

Expand All @@ -132,7 +132,7 @@ def compute_and_plot_soundfield(title):
xnorm = [0, 0, 0]
talpha = 0 # switches off tapering

d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_2d_plane(
d, selection, secondary_source = sfs.mono.nfchoa.plane_2d(
omega, array.x, 1, npw)
compute_and_plot_soundfield('circular_ls_nfchoa_2d_plane')

Expand All @@ -142,10 +142,10 @@ def compute_and_plot_soundfield(title):
xnorm = [0, 0, 0]
talpha = 0 # switches off tapering

d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_25d_point(
d, selection, secondary_source = sfs.mono.nfchoa.point_25d(
omega, array.x, 1, xs)
compute_and_plot_soundfield('circular_ps_nfchoa_25d_point')

d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_25d_plane(
d, selection, secondary_source = sfs.mono.nfchoa.plane_25d(
omega, array.x, 1, npw)
compute_and_plot_soundfield('circular_ps_nfchoa_25d_plane')
22 changes: 11 additions & 11 deletions doc/examples/sound_field_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@


# === compute driving function and determine active secondary sources ===
#d, selection, secondary_source = sfs.mono.drivingfunction.delay_3d_plane(omega, array.x, array.n, npw)
#d, selection, secondary_source = sfs.mono.wfs.plane_3d_delay(omega, array.x, array.n, npw)

#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_line(omega, array.x, array.n, xs)
#d, selection, secondary_source = sfs.mono.wfs.line_2d(omega, array.x, array.n, xs)

#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_plane(omega, array.x, array.n, npw)
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(omega, array.x, array.n, npw, xref)
#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_3d_plane(omega, array.x, array.n, npw)
#d, selection, secondary_source = sfs.mono.wfs.plane_2d(omega, array.x, array.n, npw)
d, selection, secondary_source = sfs.mono.wfs.plane_25d(omega, array.x, array.n, npw, xref)
#d, selection, secondary_source = sfs.mono.wfs.plane_3d(omega, array.x, array.n, npw)

#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_point(omega, array.x, array.n, xs)
#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(omega, array.x, array.n, xs)
#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_3d_point(omega, array.x, array.n, xs)
#d, selection, secondary_source = sfs.mono.wfs.point_2d(omega, array.x, array.n, xs)
#d, selection, secondary_source = sfs.mono.wfs.point_25d(omega, array.x, array.n, xs)
#d, selection, secondary_source = sfs.mono.wfs.point_3d(omega, array.x, array.n, xs)

#d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_2d_plane(omega, array.x, R, npw)
#d, selection, secondary_source = sfs.mono.nfchoa.plane_2d(omega, array.x, R, npw)

#d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_25d_point(omega, array.x, R, xs)
#d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_25d_plane(omega, array.x, R, npw)
#d, selection, secondary_source = sfs.mono.nfchoa.point_25d(omega, array.x, R, xs)
#d, selection, secondary_source = sfs.mono.nfchoa.plane_25d(omega, array.x, R, npw)


# === compute tapering window ===
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/soundfigures.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# driving function for sound figure
figure = np.array(Image.open('figures/tree.png')) # read image from file
figure = np.rot90(figure) # turn 0deg to the top
d, selection, secondary_source = sfs.mono.soundfigure.wfs_3d_pw(
d, selection, secondary_source = sfs.mono.wfs.soundfigure_3d(
omega, array.x, array.n, figure, npw=npw)

# compute synthesized sound field
Expand Down
37 changes: 30 additions & 7 deletions sfs/mono/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
.. autosummary::
:toctree:

drivingfunction
source
soundfigure

"""
import numpy as _np
wfs
nfchoa
sdm
esa

from . import drivingfunction
"""
from . import source
from . import soundfigure

from .. import array as _array
import numpy as _np


def shiftphase(p, phase):
Expand Down Expand Up @@ -58,3 +57,27 @@ def synthesize(d, weights, ssd, secondary_source_function, **kwargs):
if weight != 0:
p += a * weight * d * secondary_source_function(x, n, **kwargs)
return p


def secondary_source_point(omega, c):
"""Create a point source for use in `sfs.mono.synthesize()`."""

def secondary_source(position, _, grid):
return source.point(omega, position, grid, c)

return secondary_source


def secondary_source_line(omega, c):
"""Create a line source for use in `sfs.mono.synthesize()`."""

def secondary_source(position, _, grid):
return source.line(omega, position, grid, c)

return secondary_source


from . import esa
from . import nfchoa
from . import sdm
from . import wfs
Loading
0