Skip to content
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

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

spors
Copy link
Member

@spors spors commented Jan 24, 2017

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

@trettberg
Copy link
Collaborator

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
Copy link
Member

mgeier commented Jan 29, 2017

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

@mgeier
Copy link
Member

mgeier commented Jan 29, 2017

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
Copy link
Member Author

spors commented Feb 23, 2017

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

# add collection of lines to current axis
if ax is None:
ax = plt.gca()
plt.gca().add_collection(lc)
Copy link
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
Copy link
Member

mgeier commented Feb 24, 2017

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
Copy link
Member

hagenw commented Feb 27, 2017

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.

4 participants