Skip to content

Commit 4f83604

Browse files
committed
Split "plot" module into "plot2d" and "plot3d"
See #26.
1 parent e9b2698 commit 4f83604

20 files changed

+116
-109
lines changed

doc/examples/animations_pulsating_sphere.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def particle_displacement(omega, center, radius, amplitude, grid, frames,
1515

1616
fig, ax = plt.subplots(figsize=figsize)
1717
ax.axis([grid[0].min(), grid[0].max(), grid[1].min(), grid[1].max()])
18-
scat = sfs.plot.particles(grid + displacement, **kwargs)
18+
scat = sfs.plot2d.particles(grid + displacement, **kwargs)
1919

2020
def update_frame_displacement(i):
2121
position = (grid + displacement * phasor**i).apply(np.real)
@@ -38,7 +38,7 @@ def particle_velocity(omega, center, radius, amplitude, grid, frames,
3838

3939
fig, ax = plt.subplots(figsize=figsize)
4040
ax.axis([grid[0].min(), grid[0].max(), grid[1].min(), grid[1].max()])
41-
quiv = sfs.plot.vectors(
41+
quiv = sfs.plot2d.vectors(
4242
velocity, grid, clim=[-omega * amplitude, omega * amplitude],
4343
**kwargs)
4444

@@ -59,7 +59,7 @@ def sound_pressure(omega, center, radius, amplitude, grid, frames,
5959
phasor = np.exp(1j * 2 * np.pi / frames)
6060

6161
fig, ax = plt.subplots(figsize=figsize)
62-
im = sfs.plot.soundfield(np.real(pressure), grid, **kwargs)
62+
im = sfs.plot2d.amplitude(np.real(pressure), grid, **kwargs)
6363
ax.axis([grid[0].min(), grid[0].max(), grid[1].min(), grid[1].max()])
6464

6565
def update_frame_pressure(i):

doc/examples/horizontal_plane_arrays.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ def compute_and_plot_soundfield(title):
3434

3535
plt.figure(figsize=(15, 15))
3636
plt.cla()
37-
sfs.plot.soundfield(p, grid, xnorm)
38-
sfs.plot.loudspeaker_2d(array.x, array.n, twin)
39-
sfs.plot.virtualsource_2d(xs)
40-
sfs.plot.virtualsource_2d([0, 0], npw, type='plane')
37+
sfs.plot2d.amplitude(p, grid, xnorm)
38+
sfs.plot2d.loudspeakers(array.x, array.n, twin)
39+
sfs.plot2d.virtualsource(xs)
40+
sfs.plot2d.virtualsource([0, 0], npw, type='plane')
4141
plt.title(title)
4242
plt.grid()
4343
plt.savefig(title + '.png')

doc/examples/mirror-image-source-model.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"metadata": {},
104104
"outputs": [],
105105
"source": [
106-
"sfs.plot.soundfield(P, grid, xnorm=[L[0]/2, L[1]/2, L[2]/2]);"
106+
"sfs.plot2d.amplitude(P, grid, xnorm=[L[0]/2, L[1]/2, L[2]/2]);"
107107
]
108108
},
109109
{
@@ -140,8 +140,8 @@
140140
"metadata": {},
141141
"outputs": [],
142142
"source": [
143-
"sfs.plot.level(p, grid)\n",
144-
"sfs.plot.virtualsource_2d(x0)"
143+
"sfs.plot2d.level(p, grid)\n",
144+
"sfs.plot2d.virtualsource(x0)"
145145
]
146146
}
147147
],

doc/examples/modal-room-acoustics.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"metadata": {},
115115
"outputs": [],
116116
"source": [
117-
"sfs.plot.soundfield(p, grid);"
117+
"sfs.plot2d.amplitude(p, grid);"
118118
]
119119
},
120120
{

doc/examples/plot_particle_density.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def plot_particle_displacement(title):
2323
# plot displacement
2424
plt.figure(figsize=(15, 15))
2525
plt.cla()
26-
sfs.plot.particles(X, facecolor='black', s=3, trim=[-3, 3, -3, 3])
26+
sfs.plot2d.particles(X, facecolor='black', s=3, trim=[-3, 3, -3, 3])
2727
plt.axis('off')
2828
plt.title(title)
2929
plt.grid()

doc/examples/sound_field_synthesis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@
7373

7474
# === plot synthesized sound field ===
7575
plt.figure(figsize=(10, 10))
76-
sfs.plot.soundfield(p, grid, [0, 0, 0])
77-
sfs.plot.loudspeaker_2d(array.x, array.n, twin)
76+
sfs.plot2d.amplitude(p, grid, [0, 0, 0])
77+
sfs.plot2d.loudspeakers(array.x, array.n, twin)
7878
plt.grid()
7979
plt.savefig('soundfield.png')
8080

8181

82-
#sfs.plot.loudspeaker_3d(array.x, array.n, twin)
82+
#sfs.plot3d.secondary_sources(array.x, array.n, twin)
8383
#plt.savefig('loudspeakers.png')

doc/examples/soundfigures.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737

3838
# plot and save synthesized sound field
3939
plt.figure(figsize=(10, 10))
40-
sfs.plot.soundfield(p, grid, xnorm=[0, -2.2, 0], cmap='BrBG', colorbar=False,
41-
vmin=-1, vmax=1)
40+
sfs.plot2d.amplitude(p, grid, xnorm=[0, -2.2, 0], cmap='BrBG', colorbar=False,
41+
vmin=-1, vmax=1)
4242
plt.title('Synthesized Sound Field')
4343
plt.savefig('soundfigure.png')
4444

4545
# plot and save level of synthesized sound field
4646
plt.figure(figsize=(12.5, 12.5))
47-
im = sfs.plot.level(p, grid, xnorm=[0, -2.2, 0], vmin=-50, vmax=0,
48-
colorbar_kwargs=dict(label='dB'))
47+
im = sfs.plot2d.level(p, grid, xnorm=[0, -2.2, 0], vmin=-50, vmax=0,
48+
colorbar_kwargs=dict(label='dB'))
4949
plt.title('Level of Synthesized Sound Field')
5050
plt.savefig('soundfigure_level.png')

doc/examples/time_domain.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
p = p * 100 # scale absolute amplitude
3737

3838
plt.figure(figsize=(10, 10))
39-
sfs.plot.level(p, grid, cmap=my_cmap)
40-
sfs.plot.loudspeaker_2d(array.x, array.n, twin)
39+
sfs.plot2d.level(p, grid, cmap=my_cmap)
40+
sfs.plot2d.loudspeakers(array.x, array.n, twin)
4141
plt.grid()
42-
sfs.plot.virtualsource_2d(xs)
42+
sfs.plot2d.virtualsource(xs)
4343
plt.title('impulse_ps_wfs_25d')
4444
plt.savefig('impulse_ps_wfs_25d.png')
4545

@@ -59,10 +59,10 @@
5959
secondary_source, observation_time=t, grid=grid)
6060

6161
plt.figure(figsize=(10, 10))
62-
sfs.plot.level(p, grid, cmap=my_cmap)
63-
sfs.plot.loudspeaker_2d(array.x, array.n, twin)
62+
sfs.plot2d.level(p, grid, cmap=my_cmap)
63+
sfs.plot2d.loudspeakers(array.x, array.n, twin)
6464
plt.grid()
65-
sfs.plot.virtualsource_2d([0, 0], npw, type='plane')
65+
sfs.plot2d.virtualsource([0, 0], npw, type='plane')
6666
plt.title('impulse_pw_wfs_25d')
6767
plt.savefig('impulse_pw_wfs_25d.png')
6868

@@ -82,9 +82,9 @@
8282
p = p * 100 # scale absolute amplitude
8383

8484
plt.figure(figsize=(10, 10))
85-
sfs.plot.level(p, grid, cmap=my_cmap)
86-
sfs.plot.loudspeaker_2d(array.x, array.n, twin)
85+
sfs.plot2d.level(p, grid, cmap=my_cmap)
86+
sfs.plot2d.loudspeakers(array.x, array.n, twin)
8787
plt.grid()
88-
sfs.plot.virtualsource_2d(xs)
88+
sfs.plot2d.virtualsource(xs)
8989
plt.title('impulse_fs_wfs_25d')
9090
plt.savefig('impulse_fs_wfs_25d.png')

doc/examples/time_domain_nfchoa.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
observation_time=t, grid=grid)
2828

2929
plt.figure()
30-
sfs.plot.level(p, grid)
31-
sfs.plot.loudspeaker_2d(array.x, array.n)
32-
sfs.plot.virtualsource_2d([0, 0], ns=npw, type='plane')
30+
sfs.plot2d.level(p, grid)
31+
sfs.plot2d.loudspeakers(array.x, array.n)
32+
sfs.plot2d.virtualsource([0, 0], ns=npw, type='plane')
3333
plt.savefig('impulse_pw_nfchoa_25d.png')
3434

3535
# Point source
@@ -44,7 +44,7 @@
4444
observation_time=t, grid=grid)
4545

4646
plt.figure()
47-
sfs.plot.level(p, grid)
48-
sfs.plot.loudspeaker_2d(array.x, array.n)
49-
sfs.plot.virtualsource_2d(xs, type='point')
47+
sfs.plot2d.level(p, grid)
48+
sfs.plot2d.loudspeakers(array.x, array.n)
49+
sfs.plot2d.virtualsource(xs, type='point')
5050
plt.savefig('impulse_ps_nfchoa_25d.png')

sfs/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
td
1212
array
1313
tapering
14-
plot
14+
plot2d
15+
plot3d
1516
util
1617
1718
"""
@@ -59,7 +60,11 @@ def reset(self):
5960
from . import array
6061
from . import util
6162
try:
62-
from . import plot
63+
from . import plot2d
64+
except ImportError:
65+
pass
66+
try:
67+
from . import plot3d
6368
except ImportError:
6469
pass
6570

0 commit comments

Comments
 (0)