LinearMerit#

class esis.optics.LinearMerit(instrument, parameters, scene, observation, device=None, degree=2, merit='correlation', axis_wavelength='velocity', axis_field=('detector_x', 'detector_y'), seed=0)[source]#

Bases: object

The merit of a set of DistortionParameters for one channel.

Each evaluation applies the parameters to the channel, linearizes the resulting optical system (optika.systems.SequentialSystem.linearize()), clips the scene by the field stop in object space, images it with a conservative regrid onto the sensor, and compares it with the observed frame. The linearized image has no sampling noise, so the merit is deterministic and smooth.

The merit is geometric: the effective area of every line is pinned to a common value, so that the fit measures where light lands and not how much of it there is.

Instances are callables of a flat parameter vector, picklable so that scipy.optimize.differential_evolution() can evaluate them in worker processes, and return the negative merit for minimization.

Parameters:
  • instrument (esis.optics.abc.AbstractInstrument) – The channel to fit, usually the as-built model reduced to a single channel.

  • parameters (esis.optics.DistortionParameters) – The prototype which defines the units and structure of the flat parameter vector.

  • scene (na.FunctionArray) – The spectral radiance of the scene as a function of wavelength and field position, on the cell vertices of the field grid.

  • observation (na.AbstractScalar) – The observed frame of this channel.

  • device (None | str) – The device on which to build and apply the regridding weights; see optika.systems.AbstractLinearSystem.image().

  • degree (int) – The degree of the polynomial distortion model.

  • merit (str) – Which comparison __call__() maximizes: "correlation", the Pearson correlation of correlation(), or "least_squares", the absolute comparison of score(), which lets the channel’s degradation set the level of the image.

  • axis_wavelength (str) – The logical axis of the scene along which the wavelength varies within each spectral line.

  • axis_field (tuple[str, str]) – The logical axes of the scene corresponding to field position.

  • seed (int) – The seed of the draws which place a field position and a pupil position inside each cell when the channel is linearized, see seed_field and seed_pupil of optika.systems.SequentialSystem.linearize(). The same seed gives the same merit, and another seed draws other positions.

Methods

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

correlation(parameters)

Compute the Pearson correlation of the linearized image with the observation.

estimate_degradation(parameters)

Estimate the degradation that best scales the image onto the observation.

image(parameters)

Compute the linearized image of the scene for the given parameters.

linearize(instrument)

Linearize the channel with the effective area pinned per line.

score(parameters)

Compute the least-squares score of the linearized image against the observation.

Inheritance Diagram

Inheritance diagram of esis.optics.LinearMerit
correlation(parameters)[source]#

Compute the Pearson correlation of the linearized image with the observation.

Parameters:

parameters (DistortionParameters) – The distortion parameters to apply to the channel.

Return type:

float

estimate_degradation(parameters)[source]#

Estimate the degradation that best scales the image onto the observation.

The least-squares gain of the image at the given parameters, whose own degradation plays no part.

Parameters:

parameters (DistortionParameters) – The distortion parameters to image the scene with.

Return type:

Quantity

image(parameters)[source]#

Compute the linearized image of the scene for the given parameters.

Parameters:

parameters (DistortionParameters) – The distortion parameters to apply to the channel.

Return type:

ScalarArray

linearize(instrument)[source]#

Linearize the channel with the effective area pinned per line.

Parameters:

instrument – The channel with the current parameters applied.

Return type:

LinearSystem

score(parameters)[source]#

Compute the least-squares score of the linearized image against the observation.

The image is scaled by the channel’s degradation before the comparison, see least_squares().

Parameters:

parameters (DistortionParameters) – The distortion parameters to apply to the channel.

Return type:

float