Commit a141d66e authored by Martin Reinecke's avatar Martin Reinecke

something seems to be working

parent b76e0847
......@@ -13,7 +13,8 @@ def _dist_from_LOS(start, end, pos):
start = start.reshape((-1,1))
end = end.reshape((-1,1))
dir = end-start
dir *= 1./np.sqrt(np.sum(dir*dir))
dlen = np.sqrt(np.sum(dir*dir))
dir *= 1./dlen
t1 = pos - start
dotpr = np.sum(dir*t1,axis=0)
t2 = start + dir*dotpr.reshape((1,-1))
......@@ -22,7 +23,7 @@ def _dist_from_LOS(start, end, pos):
d2 = np.sqrt(np.sum(t1*t1,axis=0))
d3 = pos-end
d3 = np.sqrt(np.sum(d3*d3,axis=0))
return np.where(dotpr<0, d2, np.where(dotpr<1, d1,d3))
return np.where(dotpr<0, d2, np.where(dotpr<dlen, d1, d3))
def _comp_traverse(start, end, shp, dist):
ndim = start.shape[0]
......@@ -30,6 +31,11 @@ def _comp_traverse(start, end, shp, dist):
inc = np.full(len(shp), 1)
for i in range(-2, -len(shp)-1, -1):
inc[i] = inc[i+1]*shp[i+1]
combo = [0]
for i in range(len(shp)):
tmp = [x+inc[i] for x in combo]
tmp += [x-inc[i] for x in combo]
combo += tmp
pmax = np.array(shp)
......@@ -79,7 +85,18 @@ def _comp_traverse(start, end, shp, dist):
mdist = 0.5*(cdist[:-1]+cdist[1:])
add = np.append(pos1, add)
add = np.cumsum(add)
out[i] = (add, wgt)
zone = set()
for x in combo:
zone.update(add+x)
npix = np.prod(shp)
zone = [z for z in zone if z>=0 and z<npix]
fullidx = np.unravel_index(zone, shp)
fullidx=np.array(fullidx)
xdist = _dist_from_LOS(start[:,i], end[:,i], fullidx)
xxwgt = np.exp(-9*xdist*xdist)
twgt = np.sum(xxwgt)
xxwgt /= twgt
out[i] = (np.array(zone), np.array(xxwgt))
return out
......@@ -143,7 +160,7 @@ class LOSResponse(LinearOperator):
w_i = _comp_traverse(localized_pixel_starts,
localized_pixel_ends,
self._local_shape,
np.array(self.domain[0].distances))
np.array(self.domain[0].distances[0]))
boxsz = 16
nlos = len(w_i)
......
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