Skip to content

Commit 1fb2e65

Browse files
SebastienJolySebastienJoly
authored andcommitted
Add documentation
1 parent 672996c commit 1fb2e65

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pySC/correction/loco.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,24 @@ def select_equally_spaced_elements(total_elements, num_elements):
158158

159159

160160
def get_inverse(jacobian, B, s_cut, weights, LM_lambda=0, plot=False):
161+
"""
162+
Calculates $(J^t J + \lambda diag(J^t J))^{-1} J^t r_0$ using a modified
163+
version of the Levenberg-Marquardt method. More information at p.114 of
164+
https://inis.iaea.org/collection/NCLCollectionStore/_Public/54/003/54003559.pdf
165+
166+
Args:
167+
jacobian: jacobian matrix obtained from calculate_jacobian()
168+
bpm_ords: array of element indices of registered BPMs for which to calculate readings
169+
(for convenience, otherwise `SC.ORD.BPM` is used)
170+
s_cut: number of kept singular values when inverting the matrix
171+
weights: weights applied to the elements of the jacobian
172+
LM_lambda: Levenberg-Marquardt lambda parameter. If LM_lambda=0, the
173+
function is equivalent to the Gauss-Newton method
174+
plot: boolean flag to plot the resulting inverse matrix
175+
176+
Returns:
177+
Array of correction values of the same size as B.
178+
"""
161179
n_resp_mats = len(jacobian)
162180
Jt = np.sum(jacobian, axis=2) # Sum over i and j for all planes
163181
Jt_dot_J = np.dot(np.dot(Jt, weights), Jt.T)

0 commit comments

Comments
 (0)