pyoptools.raytrace.library.library module¶
- class pyoptools.raytrace.library.library.LibraryModule¶
Bases:
objectThe optics library provides access to optical components from the catalogs of well-known optical suppliers or user-supplied libraries.
Currently, catalogs from Thorlabs [thorlabs.com] and Edmund [edmundoptics.com] are available.
Optical elements can be retrieved by part number using dictionary-style access from the library module i.e:
library[‘LB1862’] returns a SphericalLens based on an optic from Thorlabs.
optionally, the specific supplier catalog can be specified via attribute access. This can be used in the rare case that different catalogs have parts with matching part number, or to speed up lookup time. I.e.
library.Thorlabs[‘LB1862’]
It is also possible to retrieve a dictionary-descriptor for an optic without instantiating the optical component instance. This is done with the .descriptor() method. Descriptors can be used to instantiate optical components using the component.optic_factory.
The library module is iterable using .items(). This dictionary-style iterator returns component descriptor. A common usage is to search for optical components matching specific requirements.
User supplied catalogs can be added using the .add() method, which requires the path (string or Pathlib.Path) to a .json optic catalog file. The user supplied catalog can then be accessed by attribute using the given filename.
- add(userlib)¶
Add a user-defined .json file containing optical component descriptors to the library. userlib : string path to the .json file or pathlib.Path
- catalogs()¶
- descriptor(part)¶
Return the dictionary-descriptor for optic with given part number.
- get(part: str)¶
Deprecated method. Simply use dictionary style access to get an optic given the part number.
- items()¶
Generates a dictionary iterator which allows iteration through all optical components descriptors in all libraries. Note : to instantiate an optical component given a descriptor, use component.optic_factory(**descriptor).
- parts()¶
Returns a list of all available optical component by part number.
- remove(libname: str)¶
Remove a user-defined optical component library.