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
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
def mk_bound(Fkappa, n1, n2, size): ##DESCRIPTION: ## Function that returns the support of the lens image in 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_bound(dirac, size, Fkappa, lensed=[0]) bound = lensed / lensed bound[lensed == 0] = 0 return bound
import SLIT as slit from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes from mpl_toolkits.axes_grid1.inset_locator import mark_inset import warnings warnings.simplefilter("ignore") S = pf.open('../Files/source.fits')[0].data G = pf.open('../Files/Galaxy.fits')[0].data ##Sizes in image and source planes nt1 = 100 nt2 = 100 size = 1 #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
def F_apply(Si): return Lens.source_to_image(Si, ns1, ns2, Fkappa)
def Lens_op2(I): return Lens.image_to_source(I, 1, Fkappa, lensed=lensed, square=1)
def Finv_apply(I): return Lens.image_to_source(I, 1, Fkappa, lensed=lensed)