MassFunc
A Python package for cosmological mass function calculations, including Press-Schechter, Sheth-Tormen mass functions, star formation rate density calculations, and more.
Features
- Cosmological calculations: Support for various cosmological parameters and models
- Mass function calculations: Implements Press-Schechter and Sheth-Tormen mass functions
- Star formation rate density: Calculate SFRD with customizable parameters
- Collapse fraction: Tools for calculating collapse fractions
- Efficient interpolation: Built-in interpolation for fast calculations
Installation
From PyPI (recommended)
pip install massfunc
From source
git clone https://github.com/SOYONAOC/MassFunction.git
cd massfunc
pip install -e .
Quick Start
import massfunc
# Create a mass function calculator with default cosmology
mf = massfunc.Mass_func(ns=0.965, sigma8=0.811, h=0.674, omegam=0.315)
# Setup interpolation for faster calculations
mf.sigma2_interpolation_set()
mf.dsig2dm_interpolation_set()
# Calculate mass function at z=0 for a range of masses
import numpy as np
masses = np.logspace(10, 15, 100) # 10^10 to 10^15 solar masses
z = 0.0
# Press-Schechter mass function
dndm_ps = mf.dndmps(masses, z)
# Sheth-Tormen mass function
dndm_st = mf.dndmst(masses, z)
# Star formation rate density
sfrd = massfunc.SFRD(ns=0.965, sigma8=0.811)
rho_sfr = sfrd.rhosfr(1e4, 1e8, z)
Classes and Methods
CosmologySet
Base class for cosmological parameters:
h: Dimensionless Hubble parameteromegam: Matter density parameteromegab: Baryon density parameteromegalam: Dark energy density parameter
Mass_func
Main class for mass function calculations:
sigma2(): Variance of density fielddndmps(): Press-Schechter mass functiondndmst(): Sheth-Tormen mass functiondndmeps(): Extended PS mass function
Collapse_fraction
Calculate collapse fractions:
fcoll(): Collapse fractiondfcolldz(): Derivative of collapse fraction with redshift
SFRD
Star formation rate density calculations:
rhosfr(): Star formation rate densityfstar(): Star formation efficiencyfduty(): Duty cycle
Dependencies
- numpy >= 1.18.0
- scipy >= 1.5.0
- astropy >= 4.0
- matplotlib >= 3.0.0
- sympy >= 1.6.0
- joblib >= 1.0.0
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Citation
If you use this package in your research, please cite:
@software{massfunc,
author = {Your Name},
title = {MassFunc: A Python package for cosmological mass function calculations},
url = {https://github.com/yourusername/massfunc},
version = {0.1.0},
year = {2025}
}
Support
If you encounter any issues or have questions, please file an issue on the GitHub repository.
Update log
Version 0.1.1
- Added EPS (Extended Press-Schechter) collapse fraction calculation
- New method
fcolleps()in Collapse_fraction class - Enhanced collapse fraction functionality
Metadata
Release files for massfunc 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| massfunc-0.2.2.tar.gz | 145.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| massfunc-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 152.1 kB
Release files / massfunc-0.2.2.tar.gz
| Download URL | massfunc-0.2.2.tar.gz |
|---|---|
| Size | 145.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e14feda28f0637fed59bfc048be78ffc23a039c7491e9c1b59533897f75a493
|
|
BLAKE2b-256 checksum How to use checksums |
f307ccf7a34014c8e683457d2176c9ddd89ca444ab64df1d8b84fc0d2fecdbc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Sep 3, 2025.
Transparency logRelease files / massfunc-0.2.2-py3-none-any.whl
| Download URL | massfunc-0.2.2-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5398741d33c6cb6d4cc3c9a1a92ca8a2dfd5a5d850e5c747e25c0c7fce49f49
|
|
BLAKE2b-256 checksum How to use checksums |
46d729cf7a3681ecf39b55c62269861d5e0c0e29d3b1f822d7b783de6eb13650
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Sep 3, 2025.
Transparency log