[docs]classExternalShear(MassProfile):def__init__(self,gamma_1:float=0.0,gamma_2:float=0.0):""" An `ExternalShear` term, to model the line-of-sight contribution of other galaxies / satellites. The shear angle is defined in the direction of stretching of the image. Therefore, if an object located \ outside the lens is responsible for the shear, it will be offset 90 degrees from the value of angle. Parameters ---------- gamma """super().__init__(centre=(0.0,0.0),ell_comps=(0.0,0.0))self.gamma_1=gamma_1self.gamma_2=gamma_2@propertydefmagnitude(self):returnconvert.shear_magnitude_from(gamma_1=self.gamma_1,gamma_2=self.gamma_2)@propertydefangle(self):returnconvert.shear_angle_from(gamma_1=self.gamma_1,gamma_2=self.gamma_2)defconvergence_func(self,grid_radius:float)->float:return0.0
@aa.grid_dec.to_arraydefconvergence_2d_from(self,grid:aa.type.Grid2DLike,**kwargs):returnnp.zeros(shape=grid.shape[0])@aa.grid_dec.to_arraydefpotential_2d_from(self,grid:aa.type.Grid2DLike,**kwargs):shear_angle=(self.angle-90)##to be onsistent with autolens deflection angle calculationphig=np.deg2rad(shear_angle)shear_amp=self.magnitudephicoord=np.arctan2(grid[:,0],grid[:,1])rcoord=np.sqrt(grid[:,0]**2.0+grid[:,1]**2.0)return-0.5*shear_amp*rcoord**2*np.cos(2*(phicoord-phig))
[docs]@aa.grid_dec.to_vector_yx@aa.grid_dec.transform@aa.grid_dec.relocate_to_radial_minimumdefdeflections_yx_2d_from(self,grid:aa.type.Grid2DLike,**kwargs):""" Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """deflection_y=-np.multiply(self.magnitude,grid[:,0])deflection_x=np.multiply(self.magnitude,grid[:,1])returnself.rotated_grid_from_reference_frame_from(np.vstack((deflection_y,deflection_x)).T)