corset.database#
Lens database class for managing collections of lenses.
This class can be used to load the lens databases included with Beam Corset.
Use LensList.available() to list the available databases
and LensList.load() to load a database by name.
The typical naming scheme for these databases is as follows:
[domain]/[manufacturer]_[lens type]_L[applicable wavelength in nm]_M[total margins in mm]
e.g. quantum_control/Thorlabs_BX_L1064_M10 is a database from the Quantum Control made up of
Thorlabs bi-convex lenses applicable for 1064 nm light with a total margin (left + right) of 10 mm.
There are also combined databases, where the manufacturer and lens type are replaced with Combined.
The lens type shorthands are as follows:
BX: Bi-ConvexBV: Bi-ConcavePX: Plan-ConvexXP: Convex-PlanPV: Plan-ConcaveVP: Concave-Plan
The lenses in these databases adhere to the following conventions:
[first letter of manufacturer][lens type][nominal focal length in mm]
so a Thorlabs bi-convex lens with a nominal focal length of 50 mm is named TBX50.
This keeps the name short for plotting and makes it easier to index into lens lists by name.
- class corset.database.LensList(lenses) None#
A list of lenses with convenient access methods.
Supports (array) indexing and other list-like operations, indices can also be strings or list of strings to access lenses by name. Implements
_repr_html_()to show apandas.DataFramerepresentation in IPython environments.- classmethod load(name) LensList#
Load a lens database from the built-in library.
- Parameters:
name (
str) – Name of the lens database to load.- Returns:
The loaded lens database.
- Return type:
- Raises:
FileNotFoundError – If the lens database name is not found in the library.
- classmethod load_csv(path) LensList#
Load a lens list from a CSV file.
- Parameters:
path (
str|Path) – Path to the CSV file. This is passed directly topandas.read_csv()so it also accepts other types supported by that function like URL strings or file-like objects.- Returns:
The loaded lens list.
- Return type:
- Raises:
ValueError – If the CSV file contains invalid data.
KeyError – If required fields are missing in the CSV file.
- classmethod load_yaml(filename) Self#
Load an object from a YAML file.
If this is called from a subclass the loaded object type must match that subclass.
- Parameters:
- Return type:
Self- Returns:
The loaded object.
- Raises:
ValueError – If the YAML file does not contain a ‘data’ field.
TypeError – If the loaded object type does not match the class used to call this method.
- property df: DataFrame#
A
pandas.DataFramerepresentation of the lens list.