finesse.detectors.workspace.MaskedDetectorWorkspace¶
Overview
- class finesse.detectors.workspace.MaskedDetectorWorkspace(owner, BaseSimulation sim, values=None, oinfo=None, *, **kwargs)¶
Bases:
DetectorWorkspaceSpecialised 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
wswhich inherits fromMaskedDetectorWorkspace.Using via Python
The
unmasked_indices_arrattribute is anumpy.ndarray, of dtypenp.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.gfor 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 = 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_indicespointer (only accessible from other Cython code) which corresponds to the data of theunmasked_indices_arrNumPy array described above. The attributenum_unmasked_homsis 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.gcdef 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 = carrier.get_out_fast(ws.dc_node_id, 0, k) # use a_0k for some calculation ...
where each
kis then the index of the mode at positioniin 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)whereNhomsis the total number of modes in the simulation.