예제 #1
0
파일: Solve.py 프로젝트: aymgal/SLIT
def lens_one(Fkappa, n1, n2, size):
    ##DESCRIPTION:
    ##    Function that maps an all at one image to source plane.
    ##
    ##INPUTS:
    ##  -Fkappa: the mapping between source and image planes
    ##  -n1,n2: the shape of the image.
    ##  -size: the factor that scales the shape of the source relative to the shape of the image
    ##
    ##OUTPUTS:
    ##  -lensed: the projection to source plane of an all at aone image.
    dirac = np.ones((n1, n2))
    lensed = Lens.image_to_source(dirac, size, Fkappa, lensed=[0])
    return lensed
예제 #2
0
파일: mk_SLIT_plot.py 프로젝트: aymgal/SLIT
def plot_critical(kappa, Fkappa, n1, n2, size, extra=1):

    det = 1. / Lens.Jacobian_det(kappa, n1, n2)[extra / 2:-extra / 2.,
                                                extra / 2:-extra / 2.]

    kernel = np.array([[1, 0], [0, -1]])
    kernelT = np.array([[0, 1], [-1, 0]])
    diff = np.abs(-det + np.abs(det))

    diff[diff != 0] = 1
    xderiv = scp.convolve2d(diff, kernel, mode='same')
    yderiv = scp.convolve2d(diff, kernelT, mode='same')

    x, y = np.where(np.abs(xderiv) + np.abs(yderiv) > 0)
    #newx,newy = mk_curve(x,y)
    critical = np.zeros((n1, n2))
    critical[x, y] = 1

    Splane = Lens.image_to_source(critical, Fkappa, 0)

    xs, ys = np.where(Splane != 0)
    #newxs,newys = mk_curve(xs,ys)
    factor = np.float(size)
    return x / factor, y / factor, xs, ys
예제 #3
0
#Mass profile of the lens
kappa = pf.open('../Files/kappa.fits')[0].data
Fkappa = Lens.F(kappa, nt1, nt2, size, nt1 / 2., nt2 / 2.)
lensed = slit.lens_one(Fkappa, nt1, nt2, size)

#Levels for normalisation
lev = slit.level(nt1, nt1)

#Starlet transforms of the lens and source in their respective planes
wG = mw.wave_transform(G, lvl=6, newwave=1) / lev
wS = mw.wave_transform(S, lvl=6, newwave=1) / lev
#Lensed source
FS = Lens.source_to_image(S, nt1, nt2, Fkappa)
#Unlensed lens
FG = Lens.image_to_source(G, size, Fkappa, lensed=lensed)
#Starlet transform of the unlensed lens
wFG = mw.wave_transform(FG, 6, newwave=1) / lev
#Starlet transform of the lensed
wFS = mw.wave_transform(FS, 6, newwave=1) / lev


def mk_sort(X):
    Y = np.sort(np.resize(np.abs(X), X.size))
    return Y[::-1]


#Function that computes the reconstruction error from the p% highest coefficients
def error_rec_from(X, p, wave=0):
    Xcopy = np.copy(X)
    Y = mk_sort(X)
예제 #4
0
파일: Solve.py 프로젝트: aymgal/SLIT
 def Lens_op2(I):
     return Lens.image_to_source(I, 1, Fkappa, lensed=lensed, square=1)
예제 #5
0
파일: Solve.py 프로젝트: aymgal/SLIT
 def Finv_apply(I):
     return Lens.image_to_source(I, 1, Fkappa, lensed=lensed)