Skip to content
Snippets Groups Projects
Commit 0ad1f1db authored by Martin Reinecke's avatar Martin Reinecke
Browse files

work around floating point errors

parent 82a92a51
No related branches found
No related tags found
1 merge request!150work around floating point errors
Pipeline #
...@@ -53,10 +53,13 @@ class DirectSmoothingOperator(SmoothingOperator): ...@@ -53,10 +53,13 @@ class DirectSmoothingOperator(SmoothingOperator):
wgt = [] wgt = []
expfac = 1. / (2. * sigma*sigma) expfac = 1. / (2. * sigma*sigma)
for i in range(x.size): for i in range(x.size):
t = x[ibegin[i]:ibegin[i]+nval[i]]-x[i] if nval[i]>0:
t = np.exp(-t*t*expfac) t = x[ibegin[i]:ibegin[i]+nval[i]]-x[i]
t *= 1./np.sum(t) t = np.exp(-t*t*expfac)
wgt.append(t) t *= 1./np.sum(t)
wgt.append(t)
else:
wgt.append(np.array([]))
return ibegin, nval, wgt return ibegin, nval, wgt
...@@ -146,7 +149,7 @@ class DirectSmoothingOperator(SmoothingOperator): ...@@ -146,7 +149,7 @@ class DirectSmoothingOperator(SmoothingOperator):
#MR FIXME: this causes calls of log(0.) which should probably be avoided #MR FIXME: this causes calls of log(0.) which should probably be avoided
if self.log_distances: 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 # collect the local data + ghost cells
local_data_Q = False local_data_Q = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment