fpipy.simulate

Tools for simulating CFA data from radiance cubes.

Functions

bayer_sensor(radiance, exposure, T_mosaic, …)

Simulate a Bayer sensor image.

create_cfa(rad, S, pattern)

Simulate a colour filter array data from radiance data.

etalon_gap(wl, fsr, ng, theta)

Approximate value of the Fabry-Perot etalon gap.

finesse_coefficient(R)

Finesse coefficient of the etalon

fpi_bandpass_lims(d, n)

Bandpass filter limits for a single order of an FPI at given gap.

fpi_bayer_imager(radiance, T_fpi, exposure, …)

Simulate a Fabry-Perot interferometer filtered Bayer sensor image.

fpi_bayer_spectral_signal(T_fpi, Q_eff, T_rgb)

Spectral signal for a given FPI gap and order.

fpi_gap(wl, fsr)

Approximate value of the FPI gap.

fpi_phase_difference(wl, l)

Phase difference between pairs of transmitted beams in the FPI

fpi_transmittance(wl, l, R)

Transmittance of the FPI at given wavelength, gap and mirror reflectance

fpi_triplet(wl, l)

Generate a triplet of etalon peaks (wavelengths) given the lowest.

free_spectral_range(wl, l, ng, theta)

Free spectral range of the Fabry-Perot etalon as

fsr_fpi(wl, l)

Free spectral range in the FPI.

mono_sensor(radiance, exposure, Qeff, pxformat)

Simulate a monochromatic sensor image.

mosaic_transmittances(shape, pattern, T_rgb)

Transmittances of a Bayer filter mosaic.

phase_difference(wl, n, l, theta)

Phase difference between pairs of transmitted beams in the etalon

quantize(im, pxformat)

Quantize a floating-point image to the desired pixel format.

fpipy.simulate.bayer_sensor(radiance, exposure, T_mosaic, Q_eff, pxformat)[source]

Simulate a Bayer sensor image.

Parameters
  • radiance (array-like) – (y, x, band) array of radiance values.

  • exposure (float) – Exposure (integration time) in milliseconds.

  • T_mosaic (array-like) – (y, x, band) array of spectral transmittances for the Bayer mosaic.

  • Q_eff (array-like) – Quantum efficiencies of the sensor for each band/wavelength.

  • pxformat (str) – Pixel format to discretize result to.

  • Result

  • ------

  • np.ndarray – (y, x) Bayer mosaic

fpipy.simulate.create_cfa(rad, S, pattern)[source]

Simulate a colour filter array data from radiance data.

Parameters
  • rad (xarray.DataArray) – Radiance datacube with wavelength information.

  • S (list of xarray.DataArray) – Responses for different colours of the CFA for each wavelength

  • pattern (BayerPattern or str) – Bayer pattern for the CFA.

Returns

cfa – CFA images with the given pattern and responses.

Return type

xarray.Dataset

Examples

Using a mockup response matrix to create a CFA from radiance:

import xarray as xr
import numpy as np
from fpipy.data import house_radiance
from fpipy.simulate import create_cfa

# load example radiance data
rad = house_radiance()
rad = rad.swap_dims({'band':'wavelength'})

# create a mockup response matrix
S1 = xr.DataArray(
    np.eye(3),
    dims=('colour', 'wavelength'),
    coords={
        'colour':['R','G','B'],
        'wavelength': rad.wavelength.data[:-1]
        }
    )
S2 = xr.DataArray(
    np.eye(3),
    dims=('colour', 'wavelength'),
    coords={
        'colour':['R','G','B'],
        'wavelength': rad.wavelength.data[1:]
        }
    )

S = [S1, S2]

# Simulate a RGGB pattern CFA
simulated_raw = create_cfa(rad, S, 'RGGB')
fpipy.simulate.etalon_gap(wl, fsr, ng, theta)[source]

Approximate value of the Fabry-Perot etalon gap.

Approximates the gap length \(l\) from the formula of the FSR as

\[l = \frac{\lambda (\lambda - \Delta\lambda)} {\Delta\lambda 2 n \cos(\theta)}\]
Parameters
  • wl (np.float64) – Peak wavelength

  • fsr (np.float64) – Free spectral range near the peak.

  • ng (np.float64) – Group refractive index of the media.

  • theta (np.float64) – Angle of the light entering the etalon.

Returns

l – Approximate gap length of the Fabry-Perot etalon.

Return type

np.float64

fpipy.simulate.finesse_coefficient(R)[source]

Finesse coefficient of the etalon

Parameters

R (np.float64) – Reflectance of the etalon mirrors

Returns

Finesse coefficient of the etalon

Return type

np.float64

fpipy.simulate.fpi_bandpass_lims(d, n)[source]

Bandpass filter limits for a single order of an FPI at given gap.

Parameters
  • d (float) – Gap length of the Fabry-Perot etalon.

  • n (int) – The order of the FPI peak included in the limits

Returns

(lmin, lmax) – Minimum and maximum wavelengths that include the three FPI orders.

Return type

tuple of float

fpipy.simulate.fpi_bayer_imager(radiance, T_fpi, exposure, T_mosaic, Q_eff, pxformat)[source]

Simulate a Fabry-Perot interferometer filtered Bayer sensor image.

Parameters
  • radiance (array-like) – (y, x, band) array of radiance values.

  • T_fpi (array-like) – (a, b) array of Fabry-Perot interferometer transmittances for each band and gap length value a.

  • exposure (float) – Exposure (integration time) in milliseconds.

  • T_mosaic (array-like) – (y, x, band) array of spectral transmittances for the Bayer mosaic.

  • Q_eff (array-like) – Quantum efficiencies of the sensor for each band/wavelength.

  • pxformat (str) – Pixel format to discretize result to.

  • Result

  • ------

  • np.ndarray – (a, y, x) stack of Bayer mosaic images

fpipy.simulate.fpi_bayer_spectral_signal(T_fpi, Q_eff, T_rgb)[source]

Spectral signal for a given FPI gap and order.

Parameters
  • T_fpi (array-like) – (3, band) array of FPI transmittances for orders n, n+1 and n+2 for a given etalon gap length.

  • Q_eff (array-like) – (band,) array of quantum efficiencies of the sensor

  • T_rgb (array-like) – (3, band) array of tranmittances of the R, G and B pixels.

Returns

S – (3, 3) matrix of effective transmittances for the FPI imager.

Return type

np.ndarray

fpipy.simulate.fpi_gap(wl, fsr)[source]

Approximate value of the FPI gap.

Special case of etalon_gap with \(ng = 1\) and \(\theta=0\).

Parameters
  • wl (np.float64) – Peak wavelength

  • fsr (np.float64) – Free spectral range near the peak.

Returns

l – Approximate gap length of the FPI.

Return type

np.float64

fpipy.simulate.fpi_phase_difference(wl, l)[source]

Phase difference between pairs of transmitted beams in the FPI

Parameters
  • wl (np.float64) – Wavelength of the light in chosen units (matching gap length)

  • l (np.float64) – Gap length in chosen units (matching wavelength)

Returns

Phase difference in radians

Return type

np.float64

fpipy.simulate.fpi_transmittance(wl, l, R)[source]

Transmittance of the FPI at given wavelength, gap and mirror reflectance

Parameters
  • wl (np.float64) – Wavelength in chosen units (matching gap length)

  • l (np.float64) – Gap length in chosen units (matching wavelength)

  • R (np.float64) – Reflectance of the FPI mirrors

Returns

Reflectance of the Fabry-Perot interferometer

Return type

np.float64

fpipy.simulate.fpi_triplet(wl, l)[source]

Generate a triplet of etalon peaks (wavelengths) given the lowest.

Parameters
  • wl (np.float64) – Lowest wavelength of the triplet.

  • l (np.float64) – Gap of the etalon.

Returns

(wl1, wl2, wl3) – Triplet of consecutive peaks of the Fabry-Perot etalon

Return type

tuple of np.float64

fpipy.simulate.free_spectral_range(wl, l, ng, theta)[source]

Free spectral range of the Fabry-Perot etalon as

\[\Delta\lambda = \frac{\lambda^2}{2 n l \cos(\theta)}\]
Parameters
  • wl (np.float64) – Wavelength of the nearest peak.

  • l (np.float64) – Gap of the etalon.

  • ng (np.float64) – Group refractive index of the media.

  • theta (np.float64) – Angle of the ligth entering the etalon.

Returns

fsr – Free spectral range of the Fabry-Perot etalon

Return type

np.float64

fpipy.simulate.fsr_fpi(wl, l)[source]

Free spectral range in the FPI.

Special case of free_spectral_range with \(n_g = 1\) for air and collimated light at \(\theta=0\).

Parameters
  • wl (np.float64) – Wavelength of the nearest peak.

  • l (np.float64) – Gap of the etalon.

Returns

FSR of the FPI at the given values.

Return type

np.float64

fpipy.simulate.mono_sensor(radiance, exposure, Qeff, pxformat)[source]

Simulate a monochromatic sensor image.

Simulates a linear monochromatic sensor response for a given radiance signal and exposure.

Parameters
  • radiance (array-like) – (y, x, band) array of radiance values.

  • exposure (float) – Exposure (integration time) in milliseconds.

  • Q_eff (array-like) – Quantum efficiencies of the sensor for each band/wavelength.

  • pxformat (str) – Pixel format to discretize result to.

Returns

(y, x) monochromatic image.

Return type

np.ndarray

fpipy.simulate.mosaic_transmittances(shape, pattern, T_rgb)[source]

Transmittances of a Bayer filter mosaic.

Parameters
  • shape (pair of int) – (y, x) Shape of the filter array.

  • pattern (BayerPattern or str) – The Bayer filter pattern of the array.

  • T_rgb (array-like) – (3, b) arrays of transmittances of the R, G and B pixels for each band.

  • Result

  • ------

  • np.ndarray – (y, x, b) array of mosaic responses for each band.

fpipy.simulate.phase_difference(wl, n, l, theta)[source]

Phase difference between pairs of transmitted beams in the etalon

Parameters
  • wl (np.float64) – Wavelength of the light in chosen units (matching gap length)

  • n (np.float64) – Refractive index of the mirrors

  • l (np.float64) – Gap length in chosen units (matching wavelength)

  • theta (np.float64) – Angle of the beam entering the etalon in radians

Returns

Phase difference in radians

Return type

np.float64

fpipy.simulate.quantize(im, pxformat)[source]

Quantize a floating-point image to the desired pixel format.

Simple quantization to maximum levels allowed by the pixel format and including the full range of the data.

Parameters
  • im (array-like) – Array of floating point values.

  • pxformat (str) – Pixel format string (as defined in GenICAM).