Source Code#
Welcome to the PyOptik Source Code Documentation. This section provides a comprehensive overview of the key classes, functions, and utilities available within the PyOptik library. Each component is documented in detail, with information on its members, inherited properties, and direct links to the source code.
Class Documentation#
Below, you will find detailed, automatically generated documentation for significant classes and functions in the PyOptik library. These descriptions are intended to help you understand how each class and function fits into the overall framework, and how to utilize them effectively in your projects.
MaterialBank#
The MaterialBank is the main interface for the user.
- class _MaterialBank[source]#
Bases:
object
A class representing a centralized material bank for common optical materials available in the PyOptik library.
The _MaterialBank class provides access to a predefined list of materials used in optical simulations, categorized into Sellmeier and Tabulated materials. It allows users to dynamically retrieve materials based on their names without the need to instantiate the class. The material bank can be expanded or modified by adding or removing materials from the bank, and it provides utilities to fetch material data dynamically when accessed as class attributes.
- all#
A combined list of all materials, including both Sellmeier and Tabulated materials.
- Type:
list
- Usage#
- -----
- Materials can be accessed directly as class attributes
- >>> material = _MaterialBank
- >>> bk7_material = material.BK7 # Dynamically retrieves the BK7 material.
- To add a new material to the Sellmeier bank
- >>> material.add_sellmeier_to_bank("new_material.yml", "https
- Type:
//refractiveindex.info/database/data-nk/main/SiO2/Malitson.yml”)
- To remove a material from the bank
- >>> MaterialBank.remove_item("obsolete_material.yml")
- Raises:
FileNotFoundError – If a material is not found in either the Sellmeier or Tabulated material lists.
SellmeierMaterial#
The SellmeierMaterial class extends the Material base class to handle materials defined by the Sellmeier equation. It allows for precise modeling of refractive indices using parameters from the Sellmeier formula, which is essential for optical design and simulation.
- class SellmeierMaterial(filename: str)[source]#
Bases:
BaseMaterial
Class representing a material with Sellmeier coefficients for refractive index computation.
- filename#
The name of the YAML file containing material properties.
- Type:
str
- coefficients#
The Sellmeier coefficients used for calculating the refractive index.
- Type:
numpy.ndarray
- wavelength_range#
The allowable wavelength range for the material in micrometers.
- Type:
Optional[Tuple[float, float]]
- reference#
Reference information for the material data.
- Type:
Optional[str]
- formula_type#
The formula type to use for refractive index calculation.
- Type:
int
TabulatedMaterial#
The TabulatedMaterial class extends the Material base class to handle materials characterized by tabulated refractive index and absorption values. This class is particularly useful when working with empirical data from experiments or literature.
- class TabulatedMaterial(filename: str)[source]#
Bases:
BaseMaterial
Class representing a material with tabulated refractive index (n) and absorption (k) values.
- filename#
The name of the YAML file containing material properties.
- Type:
str
- wavelength#
Array of wavelengths in micrometers for which the refractive index and absorption values are tabulated.
- Type:
numpy.ndarray
- n_values#
Array of tabulated refractive index values (n) corresponding to the wavelengths.
- Type:
numpy.ndarray
- k_values#
Array of tabulated absorption values (k) corresponding to the wavelengths.
- Type:
numpy.ndarray
- reference#
Reference information for the material data.
- Type:
Optional[str]
Utility Functions#
The PyOptik.utils module contains various utility functions that facilitate tasks like downloading data files, creating custom material definitions, and managing directories effectively.
Directives for Sphinx Gallery#
To further enhance your understanding of PyOptik, we have integrated practical examples throughout the documentation using Sphinx Gallery. These examples demonstrate how to use the library’s classes and functions in realistic scenarios.
Note
You can find example usage of the SellmeierMaterial and TabulatedMaterial classes, as well as utility functions, in the “Examples” section of the documentation. These examples are automatically generated from the source code and provide hands-on insight into the practical applications of the library.