thin_film.analysis

Thin film analysis class.

This provides thin film analysis class for optical response calculations using the transfer matrix method (TMM).

Corentin Nannini, 2025

Classes

SpectralAnalyzer(stack)

Class for analyzing thin film stacks optical response (R/T/A).

class SpectralAnalyzer(stack: ThinFilmStack)[source]

Class for analyzing thin film stacks optical response (R/T/A).

stack

The thin film stack to be analyzed.

Type:

ThinFilmStack

analyze_color(wavelength_values: float | Any, wavelength_unit: Literal['um', 'nm', 'frequency', 'energy', 'wavenumber', 'relative_wavenumber'] = 'um', aoi: float = 0.0, aoi_unit: Literal['deg', 'rad'] = 'deg', polarization: Literal['s', 'p', 'u'] | list[Literal['s', 'p', 'u']] = 'u', quantity: Literal['R', 'T'] = 'R', observer: Literal['2deg', '10deg'] = '2deg', illuminant: list[float] | None = None) dict[str, tuple[float, float, float] | tuple[int, int, int]][source]

Return XYZ, xyY, and sRGB for a thin-film spectrum.

Parameters:
  • wavelength_values – Wavelength values in the specified unit.

  • wavelength_unit – Unit of wavelength values.

  • aoi – Angle of incidence (scalar).

  • aoi_unit – Unit of the angle.

  • polarization – Polarization type(s).

  • quantity – Quantity to analyze (‘R’ or ‘T’).

  • observer – CIE standard observer (‘2deg’ or ‘10deg’).

  • illuminant – Optional custom illuminant spectrum.

Returns:

Dictionary containing ‘xyz’, ‘xyY’, and ‘sRGB’ values.

Return type:

dict

angular_view(aoi_values: float | Any, aoi_unit: Literal['deg', 'rad'] = 'deg', wavelength: float = 0.55, wavelength_unit: Literal['um', 'nm', 'frequency', 'energy', 'wavenumber', 'relative_wavenumber'] = 'um', polarization: Literal['s', 'p', 'u'] | list[Literal['s', 'p', 'u']] = 'u', to_plot: Literal['R', 'T', 'A'] | list[Literal['R', 'T', 'A']] = 'R', ax: Axes = None) tuple[Figure, Axes][source]

Plot R/T/A vs angle of incidence.

Parameters:
  • aoi_values – Angle of incidence values in the specified unit

  • aoi_unit – Unit of the angle values

  • wavelength – Wavelength value (scalar)

  • wavelength_unit – Unit of the wavelength

  • polarization – Polarization type(s) - single string or list

  • to_plot – Quantity(ies) to plot

  • ax – Optional matplotlib Axes

Returns:

Tuple of (figure, axes)

map_view(wavelength_values: float | Any, wavelength_unit: Literal['um', 'nm', 'frequency', 'energy', 'wavenumber', 'relative_wavenumber'] = 'um', aoi_values: float | Any = None, aoi_unit: Literal['deg', 'rad'] = 'deg', polarization: Literal['s', 'p', 'u'] | list[Literal['s', 'p', 'u']] = 'u', to_plot: Literal['R', 'T', 'A'] | list[Literal['R', 'T', 'A']] = 'R', colormap: str = 'viridis', fig: Figure = None, axs: Axes | list[Axes] = None) tuple[Figure, Axes | list[Axes]][source]

Plot 2D maps of R/T/A vs wavelength and angle of incidence.

Parameters:
  • wavelength_values – Wavelength values in the specified unit

  • wavelength_unit – Unit of wavelength values

  • aoi_values – Angle of incidence values in the specified unit

  • aoi_unit – Unit of the angle values

  • polarization – Polarization type(s) - single string or list

  • to_plot – Quantity(ies) to plot

  • fig – Optional matplotlib Figure

  • axs – Optional matplotlib Axes (single or list)

Returns:

Tuple of (figure, axes or list of axes)

plot_color_on_cie_1931(wavelength_values: float | Any, wavelength_unit: Literal['um', 'nm', 'frequency', 'energy', 'wavenumber', 'relative_wavenumber'] = 'um', aoi: float = 0.0, aoi_unit: Literal['deg', 'rad'] = 'deg', polarization: Literal['s', 'p', 'u'] | list[Literal['s', 'p', 'u']] = 'u', quantity: Literal['R', 'T'] = 'R', observer: Literal['2deg', '10deg'] = '2deg', illuminant: list[float] | None = None, ax: Axes | None = None, color: Literal['no', 'contour', 'fill'] = 'contour', marker: str = 'o', marker_size: float = 6.0, marker_color: str = 'black') tuple[Figure, Axes][source]

Plot the chromaticity point on a CIE 1931 diagram.

spectrum_to_xyY(wavelength_values: float | Any, wavelength_unit: Literal['um', 'nm', 'frequency', 'energy', 'wavenumber', 'relative_wavenumber'] = 'um', aoi: float = 0.0, aoi_unit: Literal['deg', 'rad'] = 'deg', polarization: Literal['s', 'p', 'u'] | list[Literal['s', 'p', 'u']] = 'u', quantity: Literal['R', 'T'] = 'R', observer: Literal['2deg', '10deg'] = '2deg', illuminant: list[float] | None = None) tuple[float, float, float][source]

Compute xyY chromaticity from a normalized power spectrum.

Parameters:
  • wavelength_values – Wavelength values in the specified unit.

  • wavelength_unit – Unit of wavelength values.

  • aoi – Angle of incidence (scalar).

  • aoi_unit – Unit of the angle.

  • polarization – Polarization type(s).

  • quantity – Quantity to analyze (‘R’ or ‘T’).

  • observer – CIE standard observer (‘2deg’ or ‘10deg’).

  • illuminant – Optional custom illuminant spectrum.

Returns:

(x, y, Y) chromaticity coordinates.

Return type:

tuple[float, float, float]

wavelength_view(wavelength_values: float | Any, wavelength_unit: Literal['um', 'nm', 'frequency', 'energy', 'wavenumber', 'relative_wavenumber'] = 'um', aoi: float = 0.0, aoi_unit: Literal['deg', 'rad'] = 'deg', polarization: Literal['s', 'p', 'u'] | list[Literal['s', 'p', 'u']] = 'u', to_plot: Literal['R', 'T', 'A'] | list[Literal['R', 'T', 'A']] = 'R', ax: Axes = None) tuple[Figure, Axes][source]

Plot R/T/A vs wavelength (or equivalent units).

Parameters:
  • wavelength_values – Wavelength values in the specified unit

  • wavelength_unit – Unit of wavelength values

  • aoi – Angle of incidence (scalar)

  • aoi_unit – Unit of the angle

  • polarization – Polarization type(s) - single string or list

  • to_plot – Quantity(ies) to plot

  • ax – Optional matplotlib Axes

Returns:

Tuple of (figure, axes)