Commit 1328c826 authored by Martin Reinecke's avatar Martin Reinecke

tweaks

parent 2c7b4895
Pipeline #28350 passed with stages
in 2 minutes and 36 seconds
......@@ -17,8 +17,8 @@ if __name__ == "__main__":
ss = ht(sh)
def make_random_los(n):
starts = np.random.random((2, n))*2-0.5
ends = np.random.random((2, n))*2-0.5
starts = np.random.random((2, n))
ends = np.random.random((2, n))
return starts, ends
nlos = 1000
......
......@@ -11,9 +11,8 @@ from array import array
class Pixellister(object):
Rmax = np.sqrt(3.)*0.5
def __init__(self, start, end, inc):
self._Rmax = 0.5*np.sqrt(start.shape[0]) # cell center to corner
self._start = start
self._dir = end - start
self._dirlen = np.linalg.norm(self._dir, axis=0)
......@@ -25,7 +24,7 @@ class Pixellister(object):
didx = self._dir[:, idx]
t1 = pos2 - self._start[:, idx]
dotpr = np.sum(didx*t1, axis=0)
dotpr = np.maximum(0., np.minimum (self._dirlen[idx], dotpr))
dotpr = np.maximum(0., np.minimum(self._dirlen[idx], dotpr))
return np.linalg.norm(t1 - didx*dotpr, axis=0)
def build_pixellist(self, idx, lo, hi, pixels):
......@@ -34,12 +33,12 @@ class Pixellister(object):
dist = self._losdist(idx, mid)
if np.all(diff == 1):
for i in range(len(dist)):
if dist[i] < self.Rmax:
if dist[i] < self._Rmax:
pixels[0][idx[i]].append(np.sum(self._inc*lo))
pixels[1][idx[i]].append(dist[i])
else:
t1 = mid-lo
idx2 = idx[dist < np.linalg.norm(t1) + self.Rmax]
idx2 = idx[dist < np.linalg.norm(t1) + self._Rmax]
del dist
if len(idx2) > 0:
dim = np.argmax(diff)
......@@ -59,7 +58,8 @@ def _comp_traverse(start, end, shp):
for i in range(-2, -len(shp)-1, -1):
inc[i] = inc[i+1]*shp[i+1]
pl = Pixellister(start, end, inc)
pixels = [[array("l") for _ in range(nlos)], [array("d") for _ in range(nlos)]]
pixels = [[array("l") for _ in range(nlos)],
[array("d") for _ in range(nlos)]]
pl.build_pixellist(np.arange(nlos), np.array(shp)*0, np.array(shp), pixels)
return [(np.array(p), np.exp(-(np.array(w)**2)))
for p, w in zip(pixels[0], pixels[1])]
......
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