finesse.analysis.actions.sensing module
Collection of Actions that deal with sensing tasks such as computing sensing matrices, optimising RF readouts, etc.
- class finesse.analysis.actions.sensing.CheckLinearity(*locks, num_points=10, plot_results=True, xlim=None, name='run locks')[source]
Bases:
ActionAn action that shows the relationships between all DOFs and all error signals, to check whether they are related linearly. Plotted for DOFs starting at their initial values and up until their initial values + 2*gain*intial error signal.
Parameters
- *lockslist, optional
A list of locks to use in each
RunLocksstep. Acts like *locks parameter inRunLocks: if not provided, all locks in model are used.- num_pointsint
Number of points to plot in the DOF range.
- plot_resultsboolean
Whether or not to plot results (requires matplotlib)
- xlimlist or None
Defines (half of) the range of DOF values over which to plot the error signals. If not specified, gains are used to find a useful range of DOF values to plot over.
- namestr
Name of the action.
- class finesse.analysis.actions.sensing.CheckLinearitySolution(*args, **kwargs)[source]
Bases:
BaseSolution
- class finesse.analysis.actions.sensing.GetErrorSignals(*locks, name='get error signals')[source]
Bases:
ActionAn action that quickly calculates the current error signals for all or a subset of locks in a model.
Parameters
- *lockslist, optional
A list of lock names to compute the error signals for. If not provided, all locks in model are used.
- namestr
Name of the action.
- class finesse.analysis.actions.sensing.GetErrorSignalsSolution(*args, **kwargs)[source]
Bases:
BaseSolution
- class finesse.analysis.actions.sensing.OptimiseRFReadoutPhaseDC(*args, d_dof=1e-10, name='optimise_demod_phases_dc', verbose=False)[source]
Bases:
ActionThis optimises the demodulation phase of
ReadoutRFelements relative to someDegreeOfFreedomor drivenParameterin the model. The phases are optimised by calculating the DC response of the readouts. ThisActionchanges the state of the model by varying the readout demodulation phases. If no arguments are given it will try to automatically optimise any lock element in the model that is using an RF readout with respect to the lock feedback parameter.Parameters
- args
Pairs of
DegreeOfFreedomorParameterandReadoutRFelements, or pairs of their names. If none are provided OptimiseRFReadoutPhaseDC will automatically search forLockelements which haveReadoutRFerror signal and optimise them. Every readout can only be optimised to a singleDegreeOfFreedomorParameter. If a readout is paired with multiple drives, its phase is optimised to the first and the others are ignored.- d_doffloat, optional
A small offset applied to the DOFs to compute the gradients of the error signals
- verbosebool
If True this will print the initial and optimised readout phases. Defaults to False
Examples
Take a typicaly Pound-Drever-Hall lock of a cavity. Here is some KatScript to setup such a model:
>>> import finesse >>> from finesse.analysis.actions import OptimiseRFReadoutPhaseDC >>> >>> model = finesse.Model() >>> model.parse(''' >>> l l1 >>> mod mod1 10M 0.1 mod_type=pm >>> readout_rf PD f=mod1.f phase=33 output_detectors=True optical_node=m1.p1.o >>> m m1 R=0.99 T=0.01 >>> m m2 R=1 T=0 >>> link(l1, mod1, m1, 1, m2) >>> lock cav_lock PD_I m2.phi 0.01 1e-3 >>> ''')
We have defined a lock above using the I quadrature RF demodulation and feeding back to the m2 mirror position. We can optimise this demodulation phase by running. Here we manually provied which drives and readouts to use:
>>> sol = model.run(OptimiseRFReadoutPhaseDC("m2.phi", 'PD_I')) >>> print(sol.phases) {'PD': 181.3535303754581} >>> print(model.PD.phase) 181.3535303754581
Alternatively, PD_Q could also be optimised for above. You can also just optimise all locks that are using RF readouts by providing no arguments:
>>> sol = model.run(OptimiseRFReadoutPhaseDC()) >>> print(sol.phases) {'PD': 181.3535303754581}
To tell what was optimised, see the sol.phases dictionary.
- class finesse.analysis.actions.sensing.OptimiseRFReadoutPhaseDCSolution[source]
Bases:
BaseSolution
- class finesse.analysis.actions.sensing.SensingMatrixAC(dofs, readouts, f=0.001, name='sensing_matrix_ac')[source]
Bases:
ActionComputes the sensing matrix elements for various degrees of freedom and readouts that should be present in the model. The solution object for this action then contains all the information on the sensing matrix. This can be plotted in polar coordinates, displayed in a table, or directly accessed.
The sensing gain is computed by calculating the gradient of each readout signal, which means it is a DC measurement. This will not include any suspension or radiation pressure effects.
This action does not modify the states model.
Parameters
- dofsiterable[str]
String names of degrees of freedom
- readoutsiterable[str]
String names of readouts
- ffloat
Frequency to measure sensing matrix at
- class finesse.analysis.actions.sensing.SensingMatrixDC(dofs, readouts, d_dof=1e-09, name='sensing_matrix_dc')[source]
Bases:
ActionComputes the sensing matrix elements for various degrees of freedom and readouts that should be present in the model. The solution object for this action then contains all the information on the sensing matrix. This can be plotted in polar coordinates, displayed in a table, or directly accessed.
The sensing gain is computed by calculating the gradient of each readout signal, which means it is a DC measurement. This will not include any suspension or radiation pressure effects.
This action does not modify the states model.
Parameters
- dofsiterable[str]
String names of degrees of freedom
- readoutsiterable[str]
String names of readouts
- d_doffloat, optional
Small step used to compute derivative
- class finesse.analysis.actions.sensing.SensingMatrixSolution[source]
Bases:
BaseSolutionSensing matrix solution.
The raw sensing matrix information can be accessed using the SensingMatrixSolution.out member. This is a complex-valued array with dimensions (DOFs, Readouts), which are accessible via SensingMatrixSolution.dofs and SensingMatrixSolution.readouts.
A table can be printed using
SensingMatrixSolution.display().Polar plot can be generated using
SensingMatrixSolution.plot()Printing
SensingMatrixSolutionwill show an ASCII table of the data.- display(dofs=None, readouts=None, tablefmt='pandas', numfmt='{:.2G}', highlight=None, highlight_color='#808080')[source]
Displays a HTML table of the sensing matrix, optionally highlighting the largest absolute value for each readout or dof.
Notes
Only works when called from an IPython environment with the display method available. Pandas is required for highlighting.
Parameters
- dofsiterable[str], optional
Names of degrees of freedom to show, defaults to all if None
- readoutsiterable[str], optional
Names of readouts to show, defaults to all if None
- tablefmtstr, optional
Either ‘pandas’ for pandas formatting, or anything else to use finesse.utilities.tables.Table. Defaults to ‘pandas’ if available.
- numfmtstr or func or array, optional
Either a function to format numbers or a formatting string. The function must return a string. Can also be an array with one option per row, column or cell. Defaults to ‘{:.2G}’.
- highlightstr or None, optional
Either ‘dof’ to highlight the readout that gives the largest output for each dof, or ‘readout’ to highlight the dof for which each readout gives the largest output. Defaults to None (no highlighting).
- highlight_colorstr, optional
Color to highlight the maximum values with. Pandas is required for this to have an effect. Defaults to pale orange.
- matrix_data(dofs=None, readouts=None)[source]
Generates a sensing matrix table.
Parameters
- dofsiterable[str], optional
Names of degrees of freedom to show, defaults to all if None
- readoutsiterable[str], optional
Names of readouts to show, defaults to all if None
Returns
matrix : 2D numpy array, complex dofs : list of
strreadouts: list ofstr
- plot(self, *args, show=True, **kwargs)[source]
Plot solution(s).
If the solution contains child solutions, they are plotted in order. Solutions without plot arguments are skipped. Positional arguments passed to this method are assumed to be
dictand are unpacked into calls to each child’s plot method. Global arguments to be passed to all plot methods can be specified directly as keyword arguments. Duplicate arguments specified in a positional argumentdictionariestake precendence over global arguments.Parameters
- show
bool, optional Show the figures.
Other Parameters
- *args
Sequence of
dictto use as parameters for the call to each child solution’s plot method.- **kwargs
Keyword arguments supported by the child solution(s).
Notes
If the Nth solution contains no plot method, it still consumes the Nth positional argument passed to this method.
- show
- finesse.analysis.actions.sensing.get_readout_workspace(readouts, output, readout_workspaces)[source]
Return the readout workspaces for a particular readout’s quadrature outputs.
Parameters
- readoutsiterable
ReadoutRFelements- outputstr
Quadrature output to try and select, ‘I’, ‘Q’, ‘DC’
- readout_workspacesdict
Workspaces of the readouts in the simulation