def __init__( self, redshift: float, pixelization: Optional[pix.Pixelization] = None, regularization: Optional[reg.Regularization] = None, hyper_galaxy: Optional["HyperGalaxy"] = None, **kwargs, ): """Class representing a galaxy, which is composed of attributes used for fitting hyper_galaxies (e.g. light profiles, \ mass profiles, pixelizations, etc.). All *has_* methods retun `True` if galaxy has that attribute, `False` if not. Parameters ---------- redshift The redshift of the galaxy. light_profiles: [lp.LightProfile] A list of the galaxy's light profiles. mass_profiles: [mp.MassProfile] A list of the galaxy's mass profiles. hyper_galaxy : HyperGalaxy The hyper_galaxies-parameters of the hyper_galaxies-galaxy, which is used for performing a hyper_galaxies-analysis on the noise-map. Attributes ---------- pixelization : inversion.Pixelization The pixelization of the galaxy used to reconstruct an observed image using an inversion. regularization : inversion.Regularization The regularization of the pixel-grid used to reconstruct an observed using an inversion. """ super().__init__() self.redshift = redshift self.hyper_model_image = None self.hyper_galaxy_image = None for name, val in kwargs.items(): setattr(self, name, val) self.pixelization = pixelization self.regularization = regularization if pixelization is not None and regularization is None: raise exc.GalaxyException( "If the galaxy has a pixelization, it must also have a regularization." ) if pixelization is None and regularization is not None: raise exc.GalaxyException( "If the galaxy has a regularization, it must also have a pixelization." ) self.hyper_galaxy = hyper_galaxy
def mass_angular_within_circle(self, radius: float): """ Integrate the mass profiles's convergence profile to compute the total mass within a circle of \ specified radius. This is centred on the mass profile. The following unit_label for mass can be specified and output: - Dimensionless angular unit_label (default) - 'angular'. - Solar masses - 'angular' (multiplies the angular mass by the critical surface mass density). Parameters ---------- radius : dim.Length The radius of the circle to compute the dimensionless mass within. unit_mass : str The unit_label the mass is returned in {angular, angular}. critical_surface_density : float or None The critical surface mass density of the strong lens configuration, which converts mass from angulalr \ unit_label to phsical unit_label (e.g. solar masses). """ if self.has_mass_profile: return sum( map( lambda p: p.mass_angular_within_circle(radius=radius), self.mass_profiles, )) else: raise exc.GalaxyException( "You cannot perform a mass-based calculation on a galaxy which does not have a mass-profile" )
def dark_mass_angular_within_circle(self, radius: float): if self.has_dark_profile: return sum([ profile.mass_angular_within_circle(radius=radius) for profile in self.dark_profiles ]) else: raise exc.GalaxyException( "You cannot perform a dark mass-based calculation on a galaxy which does not have a dark mass-profile" )
def stellar_mass_angular_within_circle_from(self, radius: float): if self.has_stellar_profile: return sum( [ profile.mass_angular_within_circle_from(radius=radius) for profile in self.stellar_profile_list ] ) else: raise exc.GalaxyException( "You cannot perform a stellar mass-based calculation on a galaxy which does not have a stellar " "mass-profile " )
def __init__( self, galaxy_data, mask, grid_class=grid_2d.Grid2D, fractional_accuracy=0.9999, sub_steps=None, pixel_scales_interp=None, use_image=False, use_convergence=False, use_potential=False, use_deflections_y=False, use_deflections_x=False, ): """ A galaxy-fit data is a collection of fit data components which are used to fit a galaxy to another galaxy. \ This is where a component of a galaxy's light profiles (e.g. image) or mass profiles (e.g. surface \ density, potential or deflection angles) are fitted to one another. This is primarily performed for automatic prior linking, as a means to efficiently link the priors of a galaxy \ using one inferred parametrization of light or mass profiles to a new galaxy with a different parametrization \ of light or mass profiles. This omits a number of the fit data components typically used when fitting an image (e.g. the observed image, PSF, \ exposure time map), but still has a number of the other components (e.g. an effective noise_map, grid_stacks). Parameters ---------- galaxy_data : GalaxyData The collection of data about the galaxy (image of its profile map, noise-map, etc.) that is fitted. mask: aa.AbstractMask The 2D masks that is applied to image fit data. sub_size : int The size of the sub-grid used for computing the SubGrid (see imaging.masks.SubGrid). Attributes ---------- noise_map_1d : np.ndarray The masked 1D arrays of the noise_map grid_stacks : imaging.masks.GridStack Grids of (y,x) Cartesian coordinates which map over the masked 1D fit data arrays's pixels (includes an \ grid, sub-grid, etc.) """ self.mask = mask self.galaxy_data = galaxy_data self.pixel_scales = galaxy_data.pixel_scales self.image = array_2d.Array2D.manual_mask( array=galaxy_data.image.binned.native, mask=mask.mask_sub_1) self.noise_map = array_2d.Array2D.manual_mask( array=galaxy_data.noise_map.binned.native, mask=mask.mask_sub_1) self.signal_to_noise_map = self.image / self.noise_map self.sub_size = mask.sub_size self.grid = abstract_dataset.grid_from_mask_and_grid_class( mask=mask, grid_class=grid_class, fractional_accuracy=fractional_accuracy, sub_steps=sub_steps, pixel_scales_interp=pixel_scales_interp, ) if all(not element for element in [ use_image, use_convergence, use_potential, use_deflections_y, use_deflections_x, ]): raise exc.GalaxyException( "The galaxy fit data has not been supplied with a use_ method." ) if (sum([ use_image, use_convergence, use_potential, use_deflections_y, use_deflections_x, ]) > 1): raise exc.GalaxyException( "The galaxy fit data has not been supplied with multiple use_ methods, only supply " "one.") self.use_image = use_image self.use_convergence = use_convergence self.use_potential = use_potential self.use_deflections_y = use_deflections_y self.use_deflections_x = use_deflections_x
def __init__( self, redshift: float, pixelization: Optional[AbstractPixelization] = None, regularization: Optional[AbstractRegularization] = None, hyper_galaxy: Optional["HyperGalaxy"] = None, **kwargs, ): """ Class representing a galaxy, which is composed of attributes used for fitting hyper_galaxies (e.g. light profiles, \ mass profiles, pixelizations, etc.). All *has_* methods retun `True` if galaxy has that attribute, `False` if not. Parameters ---------- redshift The redshift of the galaxy. pixelization : inversion.Pixelization The pixelization of the galaxy used to reconstruct an observed image using an inversion. regularization : inversion.Regularization The regularization of the pixel-grid used to reconstruct an observed using an inversion. hyper_galaxy The hyper_galaxies-parameters of the hyper_galaxies-galaxy, which is used for performing a hyper_galaxies-analysis on the noise-map. Attributes ---------- light_profile_list A list of the galaxy's light profiles. mass_profile_list A list of the galaxy's mass profiles. hyper_model_image The best-fit model image to the observed image from a previous analysis search. This provides the total light attributed to each image pixel by the model. hyper_galaxy_image A model image of the galaxy (from light profiles or an inversion) from a previous analysis search. """ super().__init__() self.redshift = redshift self.hyper_model_image = None self.hyper_galaxy_image = None for name, val in kwargs.items(): setattr(self, name, val) self.pixelization = pixelization self.regularization = regularization if pixelization is not None and regularization is None: raise exc.GalaxyException( "If the galaxy has a pixelization, it must also have a regularization." ) if pixelization is None and regularization is not None: raise exc.GalaxyException( "If the galaxy has a regularization, it must also have a pixelization." ) self.hyper_galaxy = hyper_galaxy