def zoom_source(self, x_pos, y_pos, kwargs_lens, source_sigma=0.003, window_size=0.1, grid_number=100, shape="GAUSSIAN"): """ computes the surface brightness on an image with a zoomed window :param x_pos: angular coordinate of center of image :param y_pos: angular coordinate of center of image :param kwargs_lens: lens model parameter list :param source_sigma: source size (in angular units) :param window_size: window size in angular units :param grid_number: number of grid points per axis :param shape: string, shape of source, supports 'GAUSSIAN' and 'TORUS :return: 2d numpy array """ deltaPix = float(window_size) / grid_number if shape == 'GAUSSIAN': from lenstronomy.LightModel.Profiles.gaussian import Gaussian quasar = Gaussian() elif shape == 'TORUS': import lenstronomy.LightModel.Profiles.ellipsoid as quasar else: raise ValueError("shape %s not valid for finite magnification computation!" % shape) x_grid, y_grid = util.make_grid(numPix=grid_number, deltapix=deltaPix, subgrid_res=1) center_x, center_y = self._lensModel.ray_shooting(x_pos, y_pos, kwargs_lens) betax, betay = self._lensModel.ray_shooting(x_grid + x_pos, y_grid + y_pos, kwargs_lens) image = quasar.function(betax, betay, 1., source_sigma, center_x, center_y) return util.array2image(image)
def test_function(self): """ :return: """ output = torus.function(x=1, y=1, amp=1., sigma=2, center_x=0, center_y=0) assert output == 0.079577471545947673
def magnification_finite(self, x_pos, y_pos, kwargs_lens, source_sigma=0.003, window_size=0.1, grid_number=100, shape="GAUSSIAN", polar_grid=False, aspect_ratio=0.5): """ returns the magnification of an extended source with Gaussian light profile :param x_pos: x-axis positons of point sources :param y_pos: y-axis position of point sources :param kwargs_lens: lens model kwargs :param source_sigma: Gaussian sigma in arc sec in source :param window_size: size of window to compute the finite flux :param grid_number: number of grid cells per axis in the window to numerically comute the flux :return: numerically computed brightness of the sources """ mag_finite = np.zeros_like(x_pos) deltaPix = float(window_size)/grid_number if shape == 'GAUSSIAN': from lenstronomy.LightModel.Profiles.gaussian import Gaussian quasar = Gaussian() elif shape == 'TORUS': import lenstronomy.LightModel.Profiles.ellipsoid as quasar else: raise ValueError("shape %s not valid for finite magnification computation!" % shape) x_grid, y_grid = util.make_grid(numPix=grid_number, deltapix=deltaPix, subgrid_res=1) if polar_grid is True: a = window_size*0.5 b = window_size*0.5*aspect_ratio ellipse_inds = (x_grid*a**-1) **2 + (y_grid*b**-1) **2 <= 1 x_grid, y_grid = x_grid[ellipse_inds], y_grid[ellipse_inds] for i in range(len(x_pos)): ra, dec = x_pos[i], y_pos[i] center_x, center_y = self._lensModel.ray_shooting(ra, dec, kwargs_lens) if polar_grid is True: theta = np.arctan2(dec,ra) xcoord, ycoord = util.rotate(x_grid, y_grid, theta) else: xcoord, ycoord = x_grid, y_grid betax, betay = self._lensModel.ray_shooting(xcoord + ra, ycoord + dec, kwargs_lens) I_image = quasar.function(betax, betay, 1., source_sigma, center_x, center_y) mag_finite[i] = np.sum(I_image) * deltaPix**2 return mag_finite