wavelength

Wavelength Module

This module defines the Wavelength and WavelengthGroup classes for managing wavelengths in optical simulations. The Wavelength class represents a single wavelength, allowing for its value to be defined in various units and converted to microns for internal consistency. The WavelengthGroup class manages collections of Wavelength objects, providing functionality to work with multiple wavelengths simultaneously.

Kramer Harrison, 2024

Functions

add_wavelengths(wavelength_group, min_value, ...)

Add new wavelengths corresponding to the geometrically-spaced Chebyshev nodes

Classes

Wavelength(value[, is_primary, unit, weight])

Represents a wavelength value with support for unit conversion.

WavelengthGroup()

Represents a group of wavelengths, each with an optional weight.

class Wavelength(value: ScalarOrArray, is_primary: bool = True, unit: str = 'um', weight: float = 1.0)[source]

Represents a wavelength value with support for unit conversion.

_convert_to_um()[source]

Converts the wavelength value to microns.

classmethod from_dict(data: dict) Wavelength[source]

Create a Wavelength instance from a dictionary representation.

Parameters:

data – A dictionary containing the wavelength data.

Returns:

A new Wavelength instance created from the data.

to_dict() dict[source]

Get a dictionary representation of the wavelength.

Returns:

A dictionary representation of the wavelength.

property unit: str

the unit of the wavelength

Type:

str

property value: float

the value of the wavelength

Type:

float

property weight: float

Non-negative relative importance scalar for this wavelength.

Type:

float

class WavelengthGroup[source]

Represents a group of wavelengths, each with an optional weight.

wavelengths

A list of Wavelength objects.

Type:

list

num_wavelengths()

Returns the number of wavelengths in the group.

primary_index()

Returns the index of the primary wavelength.

primary_wavelength()

Returns the primary wavelength.

add_wavelength(value, is_primary=True, unit='um')

Adds a new wavelength to the group.

get_wavelength(wavelength_number)[source]

Returns the value of a specific wavelength.

get_wavelengths()[source]

Returns a list of all the wavelength values in the group.

add(value: float, is_primary: bool = False, unit: str = 'um', weight: float = 1.0)[source]

Adds a new wavelength to the list of wavelengths.

Parameters:
  • value – The value of the wavelength.

  • is_primary – Indicates if the wavelength is primary. Default is True.

  • unit – The unit of the wavelength. Default is ‘um’.

  • weight – The weight of the wavelength. Default is 1.0.

classmethod from_dict(data) WavelengthGroup[source]

Create a WavelengthGroup instance from a dictionary representation.

Parameters:

data – A dictionary containing the wavelength group data.

Returns:

A new WavelengthGroup instance created from the

data.

get_wavelength(wavelength_number: int) float[source]

Get the value of a specific wavelength.

Parameters:

wavelength_number – The index of the desired wavelength.

Returns:

The value of the specified wavelength.

get_wavelengths() list[float][source]

Returns a list of wavelength values.

Returns:

A list of wavelength values.

property num_wavelengths: int

The number of wavelengths

property primary_index: int

The index of the primary wavelength

Raises:

StopIteration – If no primary wavelength is found

property primary_wavelength: Wavelength

The primary wavelength

remove(index: int) None[source]

Remove a wavelength from the group.

Parameters:

index – The index of the wavelength to remove.

to_dict() dict[source]

Get a dictionary representation of the wavelength group.

Returns:

A dictionary representation of the wavelength group.

property weights: tuple[float, ...]

The weights of the wavelengths

add_wavelengths(wavelength_group: WavelengthGroup, min_value: float, max_value: float, num_wavelengths: int, unit: str = 'um', *, sampling: str = 'chebyshev', scale: str = 'log')[source]

Add new wavelengths corresponding to the geometrically-spaced Chebyshev nodes

Parameters:
  • min_value – Minimum wavelength value.

  • max_value – Maximum wavelength value.

  • num_wavelengths – The number of wavelengths to be added. Has to be an odd integer.

  • unit – The unit of the wavelength. Default is ‘um’.

  • sampling

    The sampling algorithm used. Defaults to ‘chebyshev’. Currently supported options are:

    ’chebyshev’ - chebyshev nodes of the first type ‘uniform’ - uniformly spaced nodes across the specified range

  • scale

    space in which the nodes are sampled. Defaults to ‘log’. Currently supported options are:

    ’log’ - nodes are sampled in the logarithms of wavelength. ‘frequency’ - nodes sampled in the frequency domain. ‘wavelength’ - nodes sampled in the frequency domain. Not recommended.