rayoptics.seq.medium module

Module building on opticalglass for ray-optics material support

glass_encode(n: float, v: float) str[source]
glass_decode(gc: float) float[source]
decode_medium(*inputs, **kwargs)[source]

Input utility for parsing various forms of glass input.

The inputs can have several forms:

class GlassHandlerBase(filename)[source]

Bases: object

Base class for glass matching capability.

This class is used to match catalog glasses to input glass names. It is implemented as a class for ease of use by file importers. If the glass can be matched up with an existing opticalglass catalog, the glass is instantiated and entered into the model. If the glass cannot be found, a search for a .smx file of the same name as the model file is made. If found, it is a JSON file with a dict that provides an eval() string to create an instance to replace the missing glass name. If this file isn’t found, it is created and contains a JSON template of a dict that has the missing glass names as keys; the values are the number of times the glass occurs in the file. These values should be replaced with the desired eval() string to create a replacement glass.

Subclasses, e.g. used for different importers, should implement a single method that can be called during the import process to return a glass instance given an input string.


If unfound glasses, write smx template file.

find_glass(name, catalog, always=True)[source]

find name glass or a substitute or, if always is True, n=1.5


process name as a 6 digit glass code


Try to find a similar glass to name.


Record missing glasses or create new replacement glass instances.