synthesizer.parametric.morphology¶
A submodule 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)[source]¶
Compute density grid.
- Parameters:
x (unyt_array of float) – x values on a 2D grid.
y (unyt_array of float) – y values on a 2D grid.
- Returns:
- A 2D array representing the Gaussian density values at each
(x, y) point.
- float:
The normalisation factor for the Gaussian density grid.
- Return type:
np.ndarray
- Raises:
ValueError – If either x or y is None.
- class synthesizer.parametric.morphology.Gaussian2DAnnuli(x_mean, y_mean, stddev_x, stddev_y, radii, rho=0)[source]¶
A subclass of Gaussian2D that supports masking of concentric annuli.
- 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.
- radii¶
The radii defining the annuli.
- Type:
list of float
- annulus_index¶
Index of the annulus to be used.
- Type:
int
- compute_density_grid(x, y, annulus)[source]¶
Compute the Gaussian density grid with optional annulus masking.
- Parameters:
x (array-like) – x values on a 2D grid.
y (array-like) – y values on a 2D grid.
annulus (int) – Index of the annulus to be used.
- Returns:
The masked Gaussian density grid. float: The normalisation factor for the density grid.
- Return type:
np.ndarray
- class synthesizer.parametric.morphology.MorphologyBase[source]¶
A base class holding common methods for parametric morphologies.
- 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
- grid¶
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, **kwargs)[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.
**kwargs – Additional keyword arguments to pass to the compute_density_grid method.
Examples using synthesizer.parametric.morphology.MorphologyBase
¶
- 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)[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)
- Parameters:
xx – array-like (unyt_array of float): x values on a 2D grid.
yy – array-like (unyt_array of float): y values on a 2D grid.
- Returns:
The density grid produced float:
The normalisation factor for the density grid.
- Return type:
np.ndarray
- class synthesizer.parametric.morphology.Sersic2D(r_eff, amplitude=1, sersic_index=1, x_0=unyt_quantity(0, 'kpc'), y_0=unyt_quantity(0, 'kpc'), 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
- grid¶
The 2D Sersic model in kpc.
- model_mas¶
The 2D Sersic model in milliarcseconds.
- compute_density_grid(x, y)[source]¶
Compute the density grid.
- Parameters:
x – array-like (float): x values on a 2D grid.
y – array-like (float): y values on a 2D grid.
- Returns:
- The density grid produced from either
the kpc or mas Sersic profile.
- float:
The normalisation factor for the density grid.
- Return type:
np.ndarray
- class synthesizer.parametric.morphology.Sersic2DAnnuli(r_eff, radii, amplitude=1, sersic_index=1, x_0=0, y_0=0, theta=0, ellipticity=0, cosmo=None, redshift=None)[source]¶
A subclass of Sersic2D that supports masking of concentric annuli.
- 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
- grid¶
The 2D Sersic model in kpc.
- model_mas¶
The 2D Sersic model in milliarcseconds.
- radii¶
The radii defining the annuli.
- Type:
list of float
- annulus_index¶
Index of the annulus to be used.
- Type:
int
- compute_density_grid(x, y, annulus)[source]¶
Compute the density grid with optional annulus masking.
- Parameters:
x (array-like) – x values on a 2D grid.
y (array-like) – y values on a 2D grid.
annulus (int) – Index of the annulus to be used.
- Returns:
The computed density grid, optionally masked by annuli. float: The normalisation factor for the density grid.
- Return type:
np.ndarray