autolens.HyperGalaxy#

class HyperGalaxy[source]#

Bases: object

By using a HyperGalaxy, the noise-map value in the regions of the image that the galaxy is located are increased.

This prevents over-fitting regions of the data where the model does not provide a good fit (e.g. where a high chi-squared is inferred).

This uses the parent Galaxy’s ‘contribution_map’, which determines the fraction of flux in every pixel of the image that is associated with that galaxy.

The HyperGalaxy class contains free parameters which using the contribution_map then increase the noise.

Using HyperGalaxy’s to perform noise-scaling is described fully in the following HowToGalaxy and HowToLens chapters:

Parameters
  • contribution_factor (float) – Factor that adjusts how much of the galaxy’s light is attributed to the contribution map.

  • noise_factor (float) – Factor by which the noise-map is increased in the regions of the galaxy’s contribution map.

  • noise_power (float) – The power to which the contribution map is raised when scaling the noise-map.

Methods

contribution_map_from

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

hyper_noise_map_from

Returns a hyper noise-map from an input noise-map, which is a noise-map where certain noise map values (typing those corresponding to a poor fit and high chi-squared) are increased.

contribution_map_from(hyper_model_image, hyper_galaxy_image)[source]#

Returns the contribution map of a galaxy, which represents the fraction of flux in each pixel that the galaxy is attributed to contain. This uses the contribution_factor free 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.

The contribution map is described in full in the following HowToGalaxy and HowToLens chapters:

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

Examples

import autogalaxy as ag

# For realistic use, input accurate image from a model-fit to all of the data.
hyper_model_image = ag.Array2D.ones(shape_native=(100, 100), pixel_scales=1.0)

# For realistic use, input accurate image from a model-fit to just one galaxy in the data.
hyper_galaxu_image= ag.Array2D.ones(shape_native=(100, 100), pixel_scales=1.0)

hyper_galaxy = ag.HyperGalaxy(contribution_factor=1.0)

galaxy = ag.Galaxy(
    redshift=1.0,
    hyper_galaxy=hyper_galaxy,
)

contribution_map = galaxy.hyper_galaxy.contribution_map_from(
    hyper_galaxy_image=hyper_galaxu_image,
    hyper_model_image=hyper_model_image,
)
Return type

Array2D

hyper_noise_map_from(noise_map, contribution_map)[source]#

Returns a hyper noise-map from an input noise-map, which is a noise-map where certain noise map values (typing those corresponding to a poor fit and high chi-squared) are increased.

Parameters
  • noise_map (Array2D) – The input noise-map (before scaling), which normally corresponds to the noise_map of the data being fitted.

  • contribution_map (Array2D) – The contribution map of the galaxy, which represents the fraction of flux in each pixel that the galaxy is attributed to contain.

Examples

import autogalaxy as ag

# For realistic use, input noise-map of observed data.
hyper_model_image = ag.Array2D.ones(shape_native=(100, 100), pixel_scales=1.0)

# For realistic use, input accurate image of a model-fit to all galaxies in the data.
hyper_model_image = ag.Array2D.ones(shape_native=(100, 100), pixel_scales=1.0)

# For realistic use, input accurate image from a model-fit of only this galaxy.
hyper_galaxy_image = ag.Array2D.ones(shape_native=(100, 100), pixel_scales=1.0)

hyper_galaxy = ag.HyperGalaxy(contribution_factor=1.0)

galaxy = ag.Galaxy(
    redshift=1.0,
    hyper_galaxy=hyper_galaxy,
)

contribution_map = galaxy.hyper_galaxy.contribution_map_from(
    hyper_galaxy_image=hyper_galaxu_image,
    hyper_model_image=hyper_model_image,
)

hyper_noise_map = galaxy.hyper_galaxy.hyper_noise_map_from(
    noise_map=noise_map,
    contribution_map=contribution_map
)
Return type

Array2D