Skip to content

Commit

Permalink
Change mono/time to fd/td
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Mar 16, 2019
1 parent c74e34a commit 5a6f5b4
Show file tree
Hide file tree
Showing 21 changed files with 146 additions and 146 deletions.
4 changes: 2 additions & 2 deletions doc/examples/animations-pulsating-sphere.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"particle velocity, and particle displacement, are simulated.\n",
"The first two quantities are computed with\n",
"\n",
"- [sfs.mono.source.pulsating_sphere()](../sfs.mono.source.rst#sfs.mono.source.pulsating_sphere) and \n",
"- [sfs.mono.source.pulsating_sphere_velocity()](../sfs.mono.source.rst#sfs.mono.source.pulsating_sphere_velocity)\n",
"- [sfs.fd.source.pulsating_sphere()](../sfs.fd.source.rst#sfs.fd.source.pulsating_sphere) and \n",
"- [sfs.fd.source.pulsating_sphere_velocity()](../sfs.fd.source.rst#sfs.fd.source.pulsating_sphere_velocity)\n",
"\n",
"while the last one can be obtained by using\n",
"\n",
Expand Down
6 changes: 3 additions & 3 deletions doc/examples/animations_pulsating_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def particle_displacement(omega, center, radius, amplitude, grid, frames,
figsize=(8, 8), interval=80, blit=True, **kwargs):
"""Generate sound particle animation."""
velocity = sfs.mono.source.pulsating_sphere_velocity(
velocity = sfs.fd.source.pulsating_sphere_velocity(
omega, center, radius, amplitude, grid)
displacement = sfs.util.displacement(velocity, omega)
phasor = np.exp(1j * 2 * np.pi / frames)
Expand All @@ -32,7 +32,7 @@ def update_frame_displacement(i):
def particle_velocity(omega, center, radius, amplitude, grid, frames,
figsize=(8, 8), interval=80, blit=True, **kwargs):
"""Generate particle velocity animation."""
velocity = sfs.mono.source.pulsating_sphere_velocity(
velocity = sfs.fd.source.pulsating_sphere_velocity(
omega, center, radius, amplitude, grid)
phasor = np.exp(1j * 2 * np.pi / frames)

Expand All @@ -54,7 +54,7 @@ def sound_pressure(omega, center, radius, amplitude, grid, frames,
pulsate=False, figsize=(8, 8), interval=80, blit=True,
**kwargs):
"""Generate sound pressure animation."""
pressure = sfs.mono.source.pulsating_sphere(
pressure = sfs.fd.source.pulsating_sphere(
omega, center, radius, amplitude, grid, inside=pulsate)
phasor = np.exp(1j * 2 * np.pi / frames)

Expand Down
38 changes: 19 additions & 19 deletions doc/examples/horizontal_plane_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def compute_and_plot_soundfield(title):
print('Computing', title)

twin = tapering(selection, talpha)
p = sfs.mono.synthesize(d, twin, array, secondary_source, grid=grid)
p = sfs.fd.synthesize(d, twin, array, secondary_source, grid=grid)

plt.figure(figsize=(15, 15))
plt.cla()
Expand All @@ -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.wfs.point_3d(
d, selection, secondary_source = sfs.fd.wfs.point_3d(
omega, array.x, array.n, xs)
compute_and_plot_soundfield('linear_ps_wfs_3d_point')

d, selection, secondary_source = sfs.mono.wfs.point_25d(
d, selection, secondary_source = sfs.fd.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.wfs.point_2d(
d, selection, secondary_source = sfs.fd.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.wfs.line_2d(
d, selection, secondary_source = sfs.fd.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.wfs.plane_3d(
d, selection, secondary_source = sfs.fd.wfs.plane_3d(
omega, array.x, array.n, npw)
compute_and_plot_soundfield('linear_ps_wfs_3d_plane')

d, selection, secondary_source = sfs.mono.wfs.plane_25d(
d, selection, secondary_source = sfs.fd.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.wfs.plane_2d(
d, selection, secondary_source = sfs.fd.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.wfs.point_25d(
d, selection, secondary_source = sfs.fd.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.wfs.plane_25d(
d, selection, secondary_source = sfs.fd.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.wfs.point_25d(
d, selection, secondary_source = sfs.fd.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.wfs.plane_25d(
d, selection, secondary_source = sfs.fd.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.wfs.point_25d(
d, selection, secondary_source = sfs.fd.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.wfs.plane_25d(
d, selection, secondary_source = sfs.fd.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.wfs.point_25d(
d, selection, secondary_source = sfs.fd.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.wfs.plane_25d(
d, selection, secondary_source = sfs.fd.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.nfchoa.plane_2d(
d, selection, secondary_source = sfs.fd.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.nfchoa.point_25d(
d, selection, secondary_source = sfs.fd.nfchoa.point_25d(
omega, array.x, 1, xs)
compute_and_plot_soundfield('circular_ps_nfchoa_25d_point')

d, selection, secondary_source = sfs.mono.nfchoa.plane_25d(
d, selection, secondary_source = sfs.fd.nfchoa.plane_25d(
omega, array.x, 1, npw)
compute_and_plot_soundfield('circular_ps_nfchoa_25d_plane')
8 changes: 4 additions & 4 deletions doc/examples/mirror-image-source-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
"outputs": [],
"source": [
"grid = sfs.util.xyz_grid([0, L[0]], [0, L[1]], 1.5, spacing=0.02)\n",
"P = sfs.mono.source.point_image_sources(omega, x0, grid, L,\n",
" max_order, coeffs=coeffs)"
"P = sfs.fd.source.point_image_sources(omega, x0, grid, L,\n",
" max_order, coeffs=coeffs)"
]
},
{
Expand Down Expand Up @@ -130,8 +130,8 @@
"outputs": [],
"source": [
"grid = sfs.util.xyz_grid([0, L[0]], [0, L[1]], 1.5, spacing=0.005)\n",
"p = sfs.time.source.point_image_sources(x0, signal, 0.004, grid, L, max_order,\n",
" coeffs=coeffs)"
"p = sfs.td.source.point_image_sources(x0, signal, 0.004, grid, L, max_order,\n",
" coeffs=coeffs)"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions doc/examples/modal-room-acoustics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"metadata": {},
"outputs": [],
"source": [
"p = sfs.mono.source.point_modal(omega, x0, grid, L, N=N, deltan=deltan)"
"p = sfs.fd.source.point_modal(omega, x0, grid, L, N=N, deltan=deltan)"
]
},
{
Expand Down Expand Up @@ -135,7 +135,7 @@
"\n",
"receiver = 1, 1, 1.8\n",
"\n",
"p = [sfs.mono.source.point_modal(om, x0, receiver, L, N=N, deltan=deltan)\n",
"p = [sfs.fd.source.point_modal(om, x0, receiver, L, N=N, deltan=deltan)\n",
" for om in omega]\n",
" \n",
"plt.plot(f, sfs.util.db(p))\n",
Expand Down
6 changes: 3 additions & 3 deletions doc/examples/plot_particle_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ def plot_particle_displacement(title):


# point source
v = sfs.mono.source.point_velocity(omega, xs, grid)
v = sfs.fd.source.point_velocity(omega, xs, grid)
amplitude = 1.5e6
plot_particle_displacement('particle_displacement_point_source')

# line source
v = sfs.mono.source.line_velocity(omega, xs, grid)
v = sfs.fd.source.line_velocity(omega, xs, grid)
amplitude = 1.3e6
plot_particle_displacement('particle_displacement_line_source')

# plane wave
v = sfs.mono.source.plane_velocity(omega, xs, npw, grid)
v = sfs.fd.source.plane_velocity(omega, xs, npw, grid)
amplitude = 1e5
plot_particle_displacement('particle_displacement_plane_wave')
24 changes: 12 additions & 12 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.wfs.plane_3d_delay(omega, array.x, array.n, npw)
#d, selection, secondary_source = sfs.fd.wfs.plane_3d_delay(omega, array.x, array.n, npw)

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

#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.fd.wfs.plane_2d(omega, array.x, array.n, npw)
d, selection, secondary_source = sfs.fd.wfs.plane_25d(omega, array.x, array.n, npw, xref)
#d, selection, secondary_source = sfs.fd.wfs.plane_3d(omega, array.x, array.n, npw)

#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.fd.wfs.point_2d(omega, array.x, array.n, xs)
#d, selection, secondary_source = sfs.fd.wfs.point_25d(omega, array.x, array.n, xs)
#d, selection, secondary_source = sfs.fd.wfs.point_3d(omega, array.x, array.n, xs)

#d, selection, secondary_source = sfs.mono.nfchoa.plane_2d(omega, array.x, R, npw)
#d, selection, secondary_source = sfs.fd.nfchoa.plane_2d(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)
#d, selection, secondary_source = sfs.fd.nfchoa.point_25d(omega, array.x, R, xs)
#d, selection, secondary_source = sfs.fd.nfchoa.plane_25d(omega, array.x, R, npw)


# === compute tapering window ===
Expand All @@ -68,7 +68,7 @@
twin = sfs.tapering.tukey(selection, 0.3)

# === compute synthesized sound field ===
p = sfs.mono.synthesize(d, twin, array, secondary_source, grid=grid)
p = sfs.fd.synthesize(d, twin, array, secondary_source, grid=grid)


# === plot synthesized sound field ===
Expand Down
4 changes: 2 additions & 2 deletions doc/examples/soundfigures.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
# 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.wfs.soundfigure_3d(
d, selection, secondary_source = sfs.fd.wfs.soundfigure_3d(
omega, array.x, array.n, figure, npw=npw)

# compute synthesized sound field
p = sfs.mono.synthesize(d, selection, array, secondary_source, grid=grid)
p = sfs.fd.synthesize(d, selection, array, secondary_source, grid=grid)

# plot and save synthesized sound field
plt.figure(figsize=(10, 10))
Expand Down
24 changes: 12 additions & 12 deletions doc/examples/time_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
t = 0.008
# compute driving signals
d_delay, d_weight, selection, secondary_source = \
sfs.time.wfs.point_25d(array.x, array.n, xs)
d = sfs.time.wfs.driving_signals(d_delay, d_weight, signal)
sfs.td.wfs.point_25d(array.x, array.n, xs)
d = sfs.td.wfs.driving_signals(d_delay, d_weight, signal)

# test soundfield
twin = sfs.tapering.tukey(selection, .3)

p = sfs.time.synthesize(d, twin, array,
secondary_source, observation_time=t, grid=grid)
p = sfs.td.synthesize(d, twin, array,
secondary_source, observation_time=t, grid=grid)
p = p * 100 # scale absolute amplitude

plt.figure(figsize=(10, 10))
Expand All @@ -50,13 +50,13 @@

# compute driving signals
d_delay, d_weight, selection, secondary_source = \
sfs.time.wfs.plane_25d(array.x, array.n, npw)
d = sfs.time.wfs.driving_signals(d_delay, d_weight, signal)
sfs.td.wfs.plane_25d(array.x, array.n, npw)
d = sfs.td.wfs.driving_signals(d_delay, d_weight, signal)

# test soundfield
twin = sfs.tapering.tukey(selection, .3)
p = sfs.time.synthesize(d, twin, array,
secondary_source, observation_time=t, grid=grid)
p = sfs.td.synthesize(d, twin, array,
secondary_source, observation_time=t, grid=grid)

plt.figure(figsize=(10, 10))
sfs.plot.level(p, grid, cmap=my_cmap)
Expand All @@ -72,13 +72,13 @@
nfs = sfs.util.normalize_vector(xref - xs) # main n of fsource
t = 0.003 # compute driving signals
d_delay, d_weight, selection, secondary_source = \
sfs.time.wfs.focused_25d(array.x, array.n, xs, nfs)
d = sfs.time.wfs.driving_signals(d_delay, d_weight, signal)
sfs.td.wfs.focused_25d(array.x, array.n, xs, nfs)
d = sfs.td.wfs.driving_signals(d_delay, d_weight, signal)

# test soundfield
twin = sfs.tapering.tukey(selection, .3)
p = sfs.time.synthesize(d, twin, array,
secondary_source, observation_time=t, grid=grid)
p = sfs.td.synthesize(d, twin, array,
secondary_source, observation_time=t, grid=grid)
p = p * 100 # scale absolute amplitude

plt.figure(figsize=(10, 10))
Expand Down
16 changes: 8 additions & 8 deletions doc/examples/time_domain_nfchoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
npw = [0, -1, 0] # propagating direction
t = 0 # observation time
delay, weight, sos, phaseshift, selection, secondary_source = \
sfs.time.nfchoa.plane_25d(array.x, R, npw, fs, max_order)
d = sfs.time.nfchoa.driving_signals_25d(
sfs.td.nfchoa.plane_25d(array.x, R, npw, fs, max_order)
d = sfs.td.nfchoa.driving_signals_25d(
delay, weight, sos, phaseshift, signal)
p = sfs.time.synthesize(d, selection, array, secondary_source,
observation_time=t, grid=grid)
p = sfs.td.synthesize(d, selection, array, secondary_source,
observation_time=t, grid=grid)

plt.figure()
sfs.plot.level(p, grid)
Expand All @@ -37,11 +37,11 @@
xs = [1.5, 1.5, 0] # position
t = np.linalg.norm(xs) / sfs.default.c # observation time
delay, weight, sos, phaseshift, selection, secondary_source = \
sfs.time.nfchoa.point_25d(array.x, R, xs, fs, max_order)
d = sfs.time.nfchoa.driving_signals_25d(
sfs.td.nfchoa.point_25d(array.x, R, xs, fs, max_order)
d = sfs.td.nfchoa.driving_signals_25d(
delay, weight, sos, phaseshift, signal)
p = sfs.time.synthesize(d, selection, array, secondary_source,
observation_time=t, grid=grid)
p = sfs.td.synthesize(d, selection, array, secondary_source,
observation_time=t, grid=grid)

plt.figure()
sfs.plot.level(p, grid)
Expand Down
8 changes: 4 additions & 4 deletions sfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
.. autosummary::
:toctree:
fd
td
array
tapering
mono
time
plot
util
Expand Down Expand Up @@ -63,5 +63,5 @@ def reset(self):
except ImportError:
pass

from . import mono
from . import time
from . import fd
from . import td

0 comments on commit 5a6f5b4

Please sign in to comment.