synthesizer.parametric.morphology

A module for defining parametric morphologies for use in making images.

This module provides a base class for defining parametric morphologies, and specific classes for the Sersic profile and point sources. The base class provides a common interface for defining morphologies, and the specific classes provide the functionality for the Sersic profile and point sources.

Example usage:

# Import the module
from synthesizer import morphology

# Define a Sersic profile
sersic = morphology.Sersic(r_eff=10.0, sersic_index=4, ellipticity=0.5)

# Define a point source
point_source = morphology.PointSource(offset=[0.0, 0.0])

Classes

class synthesizer.parametric.morphology.Gaussian2D(x_mean, y_mean, stddev_x, stddev_y, rho=0)[source]

A class holding a 2-dimensional Gaussian distribution.

This is a morphology where a 2-dimensional Gaussian density grid is populated based on provided x and y values.

x_mean

(float) The mean of the Gaussian along the x-axis.

y_mean

(float) The mean of the Gaussian along the y-axis.

stddev_x

(float) The standard deviation along the x-axis.

stddev_y

(float) The standard deviation along the y-axis.

rho

(float) The population correlation coefficient between x and y.

compute_density_grid(x, y, units=None)[source]

Compute density grid.

Parameters:
  • x – array-like (float) A 1D array of x values.

  • y – array-like (float) A 1D array of y values.

Returns:

np.ndarray:

A 2D array representing the Gaussian density values at each (x, y) point.

Return type:

g_2d_mat

Raises:

ValueError – If either x or y is None.

Examples using synthesizer.parametric.morphology.Gaussian2D

Generate parametric morphology profile

Generate parametric morphology profile
class synthesizer.parametric.morphology.MorphologyBase[source]

A base class holding common methods for parametric morphology descriptions.

r_eff_kpc

The effective radius in kpc.

Type:

float

r_eff_mas

The effective radius in milliarcseconds.

Type:

float

sersic_index

The Sersic index.

Type:

float

ellipticity

The ellipticity.

Type:

float

theta

The rotation angle.

Type:

float

cosmo

The cosmology object.

Type:

astropy.cosmology

redshift

The redshift.

Type:

float

model_kpc

The Sersic2D model in kpc.

Type:

astropy.modeling.models.Sersic2D

model_mas

The Sersic2D model in

Type:

astropy.modeling.models.Sersic2D

abstract compute_density_grid(*args)[source]

Compute the density grid from coordinate grids.

This is a place holder method to be overwritten by child classes.

get_density_grid(resolution, npix)[source]

Get the density grid based on resolution and npix.

Parameters:
  • resolution (unyt_quantity) – The resolution of the grid.

  • npix (tuple, int) – The number of pixels in each dimension.

plot_density_grid(resolution, npix)[source]

Make a quick density plot.

Parameters:
  • resolution (float) – The resolution (in the same units provded to the child class).

  • npix (int) – The number of pixels.

Examples using synthesizer.parametric.morphology.MorphologyBase

Image addition example

Image addition example

Generate parametric morphology profile

Generate parametric morphology profile

Create image example

Create image example
class synthesizer.parametric.morphology.PointSource(offset=unyt_array([0., 0.], 'kpc'), cosmo=None, redshift=None)[source]

A class holding a PointSource profile.

This is a morphology where a single cell of the density grid is populated.

cosmo

The cosmology object.

Type:

astropy.cosmology

redshift

The redshift.

Type:

float

offset_kpc

The offset of the point source relative to the centre of the image in kpc.

Type:

float

compute_density_grid(xx, yy, units=kpc)[source]

Compute the density grid.

This acts as a wrapper to astropy functionality (defined above) which only work in units of kpc or milliarcseconds (mas)

Args
xx: array-like (float)

x values on a 2D grid.

yy: array-like (float)

y values on a 2D grid.

unitsunyt.unit

The units in which the coordinate grids are defined.

Returns
density_gridnp.ndarray

The density grid produced

class synthesizer.parametric.morphology.Sersic2D(r_eff, amplitude=1, sersic_index=1, x_0=0, y_0=0, theta=0, ellipticity=0, cosmo=None, redshift=None)[source]

A class holding a 2D Sersic profile.

r_eff_kpc

The effective radius in kpc.

Type:

float

r_eff_mas

The effective radius in milliarcseconds.

Type:

float

sersic_index

The Sersic index.

Type:

float

ellipticity

The ellipticity.

Type:

float

theta

The rotation angle.

Type:

float

cosmo

The cosmology object.

Type:

astropy.cosmology

redshift

The redshift.

Type:

float

model_kpc

The 2D Sersic model in kpc.

model_mas

The 2D Sersic model in milliarcseconds.

compute_density_grid(x, y, units=kpc)[source]

Compute the density grid.

Args
x: array-like (float)

x values on a 2D grid.

y: array-like (float)

y values on a 2D grid.

unitsunyt.unit

The units in which the coordinate grids are defined.

Returns
density_gridnp.ndarray

The density grid produced from either the kpc or mas Sersic profile.