finesse.detectors.general module
Top-level objects which specific detectors should inherit from.
- class finesse.detectors.general.Detector(*args, **kwargs)[source]
Bases:
ABC,ModelElementAbstract representation of a component that produces a numerical output.
User detector classes should subclass this class. The simulation will then generate a dictionary of output values.
Parameters
- namestr
Name of newly created detector.
- node
NodeorPort Node to read output from. If a port is given, it must have one node, so that is is unambiguous which node to use.
- dtypetype, optional
The numpy datatype for which this output result will be stored in.
- unitstr, optional
A human readable unit for the output. E.g. W, m, m/rtHz.
- property dtype_size[source]
Size of the output in terms of number of elements.
This is typically unity as most detectors return a single value via their output functions.
Equivalent to the product of
Detector.dtype_shape.
- class finesse.detectors.general.MaskedDetector(*args, **kwargs)[source]
-
An abstract class from which detector types which can have mode masks derive.
Any detector object which calculates quantities involving loops over the modes of a model should inherit from this — allowing masks to be applied to mode patterns via the methods of this class. Examples of detectors which should derive from MaskedDetector are power-detectors, amplitude-detectors and cameras.
- add_to_mask(modes)[source]
Inserts the specified mode indices into the detector mask.
Parameters
- modessequence, str
A single mode index pair or an iterable of mode indices. Each element must unpack to two integer convertible values.
- property has_mask[source]
Whether the detector has a mask applied to it.
Simply checks to see if the
MaskedDetector.masklength is non-zero.
- property mask[source]
An array of HOMs to mask from the output. Any contributions from these modes will be zeroed when calculating the detector output.
- Getter:
Returns the array of masked indices.
- Setter:
Sets the masked indices. See
MaskedDetector.select_mask()for the options available.
- remove_from_mask(modes)[source]
Removes the specified mode indices from the detector mask.
Parameters
- modessequence, str
A single mode index pair or an iterable of mode indices. Each element must unpack to two integer convertible values.
- select_mask(modes=None, maxtem=None, exclude=None)[source]
Select the HOM indices to include in the mask.
The mode-selecting examples in Selecting the modes to model may be referred to for typical patterns when using this method, as the same concepts apply equally to making detector masks (equivalent code under-the-hood).
Parameters
- modessequence, str, optional; default: None
Identifier for the mode indices to generate. This can be:
An iterable of mode indices, where each element in the iterable must unpack to two integer convertible values.
A string identifying the type of modes to include, must be one of “even”, “odd”, “x” or “y”.
By default this is None, such that, for example, this method can be used to select a mask of all modes up to a given maxtem.
- maxtemint, optional; default: None
Optional maximum mode order. If not specified then the maxtem used internally will be equal to the maximum mode order of the associated model.
Note that this argument is ignored if modes is an iterable of mode indices.
- excludesequence, str, optional; default: None
A mode, or iterable of modes, to exclude from the selected pattern. For example, if one calls
select_mask("even", exclude="00")then the mask will be an array of all even-order HOM indices excluding the 00 mode.
Examples