Skip to content

Visualization of (continuous) secondary source contour by polygon#38

Open
spors wants to merge 4 commits into
masterfrom
secondarysource_contour
Open

Visualization of (continuous) secondary source contour by polygon#38
spors wants to merge 4 commits into
masterfrom
secondarysource_contour

Conversation

@spors

@spors spors commented Jan 24, 2017

Copy link
Copy Markdown
Member
import numpy as np
import sfs

xs = [0, 2, 0]
grid = sfs.util.xyz_grid([-2.5, 2.5], [-2.5, 2.5], 0, spacing=0.02)
omega = 2*np.pi*1000

x0, n0, a0 = sfs.array.circular(200, 1.5)
d = sfs.mono.drivingfunction.wfs_2d_line(omega, x0, n0, xs)
a = sfs.mono.drivingfunction.source_selection_point(n0, x0, xs)
twin = sfs.tapering.tukey(a, 0.3)
p = sfs.mono.synthesized.generic(omega, x0, n0, d * a0 * twin, grid)

sfs.plot.soundfield(p, grid, xnorm=[0, 0, 0], vmin=-1.5, vmax=1.5)
sfs.plot.secondarysourcecontour_2d(x0, a)
sfs.plot.virtualsource_2d(xs)

grafik

@ghost

ghost commented Jan 25, 2017

Copy link
Copy Markdown

Two observations:

  • The contour has a gap.
  • The region of active sources is not symmetric. (Easier to see with few speakers, 16 or so).

@mgeier

mgeier commented Jan 29, 2017

Copy link
Copy Markdown
Member

I guess this needs a closed parameter like sfs.array.weights_midpoint()?

@mgeier

mgeier commented Jan 29, 2017

Copy link
Copy Markdown
Member

Possible fix for the second point made by @trettberg above: instead of line segments from one secondary source to the next, we should use line segments from halfway from the previous source to the current source to halfway to the next source. Again, the implementation could be similar to sfs.array.weights_midpoint().

@spors

spors commented Feb 23, 2017

Copy link
Copy Markdown
Member Author

I have fixed the issue regarding the gap and the region of active secondary sources:

import numpy as np
import sfs
import matplotlib.pyplot as plt

xs = [5, 0, 0]

x0, n0, a0 = sfs.array.circular(20, 1.5)
a = sfs.mono.drivingfunction.source_selection_point(n0, x0, xs)

plt.figure(figsize=(10, 10))
sfs.plot.secondarysourcecontour_2d(x0, a)
sfs.plot.loudspeaker_2d(x0, n0, a, size=0.2)
sfs.plot.virtualsource_2d(xs)
plt.axis([-5.2, 5.2, -5.2, 5.2])

grafik

Comment thread sfs/plot.py
# add collection of lines to current axis
if ax is None:
ax = plt.gca()
plt.gca().add_collection(lc)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ax.add_collection(lc)

@mgeier

mgeier commented Feb 24, 2017

Copy link
Copy Markdown
Member

Now it looks like the array is always closed, even if we don't want it to be:

sfs.plot.secondarysourcecontour_2d([(0, 0), (1, 1), (2, 1), (3, 0)],
                                   [False, True, True, False])
plt.axis('equal');

image

@hagenw

hagenw commented Feb 27, 2017

Copy link
Copy Markdown
Member

Have the secondary sources to be connected by a line?
Under Matlab I solved the gap issue by using only points for plotting secondary sources. If the distance between them becomes very small then they appear as a line. If the distance is not small, points have the advantage that you still are able to see the actual distance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants