model_to_image

petrofit.modeling.model_to_image(model, size, mode='center', factor=1, center=None)[source]

Converts 2D models into images using astropy.convolution.utils.discretize_model.

Parameters:
modelFittableModel or callable.

Analytic model function to be discretized. Callables, which are not an instances of FittableModel are passed to custom_model and then evaluated.

sizeint or tuple

The x and y size (in pixels) of the image in pixels (must be an whole number). If only a single integer is provided, an image of equal x and y size is generated. If tuple is provided (x_size, y_size) is assumed (N.B reverse of numpy.array.shape output).

modestr, optional
One of the following modes (astropy.convolution.utils.discretize_model):
  • 'center' (default)

    Discretize model by taking the value at the center of the bin.

  • 'linear_interp'

    Discretize model by linearly interpolating between the values at the corners of the bin. For 2D models interpolation is bilinear.

  • 'oversample'

    Discretize model by taking the average on an oversampled grid.

  • 'integrate'

    Discretize model by integrating the model over the bin using scipy.integrate.quad. Very slow.

factorfloat or int

Factor of oversampling. Default = 1 (no oversampling).

centertuple

(x, y) Coordinate of the center of the image (in pixels). The origin of the image is defined as origin = center - floor_divide(size, 2) (i.e the image will range from (origin -> origin + size)). If None, the origin of the image is assumed to be at (0, 0) (i.e center = floor_divide(size, 2)).

Returns:
arraynumpy.array

Model image