PSFConvolvedModel2D

class petrofit.modeling.PSFConvolvedModel2D(model, psf=None, oversample=None, psf_oversample=None, name=None, **kwargs)[source]

Bases: FittableModel

Fittable model for converting FittableModel and CompoundModel into 2D images. This model takes the input sub-model and adds PSF convolution, as well as PSF convolution.

Parameters:
modelastropy.modeling.core.Model

Base model to convert into an image.

psfarray

2D normalized (i.e sum(psf) = 1) image of the point spread function.

oversampleNone or int or tuple

Oversampling factor. If set to None, no oversampling will be applied to the image. If an integer is provided, the whole image will be oversampled by that factor. If a tuple of (center_x, center_y, box_length, oversample_factor) can be used to define an oversampling window. box_length and oversample_factor should always be integers. center_x and center_y can be either float values of the oversampling window or string names of parameters in the input model (for example "x_0").

psf_oversampleNone or int

Oversampling factor of the PSF relative to data. The oversample factor should be an integer multiple of the PSF oversampling factor (i.e oversample > psf_oversample).

namestring

Name for the PSFConvolvedModel2D model instance.

Attributes Summary

cache_grid

Returns the cached sampling grid

model

Returns sub-model with current parameters of the PSFConvolvedModel2D

n_inputs

n_outputs

oversample

Sampling grid oversample Factor

param_names

On most Model classes this is a class attribute, but for PSFConvolvedModel2D models it is an instance attribute since each input sub-model can have different parameters.

psf

PSF Image

psf_oversample

PSF oversample factor relative to data

Methods Summary

__call__(*inputs[, model_set_axis, ...])

Evaluate this model using the given input(s) and the parameter values that were specified when the model was instantiated.

clear_cached_grid()

Clears cached grid and resets class attributes to default values

evaluate(x, y, *params, **kwargs)

Evaluate the model on given coordinates and parameters. Parameters: ----------- x : numpy.ndarray Array of x-coordinates where the model is to be evaluated. y : numpy.ndarray Array of y-coordinates where the model is to be evaluated. *params : tuple Additional parameters for the wrapped model, though the last parameter is expected to be psf_p. **kwargs : dict Additional keyword arguments for the wrapped mode. Returns: -------- numpy.ndarray The evaluated model image at the given coordinates. Notes: ------ - The function prepares the main sampling grid based on the provided coordinates and oversampling factors. - It constructs the main model image by sampling the sub-model. - If oversampling is specified, the function handles both integer and sub-grid based oversampling. - The model image is convolved with the PSF if provided. - The final model image is reduced to the data resolution if the PSF is oversampled. - The function returns the model image at the specified coordinates.

Attributes Documentation

cache_grid

Returns the cached sampling grid

model

Returns sub-model with current parameters of the PSFConvolvedModel2D

n_inputs = 2
n_outputs = 1
oversample

Sampling grid oversample Factor

param_names

Names of the parameters that describe models of this type.

The parameters in this tuple are in the same order they should be passed in when initializing a model of a specific type. Some types of models, such as polynomial models, have a different number of parameters depending on some other property of the model, such as the degree.

When defining a custom model class the value of this attribute is automatically set by the Parameter attributes defined in the class body.

psf

PSF Image

psf_oversample

PSF oversample factor relative to data

Methods Documentation

__call__(*inputs, model_set_axis=None, with_bounding_box=False, fill_value=nan, equivalencies=None, inputs_map=None, **new_inputs)

Evaluate this model using the given input(s) and the parameter values that were specified when the model was instantiated.

clear_cached_grid()[source]

Clears cached grid and resets class attributes to default values

evaluate(x, y, *params, **kwargs)[source]

Evaluate the model on given coordinates and parameters. Parameters: ———– x : numpy.ndarray

Array of x-coordinates where the model is to be evaluated.

ynumpy.ndarray

Array of y-coordinates where the model is to be evaluated.

*paramstuple

Additional parameters for the wrapped model, though the last parameter is expected to be psf_p.

**kwargsdict

Additional keyword arguments for the wrapped mode.

Returns:

numpy.ndarray

The evaluated model image at the given coordinates.

Notes:

  • The function prepares the main sampling grid based on the provided coordinates and oversampling factors.

  • It constructs the main model image by sampling the sub-model.

  • If oversampling is specified, the function handles both integer and sub-grid based oversampling.

  • The model image is convolved with the PSF if provided.

  • The final model image is reduced to the data resolution if the PSF is oversampled.

  • The function returns the model image at the specified coordinates.