kontrol.transfer_function
Primary modules
kontrol.transfer_function.transfer_function
Transfer function class. Wrapper around control.TransferFunction to provide custom functionality related to KAGRA.
- class kontrol.transfer_function.transfer_function.TransferFunction(*args)
Bases:
TransferFunction
Transfer function class
- Parameters
*args – Arguments passed to control.TransferFunction class.
- clean(tol_order=5)
Remove numerator/denominator coefficients that are small outliers
- Parameters
tol_order (int, optional) – If the coefficient is
tol_order
order smaller than the rest of the coefficients, then this coefficient is an outlier. Defaults 5.
- foton(expression='zpk', root_location='s', significant_figures=6, itol=1e-25, epsilon=1e-25)
Foton expression of this transfer function
Calls kontrol.core.foton.tf2foton and returns a foton expression of this transfer function
- Parameters
expression (str, optional) – Format of the foton expression. Choose from [“zpk”, “rpoly”]. Defaults to “zpk”.
root_location (str, optional) – Root location of the zeros and poles for expression==”zpk”. Choose from [“s”, “f”, “n”]. “s”: roots in s-plane, i.e. zpk([…], […], …, “s”). “f”: roots in frequency plane, i.e. zpk([…], [,,,], …, “f”). “n”: roots in frequency plane but negated and gains are normalized, i.e. real parts are positive zpk([…], […], …, “n”). Defaults to “s”.
significant_figures (int, optional) – Number of significant figures to print out. Defaults to 6.
itol (float, optional) – Treating complex roots as real roots if the ratio of the imaginary part and the real part is smaller than this tolerance Defaults to 1e-25.
epsilon (float, optional) – Small number to add to denominator to prevent division error. Defaults to 1e-25.
- Returns
foton_expression – The foton expression in selected format.
- Return type
str
- lstrip(element, fc=None)
Remove zero or pole from the left.
- Parameters
element (str) – Element to be removed. Choose from [“any”, “zero”, “pole”, “pair”, “all”].
fc (float or None, optional) – Cutoff frequency. If element is in [“any”, “all”], remove any or all elements on the left of the cutoff. Defaults None.
- rstrip(element, fc=None)
Remove zero or pole from the right.
- Parameters
element (str) – Element to be removed. Choose from [“any”, “zero”, “pole”, “pair”, “all”].
fc (float or None, optional) – Cutoff frequency. If element is in [“any”, “all”], remove any or all elements on the left of the cutoff. Defaults None.
- save(path, overwrite=True)
Save the transfer function to a specified path.
This functions extracts the numerator and denominator coefficients and puts it into a pandas DataFrame with keys {“num” and “den”}. Then it outputs to the specified path with a pickle format.
- Parameters
path (str) – The string of the path.
overwrite (boolean, optional) – Overwrite if the file exists.
- stabilize()
Convert unstable zeros and poles to stable ones.
- kontrol.transfer_function.transfer_function.load_transfer_function(path)
Load a kontrol TransferFunction object from path.
- Parameters
path (str) – The path of the saved transfer function
- Returns
The loaded TransferFunction object.
- Return type
kontrol.transfer_function.notch
Foton defined Notch filter.
- class kontrol.transfer_function.notch.Notch(frequency, q, depth=None, depth_db=None)
Bases:
TransferFunction
Notch Filter Object
- Parameters
frequency (float) – The notch frequency (Hz).
q (float) – The quality factor.
depth (float) – The depth of the notch filter (magnitude). If not specified,
depth_db
will be used. Defaults None.depth_db (float, optional) – The depth of the notch filter (decibel). If not specified,
depth
will be used instead. Defaults None.Attritubes –
---------- –
frequency – The notch frequency (Hz).
q – The quality factor.
depth – The depth of the notch filter (magnitude).
Notes
The notch filter is defined by Foton, as
\[N(s) = \frac{s^2 + (2\pi f_n)/(dQ/2)s + (2\pi f_n)^2} {s^2 + (2\pi f_n)/(Q/2)s + (2\pi f_n)^2}\,,\]where \(f_n\) is the notch frequency, \(q\) is the quality factor , and \(d\) is the depth.
- property depth
The depth of the notch filter (magnitude).
- foton()
Foton expression of this notch filter.
- property frequency
The notch frequency (Hz).
- property q
The quality factor