DistortionObjective#

class esis.optics.DistortionObjective(instrument, parameters, scene, observation, pupil=None, axis_wavelength=None, axis_field=None, axis_channel=None, weight_correlation=1000)[source]#

Bases: Printable

An objective function which compares modeled images to an observation.

Instances of this class are intended to be passed directly to scipy.optimize routines such as scipy.optimize.differential_evolution(): they are callables of a flat, dimensionless parameter vector, and they are picklable so that the optimizer can evaluate them in parallel worker processes.

Each evaluation unpacks the vector into a DistortionParameters using parameters as the prototype, applies it to a copy of instrument, images scene through the resulting optical system, and compares the result to observation using the Pearson correlation coefficient. A penalty proportional to the squared distance between the mean ray position and the origin of the sensor discourages solutions that walk the image off the detector.

Note that the imaging model samples photons randomly, so evaluations of this objective are stochastic even for identical parameter vectors, and it should only be used with optimizers that tolerate a noisy objective, such as scipy.optimize.differential_evolution().

Attributes

axis_channel

The logical axis of the observation corresponding to changing camera channel.

axis_field

The logical axes of the scene corresponding to changing field position.

axis_wavelength

The logical axis of the scene corresponding to changing wavelength.

pupil

The vertices of the pupil grid used to image the scene.

weight_correlation

The weight of the correlation term relative to the distance penalty.

instrument

The instrument model being fit to the observation.

parameters

The prototype which defines the units and structure of the flat parameter vector, usually the initial guess of the fit.

scene

The spectral radiance of the scene as a function of wavelength and field position, imaged through the instrument on every evaluation.

observation

The observed image that the modeled image is compared against.

Methods

__init__(instrument, parameters, scene, ...)

to_string([prefix])

Public-facing version of the __repr__ method that allows for defining a prefix string, which can be used to calculate how much whitespace to add to the beginning of each line of the result.

Inheritance Diagram

Inheritance diagram of esis.optics.DistortionObjective
Parameters:
to_string(prefix=None)#

Public-facing version of the __repr__ method that allows for defining a prefix string, which can be used to calculate how much whitespace to add to the beginning of each line of the result.

Parameters:

prefix (None | str) – an optional string, the length of which is used to calculate how much whitespace to add to the result.

Return type:

str

axis_channel: None | str = None#

The logical axis of the observation corresponding to changing camera channel.

If given, the correlation and the off-target penalty are computed independently for each channel and then averaged, so that brightness differences between the channels (e.g. from differing gains) do not suppress the correlation. This is the appropriate setting when fitting several channels at once with shared parameters.

axis_field: None | tuple[str, str] = None#

The logical axes of the scene corresponding to changing field position.

axis_wavelength: None | str = None#

The logical axis of the scene corresponding to changing wavelength.

instrument: AbstractInstrument#

The instrument model being fit to the observation.

observation: AbstractScalar#

The observed image that the modeled image is compared against.

Any axes of the modeled image which are not present in this array are summed over before comparing.

parameters: DistortionParameters#

The prototype which defines the units and structure of the flat parameter vector, usually the initial guess of the fit.

pupil: None | AbstractCartesian2dVectorArray = None#

The vertices of the pupil grid used to image the scene.

scene: FunctionArray#

The spectral radiance of the scene as a function of wavelength and field position, imaged through the instrument on every evaluation.

weight_correlation: float = 1000#

The weight of the correlation term relative to the distance penalty.