Commit 0ad1f1db authored by Martin Reinecke's avatar Martin Reinecke
Browse files

work around floating point errors

parent 82a92a51
Pipeline #13065 passed with stage
in 5 minutes and 21 seconds
......@@ -53,10 +53,13 @@ class DirectSmoothingOperator(SmoothingOperator):
wgt = []
expfac = 1. / (2. * sigma*sigma)
for i in range(x.size):
t = x[ibegin[i]:ibegin[i]+nval[i]]-x[i]
t = np.exp(-t*t*expfac)
t *= 1./np.sum(t)
wgt.append(t)
if nval[i]>0:
t = x[ibegin[i]:ibegin[i]+nval[i]]-x[i]
t = np.exp(-t*t*expfac)
t *= 1./np.sum(t)
wgt.append(t)
else:
wgt.append(np.array([]))
return ibegin, nval, wgt
......@@ -146,7 +149,7 @@ class DirectSmoothingOperator(SmoothingOperator):
#MR FIXME: this causes calls of log(0.) which should probably be avoided
if self.log_distances:
np.log(distance_array, out=distance_array)
np.log(np.maximum(distance_array,1e-15), out=distance_array)
# collect the local data + ghost cells
local_data_Q = False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment