fftvis 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ [run]
2
+ include = fftvis/*
3
+ branch = True
4
+
5
+ [report]
6
+ omit = */tests/*
@@ -0,0 +1,54 @@
1
+ name: Run Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [ main ]
6
+ push:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ tests:
11
+ env:
12
+ ENV_NAME: tests
13
+ PYTHON: ${{ matrix.python-version }}
14
+ OS: ${{ matrix.os }}
15
+ LOG_LEVEL: ${{ (matrix.os == 'macos-latest' && 'WARNING') || 'INFO' }} # Suppress logging on macOS
16
+
17
+ name: Tests
18
+ runs-on: ${{ matrix.os }}
19
+
20
+ strategy:
21
+ matrix:
22
+ os: [ubuntu-latest, macos-latest]
23
+ python-version: [3.9, "3.10", "3.11", "3.12"]
24
+ fail-fast: false
25
+
26
+ steps:
27
+ - uses: actions/checkout@main
28
+ with:
29
+ fetch-depth: 1
30
+ - uses: mpi4py/setup-mpi@v1
31
+
32
+ - name: Setup Python
33
+ uses: actions/setup-python@v4
34
+ with:
35
+ python-version: ${{ matrix.python-version }}
36
+
37
+ - name: Install
38
+ run: |
39
+ pip install --upgrade pip
40
+ pip install .[dev]
41
+
42
+ - name: Run Tests
43
+ run: |
44
+ python -m pytest --cov=fftvis --cov-config=./.coveragerc --cov-report xml:./coverage.xml --durations=15
45
+
46
+ - name: Upload coverage report
47
+ if: matrix.os == 'ubuntu-latest' && success()
48
+ uses: codecov/codecov-action@v3.1.3
49
+ with:
50
+ token: ${{ secrets.CODECOV_TOKEN }}
51
+ file: ./coverage.xml
52
+ flags: unittests
53
+ name: codecov-umbrella
54
+ fail_ci_if_error: true
@@ -0,0 +1,161 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
161
+ .vscode
fftvis-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tyler Cox
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
fftvis-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.1
2
+ Name: fftvis
3
+ Version: 0.0.1
4
+ Summary: A package for simulating visibilities using FFTs
5
+ Home-page: https://github.com/tyler-a-cox/fftvis
6
+ Author: Tyler Cox
7
+ Author-email: tyler.a.cox@berkeley.edu
8
+ License: MIT
9
+ Platform: any
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.6
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
22
+ Classifier: Topic :: Scientific/Engineering :: Visualization
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: numpy
26
+ Requires-Dist: matvis
27
+ Requires-Dist: finufft
28
+ Requires-Dist: pyuvdata
29
+ Provides-Extra: dev
30
+ Requires-Dist: mpi4py; extra == "dev"
31
+ Requires-Dist: pyuvsim[sim]; extra == "dev"
32
+ Requires-Dist: pyradiosky; extra == "dev"
33
+ Requires-Dist: pytest; extra == "dev"
34
+ Requires-Dist: pre-commit; extra == "dev"
35
+ Requires-Dist: pytest-cov; extra == "dev"
36
+ Requires-Dist: hera_sim; extra == "dev"
37
+ Requires-Dist: pytest-xdist; extra == "dev"
38
+
39
+ # fftvis: A Non-Uniform Fast Fourier Transform-based Visibility Simulator
40
+
41
+ ![Tests](https://github.com/tyler-a-cox/fftvis/actions/workflows/ci.yml/badge.svg)
42
+ ![codecov](https://codecov.io/gh/tyler-a-cox/fftvis/branch/main/graph/badge.svg)
43
+ ![Black Formatting](https://img.shields.io/badge/code%20style-black-000000.svg)
44
+
45
+ `fftvis` is a fast Python package designed for simulating interferometric visibilities using the Non-Uniform Fast Fourier Transform (NUFFT). It provides a convenient and efficient way to generate simulated visibilities.
46
+
47
+ ## Features
48
+
49
+ - Utilizes the Flatiron Institute NUFFT (finufft) [algorithm](https://arxiv.org/abs/1808.06736) for fast visibility simulations that agree with similar methods ([`matvis`](https://github.com/HERA-team/matvis)) to nearly machine precision.
50
+ - Designed to be a near drop-in replacement to `matvis` with a ~10x improvement in runtime
51
+
52
+ ## Limitations
53
+ - Currently no support for per-antenna beams
54
+ - Currently no support for polarized sky emission
55
+ - Currently no GPU support
56
+ - Diffuse sky models must be pixelized
57
+
58
+ ## Installation
59
+
60
+ You can install `fftvis` via pip:
61
+
62
+ ```bash
63
+ git clone https://github.com/tyler-a-cox/fftvis
64
+ cd fftvis
65
+ pip install .
66
+ ```
67
+
68
+ ## Contributing
69
+ Contributions to `fftvis` are welcome! If you find any issues, have feature requests, or want to contribute improvements, please open an issue or submit a pull request on the GitHub repository: `fftvis` on GitHub
70
+
71
+ ## License
72
+
73
+ This project is licensed under the MIT License - see the LICENSE file for details.
74
+
75
+ ## Acknowledgments
76
+ This package relies on the `finufft` implementation provided by [finufft](https://github.com/flatironinstitute/finufft) library. Special thanks to the contributors and maintainers of open-source libraries used in this project.
fftvis-0.0.1/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # fftvis: A Non-Uniform Fast Fourier Transform-based Visibility Simulator
2
+
3
+ ![Tests](https://github.com/tyler-a-cox/fftvis/actions/workflows/ci.yml/badge.svg)
4
+ ![codecov](https://codecov.io/gh/tyler-a-cox/fftvis/branch/main/graph/badge.svg)
5
+ ![Black Formatting](https://img.shields.io/badge/code%20style-black-000000.svg)
6
+
7
+ `fftvis` is a fast Python package designed for simulating interferometric visibilities using the Non-Uniform Fast Fourier Transform (NUFFT). It provides a convenient and efficient way to generate simulated visibilities.
8
+
9
+ ## Features
10
+
11
+ - Utilizes the Flatiron Institute NUFFT (finufft) [algorithm](https://arxiv.org/abs/1808.06736) for fast visibility simulations that agree with similar methods ([`matvis`](https://github.com/HERA-team/matvis)) to nearly machine precision.
12
+ - Designed to be a near drop-in replacement to `matvis` with a ~10x improvement in runtime
13
+
14
+ ## Limitations
15
+ - Currently no support for per-antenna beams
16
+ - Currently no support for polarized sky emission
17
+ - Currently no GPU support
18
+ - Diffuse sky models must be pixelized
19
+
20
+ ## Installation
21
+
22
+ You can install `fftvis` via pip:
23
+
24
+ ```bash
25
+ git clone https://github.com/tyler-a-cox/fftvis
26
+ cd fftvis
27
+ pip install .
28
+ ```
29
+
30
+ ## Contributing
31
+ Contributions to `fftvis` are welcome! If you find any issues, have feature requests, or want to contribute improvements, please open an issue or submit a pull request on the GitHub repository: `fftvis` on GitHub
32
+
33
+ ## License
34
+
35
+ This project is licensed under the MIT License - see the LICENSE file for details.
36
+
37
+ ## Acknowledgments
38
+ This package relies on the `finufft` implementation provided by [finufft](https://github.com/flatironinstitute/finufft) library. Special thanks to the contributors and maintainers of open-source libraries used in this project.
@@ -0,0 +1,23 @@
1
+ name: tests
2
+ channels:
3
+ - conda-forge
4
+ - defaults
5
+ dependencies:
6
+ - pip
7
+ - astropy
8
+ - numpy
9
+ - pytest
10
+ - scipy
11
+ - pyyaml
12
+ - pycodestyle
13
+ - psutil
14
+ - astropy-healpix
15
+ - future
16
+ - pytest-cov
17
+ - finufft
18
+ - matvis
19
+ - mpi4py
20
+ - pyuvdata
21
+ - pip:
22
+ - pyuvsim[sim]
23
+ - pyradiosky
@@ -0,0 +1 @@
1
+ from . import beams, utils, simulate
@@ -0,0 +1,75 @@
1
+ import numpy as np
2
+ from pyuvdata import UVBeam
3
+
4
+
5
+ def _evaluate_beam(
6
+ A_s: np.ndarray,
7
+ beam: UVBeam,
8
+ az: np.ndarray,
9
+ za: np.ndarray,
10
+ polarized: bool,
11
+ freq: float,
12
+ check: bool = False,
13
+ spline_opts: dict = None,
14
+ ):
15
+ """Evaluate the beam on the CPU. Simplified version of the `_evaluate_beam_cpu` function
16
+ in matvis.
17
+
18
+ This function will either interpolate the beam to the given coordinates tx, ty,
19
+ or evaluate the beam there if it is an analytic beam.
20
+
21
+ Parameters
22
+ ----------
23
+ A_s
24
+ Array of shape (nax, nfeed, nsrcs_up) that will be filled with beam
25
+ values.
26
+ beam
27
+ UVBeam object to evaluate.
28
+ tx, ty
29
+ Coordinates to evaluate the beam at, in sin-projection.
30
+ polarized
31
+ Whether to use beam polarization.
32
+ freq
33
+ Frequency to interpolate beam to.
34
+ check
35
+ Whether to check that the beam has no inf/nan values. Set to False if you are
36
+ sure that the beam is valid, as it will be faster.
37
+ spline_opts
38
+ Extra options to pass to the RectBivariateSpline class when interpolating.
39
+ """
40
+ # Primary beam pattern using direct interpolation of UVBeam object
41
+ kw = (
42
+ {
43
+ "reuse_spline": True,
44
+ "check_azza_domain": False,
45
+ "spline_opts": spline_opts,
46
+ }
47
+ if isinstance(beam, UVBeam)
48
+ else {}
49
+ )
50
+ if isinstance(beam, UVBeam) and not beam.future_array_shapes:
51
+ beam.use_future_array_shapes()
52
+
53
+ interp_beam = beam.interp(
54
+ az_array=az,
55
+ za_array=za,
56
+ freq_array=np.atleast_1d(freq),
57
+ **kw,
58
+ )[0]
59
+
60
+ if polarized:
61
+ interp_beam = interp_beam[:, :, 0, :]
62
+ else:
63
+ # Here we have already asserted that the beam is a power beam and
64
+ # has only one polarization, so we just evaluate that one.
65
+ interp_beam = np.sqrt(interp_beam[0, 0, 0, :])
66
+
67
+ A_s[:, :] = interp_beam
68
+
69
+ # Check for invalid beam values
70
+ if check:
71
+ sm = np.sum(A_s)
72
+ if np.isinf(sm) or np.isnan(sm):
73
+ raise ValueError("Beam interpolation resulted in an invalid value")
74
+
75
+ return A_s