Models

Contents

Models#

class astrophot.models.AiryPSF(*, filename=None, model_type=None, **kwargs)[source]#

Bases: RadialMixin, PSFModel

The Airy disk is an analytic description of the diffraction pattern for a circular aperture.

WARNING: This model does not work in JAX (it doesn’t have the required Bessel function implemented)

WARNING: PyTorch appears to have an issue with gradients wrt the R1 parameter. Optimization doesn’t seem to work for this model (maybe try scipy optimize?).

The diffraction pattern is described exactly by the configuration of the lens system under the assumption that all elements are perfect. This expression goes as:

\[I(\theta) = I_0\left[\frac{2J_1(x)}{x}\right]^2\]
\[x = ka\sin(\theta) = \frac{2\pi a r}{\lambda R}\]

where \(I(\theta)\) is the intensity as a function of the angular position within the diffraction system along its main axis, \(I_0\) is the central intensity of the airy disk, \(J_1\) is the Bessel function of the first kind of order one, \(k = \frac{2\pi}{\lambda}\) is the wavenumber of the light, \(a\) is the aperture radius, \(r\) is the radial position from the center of the pattern, \(R\) is the distance from the circular aperture to the observation plane.

In the AiryPSF class we combine the parameters \(a,R,\lambda\) and scale based on the first zero of the \(J_1\) function. This way you can work with the more intuitive radius parameter.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • I0 – The central intensity of the airy disk in flux/pix^2. [model param]

  • R1 – The radius of the first zero of the airy disk in pix. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], R1: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
usable = True#
class astrophot.models.BasisModel(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

Model described by a set of basis images.

This model is composed of a set of basis images (think eigen decomposition or zernike polynomials) that are linearly combined with some weights to form the model image. The basis images are defined on a grid of coordinates, and the brightness at any point is determined by bilinear interpolation of the basis images. This is a very flexible model that can represent a wide range of sources, but depending on the number of basis elements it can become computationally expensive to optimize.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • weights – The weights of the basis set of images in units of flux. [model param]

  • PA – the position angle of the model, in radians. [model param]

  • scale – the scale of the model, in arcsec per grid unit. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

property basis#

The basis set of images used to form the model.

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], weights: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], scale: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
usable = True#
class astrophot.models.BatchModel(*, filename=None, model_type=None, **kwargs)[source]#

Bases: GradMixin, SampleMixin, Model

A batch of models that all share the same window/target.

This can for example be used to model a crowded area of the sky with many overlapping sources, or to model a single object that is represented by many components (consider this a generalization of the Multi-gaussian expansion model). If you want to model the same object in multiple images, see the BatchSceneModel instead.

Once placed in a BatchModel, parameters for the base Model may now be given values with an extra dimension. This extra dimension is the batch dimension that will be vectorized over. For example, with a Gaussian Model, the sigma parameter is normally a single value scalar. You may now set it with a vector of values, and the length of that vector determines how many Gaussians the BatchModel will generate. Of course, every dynamic parameter that is batched must have the same size for its batch dimension.

Note: any model parameters that you wish to batch over must be set to

dynamic=True. See caskade hierarchical models for more details.

initialize()[source]#
property mask#
property target: TargetImage | None#
usable = True#
property window: Window | None#

The window defines a region on the sky in which this model will be optimized and evaluated. Two models with non-overlapping windows are in effect independent of each other. If there is another model with a window that spans both of them, then they are tenuously connected.

If not provided, the model will assume a window equal to the target it is fitting. Note that in this case the window is not explicitly set to the target window, so if the model is moved to another target then the fitting window will also change.

class astrophot.models.BilinearSky(*, filename=None, model_type=None, **kwargs)[source]#

Bases: SkyModel

Sky background model using a coarse bilinear grid for the sky flux.

This allows for modelling more complex sky surfaces, such as dust or galactic cirrus, without needing to specify a functional form. It is possible to specify a position angle and grid scale to control how it is oriented relative to the model target. By default it will just align with the image.

SkyModel

Prototype class for any sky background model.

This base class imposes that the center is a locked parameter not involved in the fit. Sky models also have no PSF convolution or integration mode by default, since sky backgrounds vary on spatial scales much larger than the PSF or pixel size.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • I – sky brightness grid [model param]

  • PA – position angle of the sky grid in radians. [model param]

  • scale – scale of the sky grid in arcseconds per grid unit. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Initialize the sky model, this is called after the model is created and before it is used. This is where we can set the center to be a locked parameter.

transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], scale: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
usable = True#
class astrophot.models.ComponentModel(*, filename=None, model_type=None, **kwargs)[source]#

Bases: GradMixin, SampleMixin, Model

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

internal_psf = False#
pixel_brightness(i, j, _CD=None, _crtan=None, _crpix=None)[source]#

Evaluate the model at the pixel coordinates defined by i and j (of the target image).

property psf#
psf_convolve = True#
sample(I_: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], J_: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], psf: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] = None, crop: int = 0, downsample: int = 1, _CD: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, _crtan: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, _crpix: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None)[source]#
property target#
transform_coordinates(x, y, center)[source]#
usable = False#
class astrophot.models.EdgeonIsothermal(*, filename=None, model_type=None, **kwargs)[source]#

Bases: EdgeonSech

A self-gravitating locally-isothermal edgeon disk. This comes from van der Kruit & Searle 1981.

EdgeonSech

An edgeon profile where the vertical distribution is a sech^2 profile, subclasses define the radial profile.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • PA – Position angle of the edgeon disk in radians. [model param]

  • I0 – The central intensity of the sech^2 profile in flux/arcsec^2. [model param]

  • hs – The scale height of the sech^2 profile in arcseconds. [model param]

  • rs – Scale radius of the isothermal disk in arcseconds. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], rs: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
usable = True#
class astrophot.models.EdgeonModel(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

General Edge-On galaxy model to be subclassed for any specific representation such as radial light profile or the structure of the galaxy on the sky. Defines an edgeon galaxy as an object with a position angle, no inclination information is included.

Parameters:

PA – Position angle of the edgeon disk in radians.

initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
usable = False#
class astrophot.models.EdgeonSech(*, filename=None, model_type=None, **kwargs)[source]#

Bases: EdgeonModel

An edgeon profile where the vertical distribution is a sech^2 profile, subclasses define the radial profile.

Parameters:
  • I0 – The central intensity of the sech^2 profile in flux/arcsec^2.

  • hs – The scale height of the sech^2 profile in arcseconds.

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], hs: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

usable = False#
class astrophot.models.ExponentialFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.ExponentialGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialMixin, RadialMixin, GalaxyModel

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.ExponentialMixin[source]#

Bases: object

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

Parameters:
  • Re – effective radius, radius enclosing half the total light

  • Ie – effective surface density, brightness at the effective radius

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Re: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ie: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.ExponentialPSF(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialPSFMixin, RadialMixin, PSFModel

ExponentialPSFMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.ExponentialPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialPSFMixin, EllipseMixin, RadialMixin, PSFModel

ExponentialPSFMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.ExponentialPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

ExponentialPSFMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.ExponentialPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

ExponentialPSFMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.ExponentialPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

ExponentialPSFMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.ExponentialRay(*, filename=None, model_type=None, **kwargs)#

Bases: iExponentialMixin, RayMixin, GalaxyModel

iExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

\(I_e\) is the brightness at the effective radius, and \(R_e\) is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

Re and Ie are batched by their first dimension, allowing for multiple exponential profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.ExponentialSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.ExponentialWarp(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialMixin, RadialMixin, WarpMixin, GalaxyModel

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.ExponentialWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iExponentialMixin, WedgeMixin, GalaxyModel

iExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

\(I_e\) is the brightness at the effective radius, and \(R_e\) is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

Re and Ie are batched by their first dimension, allowing for multiple exponential profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.FerrerFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.FerrerGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerMixin, RadialMixin, GalaxyModel

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.FerrerMixin[source]#

Bases: object

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

Parameters:
  • rout – Outer truncation radius in arcseconds.

  • alpha – Inner slope parameter.

  • beta – Outer slope parameter.

  • I0 – Intensity at the center of the profile in flux/arcsec^2

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], rout: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.FerrerPSF(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerPSFMixin, RadialMixin, PSFModel

FerrerPSFMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • rout – Outer truncation radius in pixels. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/pix^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.FerrerPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerPSFMixin, EllipseMixin, RadialMixin, PSFModel

FerrerPSFMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in pixels. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/pix^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.FerrerPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

FerrerPSFMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in pixels. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/pix^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.FerrerPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

FerrerPSFMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in pixels. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/pix^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.FerrerPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

FerrerPSFMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in pixels. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/pix^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.FerrerRay(*, filename=None, model_type=None, **kwargs)#

Bases: iFerrerMixin, RayMixin, GalaxyModel

iFerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

rout, alpha, beta, and I0 are batched by their first dimension, allowing for multiple Ferrer profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.FerrerSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.FerrerWarp(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerMixin, RadialMixin, WarpMixin, GalaxyModel

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.FerrerWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iFerrerMixin, WedgeMixin, GalaxyModel

iFerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

rout, alpha, beta, and I0 are batched by their first dimension, allowing for multiple Ferrer profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.FlatSky(*, filename=None, model_type=None, **kwargs)[source]#

Bases: SkyModel

Model for the sky background in which all values across the image are the same.

SkyModel

Prototype class for any sky background model.

This base class imposes that the center is a locked parameter not involved in the fit. Sky models also have no PSF convolution or integration mode by default, since sky backgrounds vary on spatial scales much larger than the PSF or pixel size.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • I0 – brightness for the sky in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Initialize the sky model, this is called after the model is created and before it is used. This is where we can set the center to be a locked parameter.

usable = True#
class astrophot.models.FourierEllipseMixin(*args, modes: Tuple[int] = (3, 4), **kwargs)[source]#

Bases: object

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

Parameters:
  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode.

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi)

  • modes – Tuple of integers indicating which Fourier modes to use.

initialize()[source]#
radius_metric(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], am: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], phim: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.GalaxyModel(*, filename=None, model_type=None, **kwargs)[source]#

Bases: InclinedMixin, ComponentModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = False#
class astrophot.models.GaussianEllipsoid(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

Model that represents a galaxy as a 3D Gaussian ellipsoid.

The model is triaxial, meaning it has three different standard deviations along the three axes. The orientation of the ellipsoid is defined by Euler angles.

If all three Euler angles are set to zero, the ellipsoid is aligned with the image axes meaning sigma_a gives the std along the x axis of the tangent plane, sigma_b gives the std along the y axis of the tangent plane, and sigma_z gives the std into the tangent plane. We use the ZXZ convention for the Euler angles. This means that for a disk galaxy, one can naturally consider sigma_c as the disk thickness and sigma_a=sigma_b as the disk radius; setting the Euler angles to zero would leave the disk face-on in the x-y tangent plane.

Note:

the model is highly degenerate, meaning that it is not possible to uniquely determine the parameters from the data. The model is useful if one already has a 3D model of the galaxy in mind and wants to produce mock data. Alternately, if one applies some constraints on the parameters, such as sigma_a = sigma_b and alpha=0, then the model will be better determined. In that case, beta is related to the inclination of the disk and gamma is related to the position angle of the disk. The initialization for this model assumes exactly this interpretation with a disk thickness of sigma_c = 0.2 *sigma_a.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • sigma_a – Standard deviation of the Gaussian along the alpha axis in arcseconds. [model param]

  • sigma_b – Standard deviation of the Gaussian along the beta axis in arcseconds. [model param]

  • sigma_c – Standard deviation of the Gaussian along the gamma axis in arcseconds. [model param]

  • alpha – Euler angle representing the rotation around the alpha axis in radians. [model param]

  • beta – Euler angle representing the rotation around the beta axis in radians. [model param]

  • gamma – Euler angle representing the rotation around the gamma axis in radians. [model param]

  • flux – Total flux of the galaxy in arbitrary units. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma_a: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma_b: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma_c: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], gamma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], flux: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Brightness of the Gaussian ellipsoid.

initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

usable = True#
class astrophot.models.GaussianFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.GaussianGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianMixin, RadialMixin, GalaxyModel

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.GaussianMixin[source]#

Bases: object

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

Parameters:
  • sigma – Standard deviation of the Gaussian profile in arcseconds.

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results).

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], flux: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.GaussianPSF(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianPSFMixin, RadialMixin, PSFModel

GaussianPSFMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • sigma – Standard deviation of the Gaussian profile in pixels. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.GaussianPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianPSFMixin, EllipseMixin, RadialMixin, PSFModel

GaussianPSFMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in pixels. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.GaussianPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

GaussianPSFMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in pixels. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.GaussianPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

GaussianPSFMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in pixels. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.GaussianPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

GaussianPSFMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in pixels. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.GaussianRay(*, filename=None, model_type=None, **kwargs)#

Bases: iGaussianMixin, RayMixin, GalaxyModel

iGaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where sigma is the standard deviation which controls the width of the profile and flux gives the total flux of the profile (assuming no perturbations).

sigma and flux are batched by their first dimension, allowing for multiple Gaussian profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.GaussianSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.GaussianWarp(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianMixin, RadialMixin, WarpMixin, GalaxyModel

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.GaussianWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iGaussianMixin, WedgeMixin, GalaxyModel

iGaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where sigma is the standard deviation which controls the width of the profile and flux gives the total flux of the profile (assuming no perturbations).

sigma and flux are batched by their first dimension, allowing for multiple Gaussian profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.GroupModel(*, filename=None, model_type=None, **kwargs)[source]#

Bases: Model

Model object which represents a list of other models. For each general AstroPhot model method, this calls all the appropriate models from its list and combines their output into a single summed model. This class should be used when describing any system more complex than makes sense to represent with a single light distribution.

Args:

name (str): unique name for the full group model target (Target_Image): the target image that this group model is trying to fit to models (Optional[Sequence[AstroPhot_Model]]): list of AstroPhot_Model objects which will combine for the group model locked (bool): if the whole group of models should be locked

deblend() Sequence[TargetImage][source]#

Generate deblended images for each sub-model in this group model. Each deblended image contains for each pixel, the fraction of the total flux at that pixel which is contributed by that sub-model.

Returns:

Sequence[TargetImage]: List of deblended TargetImage objects for each sub-model.

initialize()[source]#

Initialize each model in this group. Does this by iteratively initializing a model then subtracting it from a copy of the target.

jacobian(pass_jacobian: JacobianImage | JacobianImageList | None = None, params=None) JacobianImage[source]#

Compute the jacobian for this model. Done by first constructing a full jacobian (Npixels * Nparameters) of zeros then call the jacobian method of each sub model and add it in to the total.

Args: - pass_jacobian (Optional[JacobianImage]): A Jacobian image pre-constructed to be passed along instead of constructing new Jacobians - window (Optional[Window]): A window within which to evaluate the jacobian. If not provided, the model’s window will be used. - params (Optional[Sequence[Param]]): Parameters to use for the jacobian. If not provided, the model’s parameters will be used.

match_window(image: Image | ImageList, window: Window, model: Model) Window[source]#
sample(_CD: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, _crtan: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, _crpix: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, _psf: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None) ModelImage | ModelImageList[source]#

Sample the group model on an image. Produces the flux values for each pixel associated with the models in this group. Each model is called individually and the results are added together in one larger image.

Args: - image (Optional[ModelImage]): Image to sample on, overrides the windows for each sub model, they will all be evaluated over this entire image. If left as none then each sub model will be evaluated in its window.

segmentation_map() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Generate a segmentation map for this group model. Each pixel in the segmentation map is assigned an integer value corresponding to the index of the sub-model that corresponds to that pixel. The pixels are assigned based on “relative importance”, meaning that for each pixel, the sub-model which contributes the largest fraction of its own total flux to that pixel is assigned to it.

Returns:

ArrayLike: Segmentation map with the same shape as the target image as windowed by the group model window.

property target: TargetImage | TargetImageList | None#
usable = True#
property window: Window | WindowList | None#

The window defines a region on the sky in which this model will be optimized and typically evaluated. Two models with non-overlapping windows are in effect independent of each other. If there is another model with a window that spans both of them, then they are tenuously connected.

If not provided, the model will assume a window equal to the target it is fitting. Note that in this case the window is not explicitly set to the target window, so if the model is moved to another target then the fitting window will also change.

class astrophot.models.InclinedMixin[source]#

Bases: object

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

Parameters:
  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular.

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East.

initialize()[source]#
transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], q: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
class astrophot.models.KingFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: KingMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.KingGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: KingMixin, RadialMixin, GalaxyModel

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.KingMixin[source]#

Bases: object

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

Parameters:
  • Rc – core radius

  • Rt – truncation radius

  • alpha – concentration index which controls the shape of the brightness profile

  • I0 – intensity at the center of the profile

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rc: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rt: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.KingPSF(*, filename=None, model_type=None, **kwargs)#

Bases: KingPSFMixin, RadialMixin, PSFModel

KingPSFMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • Rc – core radius [pix] [model param]

  • Rt – truncation radius [pix] [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.KingPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: KingPSFMixin, EllipseMixin, RadialMixin, PSFModel

KingPSFMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [pix] [model param]

  • Rt – truncation radius [pix] [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.KingPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: KingPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

KingPSFMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [pix] [model param]

  • Rt – truncation radius [pix] [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.KingPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: KingPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

KingPSFMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [pix] [model param]

  • Rt – truncation radius [pix] [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.KingPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: KingPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

KingPSFMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [pix] [model param]

  • Rt – truncation radius [pix] [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.KingRay(*, filename=None, model_type=None, **kwargs)#

Bases: iKingMixin, RayMixin, GalaxyModel

iKingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

Rc, Rt, alpha, and I0 are batched by their first dimension, allowing for multiple King profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.KingSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: KingMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.KingWarp(*, filename=None, model_type=None, **kwargs)#

Bases: KingMixin, RadialMixin, WarpMixin, GalaxyModel

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.KingWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iKingMixin, WedgeMixin, GalaxyModel

iKingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

Rc, Rt, alpha, and I0 are batched by their first dimension, allowing for multiple King profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.Model(*, filename=None, model_type=None, **kwargs)[source]#

Bases: Module

Base class for all AstroPhot models.

classmethod List_Models(usable: bool | None = None, types: bool = False) set[source]#
angular_metric(x, y)[source]#
build_parameter_specs(kwargs, parameter_specs) dict[source]#
gaussian_log_likelihood() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Compute the negative log likelihood of the model wrt the target image in the appropriate window.

hessian(likelihood='gaussian')[source]#
model_type = 'model'#
options = {'softening'}#
parameter_specs = {}#
poisson_log_likelihood() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Compute the negative log likelihood of the model wrt the target image in the appropriate window.

radius_metric(x, y)[source]#
softening = 0.001#
to(dtype=None, device=None)[source]#

Moves and/or casts the values of the Node to a particular device and/or dtype.

Parameters#

device: (Optional[torch.device], optional)

The device to move the values to. Defaults to None.

dtype: (Optional[torch.dtype], optional)

The desired data type. Defaults to None.

total_flux() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
total_flux_uncertainty() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
total_magnitude() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Compute the total magnitude of the model in the given window.

total_magnitude_uncertainty() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Compute the uncertainty in the total magnitude of the model in the given window.

usable = False#
property window: Window | None#

The window defines a region on the sky in which this model will be optimized and typically evaluated. Two models with non-overlapping windows are in effect independent of each other. If there is another model with a window that spans both of them, then they are tenuously connected.

If not provided, the model will assume a window equal to the target it is fitting. Note that in this case the window is not explicitly set to the target window, so if the model is moved to another target then the fitting window will also change.

class astrophot.models.MoffatFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.MoffatGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatMixin, RadialMixin, GalaxyModel

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.MoffatMixin[source]#

Bases: object

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

Parameters:
  • n – Concentration index which controls the shape of the brightness profile

  • Rd – Scale length radius

  • I0 – Intensity at the center of the profile

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], n: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rd: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.MoffatPSF(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatPSFMixin, RadialMixin, PSFModel

MoffatPSFMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [pix] [model param]

  • I0 – Intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.MoffatPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatPSFMixin, EllipseMixin, RadialMixin, PSFModel

MoffatPSFMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [pix] [model param]

  • I0 – Intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.MoffatPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

MoffatPSFMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [pix] [model param]

  • I0 – Intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.MoffatPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

MoffatPSFMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [pix] [model param]

  • I0 – Intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.MoffatPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

MoffatPSFMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [pix] [model param]

  • I0 – Intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.MoffatRay(*, filename=None, model_type=None, **kwargs)#

Bases: iMoffatMixin, RayMixin, GalaxyModel

iMoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

n, Rd, and I0 are batched by their first dimension, allowing for multiple Moffat profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.MoffatSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.MoffatWarp(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatMixin, RadialMixin, WarpMixin, GalaxyModel

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.MoffatWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iMoffatMixin, WedgeMixin, GalaxyModel

iMoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

n, Rd, and I0 are batched by their first dimension, allowing for multiple Moffat profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.MultiGaussianExpansion(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

Model that represents a galaxy as a sum of multiple Gaussian profiles. The model is defined as:

\[I(R) = \sum_i {\rm flux}_i * \exp(-0.5*(R_i / \sigma_i)^2) / (2 * \pi * q_i * \sigma_i^2)\]

where \(R_i\) is a radius computed using \(q_i\) and \(PA_i\) for that component. All components share the same center.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – axis ratio to scale minor axis from the ratio of the minor/major axis b/a, this parameter is unitless, it is restricted to the range (0,1) [model param]

  • PA – position angle of the semi-major axis East of North, it is a cyclic parameter in the range [0,pi) [model param]

  • sigma – standard deviation of each Gaussian [model param]

  • flux – amplitude of each Gaussian [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], flux: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], q: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], q: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
usable = True#
class astrophot.models.NukerFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: NukerMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.NukerGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: NukerMixin, RadialMixin, GalaxyModel

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.NukerMixin[source]#

Bases: object

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

Parameters:
  • Rb – scale length radius

  • Ib – intensity at the scale length

  • alpha – sharpness of transition between power law slopes

  • beta – outer power law slope

  • gamma – inner power law slope

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rb: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ib: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], gamma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.NukerPSF(*, filename=None, model_type=None, **kwargs)#

Bases: NukerPSFMixin, RadialMixin, PSFModel

NukerPSFMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • Rb – scale length radius [pix] [model param]

  • Ib – intensity at the scale length [flux/pix^2] [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.NukerPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: NukerPSFMixin, EllipseMixin, RadialMixin, PSFModel

NukerPSFMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [pix] [model param]

  • Ib – intensity at the scale length [flux/pix^2] [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.NukerPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: NukerPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

NukerPSFMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [pix] [model param]

  • Ib – intensity at the scale length [flux/pix^2] [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.NukerPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: NukerPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

NukerPSFMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [pix] [model param]

  • Ib – intensity at the scale length [flux/pix^2] [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.NukerPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: NukerPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

NukerPSFMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [pix] [model param]

  • Ib – intensity at the scale length [flux/pix^2] [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.NukerRay(*, filename=None, model_type=None, **kwargs)#

Bases: iNukerMixin, RayMixin, GalaxyModel

iNukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

Rb, Ib, alpha, beta, and gamma are batched by their first dimension, allowing for multiple Nuker profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.NukerSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: NukerMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.NukerWarp(*, filename=None, model_type=None, **kwargs)#

Bases: NukerMixin, RadialMixin, WarpMixin, GalaxyModel

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.NukerWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iNukerMixin, WedgeMixin, GalaxyModel

iNukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

Rb, Ib, alpha, beta, and gamma are batched by their first dimension, allowing for multiple Nuker profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.PSFGroupModel(*, filename=None, model_type=None, **kwargs)[source]#

Bases: GroupModel

A group of PSF models. Behaves similarly to a GroupModel, but specifically designed for PSF models. Note that there is no concept of a PSFImageList, so they always represent a single PSF model.

When sampling, a PSFGroupModel tells each sub-PSFModel (including nested sub-PSFGroupModels) to sample without normalization. This way they can fit with relative strengths. The final top-level PSFGroupModel will normalize the resulting PSF, so that the image that gets passed to the regular model objects for the purpose of convolution is always normalized. This means that the sub-PSFModels in a PSFGroupModel should have their brightness parameters (i.e., I0 for the MoffatPSF) set to dynamic so they can participate in the fit. Though this is not strictly a requirement (say you already know the relative brightnesses).

sample(normalize_psf=True) PSFImage[source]#

Sample the PSF group model on the target image.

property target#
usable = True#
class astrophot.models.PSFModel(*, filename=None, model_type=None, **kwargs)[source]#

Bases: GradMixin, SampleMixin, Model

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:

center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit.

initialize()[source]#
property pad#
pixel_brightness(i, j)[source]#

Evaluate the model at the pixel coordinates defined by i and j (of the target image). For a PSF model, this is the same as the brightness since it is defined in pixel units.

sample(i: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], j: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], *args, **kwargs) PSFImage[source]#

Sample the PSF model on the pixel grid defined by i and j.

Depending on the model specification, this may involve supersampling for higher precision, or it may just be a direct evaluation of the model at the pixel centers. The output is the flux evaluated over the pixel grid at native resolution (for the PSFImage associated with this model.)

Parameters:
  • i – 2D array of x-coordinates of pixel centers (or pre-upsampled according to the sampling_mode) in pixel units.

  • j – 2D array of y-coordinates of pixel centers (or pre-upsampled according to the sampling_mode) in pixel units.

Returns:

2D array (Z) of flux values at each pixel center, representing the PSF model evaluated at those coordinates.

property target#
transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], center: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
property upsample#
usable = False#
class astrophot.models.PixelBasisPSF(*, filename=None, model_type=None, **kwargs)[source]#

Bases: PSFModel

A point source defined by a linear combination of basis images.

Point source model which uses multiple images as a basis for the PSF as its representation for point sources. Using bilinear interpolation it will shift the PSF within a pixel to accurately represent the center location of a point source. There is no functional form for this object type as any image can be supplied. Bilinear interpolation is very fast and accurate for smooth models, so it is possible to do the expensive interpolation before optimization and save time.

The initialization of the weights is currently done by setting random values. This almost certainly produces a bad initial model. You may either set weights manually, or use a fitting step to get good starting weights.

Note: The resulting PSF from the combined basis set will be normalized

before being used as a PSF model, so the sum of the weights does not need to be restricted to any particular value.

Note: It is possible for the basis elements to combine to give a PSF model

that is negative in some areas. This is likely not desired, if this is a concern then use a non-negative basis and set the valid range of the weights to be (0, None).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • weights – The weights of the basis set of images in units of flux. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

property basis#

The basis set of images used to form the eigen point source.

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], weights: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#
usable = True#
class astrophot.models.Pixelated(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

Model described by a grid of pixels on the sky (bilinear interpolation)

This model represents an extended source on the sky as a grid of pixels with some brightness. The brightness at any point is determined by bilinear interpolation of the grid values. This is a very flexible model that can represent any source, but it is also computationally expensive to optimize the large number of free parameters.

The PA and scale are also parameters of this model, so one could alternately fix the pixels to some image and just fit the PA and scale.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • I – the total flux within each pixel, in units of flux/arcsec^2. [model param]

  • PA – the position angle of the model, in radians. [model param]

  • scale – the scale of the model, in arcsec per grid unit. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], scale: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
usable = True#
class astrophot.models.PixelatedPSF(*, filename=None, model_type=None, **kwargs)[source]#

Bases: PSFModel

point source model which uses an image of the PSF as its representation for point sources. Using bilinear interpolation it will shift the PSF within a pixel to accurately represent the center location of a point source. There is no functional form for this object type as any image can be supplied. The image pixels will be optimized as individual parameters. This can very quickly result in a large number of parameters and a near impossible fitting task, ideally this should be restricted to a very small area likely at the center of the PSF.

To initialize the PSF image will by default be set to the target PSF_Image values, thus one can use an empirical PSF as a starting point. Since only bilinear interpolation is performed, it is recommended to provide the PSF at a higher resolution than the image if it is near the nyquist sampling limit. Bilinear interpolation is very fast and accurate for smooth models, so this way it is possible to do the expensive interpolation before optimization and save time. Note that if you do this you must provide the PSF as a PSF_Image object with the correct pixelscale (essentially just divide the pixelscale by the upsampling factor you used).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • pixels – the total flux within each pixel, in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], pixels: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#
usable = True#
class astrophot.models.PlaneSky(*, filename=None, model_type=None, **kwargs)[source]#

Bases: SkyModel

Sky background model using a tilted plane for the sky flux. The brightness for each pixel is defined as:

\[I(X, Y) = I_0 + X*\delta_x + Y*\delta_y\]

where \(I(X,Y)\) is the brightness as a function of image position \(X, Y\), \(I_0\) is the central sky brightness value, and \(\delta_x, \delta_y\) are the slopes of the sky brightness plane.

SkyModel

Prototype class for any sky background model.

This base class imposes that the center is a locked parameter not involved in the fit. Sky models also have no PSF convolution or integration mode by default, since sky backgrounds vary on spatial scales much larger than the PSF or pixel size.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • I0 – central sky brightness value [model param]

  • delta – An array for slope of the sky brightness in each image dimension [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], delta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Initialize the sky model, this is called after the model is created and before it is used. This is where we can set the center to be a locked parameter.

usable = True#
class astrophot.models.PointSource(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

Describes a point source in the image, this is a delta function at some position in the sky. This is typically used to describe stars, supernovae, quasars, asteroids or any other object which can essentially be entirely described by a position and total flux (no structure).

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • flux – The total flux of the point source [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

property integrate_mode#
internal_psf = True#
property psf_convolve#

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

sample(I_: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], J_: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], psf: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] = None, crop: int = 0, downsample: int = 1, center=None, flux=None, _CD=None, _crtan=None, _crpix=None)[source]#
usable = True#
class astrophot.models.RadialMixin[source]#

Bases: object

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Calculate the brightness at a given point (x, y) based on radial distance from the center.

class astrophot.models.RayMixin(*args, symmetric: bool = True, segments: int = 2, **kwargs)[source]#

Bases: object

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

Parameters:
  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
polar_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], T: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.SampleMixin(*args, sampling_mode='auto', integrate_mode='bright', **kwargs)[source]#

Bases: object

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Parameters:
  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

integrate_fraction = 0.05#
integrate_gridding = 5#
integrate_max_depth = 2#
property integrate_mode#
integrate_quad_order = 3#
property sampling_mode#
class astrophot.models.SersicFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SersicMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.SersicGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: SersicMixin, RadialMixin, GalaxyModel

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.SersicMixin[source]#

Bases: object

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

Parameters:
  • n – Sersic index which controls the shape of the brightness profile

  • Re – half light radius, also called effective radius [arcsec]

  • Ie – intensity at the half light radius [flux/arcsec^2]

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], n: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Re: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ie: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.SersicPSF(*, filename=None, model_type=None, **kwargs)#

Bases: SersicPSFMixin, RadialMixin, PSFModel

SersicPSFMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [pix] [model param]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.SersicPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SersicPSFMixin, EllipseMixin, RadialMixin, PSFModel

SersicPSFMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [pix] [model param]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.SersicPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SersicPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

SersicPSFMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [pix] [model param]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.SersicPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SersicPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

SersicPSFMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [pix] [model param]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.SersicPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: SersicPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

SersicPSFMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [pix] [model param]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.SersicRay(*, filename=None, model_type=None, **kwargs)#

Bases: iSersicMixin, RayMixin, GalaxyModel

iSersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

n, Re, and Ie are batched by their first dimension, allowing for multiple Sersic profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.SersicSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SersicMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.SersicWarp(*, filename=None, model_type=None, **kwargs)#

Bases: SersicMixin, RadialMixin, WarpMixin, GalaxyModel

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.SersicWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iSersicMixin, WedgeMixin, GalaxyModel

iSersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

n, Re, and Ie are batched by their first dimension, allowing for multiple Sersic profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.SkyModel(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

Prototype class for any sky background model.

This base class imposes that the center is a locked parameter not involved in the fit. Sky models also have no PSF convolution or integration mode by default, since sky backgrounds vary on spatial scales much larger than the PSF or pixel size.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

initialize()[source]#

Initialize the sky model, this is called after the model is created and before it is used. This is where we can set the center to be a locked parameter.

property psf_convolve: bool#

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

usable = False#
class astrophot.models.SplineFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SplineMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.SplineGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: SplineMixin, RadialMixin, GalaxyModel

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.SplineMixin[source]#

Bases: object

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

Parameters:

I_R – Array of radial brightness values in units of flux/arcsec^2.

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I_R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.SplinePSF(*, filename=None, model_type=None, **kwargs)#

Bases: SplinePSFMixin, RadialMixin, PSFModel

SplinePSFMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • I_R – Array of radial brightness values in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.SplinePSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SplinePSFMixin, EllipseMixin, RadialMixin, PSFModel

SplinePSFMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.SplinePSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SplinePSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

SplinePSFMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.SplinePSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SplinePSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

SplinePSFMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.SplinePSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: SplinePSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

SplinePSFMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.SplineRay(*, filename=None, model_type=None, **kwargs)#

Bases: iSplineMixin, RayMixin, GalaxyModel

iSplineMixin

Batched spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

Both I_R and I_R.prof are batched by their first dimension, allowing for multiple spline profiles to be defined at once. Each individual spline model is then I_R[i] and I_R.prof[i] where i indexes the profiles.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.SplineSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SplineMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.SplineWarp(*, filename=None, model_type=None, **kwargs)#

Bases: SplineMixin, RadialMixin, WarpMixin, GalaxyModel

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.SplineWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iSplineMixin, WedgeMixin, GalaxyModel

iSplineMixin

Batched spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

Both I_R and I_R.prof are batched by their first dimension, allowing for multiple spline profiles to be defined at once. Each individual spline model is then I_R[i] and I_R.prof[i] where i indexes the profiles.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.SuperEllipseMixin[source]#

Bases: object

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

Parameters:

C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse.

radius_metric(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], C: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.TruncationMixin(*args, outer_truncation: bool = True, **kwargs)[source]#

Bases: object

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

Parameters:
  • Rt – The truncation radius in arcseconds.

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius.

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rt: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], St: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.WarpMixin[source]#

Bases: object

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

Parameters:
  • q_R – Array of axis ratio values for axis ratio spline

  • PA_R – Array of position angle values as input to the spline

initialize()[source]#
transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], q_R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA_R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
class astrophot.models.WedgeMixin(*args, symmetric: bool = True, segments: int = 2, **kwargs)[source]#

Bases: object

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

Parameters:
  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

brightness(x: Tensor, y: Tensor) Tensor[source]#
polar_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], T: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.iExponentialMixin[source]#

Bases: object

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

\(I_e\) is the brightness at the effective radius, and \(R_e\) is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

Re and Ie are batched by their first dimension, allowing for multiple exponential profiles to be defined at once.

Parameters:
  • Re – effective radius, radius enclosing half the total light

  • Ie – effective surface density, brightness at the effective radius

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Re: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ie: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.iFerrerMixin[source]#

Bases: object

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

rout, alpha, beta, and I0 are batched by their first dimension, allowing for multiple Ferrer profiles to be defined at once.

Parameters:
  • rout – Outer truncation radius in arcseconds.

  • alpha – Inner slope parameter.

  • beta – Outer slope parameter.

  • I0 – Intensity at the center of the profile in flux/arcsec^2

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], rout: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.iGaussianMixin[source]#

Bases: object

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where sigma is the standard deviation which controls the width of the profile and flux gives the total flux of the profile (assuming no perturbations).

sigma and flux are batched by their first dimension, allowing for multiple Gaussian profiles to be defined at once.

Parameters:
  • sigma – Standard deviation of the Gaussian profile in arcseconds.

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results).

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], flux: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.iKingMixin[source]#

Bases: object

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

Rc, Rt, alpha, and I0 are batched by their first dimension, allowing for multiple King profiles to be defined at once.

Parameters:
  • Rc – core radius

  • Rt – truncation radius

  • alpha – concentration index which controls the shape of the brightness profile

  • I0 – intensity at the center of the profile

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rc: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rt: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.iMoffatMixin[source]#

Bases: object

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

n, Rd, and I0 are batched by their first dimension, allowing for multiple Moffat profiles to be defined at once.

Parameters:
  • n – Concentration index which controls the shape of the brightness profile

  • Rd – Scale length radius

  • I0 – Intensity at the center of the profile

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], n: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rd: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.iNukerMixin[source]#

Bases: object

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

Rb, Ib, alpha, beta, and gamma are batched by their first dimension, allowing for multiple Nuker profiles to be defined at once.

Parameters:
  • Rb – scale length radius

  • Ib – intensity at the scale length

  • alpha – sharpness of transition between power law slopes

  • beta – outer power law slope

  • gamma – inner power law slope

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rb: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ib: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], gamma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.iSersicMixin[source]#

Bases: object

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

n, Re, and Ie are batched by their first dimension, allowing for multiple Sersic profiles to be defined at once.

Parameters:
  • n – Sersic index which controls the shape of the brightness profile

  • Re – half light radius, also called effective radius [arcsec]

  • Ie – intensity at the half light radius [flux/arcsec^2]

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], n: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Re: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ie: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.iSplineMixin[source]#

Bases: object

Batched spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

Both I_R and I_R.prof are batched by their first dimension, allowing for multiple spline profiles to be defined at once. Each individual spline model is then I_R[i] and I_R.prof[i] where i indexes the profiles.

Parameters:

I_R – Array of radial brightness values in units of flux/arcsec^2.

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I_R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Sky Models#

class astrophot.models.flatsky.FlatSky(*, filename=None, model_type=None, **kwargs)[source]#

Bases: SkyModel

Model for the sky background in which all values across the image are the same.

SkyModel

Prototype class for any sky background model.

This base class imposes that the center is a locked parameter not involved in the fit. Sky models also have no PSF convolution or integration mode by default, since sky backgrounds vary on spatial scales much larger than the PSF or pixel size.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • I0 – brightness for the sky in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Initialize the sky model, this is called after the model is created and before it is used. This is where we can set the center to be a locked parameter.

usable = True#
class astrophot.models.planesky.PlaneSky(*, filename=None, model_type=None, **kwargs)[source]#

Bases: SkyModel

Sky background model using a tilted plane for the sky flux. The brightness for each pixel is defined as:

\[I(X, Y) = I_0 + X*\delta_x + Y*\delta_y\]

where \(I(X,Y)\) is the brightness as a function of image position \(X, Y\), \(I_0\) is the central sky brightness value, and \(\delta_x, \delta_y\) are the slopes of the sky brightness plane.

SkyModel

Prototype class for any sky background model.

This base class imposes that the center is a locked parameter not involved in the fit. Sky models also have no PSF convolution or integration mode by default, since sky backgrounds vary on spatial scales much larger than the PSF or pixel size.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • I0 – central sky brightness value [model param]

  • delta – An array for slope of the sky brightness in each image dimension [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], delta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Initialize the sky model, this is called after the model is created and before it is used. This is where we can set the center to be a locked parameter.

usable = True#
class astrophot.models.bilinear_sky.BilinearSky(*, filename=None, model_type=None, **kwargs)[source]#

Bases: SkyModel

Sky background model using a coarse bilinear grid for the sky flux.

This allows for modelling more complex sky surfaces, such as dust or galactic cirrus, without needing to specify a functional form. It is possible to specify a position angle and grid scale to control how it is oriented relative to the model target. By default it will just align with the image.

SkyModel

Prototype class for any sky background model.

This base class imposes that the center is a locked parameter not involved in the fit. Sky models also have no PSF convolution or integration mode by default, since sky backgrounds vary on spatial scales much larger than the PSF or pixel size.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • I – sky brightness grid [model param]

  • PA – position angle of the sky grid in radians. [model param]

  • scale – scale of the sky grid in arcseconds per grid unit. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Initialize the sky model, this is called after the model is created and before it is used. This is where we can set the center to be a locked parameter.

transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], scale: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
usable = True#

Point Source Models#

class astrophot.models.point_source.PointSource(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

Describes a point source in the image, this is a delta function at some position in the sky. This is typically used to describe stars, supernovae, quasars, asteroids or any other object which can essentially be entirely described by a position and total flux (no structure).

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • flux – The total flux of the point source [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

property integrate_mode#
internal_psf = True#
property psf_convolve#

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

sample(I_: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], J_: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], psf: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] = None, crop: int = 0, downsample: int = 1, center=None, flux=None, _CD=None, _crtan=None, _crpix=None)[source]#
usable = True#

Galaxy Models#

class astrophot.models.radial.ExponentialFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial.ExponentialGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialMixin, RadialMixin, GalaxyModel

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.ExponentialRay(*, filename=None, model_type=None, **kwargs)#

Bases: iExponentialMixin, RayMixin, GalaxyModel

iExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

\(I_e\) is the brightness at the effective radius, and \(R_e\) is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

Re and Ie are batched by their first dimension, allowing for multiple exponential profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.ExponentialSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.ExponentialWarp(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialMixin, RadialMixin, WarpMixin, GalaxyModel

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.ExponentialWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iExponentialMixin, WedgeMixin, GalaxyModel

iExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

\(I_e\) is the brightness at the effective radius, and \(R_e\) is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

Re and Ie are batched by their first dimension, allowing for multiple exponential profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.FerrerFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial.FerrerGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerMixin, RadialMixin, GalaxyModel

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.FerrerRay(*, filename=None, model_type=None, **kwargs)#

Bases: iFerrerMixin, RayMixin, GalaxyModel

iFerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

rout, alpha, beta, and I0 are batched by their first dimension, allowing for multiple Ferrer profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.FerrerSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.FerrerWarp(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerMixin, RadialMixin, WarpMixin, GalaxyModel

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.FerrerWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iFerrerMixin, WedgeMixin, GalaxyModel

iFerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

rout, alpha, beta, and I0 are batched by their first dimension, allowing for multiple Ferrer profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.GaussianFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial.GaussianGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianMixin, RadialMixin, GalaxyModel

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.GaussianRay(*, filename=None, model_type=None, **kwargs)#

Bases: iGaussianMixin, RayMixin, GalaxyModel

iGaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where sigma is the standard deviation which controls the width of the profile and flux gives the total flux of the profile (assuming no perturbations).

sigma and flux are batched by their first dimension, allowing for multiple Gaussian profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.GaussianSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.GaussianWarp(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianMixin, RadialMixin, WarpMixin, GalaxyModel

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.GaussianWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iGaussianMixin, WedgeMixin, GalaxyModel

iGaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where sigma is the standard deviation which controls the width of the profile and flux gives the total flux of the profile (assuming no perturbations).

sigma and flux are batched by their first dimension, allowing for multiple Gaussian profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.KingFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: KingMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial.KingGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: KingMixin, RadialMixin, GalaxyModel

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.KingRay(*, filename=None, model_type=None, **kwargs)#

Bases: iKingMixin, RayMixin, GalaxyModel

iKingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

Rc, Rt, alpha, and I0 are batched by their first dimension, allowing for multiple King profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.KingSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: KingMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.KingWarp(*, filename=None, model_type=None, **kwargs)#

Bases: KingMixin, RadialMixin, WarpMixin, GalaxyModel

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.KingWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iKingMixin, WedgeMixin, GalaxyModel

iKingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

Rc, Rt, alpha, and I0 are batched by their first dimension, allowing for multiple King profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [model param]

  • Rt – truncation radius [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.MoffatFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial.MoffatGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatMixin, RadialMixin, GalaxyModel

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.MoffatRay(*, filename=None, model_type=None, **kwargs)#

Bases: iMoffatMixin, RayMixin, GalaxyModel

iMoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

n, Rd, and I0 are batched by their first dimension, allowing for multiple Moffat profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.MoffatSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.MoffatWarp(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatMixin, RadialMixin, WarpMixin, GalaxyModel

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.MoffatWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iMoffatMixin, WedgeMixin, GalaxyModel

iMoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

n, Rd, and I0 are batched by their first dimension, allowing for multiple Moffat profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.NukerFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: NukerMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial.NukerGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: NukerMixin, RadialMixin, GalaxyModel

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.NukerRay(*, filename=None, model_type=None, **kwargs)#

Bases: iNukerMixin, RayMixin, GalaxyModel

iNukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

Rb, Ib, alpha, beta, and gamma are batched by their first dimension, allowing for multiple Nuker profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.NukerSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: NukerMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.NukerWarp(*, filename=None, model_type=None, **kwargs)#

Bases: NukerMixin, RadialMixin, WarpMixin, GalaxyModel

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.NukerWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iNukerMixin, WedgeMixin, GalaxyModel

iNukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

Rb, Ib, alpha, beta, and gamma are batched by their first dimension, allowing for multiple Nuker profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.SersicFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SersicMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial.SersicGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: SersicMixin, RadialMixin, GalaxyModel

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.SersicRay(*, filename=None, model_type=None, **kwargs)#

Bases: iSersicMixin, RayMixin, GalaxyModel

iSersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

n, Re, and Ie are batched by their first dimension, allowing for multiple Sersic profiles to be defined at once.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.SersicSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SersicMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.SersicWarp(*, filename=None, model_type=None, **kwargs)#

Bases: SersicMixin, RadialMixin, WarpMixin, GalaxyModel

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.SersicWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iSersicMixin, WedgeMixin, GalaxyModel

iSersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

n, Re, and Ie are batched by their first dimension, allowing for multiple Sersic profiles to be defined at once.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.SplineFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SplineMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial.SplineGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: SplineMixin, RadialMixin, GalaxyModel

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.SplineRay(*, filename=None, model_type=None, **kwargs)#

Bases: iSplineMixin, RayMixin, GalaxyModel

iSplineMixin

Batched spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

Both I_R and I_R.prof are batched by their first dimension, allowing for multiple spline profiles to be defined at once. Each individual spline model is then I_R[i] and I_R.prof[i] where i indexes the profiles.

RayMixin

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.SplineSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SplineMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.SplineWarp(*, filename=None, model_type=None, **kwargs)#

Bases: SplineMixin, RadialMixin, WarpMixin, GalaxyModel

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

usable = True#
class astrophot.models.radial.SplineWedge(*, filename=None, model_type=None, **kwargs)#

Bases: iSplineMixin, WedgeMixin, GalaxyModel

iSplineMixin

Batched spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

Both I_R and I_R.prof are batched by their first dimension, allowing for multiple spline profiles to be defined at once. Each individual spline model is then I_R[i] and I_R.prof[i] where i indexes the profiles.

WedgeMixin

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

usable = True#
class astrophot.models.radial.TExponentialFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, ExponentialMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TExponentialGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, ExponentialMixin, RadialMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TExponentialSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, ExponentialMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TExponentialWarp(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, ExponentialMixin, RadialMixin, WarpMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

ExponentialMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TFerrerFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, FerrerMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TFerrerGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, FerrerMixin, RadialMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TFerrerSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, FerrerMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TFerrerWarp(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, FerrerMixin, RadialMixin, WarpMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

FerrerMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • rout – Outer truncation radius in arcseconds. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/arcsec^2 [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TGaussianFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, GaussianMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TGaussianGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, GaussianMixin, RadialMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TGaussianSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, GaussianMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TGaussianWarp(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, GaussianMixin, RadialMixin, WarpMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

GaussianMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • sigma – Standard deviation of the Gaussian profile in arcseconds. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TKingFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, KingMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • Rc – core radius [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TKingGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, KingMixin, RadialMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TKingSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, KingMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • Rc – core radius [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TKingWarp(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, KingMixin, RadialMixin, WarpMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

KingMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • Rc – core radius [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TMoffatFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, MoffatMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TMoffatGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, MoffatMixin, RadialMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TMoffatSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, MoffatMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TMoffatWarp(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, MoffatMixin, RadialMixin, WarpMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

MoffatMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [model param]

  • I0 – Intensity at the center of the profile [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TNukerFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, NukerMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TNukerGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, NukerMixin, RadialMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TNukerSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, NukerMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TNukerWarp(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, NukerMixin, RadialMixin, WarpMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

NukerMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • Rb – scale length radius [model param]

  • Ib – intensity at the scale length [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TSersicFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, SersicMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TSersicGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, SersicMixin, RadialMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TSersicSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, SersicMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TSersicWarp(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, SersicMixin, RadialMixin, WarpMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

SersicMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [arcsec] [model param]

  • Ie – intensity at the half light radius [flux/arcsec^2] [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TSplineFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, SplineMixin, RadialMixin, FourierEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • modes – Tuple of integers indicating which Fourier modes to use.

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TSplineGalaxy(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, SplineMixin, RadialMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TSplineSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, SplineMixin, RadialMixin, SuperEllipseMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.radial.TSplineWarp(*, filename=None, model_type=None, **kwargs)#

Bases: TruncationMixin, SplineMixin, RadialMixin, WarpMixin, GalaxyModel

TruncationMixin

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

SplineMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

GalaxyModel

Intended to represent a galaxy or extended component in an image.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • I_R – Array of radial brightness values in units of flux/arcsec^2. [model param]

  • Rt – The truncation radius in arcseconds. [model param]

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

usable = True#
class astrophot.models.edgeon.EdgeonIsothermal(*, filename=None, model_type=None, **kwargs)[source]#

Bases: EdgeonSech

A self-gravitating locally-isothermal edgeon disk. This comes from van der Kruit & Searle 1981.

EdgeonSech

An edgeon profile where the vertical distribution is a sech^2 profile, subclasses define the radial profile.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • PA – Position angle of the edgeon disk in radians. [model param]

  • I0 – The central intensity of the sech^2 profile in flux/arcsec^2. [model param]

  • hs – The scale height of the sech^2 profile in arcseconds. [model param]

  • rs – Scale radius of the isothermal disk in arcseconds. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], rs: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
usable = True#
class astrophot.models.edgeon.EdgeonModel(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

General Edge-On galaxy model to be subclassed for any specific representation such as radial light profile or the structure of the galaxy on the sky. Defines an edgeon galaxy as an object with a position angle, no inclination information is included.

Parameters:

PA – Position angle of the edgeon disk in radians.

initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
usable = False#
class astrophot.models.edgeon.EdgeonSech(*, filename=None, model_type=None, **kwargs)[source]#

Bases: EdgeonModel

An edgeon profile where the vertical distribution is a sech^2 profile, subclasses define the radial profile.

Parameters:
  • I0 – The central intensity of the sech^2 profile in flux/arcsec^2.

  • hs – The scale height of the sech^2 profile in arcseconds.

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], hs: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

usable = False#
class astrophot.models.gaussian_ellipsoid.GaussianEllipsoid(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

Model that represents a galaxy as a 3D Gaussian ellipsoid.

The model is triaxial, meaning it has three different standard deviations along the three axes. The orientation of the ellipsoid is defined by Euler angles.

If all three Euler angles are set to zero, the ellipsoid is aligned with the image axes meaning sigma_a gives the std along the x axis of the tangent plane, sigma_b gives the std along the y axis of the tangent plane, and sigma_z gives the std into the tangent plane. We use the ZXZ convention for the Euler angles. This means that for a disk galaxy, one can naturally consider sigma_c as the disk thickness and sigma_a=sigma_b as the disk radius; setting the Euler angles to zero would leave the disk face-on in the x-y tangent plane.

Note:

the model is highly degenerate, meaning that it is not possible to uniquely determine the parameters from the data. The model is useful if one already has a 3D model of the galaxy in mind and wants to produce mock data. Alternately, if one applies some constraints on the parameters, such as sigma_a = sigma_b and alpha=0, then the model will be better determined. In that case, beta is related to the inclination of the disk and gamma is related to the position angle of the disk. The initialization for this model assumes exactly this interpretation with a disk thickness of sigma_c = 0.2 *sigma_a.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • sigma_a – Standard deviation of the Gaussian along the alpha axis in arcseconds. [model param]

  • sigma_b – Standard deviation of the Gaussian along the beta axis in arcseconds. [model param]

  • sigma_c – Standard deviation of the Gaussian along the gamma axis in arcseconds. [model param]

  • alpha – Euler angle representing the rotation around the alpha axis in radians. [model param]

  • beta – Euler angle representing the rotation around the beta axis in radians. [model param]

  • gamma – Euler angle representing the rotation around the gamma axis in radians. [model param]

  • flux – Total flux of the galaxy in arbitrary units. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma_a: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma_b: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma_c: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], gamma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], flux: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Brightness of the Gaussian ellipsoid.

initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

usable = True#
class astrophot.models.multi_gaussian_expansion.MultiGaussianExpansion(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

Model that represents a galaxy as a sum of multiple Gaussian profiles. The model is defined as:

\[I(R) = \sum_i {\rm flux}_i * \exp(-0.5*(R_i / \sigma_i)^2) / (2 * \pi * q_i * \sigma_i^2)\]

where \(R_i\) is a radius computed using \(q_i\) and \(PA_i\) for that component. All components share the same center.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • q – axis ratio to scale minor axis from the ratio of the minor/major axis b/a, this parameter is unitless, it is restricted to the range (0,1) [model param]

  • PA – position angle of the semi-major axis East of North, it is a cyclic parameter in the range [0,pi) [model param]

  • sigma – standard deviation of each Gaussian [model param]

  • flux – amplitude of each Gaussian [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], flux: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], q: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], q: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
usable = True#
class astrophot.models.pixelated_model.Pixelated(*, filename=None, model_type=None, **kwargs)[source]#

Bases: ComponentModel

Model described by a grid of pixels on the sky (bilinear interpolation)

This model represents an extended source on the sky as a grid of pixels with some brightness. The brightness at any point is determined by bilinear interpolation of the grid values. This is a very flexible model that can represent any source, but it is also computationally expensive to optimize the large number of free parameters.

The PA and scale are also parameters of this model, so one could alternately fix the pixels to some image and just fit the PA and scale.

ComponentModel

Component of a model for an object in an image.

This is a single component of an image model. It has a position on the sky determined by center and may or may not be convolved with a PSF to represent some data.

SampleMixin

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Model

Base class for all AstroPhot models.

Parameters:
  • center – The center of the component in arcseconds [x, y] defined on the tangent plane. [model param]

  • I – the total flux within each pixel, in units of flux/arcsec^2. [model param]

  • PA – the position angle of the model, in radians. [model param]

  • scale – the scale of the model, in arcsec per grid unit. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • psf_convolve – Whether to convolve the model with a PSF. (bool, default True)

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#

Determine initial values for the center coordinates. This is done with a local center of mass search which iterates by finding the center of light in a window, then iteratively updates until the iterations move by less than a pixel.

transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], scale: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
usable = True#

PSF Models#

class astrophot.models.radial_psf.ExponentialPSF(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialPSFMixin, RadialMixin, PSFModel

ExponentialPSFMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.ExponentialPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialPSFMixin, EllipseMixin, RadialMixin, PSFModel

ExponentialPSFMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.ExponentialPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

ExponentialPSFMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial_psf.ExponentialPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

ExponentialPSFMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.ExponentialPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: ExponentialPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

ExponentialPSFMixin

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Re – effective radius, radius enclosing half the total light [model param]

  • Ie – effective surface density, brightness at the effective radius [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.FerrerPSF(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerPSFMixin, RadialMixin, PSFModel

FerrerPSFMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • rout – Outer truncation radius in pixels. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/pix^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.FerrerPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerPSFMixin, EllipseMixin, RadialMixin, PSFModel

FerrerPSFMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in pixels. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/pix^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.FerrerPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

FerrerPSFMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in pixels. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/pix^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial_psf.FerrerPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

FerrerPSFMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in pixels. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/pix^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.FerrerPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: FerrerPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

FerrerPSFMixin

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • rout – Outer truncation radius in pixels. [model param]

  • alpha – Inner slope parameter. [model param]

  • beta – Outer slope parameter. [model param]

  • I0 – Intensity at the center of the profile in flux/pix^2 [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.GaussianPSF(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianPSFMixin, RadialMixin, PSFModel

GaussianPSFMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • sigma – Standard deviation of the Gaussian profile in pixels. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.GaussianPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianPSFMixin, EllipseMixin, RadialMixin, PSFModel

GaussianPSFMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in pixels. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.GaussianPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

GaussianPSFMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in pixels. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial_psf.GaussianPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

GaussianPSFMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in pixels. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.GaussianPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: GaussianPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

GaussianPSFMixin

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • sigma – Standard deviation of the Gaussian profile in pixels. [model param]

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results). [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.KingPSF(*, filename=None, model_type=None, **kwargs)#

Bases: KingPSFMixin, RadialMixin, PSFModel

KingPSFMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • Rc – core radius [pix] [model param]

  • Rt – truncation radius [pix] [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.KingPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: KingPSFMixin, EllipseMixin, RadialMixin, PSFModel

KingPSFMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [pix] [model param]

  • Rt – truncation radius [pix] [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.KingPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: KingPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

KingPSFMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [pix] [model param]

  • Rt – truncation radius [pix] [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial_psf.KingPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: KingPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

KingPSFMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [pix] [model param]

  • Rt – truncation radius [pix] [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.KingPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: KingPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

KingPSFMixin

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rc – core radius [pix] [model param]

  • Rt – truncation radius [pix] [model param]

  • alpha – concentration index which controls the shape of the brightness profile [model param]

  • I0 – intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.MoffatPSF(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatPSFMixin, RadialMixin, PSFModel

MoffatPSFMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [pix] [model param]

  • I0 – Intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.MoffatPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatPSFMixin, EllipseMixin, RadialMixin, PSFModel

MoffatPSFMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [pix] [model param]

  • I0 – Intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.MoffatPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

MoffatPSFMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [pix] [model param]

  • I0 – Intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial_psf.MoffatPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

MoffatPSFMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [pix] [model param]

  • I0 – Intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.MoffatPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: MoffatPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

MoffatPSFMixin

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Concentration index which controls the shape of the brightness profile [model param]

  • Rd – Scale length radius [pix] [model param]

  • I0 – Intensity at the center of the profile [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.NukerPSF(*, filename=None, model_type=None, **kwargs)#

Bases: NukerPSFMixin, RadialMixin, PSFModel

NukerPSFMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • Rb – scale length radius [pix] [model param]

  • Ib – intensity at the scale length [flux/pix^2] [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.NukerPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: NukerPSFMixin, EllipseMixin, RadialMixin, PSFModel

NukerPSFMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [pix] [model param]

  • Ib – intensity at the scale length [flux/pix^2] [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.NukerPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: NukerPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

NukerPSFMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [pix] [model param]

  • Ib – intensity at the scale length [flux/pix^2] [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial_psf.NukerPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: NukerPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

NukerPSFMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [pix] [model param]

  • Ib – intensity at the scale length [flux/pix^2] [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.NukerPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: NukerPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

NukerPSFMixin

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • Rb – scale length radius [pix] [model param]

  • Ib – intensity at the scale length [flux/pix^2] [model param]

  • alpha – sharpness of transition between power law slopes [model param]

  • beta – outer power law slope [model param]

  • gamma – inner power law slope [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.SersicPSF(*, filename=None, model_type=None, **kwargs)#

Bases: SersicPSFMixin, RadialMixin, PSFModel

SersicPSFMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [pix] [model param]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.SersicPSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SersicPSFMixin, EllipseMixin, RadialMixin, PSFModel

SersicPSFMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [pix] [model param]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.SersicPSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SersicPSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

SersicPSFMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [pix] [model param]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial_psf.SersicPSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SersicPSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

SersicPSFMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [pix] [model param]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.SersicPSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: SersicPSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

SersicPSFMixin

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • n – Sersic index which controls the shape of the brightness profile [model param]

  • Re – half light radius, also called effective radius [pix] [model param]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2] [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.SplinePSF(*, filename=None, model_type=None, **kwargs)#

Bases: SplinePSFMixin, RadialMixin, PSFModel

SplinePSFMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • I_R – Array of radial brightness values in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.SplinePSFEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SplinePSFMixin, EllipseMixin, RadialMixin, PSFModel

SplinePSFMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

EllipseMixin

PSF model with elliptical isophotes defined by a position angle and axis ratio.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.SplinePSFFourierEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SplinePSFMixin, InclinedMixin, RadialMixin, FourierEllipseMixin, PSFModel

SplinePSFMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

FourierEllipseMixin

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode. [model param]

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi) [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

  • modes – Tuple of integers indicating which Fourier modes to use.

usable = True#
class astrophot.models.radial_psf.SplinePSFSuperEllipse(*, filename=None, model_type=None, **kwargs)#

Bases: SplinePSFMixin, InclinedMixin, RadialMixin, SuperEllipseMixin, PSFModel

SplinePSFMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

SuperEllipseMixin

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse. [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.radial_psf.SplinePSFWarp(*, filename=None, model_type=None, **kwargs)#

Bases: SplinePSFMixin, InclinedMixin, RadialMixin, WarpMixin, PSFModel

SplinePSFMixin

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

InclinedMixin

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

WarpMixin

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • q_R – Array of axis ratio values for axis ratio spline [model param]

  • PA_R – Array of position angle values as input to the spline [model param]

  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular. [model param]

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East. [model param]

  • I_R – Array of radial brightness values in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

usable = True#
class astrophot.models.airy.AiryPSF(*, filename=None, model_type=None, **kwargs)[source]#

Bases: RadialMixin, PSFModel

The Airy disk is an analytic description of the diffraction pattern for a circular aperture.

WARNING: This model does not work in JAX (it doesn’t have the required Bessel function implemented)

WARNING: PyTorch appears to have an issue with gradients wrt the R1 parameter. Optimization doesn’t seem to work for this model (maybe try scipy optimize?).

The diffraction pattern is described exactly by the configuration of the lens system under the assumption that all elements are perfect. This expression goes as:

\[I(\theta) = I_0\left[\frac{2J_1(x)}{x}\right]^2\]
\[x = ka\sin(\theta) = \frac{2\pi a r}{\lambda R}\]

where \(I(\theta)\) is the intensity as a function of the angular position within the diffraction system along its main axis, \(I_0\) is the central intensity of the airy disk, \(J_1\) is the Bessel function of the first kind of order one, \(k = \frac{2\pi}{\lambda}\) is the wavenumber of the light, \(a\) is the aperture radius, \(r\) is the radial position from the center of the pattern, \(R\) is the distance from the circular aperture to the observation plane.

In the AiryPSF class we combine the parameters \(a,R,\lambda\) and scale based on the first zero of the \(J_1\) function. This way you can work with the more intuitive radius parameter.

RadialMixin

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • I0 – The central intensity of the airy disk in flux/pix^2. [model param]

  • R1 – The radius of the first zero of the airy disk in pix. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], R1: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
usable = True#
class astrophot.models.pixelated_psf.PixelatedPSF(*, filename=None, model_type=None, **kwargs)[source]#

Bases: PSFModel

point source model which uses an image of the PSF as its representation for point sources. Using bilinear interpolation it will shift the PSF within a pixel to accurately represent the center location of a point source. There is no functional form for this object type as any image can be supplied. The image pixels will be optimized as individual parameters. This can very quickly result in a large number of parameters and a near impossible fitting task, ideally this should be restricted to a very small area likely at the center of the PSF.

To initialize the PSF image will by default be set to the target PSF_Image values, thus one can use an empirical PSF as a starting point. Since only bilinear interpolation is performed, it is recommended to provide the PSF at a higher resolution than the image if it is near the nyquist sampling limit. Bilinear interpolation is very fast and accurate for smooth models, so this way it is possible to do the expensive interpolation before optimization and save time. Note that if you do this you must provide the PSF as a PSF_Image object with the correct pixelscale (essentially just divide the pixelscale by the upsampling factor you used).

PSFModel

Prototype point source (e.g., a star) model, to be subclassed by other point source models which define specific behavior.

PSF models behave differently than component models. Their target image must be a PSFImage object instead of a TargetImage object. PSF models do not fit a free center parameter; their center is always (0, 0) in pixel coordinates, matching the convention of a PSFImage. A PSF model is never convolved with another PSF model.

Instead of units of arcsec for most length scales, PSFModel objects use pix units. This corresponds to the width of a pixel in the data target image; so if the PSFModel has an upsample factor of 2 then 1 pix corresponds to two pixels in the image that the PSFModel outputs. This way, two PSFModels with different upsample factors, but applied to the same data target image, should still have the same parameter values for their shape parameters.

Parameters:
  • center – Center of the PSF in pixel coordinates [x, y]. Fixed at (0, 0) by default and not included in the fit. [model param]

  • pixels – the total flux within each pixel, in units of flux/pix^2. [model param]

  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

  • jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], pixels: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
initialize()[source]#
usable = True#

Model Mixins#

class astrophot.models.mixins.ExponentialMixin[source]#

Bases: object

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

Parameters:
  • Re – effective radius, radius enclosing half the total light

  • Ie – effective surface density, brightness at the effective radius

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Re: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ie: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.ExponentialPSFMixin[source]#

Bases: object

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

Ie is the brightness at the effective radius, and Re is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

Parameters:
  • Re – effective radius, radius enclosing half the total light

  • Ie – effective surface density, brightness at the effective radius

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Re: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ie: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.FerrerMixin[source]#

Bases: object

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

Parameters:
  • rout – Outer truncation radius in arcseconds.

  • alpha – Inner slope parameter.

  • beta – Outer slope parameter.

  • I0 – Intensity at the center of the profile in flux/arcsec^2

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], rout: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.FerrerPSFMixin[source]#

Bases: object

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

Parameters:
  • rout – Outer truncation radius in pixels.

  • alpha – Inner slope parameter.

  • beta – Outer slope parameter.

  • I0 – Intensity at the center of the profile in flux/pix^2

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], rout: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.FourierEllipseMixin(*args, modes: Tuple[int] = (3, 4), **kwargs)[source]#

Bases: object

Sine wave perturbation of the elliptical radius metric.

This allows for the expression of arbitrarily complex isophotes instead of pure ellipses. This is a common extension of the standard elliptical representation. The form of the Fourier perturbations is:

\[R' = R * \exp\left(\sum_m(a_m * \cos(m * \theta + \phi_m))\right)\]

where R’ is the new radius value, R is the original radius (typically computed as \(\sqrt{x^2+y^2}\)), m is the index of the Fourier mode, a_m is the amplitude of the m’th Fourier mode, theta is the angle around the ellipse (typically \(\arctan(y/x)\)), and phi_m is the phase of the m’th fourier mode.

One can create extremely complex shapes using different Fourier modes, however usually it is only low order modes that are of interest. For intuition, the first Fourier mode is roughly equivalent to a lopsided galaxy, one side will be compressed and the opposite side will be expanded. The second mode is almost never used as it is nearly degenerate with ellipticity. The third mode is an alternate kind of lopsidedness for a galaxy which makes it somewhat triangular, meaning that it is wider on one side than the other. The fourth mode is similar to a boxyness/diskyness parameter of a superelllipse which tends to make more pronounced peanut shapes since it is more rounded than a superellipse representation. Modes higher than 4 are only useful in very specialized situations. In general one should consider carefully why the Fourier modes are being used for the science case at hand.

Parameters:
  • am – Array of amplitudes for the Fourier modes, indicates the strength of each mode.

  • phim – Array of phases for the Fourier modes, adjusts the orientation of the mode perturbation relative to the major axis. It is cyclically defined in the range [0,2pi)

  • modes – Tuple of integers indicating which Fourier modes to use.

initialize()[source]#
radius_metric(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], am: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], phim: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.GaussianMixin[source]#

Bases: object

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

Parameters:
  • sigma – Standard deviation of the Gaussian profile in arcseconds.

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results).

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], flux: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.GaussianPSFMixin[source]#

Bases: object

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where flux is the total flux of the profile and sigma is the standard deviation which controls the width of the profile.

Parameters:
  • sigma – Standard deviation of the Gaussian profile in pixels.

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results).

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], flux: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.GradMixin[source]#

Bases: object

Parameters:

jacobian_maxparams – The maximum number of parameters before the Jacobian will be broken into smaller chunks to reduce memory consumption (int, default: 10).

gradient(params: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, likelihood: Literal['gaussian', 'poisson'] = 'gaussian') Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Compute the gradient of the model likelihood with respect to its parameters.

jacobian(pass_jacobian: JacobianImage | None = None, params: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None) JacobianImage[source]#
jacobian_maxparams = 10#
class astrophot.models.mixins.InclinedMixin[source]#

Bases: object

A model which defines a position angle and axis ratio.

PA and q operate on the coordinates to transform the model. Given some x,y the updated values are:

\[x', y' = {\rm rotate}(-PA + \pi/2, x, y)\]
\[y'' = y' / q\]

where x’ and y’’ are the final transformed coordinates. The \(\pi/2\) is included such that the position angle is defined with 0 at north. The -PA is such that the position angle increases to the East. Thus, the position angle is a standard East of North definition assuming the WCS of the image is correct.

Note that this means radii are defined with \(R = \sqrt{x^2 + \left(\frac{y}{q}\right)^2}\) rather than the common alternative which is \(R = \sqrt{qx^2 + \frac{y^2}{q}}\)

Parameters:
  • q – Axis ratio of the model, defined as the ratio of the semi-minor axis to the semi-major axis. A value of 1.0 is circular.

  • PA – Position angle of the model, defined as the angle between the semi-major axis and North, measured East of North. A value of 0.0 is North, a value of pi/2 is East.

initialize()[source]#
transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], q: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
class astrophot.models.mixins.KingMixin[source]#

Bases: object

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

Parameters:
  • Rc – core radius

  • Rt – truncation radius

  • alpha – concentration index which controls the shape of the brightness profile

  • I0 – intensity at the center of the profile

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rc: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rt: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.KingPSFMixin[source]#

Bases: object

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

Parameters:
  • Rc – core radius [pix]

  • Rt – truncation radius [pix]

  • alpha – concentration index which controls the shape of the brightness profile

  • I0 – intensity at the center of the profile [flux/pix^2]

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rc: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rt: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.MoffatMixin[source]#

Bases: object

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

Parameters:
  • n – Concentration index which controls the shape of the brightness profile

  • Rd – Scale length radius

  • I0 – Intensity at the center of the profile

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], n: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rd: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.MoffatPSFMixin[source]#

Bases: object

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

Parameters:
  • n – Concentration index which controls the shape of the brightness profile

  • Rd – Scale length radius [pix]

  • I0 – Intensity at the center of the profile [flux/pix^2]

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], n: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rd: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.NukerMixin[source]#

Bases: object

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

Parameters:
  • Rb – scale length radius

  • Ib – intensity at the scale length

  • alpha – sharpness of transition between power law slopes

  • beta – outer power law slope

  • gamma – inner power law slope

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rb: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ib: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], gamma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.NukerPSFMixin[source]#

Bases: object

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

Parameters:
  • Rb – scale length radius [pix]

  • Ib – intensity at the scale length [flux/pix^2]

  • alpha – sharpness of transition between power law slopes

  • beta – outer power law slope

  • gamma – inner power law slope

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rb: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ib: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], gamma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.RadialMixin[source]#

Bases: object

This model defines its brightness(x,y) function using a radial model. Thus the brightness is instead defined as radial_model(R)

More specifically the function is:

\[x, y = {\rm transform\_coordinates}(x, y)\]
\[R = {\rm radius\_metric}(x, y)\]
\[I(x, y) = {\rm radial\_model}(R)\]

The transform_coordinates function depends on the model. In its simplest form it simply subtracts the center of the model to re-center the coordinates.

The radius_metric function is also model dependent, in its simplest form this is just \(R = \sqrt{x^2 + y^2}\).

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Calculate the brightness at a given point (x, y) based on radial distance from the center.

class astrophot.models.mixins.RayMixin(*args, symmetric: bool = True, segments: int = 2, **kwargs)[source]#

Bases: object

Defines a model with multiple profiles along rays projected from the center.

model which defines multiple radial models separately along some number of rays projected from the center. These rays smoothly transition from one to another along angles theta. The ray transition uses a cosine smoothing function which depends on the number of rays, for example with two rays the brightness would be:

\[I(R,\theta) = I_1(R)*\cos(\theta \% \pi) + I_2(R)*\cos((\theta + \pi/2) \% \pi)\]

For \(\theta = 0\) the brightness comes entirely from I_1 while for \(\theta = \pi/2\) the brightness comes entirely from I_2.

Parameters:
  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

brightness(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
polar_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], T: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.SampleMixin(*args, sampling_mode='auto', integrate_mode='bright', **kwargs)[source]#

Bases: object

Methods for integrating the model from a smooth model defined in the tangent plane into individual pixel fluxes. This is done in a two step process. First the model is sampled at a set of points within each pixel, and then an adaptive integration method is used to further integrate pixels where it has identified the need for additional accuracy.

The sampling_mode option controls this first step. It determines at what level of depth every pixel is integrated. The midpoint option is the least accurate (and fastest) which just samples the center of each pixel. After that, each method trades more compute for more accuracy. The quad:x method is the most accurate, which uses Gaussian quadrature integration with x points per pixel. Note that quad:5 means that each pixel will be sampled at 25 points (5^2) to determine the flux in that pixel. simpsons is often a good middle ground. Note that for models over a small number of pixels you will likely not notice the runtime difference between midpoint and some higher accuracy method, since other aspects of the fitting process also take up some time.

The integrate_mode option controls the second step, which is an adaptive integration method that identifies and integrates pixels where the model needs extra accuracy. The default method is bright, which identifies the brightest pixels and then uses quadrature integration to further integrate those pixels. The default parameters are to recursively integrate the brightest 5% of pixels up to a maximum depth of 2 recursive levels. Each level does a 5x upsampling and then uses 3rd order quadrature to integrate the super sampled pixels. This means that the most highly integrated pixels will be 5x upsampled twice and the 3x sampled for the quadrature, effectively like upsampling 75 times the starting resolution for those pixels, but only for 0.25% of the pixels. Doing this roughly doubles the amount of compute needed to sample an image relative to midpoint sampling, but gives a massive boost in accuracy for models which change rapidly across a pixel.

Note: JAX does not play nicely with the adaptive integration methods, so it

massively slows down the jit compilation and the final sampling speed. With JAX it is generally better to set integrate_mode to none and use a higher accuracy sampling_mode such as quad:5.

Parameters:
  • sampling_mode – The method used to sample the model in image pixels. Options are: auto: Automatically choose the sampling method based on the image size (default). midpoint: Use midpoint sampling, evaluate the brightness at the center of each pixel. simpsons: Use Simpson’s rule for sampling integrating each pixel. upsample:x upsample the pixel in a regular grid of size x (odd positive integer), generally less accurate than quad:x. quad:x: Use quadrature sampling with order x, where x is an odd positive integer to integrate each pixel.

  • integrate_mode – The method used to select pixels to integrate further where the model varies significantly. Options are: none: No extra integration is performed (beyond the sampling_mode). bright: Select the brightest pixels for further integration (default). curvature: Select pixels which show signs of significant higher order derivatives.

  • integrate_fraction – The fraction of the pixels to super sample during integration (default: 0.05).

  • integrate_max_depth – The maximum depth of the integration method (default: 2).

  • integrate_gridding – The gridding used for the integration method to super-sample a pixel at each iteration (default: 5).

  • integrate_quad_order – The order of the quadrature used for the integration method on the super sampled pixels (default: 3).

integrate_fraction = 0.05#
integrate_gridding = 5#
integrate_max_depth = 2#
property integrate_mode#
integrate_quad_order = 3#
property sampling_mode#
class astrophot.models.mixins.SersicMixin[source]#

Bases: object

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

Parameters:
  • n – Sersic index which controls the shape of the brightness profile

  • Re – half light radius, also called effective radius [arcsec]

  • Ie – intensity at the half light radius [flux/arcsec^2]

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], n: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Re: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ie: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.SersicPSFMixin[source]#

Bases: object

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling, though it is simply a generalization of a Gaussian. It can be a good starting point for many objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It includes the gaussian, exponential, and de-Vaucouleurs profiles. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

Parameters:
  • n – Sersic index which controls the shape of the brightness profile

  • Re – half light radius, also called effective radius [pix]

  • Ie – intensity at the half light radius, also called effective intensity [flux/pix^2]

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], n: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Re: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ie: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.SplineMixin[source]#

Bases: object

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

Parameters:

I_R – Array of radial brightness values in units of flux/arcsec^2.

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I_R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.SplinePSFMixin[source]#

Bases: object

Spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/pix^2. The radius of each node is determined from I_R.prof.

Parameters:

I_R – Array of radial brightness values in units of flux/pix^2.

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I_R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.SuperEllipseMixin[source]#

Bases: object

Uses a generalized definition of radius to make boxy/disky models.

A superellipse transformation allows for the expression of “boxy” and “disky” modifications to traditional elliptical isophotes. This is a common extension of the standard elliptical representation, especially for early-type galaxies. The functional form for this is:

\[R = (|x|^C + |y|^C)^{1/C}\]

where \(R\) is the new distance metric, \(X\) and \(Y\) are the coordinates, and \(C\) is the coefficient for the superellipse. \(C\) can take on any value greater than zero where \(C = 2\) is the standard distance metric, \(0 < C < 2\) creates disky or pointed perturbations to an ellipse, and \(C > 2\) transforms an ellipse to be more boxy.

Parameters:

C – Superellipse distance metric parameter, controls the shape of the isophotes. A value of 2.0 is a standard elliptical distance metric, values less than 2.0 create disky or pointed perturbations to an ellipse, and values greater than 2.0 create boxy perturbations to an ellipse.

radius_metric(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], C: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.TruncationMixin(*args, outer_truncation: bool = True, **kwargs)[source]#

Bases: object

Truncated model with radial brightness profile.

This model will smoothly truncate the radial brightness profile at Rt. The truncation is centered on Rt and thus two identical models with the same Rt (and St) where one is inner truncated and the other is outer truncated will reproduce nearly the same as a single un-truncated model.

By default the St parameter is set fixed to 1.0, giving a relatively smooth truncation. This can be set to a smaller value for sharper truncations or a larger value for even more gradual truncation. It can be set dynamic to be optimized in a model, though it is possible for this parameter to be unstable if there isn’t a clear truncation signal in the data.

Parameters:
  • Rt – The truncation radius in arcseconds.

  • St – The steepness of the truncation profile, controlling how quickly the brightness drops to zero at the truncation radius.

  • outer_truncation – If True, the model will truncate the brightness beyond the truncation radius. If False, the model will truncate the brightness within the truncation radius.

initialize()[source]#
radial_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rt: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], St: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.WarpMixin[source]#

Bases: object

Warped model with varying PA and q as a function of radius.

This works by warping the coordinates using the same transform for a global PA, q except applied to each pixel individually based on its unwarped radius value. In the limit that PA and q are a constant, this recovers a basic model with global PA, q. However, a linear PA profile will give a spiral appearance, variations of PA, q profiles can create complex galaxy models. The form of the coordinate transformation for each pixel looks like:

\[R = \sqrt{x^2 + y^2}\]
\[x', y' = \rm{rotate}(-PA(R) + \pi/2, x, y)\]
\[y'' = y' / q(R)\]

Note that now PA and q are functions of radius R, which is computed from the original coordinates X, Y. This is achieved by making PA and q a spline profile.

Parameters:
  • q_R – Array of axis ratio values for axis ratio spline

  • PA_R – Array of position angle values as input to the spline

initialize()[source]#
transform_coordinates(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], q_R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], PA_R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
class astrophot.models.mixins.WedgeMixin(*args, symmetric: bool = True, segments: int = 2, **kwargs)[source]#

Bases: object

Defines a model with multiple profiles that form wedges projected from the center.

model which defines multiple radial models separately along some number of wedges projected from the center. These wedges have sharp transitions along boundary angles theta.

Parameters:
  • symmetric – If True, the model will have symmetry for rotations of pi radians and each ray will appear twice on the sky on opposite sides of the model. If False, each ray is independent.

  • segments – The number of segments to divide the model into. This controls how many rays are used in the model. The default is 2

brightness(x: Tensor, y: Tensor) Tensor[source]#
polar_model(R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], T: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.iExponentialMixin[source]#

Bases: object

Exponential radial light profile.

An exponential is a classical radial model used in many contexts. The functional form of the exponential profile is defined as:

\[I(R) = I_e \exp\left(- b_1\left(\frac{R}{R_e} - 1\right)\right)\]

\(I_e\) is the brightness at the effective radius, and \(R_e\) is the effective radius. \(b_1\) is a constant that ensures \(I_e\) is the brightness at \(R_e\).

Re and Ie are batched by their first dimension, allowing for multiple exponential profiles to be defined at once.

Parameters:
  • Re – effective radius, radius enclosing half the total light

  • Ie – effective surface density, brightness at the effective radius

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Re: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ie: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.iFerrerMixin[source]#

Bases: object

Modified Ferrer radial light profile (Binney & Tremaine 1987).

This model has a relatively flat brightness core and then a truncation. It is used in specialized circumstances such as fitting the bar of a galaxy. The functional form of the Modified Ferrer profile is defined as:

\[I(R) = I_0 \left(1 - \left(\frac{R}{r_{\rm out}}\right)^{2-\beta}\right)^{\alpha}\]

where rout is the outer truncation radius, alpha controls the steepness of the truncation, beta controls the shape, and I0 is the intensity at the center of the profile.

rout, alpha, beta, and I0 are batched by their first dimension, allowing for multiple Ferrer profiles to be defined at once.

Parameters:
  • rout – Outer truncation radius in arcseconds.

  • alpha – Inner slope parameter.

  • beta – Outer slope parameter.

  • I0 – Intensity at the center of the profile in flux/arcsec^2

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], rout: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.iGaussianMixin[source]#

Bases: object

Gaussian radial light profile.

The Gaussian profile is a simple and widely used model for extended objects. The functional form of the Gaussian profile is defined as:

\[I(R) = \frac{{\rm flux}}{2\pi\sigma^2} \exp(-R^2 / (2 \sigma^2))\]

where sigma is the standard deviation which controls the width of the profile and flux gives the total flux of the profile (assuming no perturbations).

sigma and flux are batched by their first dimension, allowing for multiple Gaussian profiles to be defined at once.

Parameters:
  • sigma – Standard deviation of the Gaussian profile in arcseconds.

  • flux – Total flux of an unperturbed Gaussian profile (use model.total_flux() for general results).

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], sigma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], flux: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.iKingMixin[source]#

Bases: object

Empirical King radial light profile (Elson 1999).

Often used for star clusters. By default the profile has alpha = 2 but we allow the parameter to vary freely for fitting. The functional form of the Empirical King profile is defined as:

\[I(R) = I_0\left[\frac{1}{(1 + (R/R_c)^2)^{1/\alpha}} - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{\alpha}\left[1 - \frac{1}{(1 + (R_t/R_c)^2)^{1/\alpha}}\right]^{-\alpha}\]

where R_c is the core radius, R_t is the truncation radius, and I_0 is the intensity at the center of the profile. alpha is the concentration index which controls the shape of the profile.

Rc, Rt, alpha, and I0 are batched by their first dimension, allowing for multiple King profiles to be defined at once.

Parameters:
  • Rc – core radius

  • Rt – truncation radius

  • alpha – concentration index which controls the shape of the brightness profile

  • I0 – intensity at the center of the profile

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rc: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rt: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.iMoffatMixin[source]#

Bases: object

Moffat radial light profile (Moffat 1969).

The moffat profile gives a good representation of the general structure of PSF functions for ground based data. It can also be used to fit extended objects. The functional form of the Moffat profile is defined as:

\[I(R) = \frac{I_0}{(1 + (R/R_d)^2)^n}\]

n is the concentration index which controls the shape of the profile.

n, Rd, and I0 are batched by their first dimension, allowing for multiple Moffat profiles to be defined at once.

Parameters:
  • n – Concentration index which controls the shape of the brightness profile

  • Rd – Scale length radius

  • I0 – Intensity at the center of the profile

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], n: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rd: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I0: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.iNukerMixin[source]#

Bases: object

Nuker radial light profile (Lauer et al. 1995).

This is a classic profile used widely in galaxy modelling. The functional form of the Nuker profile is defined as:

\[I(R) = I_b2^{\frac{\beta - \gamma}{\alpha}}\left(\frac{R}{R_b}\right)^{-\gamma}\left[1 + \left(\frac{R}{R_b}\right)^{\alpha}\right]^{\frac{\gamma-\beta}{\alpha}}\]

It is effectively a double power law profile. \(\gamma\) gives the inner slope, \(\beta\) gives the outer slope, \(\alpha\) is somewhat degenerate with the other slopes.

Rb, Ib, alpha, beta, and gamma are batched by their first dimension, allowing for multiple Nuker profiles to be defined at once.

Parameters:
  • Rb – scale length radius

  • Ib – intensity at the scale length

  • alpha – sharpness of transition between power law slopes

  • beta – outer power law slope

  • gamma – inner power law slope

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Rb: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ib: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], alpha: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], beta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], gamma: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.iSersicMixin[source]#

Bases: object

Sersic radial light profile (Sersic 1963).

This is a classic profile used widely in galaxy modelling. It can be a good starting point for many extended objects. The functional form of the Sersic profile is defined as:

\[I(R) = I_e \exp(- b_n((R/R_e)^{1/n} - 1))\]

It is a generalization of a gaussian, exponential, and de-Vaucouleurs profile. The Sersic index n controls the shape of the profile, with n=1 being an exponential profile, n=4 being a de-Vaucouleurs profile, and n=0.5 being a Gaussian profile.

n, Re, and Ie are batched by their first dimension, allowing for multiple Sersic profiles to be defined at once.

Parameters:
  • n – Sersic index which controls the shape of the brightness profile

  • Re – half light radius, also called effective radius [arcsec]

  • Ie – intensity at the half light radius [flux/arcsec^2]

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], n: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Re: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Ie: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
class astrophot.models.mixins.iSplineMixin[source]#

Bases: object

Batched spline radial model for brightness.

The radial_model function for this model is defined as a spline interpolation from the parameter I_R. The I_R parameter is a tensor that contains the radial profile of the brightness in units of flux/arcsec^2. The radius of each node is determined from I_R.prof.

Both I_R and I_R.prof are batched by their first dimension, allowing for multiple spline profiles to be defined at once. Each individual spline model is then I_R[i] and I_R.prof[i] where i indexes the profiles.

Parameters:

I_R – Array of radial brightness values in units of flux/arcsec^2.

initialize()[source]#
iradial_model(i: int, R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], I_R: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#