Skip to content

Commit

Permalink
Replace rcond with rtol in pinv() call
Browse files Browse the repository at this point in the history
The `pinv()` function deprecated the use of `rcond` in favour of `rtol`, and SciPy 1.14.0 removed the keyword option `rcond` completely from `pinv()`.
Replaced all occurrences of `rcond` in calls to `pinv()` with `rtol`.
  • Loading branch information
gmloose committed Jul 9, 2024
1 parent d3b1f3b commit 0a39534
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions losoto/operations/directionscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ def _fit_phase_screen(station_names, source_names, pp, airmass, rr, weights, tim
D = np.transpose(D, (1, 0, 2)) - D
D2 = np.sum(D**2, axis=2)
C = -(D2 / r_0**2)**(beta / 2.0) / 2.0
pinvC = pinv(C, rcond=1e-3)
pinvC = pinv(C, rtol=1e-3)
U, S, V = svd(C)
invU = pinv(np.dot(np.transpose(U[:, :order]), np.dot(weights[:, :, k], U[:, :order])), rcond=1e-3)
invU = pinv(np.dot(np.transpose(U[:, :order]), np.dot(weights[:, :, k], U[:, :order])), rtol=1e-3)

# Calculate real screen
rr1 = np.dot(np.transpose(U[:, :order]), np.dot(weights[:, :, k], rr_real[:, k]))
Expand Down Expand Up @@ -337,9 +337,9 @@ def _fit_tec_screen(station_names, source_names, pp, airmass, rr, weights, times
D = np.transpose(D, (1, 0, 2)) - D
D2 = np.sum(D**2, axis=2)
C = -(D2 / r_0**2)**(beta / 2.0) / 2.0
pinvC = pinv(C, rcond=1e-3)
pinvC = pinv(C, rtol=1e-3)
U, S, V = svd(C)
invU = pinv(np.dot(np.transpose(U[:, :order]), np.dot(weights[:, :, k], U[:, :order])), rcond=1e-3)
invU = pinv(np.dot(np.transpose(U[:, :order]), np.dot(weights[:, :, k], U[:, :order])), rtol=1e-3)

# Calculate screen
rr1 = np.dot(np.transpose(U[:, :order]), np.dot(weights[:, :, k], rr[:, k]))
Expand Down
4 changes: 2 additions & 2 deletions losoto/operations/stationscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def _calculate_svd(pp, r_0, beta, N_piercepoints):
D = np.transpose(D, (1, 0, 2)) - D
D2 = np.sum(D**2, axis=2)
C = -(D2 / r_0**2)**(beta / 2.0) / 2.0
pinvC = pinv(C, rcond=1e-3)
pinvC = pinv(C, rtol=1e-3)
U, S, V = svd(C)

return C, pinvC, U
Expand Down Expand Up @@ -439,7 +439,7 @@ def _fit_screen(source_names, full_matrices, pp, rr, weights, order, r_0, beta,
else:
# Recalculate for unflagged directions
C, pinvC, U = _calculate_svd(pp, r_0, beta, N_piercepoints)
invU = pinv(np.dot(np.transpose(U[:, :order]), np.dot(w, U)[:, :order]), rcond=1e-3)
invU = pinv(np.dot(np.transpose(U[:, :order]), np.dot(w, U)[:, :order]), rtol=1e-3)

# Fit screen to unflagged directions
if screen_type == 'phase':
Expand Down

0 comments on commit 0a39534

Please sign in to comment.