# autolens.Galaxy¶

class autolens.Galaxy(redshift: float, pixelization: Optional[autoarray.inversion.pixelizations.abstract.AbstractPixelization] = None, regularization: Optional[autoarray.inversion.regularization.abstract.AbstractRegularization] = None, hyper_galaxy: Optional[HyperGalaxy] = None, **kwargs)

@DynamicAttrs

__init__(redshift: float, pixelization: Optional[autoarray.inversion.pixelizations.abstract.AbstractPixelization] = None, regularization: Optional[autoarray.inversion.regularization.abstract.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. 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.
pixelization

The pixelization of the galaxy used to reconstruct an observed image using an inversion.

Type: inversion.Pixelization
regularization

The regularization of the pixel-grid used to reconstruct an observed using an inversion.

Type: inversion.Regularization

Methods

 __init__(redshift, pixelization, …) Class representing a galaxy, which is composed of attributes used for fitting hyper_galaxies (e.g. area_within_tangential_critical_curve_from(grid) blurred_image_2d_via_convolver_from(grid, …) blurred_image_2d_via_psf_from(grid, psf[, …]) caustics_from(grid[, pixel_scale]) convergence_1d_from(grid) Returns the summed 1D convergence of the galaxy’s mass profiles using a grid of Cartesian (y,x) coordinates. convergence_2d_from(grid) Returns the summed 2D convergence of the galaxy’s mass profiles using a grid of Cartesian (y,x) coordinates. convergence_func(grid_radius) convergence_via_hessian_from(grid[, buffer]) convergence_via_jacobian_from(grid[, jacobian]) critical_curves_from(grid[, pixel_scale]) dark_fraction_at_radius(radius) dark_mass_angular_within_circle(radius) deflection_magnitudes_from(grid) deflections_2d_from(grid) Returns the summed (y,x) deflection angles of the galaxy’s mass profiles using a grid of Cartesian (y,x) coordinates. deflections_2d_via_potential_2d_from(grid) dict() A dictionary representation of this object einstein_mass_angular_from(grid[, pixel_scale]) einstein_radius_from(grid[, pixel_scale]) extract_attribute(cls, attr_name) Returns an attribute of a class and its children profiles in the the galaxy as a ValueIrregular or Grid2DIrregular object. from_dict(d) Recursively parse a dictionary returning the model, collection or instance that is represents. hessian_from(grid[, buffer, deflections_func]) image_1d_from(grid) Returns the summed 1D image of all of the galaxy’s light profiles using an input grid of Cartesian (y,x) coordinates. image_2d_from(grid) Returns the summed 2D image of all of the galaxy’s light profiles using an input grid of Cartesian (y,x) coordinates. jacobian_from(grid) luminosity_within_circle(radius) Returns the total luminosity of the galaxy’s light profiles within a circle of specified radius. magnification_2d_from(grid) magnification_via_hessian_from(grid[, …]) mass_angular_within_circle(radius) Integrate the mass profiles’s convergence profile to compute the total mass within a circle of specified radius. mass_integral(x) Routine to integrate an elliptical light profiles - set axis ratio to 1 to compute the luminosity within a circle potential_1d_from(grid) Returns the summed 2D gravitational potential of the galaxy’s mass profiles using a grid of Cartesian (y,x) coordinates. potential_2d_from(grid) Returns the summed 2D gravitational potential of the galaxy’s mass profiles using a grid of Cartesian (y,x) coordinates. potential_func(u, y, x) profile_visibilities_via_transformer_from(…) radial_caustic_from(grid[, pixel_scale]) radial_critical_curve_from(grid[, pixel_scale]) radial_eigen_value_from(grid[, jacobian]) shear_via_hessian_from(grid[, buffer]) shear_via_jacobian_from(grid[, jacobian]) shear_yx_via_hessian_from(grid[, buffer]) shear_yx_via_jacobian_from(grid[, jacobian]) stellar_fraction_at_radius(radius) stellar_mass_angular_within_circle(radius) tangential_caustic_from(grid[, pixel_scale]) tangential_critical_curve_from(grid[, …]) tangential_eigen_value_from(grid[, jacobian])

Attributes

 angle centre component_number contribution_map Returns the contribution map of a galaxy, which represents the fraction of flux in each pixel that the galaxy is attributed to contain, hyper to the contribution_factor hyper_galaxies-parameter. dark_profiles has_dark_profile has_hyper_galaxy has_light_profile has_mass_profile has_pixelization has_profile has_redshift has_regularization has_stellar_profile identifier light_profiles mass_profiles point_dict stellar_profiles uses_cluster_inversion
extract_attribute(cls, attr_name)

Returns an attribute of a class and its children profiles in the the galaxy as a ValueIrregular or Grid2DIrregular object.

For example, if a galaxy has two light profiles and we want the LightProfile axis-ratios, the following:

galaxy.extract_attribute(cls=LightProfile, name=”axis_ratio”

would return:

ValuesIrregular(values=[axis_ratio_0, axis_ratio_1])

If a galaxy has three mass profiles and we want the MassProfile centres, the following:

galaxy.extract_attribute(cls=MassProfile, name=”centres”

would return:

GridIrregular2D(grid=[(centre_y_0, centre_x_0), (centre_y_1, centre_x_1), (centre_y_2, centre_x_2)])

This is used for visualization, for example plotting the centres of all light profiles colored by their profile.

image_1d_from(grid)

Returns the summed 1D image of all of the galaxy’s light profiles using an input grid of Cartesian (y,x) coordinates.

If the galaxy has no light profiles, a grid of zeros is returned.

See profiles.light_profiles for a description of how light profile images are computed.

Parameters: grid – The (y, x) coordinates in the original reference frame of the grid.
image_2d_from(grid)

Returns the summed 2D image of all of the galaxy’s light profiles using an input grid of Cartesian (y,x) coordinates.

If the galaxy has no light profiles, a grid of zeros is returned.

See profiles.light_profiles for a description of how light profile images are computed.

Parameters: grid – The (y, x) coordinates in the original reference frame of the grid.
luminosity_within_circle(radius: float)

Returns the total luminosity of the galaxy’s light profiles within a circle of specified radius.

See light_profiles.luminosity_within_circle for details of how this is performed.
Parameters: radius The radius of the circle to compute the dimensionless mass within. unit_luminosity : str The unit_label the luminosity is returned in {esp, counts}. exposure_time The exposure time of the observation, which converts luminosity from electrons per second unit_label to counts.
convergence_1d_from(grid)

Returns the summed 1D convergence of the galaxy’s mass profiles using a grid of Cartesian (y,x) coordinates.

If the galaxy has no mass profiles, a grid of zeros is returned.

See profiles.mass_profiles module for details of how this is performed.

The grid_1d_to_structure decorator reshapes the NumPy arrays the convergence is outputted on. See aa.grid_1d_to_structure for a description of the output.

Parameters: grid – The (y, x) coordinates in the original reference frame of the grid.
convergence_2d_from(grid)

Returns the summed 2D convergence of the galaxy’s mass profiles using a grid of Cartesian (y,x) coordinates.

If the galaxy has no mass profiles, a grid of zeros is returned.

See profiles.mass_profiles module for details of how this is performed.

The grid_2d_to_structure decorator reshapes the NumPy arrays the convergence is outputted on. See aa.grid_2d_to_structure for a description of the output.

Parameters: grid – The (y, x) coordinates in the original reference frame of the grid.
potential_1d_from(grid)

Returns the summed 2D gravitational potential of the galaxy’s mass profiles using a grid of Cartesian (y,x) coordinates.

If the galaxy has no mass profiles, a grid of zeros is returned.

See profiles.mass_profiles module for details of how this is performed.

The grid_2d_to_structure decorator reshapes the NumPy arrays the convergence is outputted on. See aa.grid_2d_to_structure for a description of the output.

Parameters: grid – The (y, x) coordinates in the original reference frame of the grid.
potential_2d_from(grid)

Returns the summed 2D gravitational potential of the galaxy’s mass profiles using a grid of Cartesian (y,x) coordinates.

If the galaxy has no mass profiles, a grid of zeros is returned.

See profiles.mass_profiles module for details of how this is performed.

The grid_2d_to_structure decorator reshapes the NumPy arrays the convergence is outputted on. See aa.grid_2d_to_structure for a description of the output.

Parameters: grid – The (y, x) coordinates in the original reference frame of the grid.
deflections_2d_from(grid)

Returns the summed (y,x) deflection angles of the galaxy’s mass profiles using a grid of Cartesian (y,x) coordinates.

If the galaxy has no mass profiles, two grid of zeros are returned.

See profiles.mass_profiles module for details of how this is performed.

Parameters: grid – The (y, x) coordinates in the original reference frame of the grid.
mass_angular_within_circle(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}. or None (critical_surface_density) – 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).
contribution_map

Returns the contribution map of a galaxy, which represents the fraction of flux in each pixel that the galaxy is attributed to contain, hyper to the contribution_factor hyper_galaxies-parameter.

This is computed by dividing that galaxy’s flux by the total flux in that pixel and then scaling by the maximum flux such that the contribution map ranges between 0 and 1.

Parameters: hyper_model_image (np.ndarray) – 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 (np.ndarray) – A model image of the galaxy (from light profiles or an inversion) from a previous analysis search.