Skip to main content
https://img.shields.io/badge/ascl-2002.006-blue.svg?colorB=262255 Documentation Status

A Python interface for Sub-halo Clustering and Abundance Matching

SCAMPy is a flexible library for “painting” an observed population of cosmological objects on top of the DM-halo/subhalo hierarchy obtained from DM-only simulations. The method combines the classical Halo Occupation Distribution (HOD) with sub-halo abundance matching (SHAM): a synergy dubbed Sub-halo Clustering and Abundance Matching (SCAM).

The procedure itself is quite easy since it only requires to apply the two methods in sequence:

  1. by applying the HOD scheme, the host sub-haloes are selected;

  2. the SHAM algorithm associates to each sub-halo an observable property of choice.

If the image is not directly shown in the text, it can be found in the subdirectory `images/evolving_slice.gif`

The animation is obtained running SCAMPy on the halo/subhalo catalogues of 42 different snapshots, from redshift \(z=8\) to redshift \(z=0\), of a \(64\,\mathrm{Mpc}/h\) DM-only N-body simulation. The simulation has been obtained with the GADGET-3 code, following the evolution of \(512^3\) DM particles. For each different redshift we have fixed the parameter values for the HOD and matched the UV-luminosity function of star-forming galaxies.

The background colour-code shows the underlying DM-density field computed by smoothing the contribution of DM-particles in a 10 Mpc/h thick slice of the simulation. The markers locate the positions of the mock galaxies generated with SCAMPy. Circles mark the position of central galaxies while crosses mark the position of satellite galaxies. The marker colour represents lower to higher luminosity going from brighter to darker.

Basic Usage

To populate a DM catalogue with mock galaxies assigned a UV magnitude you would do something like:

# read the GADGET SUBFIND tables
from scampy.io.subfind_table import subfind_table
tab = subfind_table( "/path/to/subhalo_tab_snap" )
tab.read_all_files()

# build halo and sub-halo catalogue objects
import numpy as np
from scampy.catalogue import haloCat, subhaloCat, catalogue

haloes = haloCat(
    len( tab.content['GroupMass'] ),
    Mhalo    = tab.content['GroupMass'],
    Rhalo    = tab.content['GroupRadiusM200'],
    X        = tab.content['GroupPos'][:, 0],
    Y        = tab.content['GroupPos'][:, 1],
    Z        = tab.content['GroupPos'][:, 2],
    firstSub = tab.content['GroupFirstSub'],
    numSubs  = tab.content['GroupNsubs'],
)
subhaloes = subhaloCat(
    len( tab.content['SubhaloMass'] ),
    Msubh  = tab.content['SubhaloMass'],
    Parent = tab.content['SubhaloGrNr'],
    X      = tab.content['SubhaloPos'][:, 0],
    Y      = tab.content['SubhaloPos'][:, 1],
    Z      = tab.content['SubhaloPos'][:, 2],
)
cat = catalogue( haloes, subhaloes, Lbox = 512. )  # Lbox in Mpc/h

# select host sub-haloes with an HOD
from scampy.hod import HOD, get_hosts
hod   = HOD( Mmin=1.e12, siglogM=0.5, M0=1.e12, M1=1.e13, alpha=1. )
hosts = get_hosts( cat, Pcen=hod.Pcen, Psat=hod.Psat )

# define a Schechter-like UV luminosity function
def schechter ( mag ) :
    alpha = -1.07
    norm  = 1.6e-2
    mstar = -19.7 + 5. * np.log10( 5. )
    lum   = -0.4 * ( mag - mstar )
    return 0.4 * np.log( 10 ) * norm * 10**( -0.07 * lum ) * np.exp( -10**lum )

# assign magnitudes via sub-halo abundance matching
from scampy.sham import match_distribution
magnitudes = match_distribution(
    cat.subhaloes['Msubh'][hosts], schechter,
    minF = -25, maxF = -10, factF = 1. / cat.volume,
)

The magnitudes array contains the UV magnitude assigned to each mock galaxy.

Installation

The recommended installation uses pip:

pip install scampy

To install from source after cloning the repository:

git clone https://github.com/TommasoRonconi/scampy.git
cd scampy
pip install .

Alternatively, a conda environment file is provided:

conda env create -f scampy_environment.yml
conda activate scampy
pip install .

Requirements

Runtime:

  • numpy

  • scipy

  • matplotlib>=3.6

  • h5py

Python: 3.10 or later recommended (3.8+ supported).

Documentation (optional):

  • sphinx>=5.0

  • sphinx-rtd-theme

  • myst-parser

Metadata

Release files for scampy 2.0.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 scampy 2.0.2
File Size Uploaded
scampy-2.0.2.tar.gz 81.6 kB Details

Built distribution (wheel)

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

Total release size: 149.3 kB

Release files / scampy-2.0.2.tar.gz

Download URL scampy-2.0.2.tar.gz
Size 81.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b505eaba41a90ed4791215fca8f51d353900e549997d2d2af87654c62590d564
BLAKE2b-256 checksum
How to use checksums
b888a5fecdaf30ed1e02f11f42bc5f0a20b00a4d6e0d0427dae5a604a502b668
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 May 18, 2026.

Transparency log

Release files / scampy-2.0.2-py3-none-any.whl

Download URL scampy-2.0.2-py3-none-any.whl
Size 67.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a3d66b899b70c41c324bf34ee851534085b5fc4483484145ad150d840e2261a
BLAKE2b-256 checksum
How to use checksums
d1d4329d31ad71672c0b7ed676e0a0c2d1169e7f07529a8f720d0d0ec3357545
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 May 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

0.0.1

1 release file

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