Skip to main content

A Python package for cosmological mass function calculations

Project description

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 parameter
  • omegam: Matter density parameter
  • omegab: Baryon density parameter
  • omegalam: Dark energy density parameter

Mass_func

Main class for mass function calculations:

  • sigma2(): Variance of density field
  • dndmps(): Press-Schechter mass function
  • dndmst(): Sheth-Tormen mass function
  • dndmeps(): Extended PS mass function

Collapse_fraction

Calculate collapse fractions:

  • fcoll(): Collapse fraction
  • dfcolldz(): Derivative of collapse fraction with redshift

SFRD

Star formation rate density calculations:

  • rhosfr(): Star formation rate density
  • fstar(): Star formation efficiency
  • fduty(): 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

massfunc-0.1.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

massfunc-0.1.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file massfunc-0.1.1.tar.gz.

File metadata

  • Download URL: massfunc-0.1.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for massfunc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9a4eea388f956e09d4e2432475a4647eaedf4c5b523638553e854765d65b7c8a
MD5 72a0607280931b7aeef230eadf56fbe7
BLAKE2b-256 baba8694cdf3dfaf3379dbbb5de3528a427f52b5f023b1e14cf089dfb29eaf71

See more details on using hashes here.

File details

Details for the file massfunc-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: massfunc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for massfunc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 213fd53f4e80630bac678e1daf9ea309829904874035abf53f436c361cad1b1b
MD5 a89933970524b9f4e82cdbe2f3d5c14b
BLAKE2b-256 0410bcca73fc65d59227e6e1f96593b20ded3006ba2c77cd393baddc314b8366

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page