Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace rcond with rtol in pinv() call #156

Merged
merged 6 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
- name: Install
run: python setup.py install
run: pip install .
- name: Test
run: python setup.py test
# We cannot yet use `pytest`; requires different test file names
run: python tools/losoto_test.py
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def run(self):
'Topic :: Software Development :: Libraries :: Python Modules',
],
tests_require=['pytest'],
install_requires=['numpy>=1.9', 'cython', 'tables>=3.4', 'configparser',
install_requires=['numpy>=1.9,<2.0', 'cython', 'tables>=3.4', 'configparser',
'scipy', 'matplotlib', 'python-casacore>=3.0'],
scripts=['bin/losoto', 'bin/H5parm_split.py',
'bin/H5parm2parmdb.py', 'bin/parmdb2H5parm.py', 'bin/killMS2H5parm.py',
Expand Down