12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- import numpy as np
- import scipy.sparse as sp
- def sys_matrix(nx, ny, nb, na, mask):
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- x,y = np.meshgrid(np.arange(0,nx)-(nx-1)/2., np.arange(0,ny)-(ny-1)/2.)
- x = x[mask]
- y = y[mask]
- npts = len(x)
- angle = np.arange(0,na) * (np.pi/na);
- tau = np.outer(np.cos(angle),x) + np.outer(np.sin(angle), y)
- tau += nb/2.
- ibl = np.floor(tau).astype(int)
- val = 1 - (tau-ibl)
-
- ii = ibl + nb*np.outer(np.arange(0,na),np.ones(npts)).astype(int)
-
- good = np.logical_and(ibl > -1,ibl < nb)
- if not(good.any()):
- print ('FOV too small')
- return
-
- nc = nx * ny
- jj = mask.ravel().nonzero()
- jj=np.outer(np.ones(na),jj).astype(int)
- G1 = sp.csc_matrix((val[good],(ii[good],jj[good])),shape=[nb*na,nc])
- good1 = (ibl > -2) & (ibl < nb-1)
- G2 = sp.csc_matrix((1-val[good1],(ii[good1]+1,jj[good1])),shape=[nb*na,nc])
- return G1 + G2
|