PSFModel

class sherpa.instrument.PSFModel(name='psfmodel', kernel=None)[source] [edit on github]

Bases: Model

Convolve a model by another model or data set.

At the moment the code does not distinguish between 1D and 2D data and models.

Parameters
  • name (str) – The name for the model.

  • kernel (sherpa.data.Data instance, callable, or None, optional) – The kernel used to convolve models. This can be changed.

Notes

A number of attributes are displayed as parameters, if set, but are not handled as parameters. The attributes are: kernel, size, origin, and center. The size, center, and origin values are only displayed when set (and will be set by the fold method if needed). There is an attempt to ensure that the size, origin, and center fields have the correct size - that is they match the dimensionality of the kernel - but it is possible for an invalid combination to be set.

Attributes Summary

BETTER_RESOLUTION

SAME_RESOLUTION

WORSE_RESOLUTION

center

array of size parameters

kernel

The kernel (sherpa.data.Data or sherpa.models.model.Model instance, callable, or None).

model

The model that applies the convolution.

ndim

The dimensionality of the model, if defined, or None.

origin

FFT origin

size

array of size parameters

thawedparhardmaxes

The hard maximum values for the thawed parameters.

thawedparhardmins

The hard minimum values for the thawed parameters.

thawedparmaxes

The maximum limits of the thawed parameters.

thawedparmins

The minimum limits of the thawed parameters.

thawedpars

The thawed parameters of the model.

Methods Summary

calc(*args, **kwargs)

Evaluate the model on a grid.

fold(data)

The data to be convolved by the PSF.

freeze()

Freeze any thawed parameters of the model.

get_center()

get_kernel(data[, subkernel])

Return a data object representing the kernel.

guess(dep, *args, **kwargs)

Set an initial guess for the parameter values.

reset()

Reset the parameter values.

set_center(*args, **kwargs)

startup([cache])

Called before a model may be evaluated multiple times.

teardown()

Called after a model may be evaluated multiple times.

thaw()

Thaw any frozen parameters of the model.

Attributes Documentation

BETTER_RESOLUTION = 1
SAME_RESOLUTION = 0
WORSE_RESOLUTION = -1
center

array of size parameters

kernel

The kernel (sherpa.data.Data or sherpa.models.model.Model instance, callable, or None).

The kernel determines the dimensionality of the model (the ndim attribute), although it can remain as None for callable arguments. The size, origin, and center fields, if set, must match the ndim field, and will be cleared if they do not match.

model

The model that applies the convolution.

This is set by the fold method and can not be changed directly.

ndim = None

The dimensionality of the model, if defined, or None.

origin

FFT origin

size

array of size parameters

thawedparhardmaxes

The hard maximum values for the thawed parameters.

The minimum and maximum range of the parameters can be changed with thawedparmins and thawedparmaxes but only within the range given by thawedparhardmins to thawparhardmaxes.

thawedparhardmins

The hard minimum values for the thawed parameters.

The minimum and maximum range of the parameters can be changed with thawedparmins and thawedparmaxes but only within the range given by thawedparhardmins to thawparhardmaxes.

thawedparmaxes

The maximum limits of the thawed parameters.

Get or set the maximum limits of the thawed parameters of the model as a list of numbers. If there are no thawed parameters then [] is used. The ordering matches that of the pars attribute.

See also

thawedpars, thawedarhardmaxes, thawedparmins

thawedparmins

The minimum limits of the thawed parameters.

Get or set the minimum limits of the thawed parameters of the model as a list of numbers. If there are no thawed parameters then [] is used. The ordering matches that of the pars attribute.

See also

thawedpars, thawedarhardmins, thawedparmaxes

thawedpars

The thawed parameters of the model.

Get or set the thawed parameters of the model as a list of numbers. If there are no thawed parameters then [] is used. The ordering matches that of the pars attribute.

Methods Documentation

calc(*args, **kwargs)[source] [edit on github]

Evaluate the model on a grid.

Parameters
  • p (sequence of numbers) – The parameter values to use. The order matches the pars field.

  • *args – The model grid. The values can be scalar or arrays, and the number depends on the dimensionality of the model and whether it is being evaluated over an integrated grid or at a point (or points).

fold(data)[source] [edit on github]

The data to be convolved by the PSF.

Parameters

data (sherpa.data.Data or sherpa.models.model.Model instance or a callable) – It must match the dimensionality of the kernel.

Raises

sherpa.utils.err.PSFErr – The kernel has not been set.

freeze() [edit on github]

Freeze any thawed parameters of the model.

get_center() [edit on github]
get_kernel(data, subkernel=True)[source] [edit on github]

Return a data object representing the kernel.

Parameters
  • data (sherpa.data.Data or sherpa.models.model.Model instance) – The data to apply the kernel to. This routine will pass data to the fold method.

  • subkernel (bool, optional) –

Returns

data

Return type

sherpa.data.Data1D or sherpa.data.Data2D instance

guess(dep, *args, **kwargs) [edit on github]

Set an initial guess for the parameter values.

Attempt to set the parameter values, and ranges, for the model to match the data values. This is intended as a rough guess, so it is expected that the model is only evaluated a small number of times, if at all.

reset() [edit on github]

Reset the parameter values.

Restores each parameter to the last value it was set to. This allows the parameters to be easily reset after a fit.

set_center(*args, **kwargs) [edit on github]
startup(cache=False) [edit on github]

Called before a model may be evaluated multiple times.

Parameters

cache (bool, optional) – Should a cache be used when evaluating the models.

See also

teardown

teardown() [edit on github]

Called after a model may be evaluated multiple times.

See also

startup

thaw() [edit on github]

Thaw any frozen parameters of the model.

Those parameters that are marked as “always frozen” are skipped.