ZMXReader
- class raytracing.ZMXReader(filepath)
Bases:
objectZemax file (ZMX) reader for compound lenses. The reader is not complete, but it can return a MatrixGroup that will behave like a compound lens with the spherical interfaces and spacing between elements.
This only works with ZMX files, not ZMF files. The ZMX files are text-based and the ZMF files are binary without documentation.
It is not particularly robust: many parameters are currently ignored and it could fail for files not from Thorlabs or Edmund (the only files tested).
- designWavelengths()
Obtain the design wavelength(s) from the file. Thorlabs appears to leave many useless wavelengths (0.55 µm) so we remove them.
- determineEncoding(filepath)
Zemax files can be in UTF-16 (e.g., Edmund Optics) We try to open it as UTF-16, we will get an error if it cannot.
- lensSurfaces()
Make sense of surfaceInfo from the Zemax file to figure out what makes up a lens.
This will not be particularly robust: it assumes it is a compound lens but that is sufficient for now.
- Returns:
lensSurfaces
- Return type:
List of Surface elements that make up the lens.
- matrixGroup()
Build and return a raytracing MatrixGroup with the interfaces and spacing as prescribed.
- Returns:
group – The created group that acts like a lens.
- Return type:
- prescription()
A text-based prescription, mostly for information purposes.
- Returns:
prescription – A prescription in text-based form
- Return type:
multi-line string
- rawSurfaceInfo(index)
Extract the raw information for surfaces from the file. All SURF elements from the file are extracted in order. No analysis is performed: making sense of the information in the context of a lens is the job of surfaceInfo.
- surfaceInfo(index)
Make sense of rawSurfaceInfo from the Zemax file to put it together into a Surface-namedtuple that makes more sense.
We figure out the material and replace it with Raytracing Material subclass.
We convert CURV into a radius.
We use DIAM as the diameter of the element. For some reason DIAM is half the diameter.
The distance to the next interface is read as well.
- Return type:
A Surface Named-tuple.
- surfaces()
List of all surface elements from the Zemax file.
- Return type:
List of Surfaces
- value(key, index=0)
Convenience function to access the information in the file with the Zemax 4-letter parameters.
If an element has several items, element [index] is returned, defaults to zero.
Methods
|
|
Obtain the design wavelength(s) from the file. |
|
|
Zemax files can be in UTF-16 (e.g., Edmund Optics) We try to open it as UTF-16, we will get an error if it cannot. |
Make sense of surfaceInfo from the Zemax file to figure out what makes up a lens. |
|
Build and return a raytracing MatrixGroup with the interfaces and spacing as prescribed. |
|
A text-based prescription, mostly for information purposes. |
|
|
Extract the raw information for surfaces from the file. |
|
Make sense of rawSurfaceInfo from the Zemax file to put it together into a Surface-namedtuple that makes more sense. |
|
List of all surface elements from the Zemax file. |
|
Convenience function to access the information in the file with the Zemax 4-letter parameters. |
Inherited Methods