PolynomialVignettingModel#

class optika.radiometry.PolynomialVignettingModel(coordinates_scene, illumination, axis_wavelength, axis_field, degree=1, where=True)[source]#

Bases: AbstractInterpolatedVignettingModel

A vignetting model which fits a polynomial to the measured illumination at known scene coordinates.

Examples

Build a vignetting model with a radial illumination falloff fit by a deliberately underfit (linear) polynomial, then plot the illumination and the fit residual.

import numpy as np
import astropy.units as u
import named_arrays as na
import optika

scene = na.SpectralPositionalVectorArray(
    wavelength=na.linspace(500, 600, axis="wavelength", num=3) * u.nm,
    position=na.Cartesian2dVectorLinearSpace(
        start=-1 * u.deg,
        stop=+1 * u.deg,
        axis=na.Cartesian2dVectorArray("field_x", "field_y"),
        num=13,
    ),
)
illumination = 1 - 0.1 * (scene.position.length / u.deg) ** 2

model = optika.radiometry.PolynomialVignettingModel(
    coordinates_scene=scene,
    illumination=illumination,
    axis_wavelength="wavelength",
    axis_field=("field_x", "field_y"),
    degree=1,
)

fig, ax = model.plot()
na.plt.set_aspect("equal", ax=ax);

fig, ax = model.plot_residual()
na.plt.set_aspect("equal", ax=ax);
../_images/optika.radiometry.PolynomialVignettingModel_0_0.png ../_images/optika.radiometry.PolynomialVignettingModel_0_1.png

Attributes

axis_field

The logical axes corresponding to changing position in the scene.

axis_wavelength

The logical axis corresponding to changing wavelength.

coordinates_scene

The wavelength and position of each calibration point in the scene.

degree

The degree of the polynomial used to model the vignetting.

fit

The polynomial fit mapping scene coordinates to illumination.

illumination

The relative illumination at each calibration point.

where

A boolean mask selecting which calibration points to use for fitting.

Methods

__init__(coordinates_scene, illumination, ...)

inverse(coordinates)

Compute the inverse of the illumination, \(1 / I\), the factor which corrects for the vignetting at the given scene coordinates.

plot([figsize, cmap, vmin, vmax])

Plot the calibration illumination as a function of field angle, with a separate subplot for each wavelength.

plot_residual([figsize, cmap, vmin, vmax])

Plot the residual of the fit as a function of field angle, with a separate subplot for each wavelength.

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 optika.radiometry.PolynomialVignettingModel
Parameters:
inverse(coordinates)#

Compute the inverse of the illumination, \(1 / I\), the factor which corrects for the vignetting at the given scene coordinates.

Parameters:

coordinates (AbstractSpectralPositionalVectorArray) – The wavelength and position of each point in the scene.

Return type:

AbstractScalar

plot(figsize=None, cmap=None, vmin=None, vmax=None, **kwargs)[source]#

Plot the calibration illumination as a function of field angle, with a separate subplot for each wavelength.

Parameters:
Return type:

tuple[Figure, ScalarArray]

plot_residual(figsize=None, cmap=None, vmin=None, vmax=None, **kwargs)[source]#

Plot the residual of the fit as a function of field angle, with a separate subplot for each wavelength.

The residual is the absolute difference between the calibration illumination and the illumination predicted by the polynomial fit.

Parameters:
Return type:

tuple[Figure, ScalarArray]

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_field: tuple[str, str] = <dataclasses._MISSING_TYPE object>#

The logical axes corresponding to changing position in the scene.

axis_wavelength: str = <dataclasses._MISSING_TYPE object>#

The logical axis corresponding to changing wavelength.

coordinates_scene: AbstractSpectralPositionalVectorArray = <dataclasses._MISSING_TYPE object>#

The wavelength and position of each calibration point in the scene.

degree: int = 1#

The degree of the polynomial used to model the vignetting.

property fit: PolynomialFitFunctionArray#

The polynomial fit mapping scene coordinates to illumination.

illumination: AbstractScalar = <dataclasses._MISSING_TYPE object>#

The relative illumination at each calibration point.

where: bool | AbstractScalar = True#

A boolean mask selecting which calibration points to use for fitting.