Skip to main content

PYthon Radio Astronomy anaLYSis and Image Synthesis

Project description

Pyralysis logo

codecov pre-commit Documentation Status Binder PyPI Wheel

Python Version PyPI Version PyPI Downloads ReadMe Read the Docs

Docker License Pipeline Status


Pyralysis

Pyralysis is an open-source Python library for radio astronomy imaging, simulation, and optimization. It is designed to be easy to install, learn, and use for modern radio interferometry workflows.

For full documentation, tutorials, and API reference, see the Pyralysis documentation on ReadTheDocs:

Try in your browser (Binder)

You can open the Binder environment from the badge above to run the sandbox notebooks in JupyterLab without installing Pyralysis locally. That is a convenient way to try small simulations, toy datasets, and step-by-step examples under examples/notebooks/. The live session uses the release branch and is meant for exploration, not large production runs. For details, see the repository examples page on Read the Docs.


Install in three steps

Stable releases are published on PyPI (pin pyralysis==X.Y.Z when you need a fixed version). For commits not yet released, install from GitLab (see the installation guide).

  • 1. Create a Python environment (Python 3.9–3.12 recommended). Use whatever you prefer: conda, mamba, micromamba, or plain venv.

  • 2. Install from PyPI using the SKA extra index (needed so pip can resolve some dependencies).

pip install --extra-index-url https://artefact.skao.int/repository/pypi-internal/simple pyralysis[all]

This installs the latest published PyPI release plus common optional dependencies (FFT, notebooks, tests). For CuPy / GPU, use pyralysis[all,cupy] or pyralysis[cupy] only. For SLURM-backed Dask workers (dask-jobqueue, used by pipeline steps such as SetupDaskCluster with dask_cluster_backend="slurm"), install pyralysis[slurm] as well (see the installation page). Simulation and imaging pipelines can attach a local cluster, SLURM, or an existing Client via context config; details are in Pipelines and distributed Dask.

For editable installs, conda env files, or Docker images, see:


Minimal example

Start by simulating a small dataset and then add thermal noise:

from pyralysis.io.antenna_config_io import AntennaConfigurationIo
from pyralysis.simulation import Simulator
from pyralysis.models.sky import PointSource
from pyralysis.injectors import ThermalNoiseInjector

# Load array configuration
interferometer = AntennaConfigurationIo(input_name="path/to/array.cfg").read()
interferometer.configure_observation(
    min_frequency_hz=1e9, max_frequency_hz=1.1e9, frequency_step_hz=1e7,
    right_ascension="12:00:00", declination="45:00:00",
    integration_time=10, observation_time="1h"
)

# Define a source and simulate
source = PointSource(
    reference_intensity=1.0,
    sky_position="12:00:00 45:00:00",
    reference_frequency=1e9,
)
sim = Simulator(interferometer=interferometer, sources=source)
dataset = sim.simulate(create_dataset=True)

# Add thermal noise
thermal = ThermalNoiseInjector(system_temperature=50, integration_time=10, channel_bandwidth=1e6)
noisy_dataset = thermal.apply(dataset)

For more simulation examples (arrays, sky models, injectors, and data access), see:

Reconstruction example

Next, reconstruct an image from the (noisy) visibilities using an objective function and L‑BFGS:

from pyralysis.reconstruction import Image
from pyralysis.optimization import ObjectiveFunction
from pyralysis.optimization.terms import ChiSquared, L1Norm
from pyralysis.optimization.optimizer import LBFGS
from pyralysis.measurement import ModelVisibility

# Create initial image (e.g. empty sky model)
image = Image.empty(imsize=(512, 512), cellsize=0.001)  # adjust to your case

# Build model visibility from dataset and image
model_visibility = ModelVisibility(dataset=noisy_dataset, image=image)

# Define objective function: data fidelity + simple L1 regularization
terms = [
    ChiSquared(model_visibility=model_visibility, penalization_factor=1.0),
    L1Norm(penalization_factor=0.01),
]
objective = ObjectiveFunction(term_list=terms, image=image, persist_gradient=True)

# Run L-BFGS reconstruction
optimizer = LBFGS(objective_function=objective, parameter=image)
reconstructed_image = optimizer.optimize()

For detailed reconstruction workflows (measurement operator, regularizers, optimizers), see:

Examples in this repository

  • Jupyter notebooks are in examples/notebooks/.
  • CLI scripts are in examples/scripts/, split by style:
    • *_components.py for explicit class composition.
    • *_pipeline.py for pipeline-based orchestration.
  • Current paired scripts:
    • dirtymapper_components.py / dirtymapper_pipeline.py
    • optimization_components.py / optimization_pipeline.py
    • simulation_components.py / simulation_pipeline.py

See the documentation page for quick usage patterns:


Learn more


Contributing and development


Citation and license

If you use Pyralysis in your research, please consider citing:

@software{carcamo2021pyralysis,
  author = {Miguel Cárcamo},
  title = {Pyralysis: A Python framework for radio interferometric imaging and simulation},
  year = {2021},
  url = {https://gitlab.com/clirai/pyralysis},
  note = {https://pyralysis.readthedocs.io/}
}

Pyralysis is distributed under the terms of the GNU General Public License version 3 (GPLv3). See LICENSE for details.


Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyralysis-1.2.0.tar.gz (12.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyralysis-1.2.0-py3-none-any.whl (911.1 kB view details)

Uploaded Python 3

File details

Details for the file pyralysis-1.2.0.tar.gz.

File metadata

  • Download URL: pyralysis-1.2.0.tar.gz
  • Upload date:
  • Size: 12.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for pyralysis-1.2.0.tar.gz
Algorithm Hash digest
SHA256 7f20febe9c9af0d4b0960444daa3ddc42e493960533c69c4443078988714d15e
MD5 91c07c4f87ce2a2a83afa5a26ccbb1b9
BLAKE2b-256 3c9d197d3b3f218cfe820623ea78e83e8d6b310833a6ebc3d5c457936116f0e1

See more details on using hashes here.

File details

Details for the file pyralysis-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyralysis-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 911.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for pyralysis-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d456dc0f3296f4a176152b6a1b49f6b6226c6667cbd83ec38797ab66f3a6f03
MD5 c0770d042a1405223a58c8fac54d9862
BLAKE2b-256 a377ffc8b83f47616e1500a6349d6166441da3829ea7dbb7f822e51e02bf26cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page