RRIvis is a Python-based application for simulating and visualizing complex visibilities in radio astronomy. It's particularly focused on the Hydrogen Epoch of Reionization Array (HERA) and similar radio telescopes, but can be used with any antenna array configuration.
The simulator calculates visibility data using antenna positions, baselines, sky models, and source catalogs. It supports various plotting libraries and offers options for both polarized and non-polarized visibility calculations.
RRIviz provides a complete pipeline for radio interferometry simulation and visualization, including:
- Antenna array configuration
- Source modeling
- Visibility calculation
- Interactive plotting capabilities
- Generate antenna positions or load them from a file
- Support for different antenna diameters (uniform or per-antenna)
- Integration with PYUVData telescope objects
- Support for various antenna types including parabolic dishes, spherical reflectors, phased arrays, and dipoles
- Dynamically compute baselines between antennas
- Trim baselines based on specified criteria
- Support for auto-correlations and cross-correlations
- Selective baseline filtering based on length
- Multiple sky model options:
- Test sources (simple 3-source configuration)
- GLEAM (GaLactic Extragalactic All-sky MWA) catalog sources
- GSM (Global Sky Model) 2008 sources
- HEALPix-based representations of sky models
- Combined models (GSM+GLEAM)
- Configurable flux limits and HEALPix resolution parameters
- Comprehensive beam pattern implementations:
- Gaussian beam patterns
- Parabolic dish models with different illumination tapers (uniform, cosine, Gaussian, 10dB/20dB taper)
- Spherical reflector models
- Phased array and dipole models
- HPBW (Half Power Beam Width) calculations for different antenna types
- Beam solid angle calculations using HEALPix
- Optimized method for visibility computation
- Support for both point source and HEALPix-based sky models
- Accounts for beam patterns and source spectral indices
- Calculates visibility modulus and phase
- Time and frequency domain simulation
- Interactive plots using Bokeh:
- Antenna layout plots (2D and 3D)
- Visibility vs. time plots
- Visibility vs. frequency plots
- Heatmaps of visibility data
- Sky model visualizations with time-evolving maps
- Static plots using Matplotlib
- Interactive plots with hover information
- Adjust parameters via a user-provided YAML config or rely on in-code defaults
- Support for fixed HPBW values or frequency-dependent calculations
- Configurable observation parameters (location, timing, frequency range)
- Save visibility data and sky model plots for further analysis in HDF5 format
- Option to save simulation data and configuration
- JSON output for visibility results
- HTML files with interactive plots
- Logs simulation details to a file and the console
- Comprehensive output of simulation parameters and progress
-
Install Pixi if you haven't already:
curl -fsSL https://pixi.sh/install.sh | bash -
Clone the repository:
git clone <repository_url> cd RRIviz
-
Install dependencies and set up the environment:
pixi install
-
Run the simulator:
pixi run start
To run a basic simulation with default parameters:
pixi run startFor a customized simulation, create a config file and specify it:
pixi run start --config /path/to/your/config.yaml --antenna-file /path/to/your/antenna.txtYou may provide a YAML configuration file to override in-code defaults. If no config is supplied, sensible defaults embedded in the program are used.
Key configuration parameters include:
telescope_type: Configuration for telescope typeuse_PYUVData_telescope: Boolean to use PYUVData telescope objectuse_custom_telescope: Boolean to use custom telescope configuration
telescope_name: Name of the telescope (e.g., "HERA")
antenna_positions_file: Absolute path to antenna positions fileall_antenna_diameter: Default diameter for all antennas in metersuse_different_diameters: Boolean to use per-antenna diametersfixed_hpbw: Optional fixed HPBW value in degrees for all antennas
use_autocorrelations: Boolean to include auto-correlationsuse_crosscorrelations: Boolean to include cross-correlationsonly_selective_baseline_length: Boolean to filter baselines by lengthselective_baseline_lengths: Array of baseline lengths to include
lat: Latitude of observation location in degreeslon: Longitude of observation location in degreesheight: Height of observation location in meters
Multiple sky model options are available:
-
test_sources: Simple test sourcesuse_test_sources: Boolean to enable test sourcesnum_sources: Number of test sourcesflux_limit: Flux limit in Janskys
-
test_sources_healpix: Test sources in HEALPix formatuse_test_sources: Boolean to enable test sourcesnum_sources: Number of test sourcesflux_limit: Flux limit in Janskysnside: HEALPix resolution parameter
-
gsm_healpix: Global Sky Model in HEALPix formatuse_gsm: Boolean to enable GSMflux_limit: Flux limit in Janskysnside: HEALPix resolution parameter
-
gleam: GLEAM catalog sourcesuse_gleam: Boolean to enable GLEAM cataloggleam_catalogue: GLEAM catalog identifierflux_limit: Flux limit in Janskys
-
gleam_healpix: GLEAM catalog in HEALPix formatuse_gleam: Boolean to enable GLEAM catalogflux_limit: Flux limit in Janskysnside: HEALPix resolution parameter
-
gsm+gleam_healpix: Combined GSM and GLEAM modelsuse_gsm_gleam: Boolean to enable combined modelflux_limit: Flux limit in Janskysnside: HEALPix resolution parameter
time_interval_between_observation: Time interval between observationstime_interval_unit: Unit for time interval ("seconds", "minutes", "hours", "days")total_duration: Total duration of observationtotal_duration_unit: Unit for total duration ("seconds", "minutes", "hours", "days")start_time: Start time of observation in ISO format
starting_frequency: Starting frequency in MHzfrequency_interval: Frequency interval in MHzfrequency_bandwidth: Total frequency bandwidth in MHzfrequency_unit: Unit for frequency parameters
output_file: Name of output HDF5 filesave_simulation_data: Boolean to save simulation dataplot_results_in_bokeh: Boolean to generate Bokeh plotssimulation_data_dir: Optional directory for simulation datasimulation_subdir: Optional subdirectory under Downloads/XDG_DOWNLOAD_DIR
Run the simulator using the src/main.py script:
python src/main.py \
--antenna-file /absolute/path/to/antenna.txt \
--config /absolute/path/to/config.yaml \
--sim-data-dir /path/for/simulation/outputs--antenna-fileis required unless provided in the config.--configis optional; if omitted, the built-in defaults are used.--sim-data-diris optional; if omitted, outputs are stored under$(XDG_DOWNLOAD_DIR or ~/Downloads)/RRIVis_simulation_data/<timestamp>. The program prints the exact location. The<timestamp>is formatted asYYYY-MM-DD_HH-MM-SS_UTC.
A sample config.yaml file is provided below:
telescope:
telescope_type:
use_PYUVData_telescope: False
use_custom_telescope: True
telescope_name: "HERA"
antenna:
antenna_positions_file: "/absolute/path/to/antenna.txt"
all_antenna_diameter: 14.0
use_different_diameters: false
fixed_hpbw: None
baseline:
use_autocorrelations: True
use_crosscorrelations: True
only_selective_baseline_length: True
selective_baseline_lengths: [14, 28, 42]
location:
lat: -30.72152777777791
lon: 21.428305555555557
height: 1073.0
sky_model:
test_sources:
use_test_sources: False
num_sources: 100
flux_limit: 50
test_sources_healpix:
use_test_sources: False
num_sources: 100
flux_limit: 50
nside: 32
gsm_healpix:
use_gsm: False
flux_limit: 50
nside: 32
gleam:
use_gleam: False
gleam_catalogue: "VIII/100/gleamegc"
flux_limit: 50
gleam_healpix:
use_gleam: False
flux_limit: 50
nside: 32
gsm+gleam_healpix:
use_gsm_gleam: False
flux_limit: 50
nside: 32
obs_time:
time_interval_between_observation: 1.0
time_interval_unit: "hours"
total_duration: 1
total_duration_unit: "days"
start_time: "2025-01-01T00:00:00"
frequency:
starting_frequency: 50.0
frequency_interval: 1.0
frequency_bandwidth: 100.0
frequency_unit: "MHz"
output:
output_file: "complex_visibility.h5"
save_simulation_data: True
plot_results_in_bokeh: True
simulation_data_dir: "/absolute/path/for/simulations"
simulation_subdir: "RRIVis_simulation_data"Handles antenna position reading and management from text files. Supports different antenna diameters and configurations.
Generates baselines between antenna pairs with associated metadata. Supports filtering based on baseline length and correlation type.
Implements various beam pattern models and HPBW calculations:
- Gaussian beam patterns
- Parabolic dish models with different illumination tapers
- Spherical reflector models
- Phased array and dipole models
- HPBW calculations using the formula:
HPBW ≈ k * (lambda / D)where k depends on antenna type
Manages observation parameters including geographic location, timing, and coordinate system transformations.
Core visibility calculation engine that computes complex visibilities for each baseline, accounting for beam patterns and source spectral indices.
Comprehensive visualization module using Bokeh for interactive plots, including antenna layouts, visibility data, and sky models.
Generates visualizations of the Global Sky Model with time-evolving sky maps and observable regions.
Provides multiple sky model options including test sources, GLEAM catalog sources, and GSM sources.
Simple FITS file inspection tool.
Utilities for reading HDF5 files.
Placeholder for future FFT-based visibility simulator implementation.
Placeholder for future matrix-based visibility simulator implementation.
The main workflow (implemented in src/main.py) follows these steps:
- Setup Configuration: Load simulation parameters from a configuration file
- Antenna Configuration: Read antenna positions and generate baselines
- Sky Model Selection: Choose and load appropriate sky model (test sources, GLEAM, GSM)
- Observation Setup: Define location, timing, and frequency parameters
- Beam Calculation: Compute beam patterns and HPBW for each antenna
- Visibility Simulation: Calculate visibilities over time and frequency
- Visualization: Generate plots of results
- Data Export: Save results in various formats (HDF5, JSON, HTML)
- Python: 3.11 (as specified in pixi.toml)
- NumPy: For numerical computations
- Astropy: For astronomical calculations and coordinate systems
- HEALPy: For spherical pixelization
- Bokeh: For interactive visualization
- Matplotlib: For static plotting
- Astroquery: For accessing astronomical catalogs
- PyYAML: For configuration file parsing
- PyGSM: For Global Sky Model access
- h5py: For HDF5 file handling
The project implements a comprehensive HPBW calculation system based on the relationship:
HPBW ≈ k * (lambda / D) in radians
Where:
lambdais the wavelength (calculated as speed_of_light / frequency)Dis the dish diameterkis a coefficient that depends on the antenna type and illumination
Different antenna types have different k values:
- Parabolic dish (uniform): k = 1.02
- Parabolic dish (cosine taper): k = 1.10
- Parabolic dish (Gaussian taper): k = 1.18
- Spherical reflector (uniform): k = 1.05
- Phased array (uniform): k = 1.10
- Dipole: Constant HPBW of π/2 radians (90 degrees)
The Gaussian primary beam pattern is calculated using:
A(theta) = exp(-(theta / (sqrt(2) * theta_HPBW))^2)
Where:
thetais the zenith angletheta_HPBWis the Half Power Beam Width in radians
The visibility calculation accounts for:
- Source positions and flux densities
- Beam patterns for each antenna
- Spectral indices of sources
- Baseline vectors and geometric delays
- Time and frequency variations
.
├── .gitignore # Git ignore rules
├── LICENSE # MIT License
├── pixi.lock # Pixi lock file
├── pixi.toml # Pixi project configuration
├── README.md # Project documentation
├── src/ # Source code
│ ├── __init__.py # Python package initialization
│ ├── antenna.py # Antenna position handling
│ ├── baseline.py # Baseline generation
│ ├── beams.py # Beam calculations and HPBW
│ ├── fits.py # FITS file handling
│ ├── gsm_map.py # GSM map integration
│ ├── main.html # HTML interface
│ ├── main.py # Entry point for the simulator
│ ├── observation.py # Observation location and time
│ ├── plot.py # Plotting functions
│ ├── reading.py # Reading data utilities
│ ├── source.py # Source modeling
│ ├── visibility.py # Visibility calculations
│ ├── visibility_results.json # Output data
│ └── simulators/ # Simulator modules
│ ├── fftvis.py # FFT-based visibility simulator
│ └── matvis.py # Matrix-based visibility simulator
└── tests/ # Unit tests
├── conftest.py # Test configuration
├── test_antenna.py # Antenna tests
├── test_baseline.py # Baseline tests
├── test_main.py # Main module tests
├── test_observation.py # Observation tests
├── test_plot.py # Plot tests
└── test_visibility.py # Visibility tests
- Python 3.11
- Key libraries:
numpy,astropy,healpy,matplotlib,bokeh,astroquery,pyyaml,pygsm,h5py
Run unit tests using pytest:
pixi run pytestIt is recommended to use pixi to manage the development environment.
-
Install
pixiif you don't have it already:curl -fsSL https://pixi.sh/install.sh | bash -
Clone the repository and navigate to it:
git clone <repository_url> cd RRIviz
-
Install dependencies:
pixi install
-
Activate the development environment:
pixi shell
The antenna file must contain at least these columns (whitespace-separated):
Name Number BeamID E N U
Where:
Name: Antenna name (string)Number: Antenna number (integer)BeamID: Beam identifier (integer)E,N,U: East, North, and Up coordinates in meters
To use different diameters per antenna, add a header column Diameter and a numeric value in each row:
Name Number BeamID E N U Diameter
HH136 136 0 0.0 0.0 0.0 14.0
HH140 140 0 14.0 0.0 0.0 14.0
HH121 121 0 28.0 0.0 0.0 14.0
The simulator generates several output files:
- HDF5 File: Contains complex visibility data and simulation parameters
- JSON File: Contains visibility results in JSON format
- HTML Files: Interactive plots generated with Bokeh
- Log File: Contains simulation details and progress information
- Configuration File: Copy of the configuration used for the simulation
- Polarized Visibility Calculation: Support for full Stokes polarimetry
- Advanced Simulator Modules: Implementation of FFT-based and matrix-based visibility simulators
- Additional Sky Models: Integration with more sky catalogs and models
- Enhanced Visualization: More interactive plotting options and 3D visualizations
- Performance Optimization: GPU acceleration and parallel processing
- Web Interface: Full web-based interface for configuration and visualization
Open-source contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License. See LICENSE for details.
If you use RRIviz in your research, please cite it as:
Mandar, K. (2025). RRIviz: Radio Astronomy Visibility Simulator.
GitHub repository: https://github.com/<username>/RRIviz
- The Hydrogen Epoch of Reionization Array (HERA) team for inspiration and testing
- Contributors to the scientific Python ecosystem (NumPy, Astropy, HEALPy, etc.)
- The radio astronomy community for feedback and suggestions