finesse.detectors.workspace.MaskedDetectorWorkspace

Overview

class finesse.detectors.workspace.MaskedDetectorWorkspace(owner, CarrierSignalMatrixSimulation sim, values=None, oinfo=None, *, **kwargs)

Bases: DetectorWorkspace

Specialised workspace for detectors which support masking of modes.

This workspace provides attributes that are exposed to both C and Python. The sections below detail how to use these for some workspace instance ws which inherits from MaskedDetectorWorkspace.

Using via Python

The unmasked_indices_arr attribute is a numpy.ndarray, of dtype np.intp, which contains the indices of modes which are not masked. One may then simply loop over this array of indices to access the corresponding field indices, e.g:

for k in ws.unmasked_indices_arr:
    # Do something with k, e.g. get field at 0 Hz freq. offset
    # at the given node for the mode index k:
    a_0k = ws.sim.carrier.get_out_fast(ws.dc_node_id, 0, k)
    # use a_0k for some calculation ...

Using via Cython

This workspace also provides a unmasked_mode_indices pointer (only accessible from other Cython code) which corresponds to the data of the unmasked_indices_arr NumPy array described above. The attribute num_unmasked_homs is the size of this array; i.e. the number of modes which are not masked.

One may then write an optimised loop from [0, num_unmasked_homs), e.g:

cdef Py_ssize_t i, k
cdef complex_t a_0k
for i in range(ws.num_unmasked_homs):
    k = ws.unmasked_mode_indices[i]
    # Do something with k, e.g. get field at 0 Hz freq. offset
    # at the given node for the mode index k:
    a_0k = ws.sim.carrier.get_out_fast(ws.dc_node_id, 0, k)
    # use a_0k for some calculation ...

where each k is then the index of the mode at position i in the unmasked indices array.

Note

If the detector mask is empty (i.e. no modes are being masked) then unmasked_indices_arr (and, correspondingly, unmasked_mode_indices) will simply be an array from [0, Nhoms) where Nhoms is the total number of modes in the simulation.