Skip to main content

https://github.com/user-attachments/assets/b185c3b8-8658-4f7d-96de-e976959e7ad6

topsy

Build Status

This package visualises simulations, and is an add-on to the pynbody analysis package. Its name nods to the TIPSY project. It is built using wgpu, which is a future-facing GPU standard (with thanks to the python wgpu bindings).

At the moment, topsy is experimental, but has proven to work well in a variety of environments. It is mainly developed and optimized on Apple M-series chips, but has also been shown to work on NVidia GPUs.

The future development path will depend on the level of interest from the community.

Installing

You will need python 3.11 or later, running in a UNIX variant (basically MacOS, Linux or if you're on Windows you need WSL). You can then install topsy using pip as usual:

pip install topsy

This will install topsy and its dependencies (including pynbody itself) into your current python environment. (If it fails, check that you have python 3.11 or later, and pip is itself up-to-date using pip install -U pip.)

Alternative 1: install into isolated environment using pipx

You can also install topsy into its own isolated environment using pipx:

pipx install topsy

The command line tool will now be available, but you won't have access to the topsy package from your existing python environment. This can be useful if you don't want to risk disturbing anything.

Alternative 2: install into new environment using venv and pip

If you want to play with topsy without disturbing your existing installation, but also want to be able to use topsy from python scripts or jupyter etc, I recommend using venv:

# create a toy environment
python -m venv visualiser-env

# activate the new environment
source visualiser-env/bin/activate 

# install
pip install topsy

... other commands ...

# get your old environment back:
deactivate 

For more information about venv, see its tutorial page.

Alternative 3: install unreleased versions or contribute to development

As usual, you can also install direct from github, e.g.

pip install git+https://github.com/pynbody/topsy

Or clone the repository and install for development using

pip install -e .

from inside the cloned repository.

Trying it out

Very quick start

Once topsy is installed, if you just want to try it out and you don't have a suitable simulation snapshot to hand, you can download some from the tangos tutorial datasets (5.1GB). You need to untar them (tar -xzf tutorial_changa.tar.gz from your command line), then you can type topsy pioneer50h128.1536gst1.bwK1.000832 to visualise that file's dark matter content.

More detailed description

If using from the command line, pass topsy the path to the simulation that you wish to visualise.

You can (and probably should) also tell it what to center on using the -c flag, to which valid arguments are:

  • -c none (just loads the file without changing the centering)
  • -c halo-1 (uses the shrink sphere center of halo 1; or you can change 1 to any other number)
  • -c zoom (uses the shrink sphere center on the highest resolution particles, without loading a halo catalogue)
  • -c all (uses the shrink sphere center on all particles in the file)

By default, it will show you dark matter particles. To change this pass -p gas to show gas particles or -p star for stars. Note that the particle type cannot be changed once the window is open (although you can open a separate window for each particle type; see below).

If your particles have other quantities defined on them (such as temp for gas particles), you can view the density-weighted average quantity by passing -q temp. The quantity to visualise can also be changed by selecting it via the main window controls (see below).

To open more than one visualisation window on different files or with different parameters, you can pass multiple groups of parameters separated by +, for example to see separate views of the gas and dark matter you could launch topsy with:

topsy -c halo-1 -p gas my_simulation + -c halo-1 -p dm my_simulation

You can choose to link the rotation/zoom of multiple views using the toolbar (see below).

Using SSPs

If you have stars in your simulation, you can try rendering using pynbody's SSP tables, using the command-line flag --render-mode rgb, or by selecting the RGB option in the colormap. Make sure you are visualising stars rather than any other particles e.g.

topsy -c halo-1 -p s --render-mode rgb my_simulation 

Even better, if you have an HDR display (e.g. recent Macbook Pros), you can use the --render-mode rgb-hdr flag to render in HDR mode.
Note in HDR mode that the magnitude range specified applies to the SDR range, i.e. HDR brightnesses extend beyond the specified maximum surface brightness limit. The exact brightest magntiude that can be displayed will depend on your display hardware.

Controls in the main window

The view in the topsy window can be manipulated as follows:

  • To spin around the centre, drag the mouse.
  • To zoom in and out, use the mouse scroll wheel.
  • To move the centre, double click on a target (topsy will determine its depth), or shift-drag to move in x-y plane.
  • To rescale the colours to an appropriate range for the current view, press r(ange)
  • To return the view to the original orientation and zoom, press h(ome)

There is also a toolbar at the bottom of the window with some buttons:

  • - start recording actions (rotations, scalings, movements and more). Press again to stop.
  • - render the recorded actions into an mp4 file. You will be prompted about various options and a filename.
  • - load and save the recorded actions to a file for later use.
  • - save a snapshot of the current view to an image file.
  • - link this window to other topsy windows, so that rotating, scaling or moving one does the same to the other
  • - open colormap control; this lets you select the rendering mode, min/max values, the quantity to visualise, the matplotlib colormap and more.

Using from jupyter

It is possible to use topsy within a jupyter notebook. Graphics are rendered on the jupyter server, and displayed within the notebook.

To open a topsy view within your jupyter notebook, try

import topsy 
topsy.load("/path/to/simulation", particle="gas")

Note that you can interact with this widget in exactly the same way as the native window produced by topsy. Most of the same options you can pass on the command line are also available via this load function (type help(topsy.load) for details).

Metadata

Release files for topsy 0.8.2

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

Source distribution (sdist)

Source distribution for topsy 0.8.2
File Size Uploaded Provenance Actions
topsy-0.8.2.tar.gz 125.3 kB With provenance Details for topsy-0.8.2.tar.gz

Built distribution (wheel)

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

Total release size: 247.7 kB

Release files / topsy-0.8.2.tar.gz

Download URL topsy-0.8.2.tar.gz
Size 125.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f64447e4cc3689d907461b14ddc26dbf4b7eb1d7530a8fdb0e4a5bbd802de350
BLAKE2b-256 checksum
How to use checksums
d78f520b9073e20ec7f48aa544ae4c3bfb2ab1ec908cba01d6b8a19362af4dbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 19, 2026.

Transparency log

Release files / topsy-0.8.2-py3-none-any.whl

Download URL topsy-0.8.2-py3-none-any.whl
Size 122.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6aeabcf38046246a18e9e1636f7fccc4391e3d9a86008d93ccfd07759406fc01
BLAKE2b-256 checksum
How to use checksums
af8c30d1541ed36cfe56afc6878a2f431d3b2c9819b724db8facf97ad7b34a2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 19, 2026.

Transparency log

Security for topsy 0.8.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for topsy-0.8.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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