PSFConvolvedModel2D
- class petrofit.modeling.PSFConvolvedModel2D(model, psf=None, oversample=None, psf_oversample=None, name=None, **kwargs)[source]
Bases:
FittableModelFittable model for converting
FittableModelandCompoundModelinto 2D images. This model takes the input sub-model and adds PSF convolution, as well as PSF convolution.- Parameters:
- model
astropy.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_lengthandoversample_factorshould always be integers.center_xandcenter_ycan 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
oversamplefactor should be an integer multiple of the PSF oversampling factor (i.eoversample > psf_oversample).- namestring
Name for the
PSFConvolvedModel2Dmodel instance.
- model
Attributes Summary
Returns the cached sampling grid
Returns sub-model with current parameters of the
PSFConvolvedModel2DSampling grid oversample Factor
On most
Modelclasses this is a class attribute, but forPSFConvolvedModel2Dmodels it is an instance attribute since each input sub-model can have different parameters.PSF Image
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.
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
Parameterattributes 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.
- 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.