Skip to content

Add ability to perform simulations with per-antenna beams#63

Merged
tyler-a-cox merged 32 commits into
mainfrom
multibeam
May 5, 2026
Merged

Add ability to perform simulations with per-antenna beams#63
tyler-a-cox merged 32 commits into
mainfrom
multibeam

Conversation

@tyler-a-cox
Copy link
Copy Markdown
Owner

This PR adds the functionality to allow users provide per-antenna beams and beam_idx as matvis does. There is a slight difference between the keyword argument used to pass beams between matvis and fftvis (i.e beam in fftvis vs. beams in matvis). It may be a good idea for us to change that in the future, but for now, I left the argument as beam keep this from breaking the API.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 91.83673% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.22%. Comparing base (e2a5a46) to head (f773460).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/fftvis/cpu/cpu_simulate.py 89.61% 5 Missing and 3 partials ⚠️
src/fftvis/cpu/beams.py 90.00% 1 Missing and 1 partial ⚠️
src/fftvis/wrapper.py 93.75% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #63      +/-   ##
==========================================
+ Coverage   93.18%   95.22%   +2.04%     
==========================================
  Files          18       18              
  Lines         484      566      +82     
  Branches       64       86      +22     
==========================================
+ Hits          451      539      +88     
+ Misses         26       17       -9     
- Partials        7       10       +3     
Flag Coverage Δ
unittests 95.22% <91.83%> (+2.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tyler-a-cox tyler-a-cox marked this pull request as ready for review May 4, 2026 06:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds per-antenna beam support to fftvis.simulate_vis (via a list of beams plus beam_idx) and propagates that capability through the CPU simulation engine, along with new tests covering multi-beam behavior and beam-pair flux helpers.

Changes:

  • Extend the public simulate_vis wrapper to accept a single beam or a list of beams and add beam_idx.
  • Update the CPU simulation engine to route baselines by beam-pair and evaluate apparent flux for mixed-beam baselines.
  • Add/expand tests for multi-beam simulations and new beam-evaluation helper paths.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/fftvis/wrapper.py Adds beam_idx, nchunks, source_buffer, and converts beam input into an internal beam_list.
src/fftvis/cpu/cpu_simulate.py Threads beam_list/beam_idx through chunk evaluation and implements beam-pair routing logic.
src/fftvis/cpu/beams.py Adds prepare_beam_evaluation plus cross-beam polarized apparent-flux kernels.
tests/test_wrapper.py Adds wrapper-level validation tests for beam list / beam_idx error cases.
tests/test_cpu_simulate.py Adds an fftvis-vs-matvis multi-beam regression test and updates calls for new arguments.
tests/test_cpu_beams.py Adds unit tests for beam-pair routing and new polarized apparent-flux helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/fftvis/wrapper.py Outdated
Comment thread src/fftvis/wrapper.py
Comment thread src/fftvis/cpu/beams.py Outdated
Comment thread src/fftvis/cpu/cpu_simulate.py
Comment thread src/fftvis/cpu/cpu_simulate.py
Comment thread src/fftvis/cpu/cpu_simulate.py Outdated
@steven-murray
Copy link
Copy Markdown
Collaborator

Thanks @tyler-a-cox -- I'm going to let you deal with Copilot's suggestions first, and then please ping me and I'll take a final look.

From my side, the code is working on bridges, so there should be nothing major to fix.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
tyler-a-cox and others added 2 commits May 4, 2026 08:28
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…aluation

Agent-Logs-Url: https://github.com/tyler-a-cox/fftvis/sessions/53224b26-52a0-4803-be07-4c1c70648550

Co-authored-by: tyler-a-cox <17678594+tyler-a-cox@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 4, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • datacenter.iers.org
    • Triggering command: /usr/bin/python python -m pytest tests/ --ignore=tests/test_cpu_simulate.py --ignore=tests/test_gpu_beams.py -q (dns block)
  • maia.usno.navy.mil
    • Triggering command: /usr/bin/python python -m pytest tests/ --ignore=tests/test_cpu_simulate.py --ignore=tests/test_gpu_beams.py -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@tyler-a-cox
Copy link
Copy Markdown
Owner Author

@steven-murray okay, this should be good for you to review now

Copy link
Copy Markdown
Collaborator

@steven-murray steven-murray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tyler-a-cox., this is looking great. Thanks also for adding the option to specify the max memory. I thnk the logic that copilot added might be wrong, so maybe have another look at that, to make sure. Otherwise this is good to go.

Comment thread src/fftvis/cpu/beams.py Outdated
Comment on lines +99 to +101
# Get number of beams: use max index + 1 so non-contiguous indices
# (e.g. [0, 2, 2]) still produce the correct set of beam pairs.
nbeams = int(np.max(beam_idx)) + 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, this actually doesn't seem right to me. We should only include beam indices that actually exist, right? We don't need to use all pairs in the range from (0,maxidx)?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm now building the unique beam pairs array with pairs actually used in beam_idx array

Comment thread src/fftvis/cpu/cpu_simulate.py Outdated
Comment on lines +274 to +277
if isinstance(beam, UVBeam):
required_shm += beam.data_array.nbytes
elif isinstance(beam, BeamInterface) and getattr(beam, "_isuvbeam", False):
required_shm += beam.beam.data_array.nbytes
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the right thing to do here actually is to only ever deal with the BeamInterface (so, if UVBeam is passed to the wrapper, convert it to a BeamInterface there, so the logic throughout the rest of the code is more uniform).

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went back to just using BeamInterface

Comment thread tests/test_cpu_beams.py
@tyler-a-cox tyler-a-cox requested a review from steven-murray May 5, 2026 18:18
Copy link
Copy Markdown
Collaborator

@steven-murray steven-murray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct to me!

@tyler-a-cox tyler-a-cox merged commit 1a76fa7 into main May 5, 2026
17 of 19 checks passed
@tyler-a-cox tyler-a-cox deleted the multibeam branch May 5, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants