autolens.Galaxy#
- class Galaxy[source]#
Bases:
ModelObject,OperateImageListClass representing a galaxy, which is composed of attributes used for fitting galaxies (e.g. light profiles, mass profiles, pixelizations, etc.).
All has_ methods retun True if galaxy has that attribute, False if not.
- Parameters:
redshift (
float) – The redshift of the galaxy.pixelization – The pixelization of the galaxy used to reconstruct an observed image using an inversion.
Methods
blurred_image_2d_fromEvaluate the light object's 2D image from a input 2D grid of coordinates and convolve it with a PSF.
blurred_image_2d_list_fromEvaluate the light object's list of 2D images from a input 2D grid of coordinates and convolve each image with a PSF.
Returns a list of objects in the galaxy which are an instance of the input cls.
Returns the summed 2D convergence of the galaxy's mass profiles from a 2D grid of Cartesian (y,x) coordinates.
Returns the summed 2D deflection angles of the galaxy's mass profiles from a 2D grid of Cartesian (y,x) coordinates.
A dictionary representation of this object
Returns an attribute of a class and its children profiles in the galaxy as a ValueIrregular or Grid2DIrregular object.
from_dictRecursively parse a dictionary returning the model, collection or instance that is represents.
hasDoes this instance have an attribute which is of type cls?
Returns the 2D image of all galaxy light profiles summed from a 2D grid of Cartesian (y,x) coordinates.
Returns a list of the 2D images of the galaxy's light profiles from a 2D grid of Cartesian (y,x) coordinates.
Returns the total luminosity of the galaxy's light profiles within a circle of specified radius.
Integrate the mass profiles's convergence profile to compute the total mass within a circle of specified radius.
next_idpadded_image_2d_fromEvaluate the light object's 2D image from a input 2D grid of padded coordinates, where this padding is sufficient to encapsulate all surrounding pixels that will blur light into the original image given the 2D shape of the PSF's kernel.
Returns the summed 2D potential of the galaxy's mass profiles from a 2D grid of Cartesian (y,x) coordinates.
replacing_for_pathCreate a new model replacing the value for a given path with a new value
Iterate over every galaxy finding all LightProfileSNR light profiles and set their intensity values to values which give their input signal_to_noise_ratio value, which is performed as follows:
Trace an input grid of (y,x) coordinates through the galaxy's deflection angles.
unmasked_blurred_image_2d_fromEvaluate the light object's 2D image from a input 2D grid of coordinates and convolve it with a PSF, using a grid which is not masked.
unmasked_blurred_image_2d_list_fromEvaluate the light object's list of 2D images from a input 2D grid of coordinates and convolve it with a PSF, using a grid which is not masked.
visibilities_fromEvaluate the light object's 2D image from a input 2D grid of coordinates and transform this to an array of visibilities using a autoarray.operators.transformer.Transformer object and therefore a Fourier Transform.
visibilities_list_fromEvaluate the light object's list of 2D image from a input 2D grid of coordinates and transform each image to arrays of visibilities using a autoarray.operators.transformer.Transformer object and therefore a Fourier Transform.
Attributes
component_numberThe half-light radius of the galaxy.
identifierlabel- cls_list_from(cls, cls_filtered=None)[source]#
Returns a list of objects in the galaxy which are an instance of the input cls.
The optional cls_filtered input removes classes of an input instance type.
For example:
If the input is cls=ag.LightProfile, a list containing all light profiles in the galaxy is returned.
If cls=ag.LightProfile and cls_filtered=ag.LightProfileLinear, a list of all light profiles excluding those which are linear light profiles will be returned.
- image_2d_list_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>, operated_only=None)[source]#
Returns a list of the 2D images of the galaxy’s light profiles from a 2D grid of Cartesian (y,x) coordinates.
If the galaxy has no light profiles, a numpy array of zeros is returned.
The images output by this function do not include instrument operations, such as PSF convolution (for imaging data) or a Fourier transform (for interferometer data).
Inherited methods in the autogalaxy.operate.image package can apply these operations to the images. These functions may have the operated_only input passed to them, which is why this function includes the operated_only input.
If the operated_only input is included, the function omits light profiles which are parents of the LightProfileOperated object, which signifies that the light profile represents emission that has already had the instrument operations (e.g. PSF convolution, a Fourier transform) applied to it and therefore that operation is not performed again.
See the autogalaxy.profiles.light package for details of how images are computed from a light profile.
- Parameters:
grid (
Union[ndarray,Grid2D,Grid2DIrregular]) – The 2D (y, x) coordinates where values of the image are evaluated.operated_only (
Optional[bool]) – By default, the returned list contains all light profile images (irrespective of whether they have been operated on or not). If this input is included as a bool, only images which are or are not already operated are included in the list, with the images of other light profiles created as a numpy array of zeros.
- image_2d_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>, operated_only=None)[source]#
Returns the 2D image of all galaxy light profiles summed from a 2D grid of Cartesian (y,x) coordinates.
This function first computes the image of each galaxy, via the function image_2d_list_from. The images are then summed to give the overall image of the galaxies.
Refer to the function image_2d_list_from for a full description of the calculation and how the operated_only input is used.
- Parameters:
grid (
Union[ndarray,Grid2D,Grid2DIrregular]) – The 2D (y, x) coordinates where values of the image are evaluated.operated_only (
Optional[bool]) – The returned list from this function contains all light profile images, and they are never operated on (e.g. via the imaging PSF). However, inherited methods in the autogalaxy.operate.image package can apply these operations to the images, which may have the operated_only input passed to them. This input therefore is used to pass the operated_only input to these methods.
- deflections_yx_2d_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>, **kwargs)[source]#
Returns the summed 2D deflection angles of the galaxy’s mass profiles from a 2D grid of Cartesian (y,x) coordinates.
If the galaxy has no mass profiles, a numpy array of zeros is returned.
See the autogalaxy.profiles.mass package for details of how deflection angles are computed from a mass profile.
The decorator to_vector_yx converts the output arrays from ndarrays to a VectorYX2D data structure using the input grid’s attributes.
- Parameters:
grid (
Union[ndarray,Grid2D,Grid2DIrregular]) – The 2D (y, x) coordinates where values of the deflection angles are evaluated.
- convergence_2d_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>, **kwargs)[source]#
Returns the summed 2D convergence of the galaxy’s mass profiles from a 2D grid of Cartesian (y,x) coordinates.
If the galaxy has no mass profiles, a numpy array of zeros is returned.
See the autogalaxy.profiles.mass package for details of how convergences are computed from a mass profile.
The decorator grid_2d_to_structure converts the output arrays from ndarrays to an Array2D data structure using the input grid’s attributes.
- Parameters:
grid (
Union[ndarray,Grid2D,Grid2DIrregular]) – The 2D (y, x) coordinates where values of the convergence are evaluated.
- property half_light_radius#
The half-light radius of the galaxy.
Returns None because a Galaxy may contain multiple light profiles with different effective radii; there is no single half-light radius that characterises the whole galaxy. Individual light profile components expose their own half_light_radius / effective_radius attributes.
- traced_grid_2d_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Trace an input grid of (y,x) coordinates through the galaxy’s deflection angles.
The traced grid is computed as:
β = θ − α(θ)
where θ is the image-plane grid and α(θ) are the deflection angles from the galaxy’s mass profiles.
This is the lensing ray-tracing step that maps image-plane positions to source-plane positions.
- Parameters:
grid (
Union[ndarray,Grid2D,Grid2DIrregular]) – The 2D (y, x) image-plane coordinates to be traced to the source plane.- Returns:
The source-plane (y, x) coordinates after deflection.
- Return type:
aa.type.Grid2DLike
- potential_2d_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>, **kwargs)[source]#
Returns the summed 2D potential of the galaxy’s mass profiles from a 2D grid of Cartesian (y,x) coordinates.
If the galaxy has no mass profiles, a numpy array of zeros is returned.
See the autogalaxy.profiles.mass package for details of how potentials are computed from a mass profile.
The decorator grid_2d_to_structure converts the output arrays from ndarrays to an Array2D data structure using the input grid’s attributes.
- Parameters:
grid (
Union[ndarray,Grid2D,Grid2DIrregular]) – The 2D (y, x) coordinates where values of the potential are evaluated.
- extract_attribute(cls, attr_name)[source]#
Returns an attribute of a class and its children profiles in 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:
ArrayIrregular(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.
- luminosity_within_circle_from(radius)[source]#
Returns the total luminosity of the galaxy’s light profiles within a circle of specified radius.
See light_profile.luminosity_within_circle for details of how this is performed.
- Parameters:
radius (
float) – The radius of the circle to compute the dimensionless mass within.unit_luminosity – 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.
- mass_angular_within_circle_from(radius)[source]#
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 (
float) – The radius of the circle to compute the dimensionless mass within.unit_mass – The unit_label the mass is returned in {angular, angular}.
None (critical_surface_density or) – 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).
- set_snr_of_snr_light_profiles(grid, exposure_time, background_sky_level=0.0, psf=None)[source]#
Iterate over every galaxy finding all LightProfileSNR light profiles and set their intensity values to values which give their input signal_to_noise_ratio value, which is performed as follows:
Evaluate the image of each light profile on the input grid.
Blur this image with a PSF, if included.
Take the value of the brightest pixel.
Use an input exposure_time and background_sky (e.g. from the SimulatorImaging object) to determine what value of intensity gives the desired signal to noise ratio for the image.
- Parameters:
grid (
Union[ndarray,Grid2D,Grid2DIrregular]) – The (y, x) coordinates in the original reference frame of the grid.exposure_time (
float) – The exposure time of the simulated imaging.background_sky_level (
float) – The level of the background sky of the simulated imaging.psf (
Optional[Convolver]) – The psf of the simulated imaging which can change the S/N of the light profile due to spreading out the emission.