Skip to content

Commit

Permalink
Hide warnings for a few undefined points
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw authored Mar 18, 2019
1 parent 725d1a7 commit 33eab32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 7 additions & 2 deletions sfs/fd/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ def point(omega, x0, grid, *, c=None):
grid = util.as_xyz_components(grid)

r = np.linalg.norm(grid - x0)
return 1 / (4*np.pi) * np.exp(-1j * k * r) / r
# If r is 0, the sound pressure is complex infinity
numerator = np.exp(-1j * k * r) / (4*np.pi)
with np.errstate(invalid='ignore', divide='ignore'):
return numerator / r


def point_velocity(omega, x0, grid, *, c=None, rho0=None):
Expand Down Expand Up @@ -395,7 +398,9 @@ def point_image_sources(omega, x0, grid, L, *, max_order, coeffs=None, c=None):
p = 0
for position, strength in zip(xs, source_strengths):
if strength != 0:
p += strength * point(omega, position, grid, c=c)
# point can be complex infinity
with np.errstate(invalid='ignore'):
p += strength * point(omega, position, grid, c=c)

return p

Expand Down
10 changes: 7 additions & 3 deletions sfs/td/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,17 @@ def point(xs, signal, observation_time, grid, c=None):
if c is None:
c = default.c
r = np.linalg.norm(grid - xs)
# evaluate g over grid
weights = 1 / (4 * np.pi * r)
# If r is +-0, the sound pressure is +-infinity
with np.errstate(divide='ignore'):
weights = 1 / (4 * np.pi * r)
delays = r / c
base_time = observation_time - signal_offset
return weights * np.interp(base_time - delays,
points_at_time = np.interp(base_time - delays,
np.arange(len(data)) / samplerate,
data, left=0, right=0)
# weights can be +-infinity
with np.errstate(invalid='ignore'):
return weights * points_at_time


def point_image_sources(x0, signal, observation_time, grid, L, max_order,
Expand Down

0 comments on commit 33eab32

Please sign in to comment.