Skip to content

Commit

Permalink
Merge branch 'main' into sky_fit_routines
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-a-cox committed Apr 21, 2024
2 parents 7d03c2b + 128b557 commit 52d0b1f
Show file tree
Hide file tree
Showing 14 changed files with 497 additions and 118 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ on:

jobs:
tests:
env:
ENV_NAME: tests
PYTHON: ${{ matrix.python-version }}
OS: ${{ matrix.os }}
LOG_LEVEL: ${{ (matrix.os == 'macos-latest' && 'WARNING') || 'INFO' }} # Suppress logging on macOS

name: Tests
runs-on: ${{ matrix.os }}

Expand All @@ -18,9 +24,10 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@main
with:
fetch-depth: 0
fetch-depth: 1
- uses: mpi4py/setup-mpi@v1

- name: Setup Python
uses: actions/setup-python@v4
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Python distributions to PyPI and TestPyPI

on:
push:
tags:
- '*'

jobs:
build-n-publish:
name: Build and publish to PyPI
runs-on: ubuntu-latest
env:
ENV_NAME: publish
PYTHON: 3.9
steps:
- uses: actions/checkout@main
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON }}

- name: Install build
run: pip install build

- name: Build a binary wheel and a source tarball
run: |
python -m build
- name: Publish to PyPI
if: startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Features

- 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.
- 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 high precision.
- Designed to be a near drop-in replacement to `matvis` with a ~10x improvement in runtime

## Limitations
Expand Down
9 changes: 7 additions & 2 deletions ci/fftvis_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: fftvis_tests
name: tests
channels:
- conda-forge
- defaults
Expand All @@ -15,4 +15,9 @@ dependencies:
- future
- pytest-cov
- finufft
- matvis
- matvis
- mpi4py
- pyuvdata
- pip:
- pyuvsim[sim]
- pyradiosky
16 changes: 0 additions & 16 deletions ci/install_conda.sh

This file was deleted.

2 changes: 1 addition & 1 deletion fftvis/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import beams, optimize, utils, simulate
from . import beams, utils, simulate
76 changes: 37 additions & 39 deletions fftvis/beams.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,9 @@ def bessel_beam_interpolation(
"""
raise NotImplementedError("Interpolation not yet implemented.")


def _evaluate_beam(
A_s: np.ndarray,
beam_list: list[UVBeam],
beam: UVBeam,
az: np.ndarray,
za: np.ndarray,
polarized: bool,
Expand All @@ -258,10 +257,10 @@ def _evaluate_beam(
Parameters
----------
A_s
Array of shape (nax, nfeed, nbeam, nsrcs_up) that will be filled with beam
Array of shape (nax, nfeed, nsrcs_up) that will be filled with beam
values.
beam_list
List of unique beams.
beam
UVBeam object to evaluate.
tx, ty
Coordinates to evaluate the beam at, in sin-projection.
polarized
Expand All @@ -275,39 +274,38 @@ def _evaluate_beam(
Extra options to pass to the RectBivariateSpline class when interpolating.
"""
# Primary beam pattern using direct interpolation of UVBeam object
for i, bm in enumerate(beam_list):
kw = (
{
"reuse_spline": True,
"check_azza_domain": False,
"spline_opts": spline_opts,
}
if isinstance(bm, UVBeam)
else {}
)
if isinstance(bm, UVBeam) and not bm.future_array_shapes:
bm.use_future_array_shapes()

interp_beam = bm.interp(
az_array=az,
za_array=za,
freq_array=np.atleast_1d(freq),
**kw,
)[0]

if polarized:
interp_beam = interp_beam[:, :, 0, :]
else:
# Here we have already asserted that the beam is a power beam and
# has only one polarization, so we just evaluate that one.
interp_beam = np.sqrt(interp_beam[0, 0, 0, :])

A_s[:, :, i] = interp_beam

# Check for invalid beam values
if check:
sm = np.sum(A_s)
if np.isinf(sm) or np.isnan(sm):
raise ValueError("Beam interpolation resulted in an invalid value")
kw = (
{
"reuse_spline": True,
"check_azza_domain": False,
"spline_opts": spline_opts,
}
if isinstance(beam, UVBeam)
else {}
)
if isinstance(beam, UVBeam) and not beam.future_array_shapes:
beam.use_future_array_shapes()

interp_beam = beam.interp(
az_array=az,
za_array=za,
freq_array=np.atleast_1d(freq),
**kw,
)[0]

if polarized:
interp_beam = interp_beam[:, :, 0, :]
else:
# Here we have already asserted that the beam is a power beam and
# has only one polarization, so we just evaluate that one.
interp_beam = np.sqrt(interp_beam[0, 0, 0, :])

A_s[:, :] = interp_beam

# Check for invalid beam values
if check:
sm = np.sum(A_s)
if np.isinf(sm) or np.isnan(sm):
raise ValueError("Beam interpolation resulted in an invalid value")

return A_s
Loading

0 comments on commit 52d0b1f

Please sign in to comment.