Coleman Bulge Density Model
A JAX-based, differentiable implementation of the Coleman et al. (2020) Milky Way bulge density model.
Features
- JAX Backend & Auto-Diff: Built on
jax.numpy, allowing for gradient computations viajax.grad. - Hybrid Evaluation: Evaluates density using
jax.scipy.ndimage.map_coordinatesfor coordinates within a pre-computed grid. It falls back to an analytical model for extrapolation outside the grid bounds. - Vectorized & JIT-Compiled: Vectorized and JIT-compiled (
@jax.jit) to process large arrays of coordinates on CPU, GPU, or TPU. - Flexible Coordinates: Accepts inputs in either Sun-centered spherical coordinates (
r,lat,lon) or Galactic Cartesian coordinates (x,y,z).
Requirements
- Python >= 3.8
- JAX >= 0.4.0
- NumPy >= 1.20.0
- SciPy >= 1.7.0
Installation
This package can be installed using pip:
pip install coleman-bulge-density-model
Usage
To use the model, import the pre-instantiated bulge_density_model.
The returned densities are in units of stars per pc^3, normalised to match the observed VVV star counts in the Ks band.
Basic Evaluation
import jax.numpy as jnp
from coleman_bulge_density import bulge_density_model
# 1. Using Galactic Cartesian coordinates (x, y, z)
density, in_bounds = bulge_density_model(x=8.0, y=0.0, z=0.0)
# 2. Processing large arrays
x_arr = jnp.linspace(0, 15, 100)
y_arr = jnp.zeros(100)
z_arr = jnp.zeros(100)
densities, bounds = bulge_density_model(x=x_arr, y=y_arr, z=z_arr)
HMC & Gradients
The model is compatible with JAX operations, allowing for gradient calculations for use in physics simulations and HMC samplers.
import jax
import jax.numpy as jnp
from coleman_bulge_density import bulge_density_model
def log_prob(position_vector):
"""Calculates the log-probability for a given (x, y, z) position."""
density, _ = bulge_density_model(
x=position_vector[0],
y=position_vector[1],
z=position_vector[2]
)
return jnp.log(density)
# Generate the gradient function
grad_log_prob = jax.grad(log_prob)
# Evaluate the gradient at a given position
position = jnp.array([8.0, 0.0, 0.0])
gradient = grad_log_prob(position)
Release files for coleman-bulge-density-model 0.3.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| coleman_bulge_density_model-0.3.6.tar.gz | 77.4 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| coleman_bulge_density_model-0.3.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 151.6 MB
Release files / coleman_bulge_density_model-0.3.6.tar.gz
| Download URL | coleman_bulge_density_model-0.3.6.tar.gz |
|---|---|
| Size | 77.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45937fcabe2ba9a755fa4e8a1256914c211d04b73b75495ba1d1009158c5d1af
|
|
BLAKE2b-256 checksum How to use checksums |
7d18661d69355b2949946cfc7c4e163293e95a84a811e57bea2ab05641571676
|
| 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 Apr 30, 2026.
Transparency logRelease files / coleman_bulge_density_model-0.3.6-py3-none-any.whl
| Download URL | coleman_bulge_density_model-0.3.6-py3-none-any.whl |
|---|---|
| Size | 74.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e9227258da9991d735a7f38fa30c5d83e578f4d9062e6a9bd791f3ef031ff09
|
|
BLAKE2b-256 checksum How to use checksums |
6c3201c9861436da94d1f268d5aabadf7849e7c0235f7b81f343816b8f872ade
|
| 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 Apr 30, 2026.
Transparency log