materials.agf#

AGF Material

This module reads glass catalogs in the AGF format used by OpticStudio and evaluates their glasses with the catalog’s own dispersion formula and coefficients. No catalog data ship with Optiland: the reader works on AGF files the user already has.

An AGF file is a list of records, one per line, keyed by their first token. The reader uses these:

  • NM name formula MIL nd vd ...: starts a glass and names its formula.

  • CD c1 c2 ...: the dispersion coefficients, for wavelengths in µm.

  • LD min max: the wavelength range of the data, in µm.

The other records (thermal, transmission, comments) are skipped. Indices are relative to air, as in the catalogs, and are evaluated at the catalog’s reference temperature; the thermal coefficients on the TD line are not applied.

Functions

agf_search_dirs([agf_dirs])

The folders to search for AGF catalogs.

evaluate_agf_formula(formula, c, wavelength)

Refractive index from an OpticStudio dispersion formula.

find_agf_catalog(catalog, agf_dirs)

The AGF file of a catalog, matching the file name ignoring case.

read_agf(path)

Read the glasses of an AGF catalog.

Classes

AGFGlass(name, formula, coefficients[, nd, ...])

One glass record of an AGF catalog.

AGFMaterial(name, formula, coefficients[, ...])

A glass evaluated from its AGF catalog entry.

class AGFGlass(name: str, formula: int, coefficients: list[float], nd: float | None = None, vd: float | None = None, wavelength_range: tuple[float, float] | None = None, catalog: str | None = None, comment: str = '')[source]#

One glass record of an AGF catalog.

catalog: str | None = None#
coefficients: list[float]#
comment: str = ''#
formula: int#
name: str#
nd: float | None = None#
vd: float | None = None#
wavelength_range: tuple[float, float] | None = None#
class AGFMaterial(name: str, formula: int, coefficients, catalog: str | None = None, wavelength_range: tuple[float, float] | None = None, propagation_model: BasePropagationModel | None = None)[source]#

A glass evaluated from its AGF catalog entry.

The index comes from the catalog’s own dispersion formula and coefficients, as OpticStudio evaluates it, relative to air at the catalog’s reference temperature. The extinction coefficient is zero.

Parameters:
  • name – The glass name.

  • formula – The OpticStudio formula code, 1 to 13.

  • coefficients – The coefficients of the AGF CD line.

  • catalog – The catalog the glass came from, if known.

  • wavelength_range – The (min, max) wavelength of the data in µm.

  • propagation_model – The propagation model; homogeneous if None.

abbe() → float#

Calculate the Abbe number (Vd) of the material.

The Abbe number is a measure of the material’s dispersion, defined as Vd = (n_d - 1) / (n_F - n_C), where n_d, n_F, and n_C are the refractive indices at the Fraunhofer d (587.5618 nm), F (486.1327 nm), and C (656.2725 nm) spectral lines, respectively.

Returns:

The Abbe number of the material.

Return type:

float

property display_name: str#

Human-readable identity; never a serialization or lookup key.

classmethod from_dict(data)[source]#

Create a material from a dictionary representation.

This factory method first delegates to the appropriate subclass to create the material instance, then handles the deserialization of the propagation model.

Parameters:

data (dict) – The dictionary representation of the material.

Returns:

An instance of a specific material subclass created from the dictionary data.

Return type:

BaseMaterial

classmethod from_file(path: str, name: str) → AGFMaterial[source]#

Create the material for glass name in the AGF file path.

The name must match exactly, ignoring case.

classmethod from_glass(glass: AGFGlass) → AGFMaterial[source]#

Create the material from a record returned by read_agf.

k(wavelength: float | be.ndarray, **kwargs) → float | be.ndarray#

Calculates the extinction coefficient at a given wavelength with caching.

Parameters:
  • wavelength (float | be.ndarray) – The wavelength(s) of light in microns. Can be a float, numpy array, or torch tensor.

  • **kwargs – Additional keyword arguments for calculation.

Returns:

The extinction coefficient at the given wavelength(s).

Return type:

float | be.ndarray

n(wavelength: float | be.ndarray, **kwargs) → float | be.ndarray#

Calculates the refractive index at a given wavelength with caching.

Parameters:
  • wavelength (float | be.ndarray) – The wavelength(s) of light in microns. Can be a float, numpy array, or torch tensor.

  • **kwargs – Additional keyword arguments for calculation (e.g., temperature).

Returns:

The refractive index at the given wavelength(s).

Return type:

float | be.ndarray

spectral_range(property_name: str = 'n') → tuple[float, float] | None[source]#

Known validity limits in micrometers, or None if unspecified.

Consumers must supply a range when none is known. This information does not change each material’s evaluation or extrapolation policy.

to_dict()[source]#

Convert the material to a dictionary.

Returns:

The dictionary representation of the material.

Return type:

dict

agf_search_dirs(agf_dirs=None) → list[str][source]#

The folders to search for AGF catalogs.

Parameters:

agf_dirs – A folder or a list of folders. If None, the folders in the OPTILAND_AGF_PATH environment variable, separated by os.pathsep, are used; if that is unset too, there are none.

Returns:

The folders, in search order.

evaluate_agf_formula(formula: int, c, wavelength)[source]#

Refractive index from an OpticStudio dispersion formula.

Parameters:
  • formula – The formula code, 1 to 13 (see FORMULA_NAMES).

  • c – The coefficients, in the order of the AGF CD line.

  • wavelength – Wavelength(s) in µm.

Returns:

The refractive index relative to air.

find_agf_catalog(catalog: str, agf_dirs: list[str]) → str | None[source]#

The AGF file of a catalog, matching the file name ignoring case.

The first folder that has the catalog wins, as for a search path.

read_agf(path: str) → dict[str, AGFGlass][source]#

Read the glasses of an AGF catalog.

Parameters:

path – The AGF file.

Returns:

The glasses keyed by name, in file order. The catalog name is the file name without its extension, as OpticStudio uses it in GCAT.