Skip to main content

GRAVITYp

GRAVITYp is a Python package for studying the optical appearance of spherically symmetric compact objects in General Relativity. It stands for Geodesic RAys and Visualization of IntensiTY profiles.

About the project

This is the Python implementation of GRAVITYp, which is originally a numerical code in Wolfram language developed by G.J. Olmo, D. Rubiera García, J.L. Rosa, D. Sáez-Chillón and collaborators arXiv:2307.06778v2. It was developed to study the optical appearance or shadow cast by black holes, wormholes and different kinds of exotic compact objects, inspired by the work of S.E. Gralla et al. arXiv:1906.00873.

Then, Á. Salazar Cuadros preferred to work on Python seeking faster execution times for simulations and a language better suited for Version Control Systems (VCS), and that's how the Python implementation was born. The goal of this open source version is to provide open access to anyone interested in using the package or learning how simulated black hole shadow images are generated.

Installation

From PyPI

GRAVITYp is available on PyPI

pip install gravityp

From source

Alternatively, you can fork this repository and clone it locally in editable mode for research and development

git clone git@github.com:<YOUR_USERNAME>/GRAVITYp.git       # SSH
git clone https://github.com/<YOUR_USERNAME>/GRAVITYp.git   # HTTPS

Then, install it together with the optional dependencies required to run the Jupyter notebooks and the Git notebook filter:

cd GRAVITYp
pip install -e ".[notebooks]"

The repository includes a Git filter that removes notebook outputs and metadata when .ipynb files are staged. Run the setup script once after installing the dependencies:

bash scripts/setup-nb-filter.sh

This is stored in .git/config, which is local to your clone and is not tracked by Git. After this setup, adding a notebook with git add strips its outputs and metadata from the staged version while leaving the working copy unchanged.

Usage

Quick example

import numpy as np
from gravityp import make_geodesics_plot

def g_rr(r: float, dummy) -> float:
    """Radial function g^{rr} of the Schwarzschild metric in units of M=1"""
    return 1 - 2./r

def g_thth(r: float, dummy) -> float:
    """Areal radius squared g^{theta theta} of the Schwarzschild in units of M=1"""
    return r**2

# Dictionary codifying Schwarzschild metric and required params
Schwarzschild_kwargs = {
    'r_phs': [3.,],         # Photon sphere at r=3M
    'inner_edge': 2.,       # Inner edge of disk at horizon r=2M
    'radial_fun': g_rr,     # Above defined radial function
    'radial_params': None,  # g_rr has no additional params
    'areal': g_thth,        # Above defined areal radius squared
    'areal_params': None,   # g_thth has no additional params
}

# Array of impact parameters from 0M to 10M
impact_parameters = np.arange(0,10,0.2)
make_geodesics_plot(impact_parameters, figsize=(4,4), **Schwarzschild_kwargs)

The output image looks like this:

ray-tracing

For a more detailed explanation, check the Jupyter notebooks in the Examples folder for details.

Intensity profiles and black hole shadows

The primary use is to obtain the observed intensity profile $I_\mathrm{ob}(b)$ as a function of the impact parameter $b$ given some predefined emission profile $I_\mathrm{em}(r)$. The emitted light is due to the matter in the accretion disk, which is assumed to be both geometrically and optically thin. Moreover, the orientation is assumed to be face-on with respect to the accretion disk, so the optical appearance has have rotational symmetry.

In the following images, the emission profile of the accretion disk has been chosen to peak at the event horizon $r=2M$, and the optical appearance corresponds to a Schwarzschild black hole.ç The code properly reproduces the predicted light rings up to two intersections with the accretion disk, as well as the central brightness depression or shadow characteristic of compact objects such as black holes.

emitted observed shadow

Further references

Watch Prof. D. Rubiera García's talk for an overview of the main concepts involved in the ray-tracing method and analysis of intensity profiles.

For an introductory discussion of the inner workings of the Wolfram Mathematica code, watch Prof. G.J. Olmo's tutorial; for a more user-friendly application, watch Dr. J.L. Rosa's talk.

Finally, for a more advanced topic regarding compact objects, watch Prof. D. Sáez-Chillón's contribution.

Citation

The use of GRAVITYp in scientific publications must be properly acknowledged. Please cite the following:

BibTeX

@article{Nojiri:2026tjn,
    author = "Nojiri, Shin'ichi and Odintsov, Sergei D. and S{\'a}ez-Chill{\'o}n G{\'o}mez, Diego and Cuadros, {\'A}lvaro Salazar",
    title = "{Horizon singularity, energy conditions and shadows in time-dependent and spherically symmetric spacetime}",
    eprint = "2608.15740",
    archivePrefix = "arXiv",
    primaryClass = "gr-qc",
    reportNumber = "KEK-TH-2861, KEK-Cosmo-0429",
    month = "8",
    year = "2026"
}

Publications using GRAVITYp

Let us know if you use GRAVITYp in your publication, and we will add it to the list of publications!

Author

The author and mantainer of the Python code is Álvaro Salazar Cuadros.

License

The software is licensed under the MIT license.

Metadata

Release files for gravityp 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gravityp 0.1.3
File Size Uploaded
gravityp-0.1.3.tar.gz 17.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gravityp 0.1.3
File Interpreter ABI Platform
gravityp-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 35.5 kB

Release files / gravityp-0.1.3.tar.gz

Download URL gravityp-0.1.3.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
74115e24ed2a6e9c6aad58ff554e122fc1ceb898e5e00d3450afd10613c8bcf8
BLAKE2b-256 checksum
How to use checksums
3fb254389803b3b231ffe35a741819afd7c34f2f8c35678894fc16425625147f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / gravityp-0.1.3-py3-none-any.whl

Download URL gravityp-0.1.3-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47e20f1fc820d5cfce765071da7b52d04ab35bd05913ec62420243d4890f57e2
BLAKE2b-256 checksum
How to use checksums
35e31e98e1ff8e7834674f54a7c8a73b362fd36d93ea2daa5bf81b06af6e1911
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page