finesse.detectors.math_detector.MathDetector

Overview

class finesse.detectors.math_detector.MathDetector(name, *args, **kwargs)[source]

Bases: Detector

A detector that performs some math operation and outputs the result.

Parameters
namestr

Name of detector

expressionSymbol

Symbolic expression to evaluate as the detectors output

dtypenumpy.dtype, optional

The expected data type when evaluating expression. Defaults to “O”.

dtype_shapetuple

The expected array shape when evaluating expression. Defaults to an empty tuple. This must be an empty tuple if dtype is a scalar type or “O”.

unitstr

The unit of the output for plotting. Defaults to “arb.”

labelstr or None

How to label the axis when plotting this detector. Defaults to None.

Notes

If dtype does not match the result when expression is evaluated the values will be silently cast to dtype. dtype_shape is used to create a numpy array in which the results are written, if this doesn’t match this should raise some Exception when running a simulation, but this is not guaranteed. If one isn’t sure of what type expression will produce, one should leave the default “O”, the generic numpy type object, and convert the data after inspecting the result. When using the default type, some functions like Solution.plot might not be able to convert the data to an appropiate type internally, in which case they cannot be used.

Examples

KatScript example:

l l1 P=1 pd P l1.p1.o fd E l1.p1.o f=l1.f bp qx l1.p1.o q x modes(maxtem=3) gauss g1 l1.p1.o w0=1m z=0

mathd Y1 P*2 mathd Y2 P**2 mathd Y3 cos(1+P**2) mathd Y4 E*2 mathd Y5 qx+1

Properties

MathDetector.expression

MathDetector.needs_fields

Flag indicating whether the detector requires light fields (i.e.

MathDetector.needs_trace

Flag indicating whether the detector requires beam traces.

Methods

MathDetector.__init__(name, expression[, ...])

MathDetector.set_expression(expression[, ...])