Skip to main content

PIANISTpy

PIANISTpy

Tests Coverage Documentation License PyPI Python DOI

Particle Initial conditions with ANISoTropy.

PIANISTpy builds spherical, non-rotating, velocity-anisotropic equilibrium models, self-consistently truncated in phase space, for dark matter (sub)halos, dwarf galaxies, stellar spheroids and star clusters. The package provides distribution functions, particle initial conditions, radial and tangential velocity dispersion profiles and line-of-sight observables, with JAX-based end-to-end differentiability for gradient-based Monte Carlo inference.

Ver. 1.0.1 adds DistributionFunction.evaluate, the distribution function at given values of the energy-like variable, and round_trip, the density and potential that a distribution function generates, compared with the analytic density as in Chiang, van den Bosch and Schive (2026d), MNRAS submitted, arXiv:2610.28758, henceforth Chiang+(2026d).

What PIANISTpy does

  • Density profiles. Analytical double-power-law density profiles with a finite central potential, including the Navarro-Frenk-White, Hernquist and Plummer profiles.

  • Velocity anisotropy. Isotropic, constant-anisotropy, Osipkov-Merritt and Cuddeford-Osipkov-Merritt (COM) models. The Osipkov-Merritt and COM models are radially (Type I) or tangentially (Type II) biased.

  • Distribution functions. Each anisotropy model’s distribution function, inverted from the input density with exact symbolic expressions up to the final numerical integration, with extensively validated numerical accuracy (Accuracy tables) and checks that the distribution function is non-negative (physical) and monotonic (a sufficient condition for dynamical stability).

  • Truncation in phase space. Model truncation performed in phase space. The truncation boundary is self-consistent and in dynamical equilibrium. Method I preserves the model’s anisotropy profile, and Method II gives different anisotropy models an identical truncated density.

  • Particle sampling. Particle initial conditions drawn from the truncated distribution function, with a finite, dynamically stable truncation boundary. The particles are given in internal, model or physical units.

  • Observables. Radial, tangential and line-of-sight velocity dispersions, line-of-sight velocity distributions and their Gauss-Hermite moments, and the local velocity distribution at a 3D radius. Projected quantities are averaged over centered or offset circular and rectangular apertures.

  • Superposition. Distribution functions of different anisotropy models on one truncated density, linearly superposed into one equilibrium model. The superposed model’s anisotropy profile can differ from every analytical family, for example an anisotropy profile fitted to simulated halos.

  • Inference. End-to-end differentiable in JAX: the likelihood of a model against kinematic data, with gradients in the superposition weights, the mass and length scales (M0 and r0) and, for Method II components, the anisotropy parameters, for gradient-based Monte Carlo inference.

Getting started

pip install pianistpy
import pianistpy as pp
import astropy.units as u

# an untruncated NFW density profile with a constant velocity anisotropy of 0.25
halo = pp.Component(pp.DoublePowerLaw.nfw(), pp.Anisotropy(beta_c=0.25))

# the untruncated distribution function
df = pp.compute_df(halo)

# Method I: truncate the distribution function so that the truncated mass equals the virial mass of the
# untruncated NFW halo of concentration 10 (the mass inside 10 scale radii)
model = pp.truncate(df, pp.Truncation(mass_t=1.0, concentration=10))

# physical units: a halo of 1e12 solar masses with R_vir = c * r_0 = 200 kpc
model = model.to("physical", mass_0=1e12 * u.Msun, r_0=20 * u.kpc)

# draw ten million equal-mass particles centered at the origin and write them to a file
particles = pp.Sampler(model).sample(10_000_000, seed=1)
particles.write("NFW_Const0p25_Mt1e12_PARIC.h5")

# the line-of-sight velocity dispersion at three projected radii
sigma = pp.sigma_los(model, [2, 20, 100] * u.kpc)

Install · Quick start

Documentation

How to cite

Please cite the initial release paper, Chiang, van den Bosch and Schive (2026d), MNRAS submitted, arXiv:2610.28758, henceforth Chiang+(2026d), in work that uses PIANISTpy.

Each release of PIANISTpy is also archived on Zenodo under doi:10.5281/zenodo.23548188, which resolves to the latest release.

License

PIANISTpy is released under the BSD 3-Clause License, copyright 2026 Barry T. Chiang. The full text is in the LICENSE file of the repository.

PIANISTpy is written and maintained by Barry T. Chiang (Yale University), barrytchiang@gmail.com.

Metadata

Release files for pianistpy 1.0.1

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

Source distribution (sdist)

Source distribution for pianistpy 1.0.1
File Size Uploaded Provenance Actions
pianistpy-1.0.1.tar.gz 804.3 kB With provenance Details for pianistpy-1.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 1.7 MB

Release files / pianistpy-1.0.1.tar.gz

Download URL pianistpy-1.0.1.tar.gz
Size 804.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e586141e45d5655b2826696636210f2ada2f9a4182b6f5516f993551ae7e5a8c
BLAKE2b-256 checksum
How to use checksums
2ab6d7b5fda99c9bb4c544a687296af621d2b9081ec1a28b010e17c085969dff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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 Nov 4, 2026.

Transparency log

Release files / pianistpy-1.0.1-py3-none-any.whl

Download URL pianistpy-1.0.1-py3-none-any.whl
Size 917.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bd891ea155992d0888bab2cf94085191f80a8e166226af0fb80b446f3ddc0aa
BLAKE2b-256 checksum
How to use checksums
4ecb4aad1de564274cb8c1ba358aeb050580e1167e60e6d2b679684b280a059f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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 Nov 4, 2026.

Transparency log

Security for pianistpy 1.0.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pianistpy-1.0.1.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 Nov 4, 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